-
Notifications
You must be signed in to change notification settings - Fork 1
add feature: add support in windows platform #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9826d12
e1bfb2a
157e9a2
f599ae8
0f77424
84d7629
e3c8053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
build/ | ||
.xmake/ | ||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
toolchain("arm-gcc") | ||
|
||
set_description("ARM Compiler of GCC") | ||
set_kind("cross") | ||
|
||
on_load(function(toolchain) | ||
if toolchain:is_plat("windows") then | ||
toolchain:set("toolset", "cc", "arm-none-eabi-gcc.exe") | ||
toolchain:set("toolset", "ld", "arm-none-eabi-gcc.exe") | ||
toolchain:set("toolset", "ar", "arm-none-eabi-ar.exe") | ||
toolchain:set("toolset", "as", "arm-none-eabi-gcc.exe") | ||
else | ||
toolchain:set("toolset", "cc", "arm-none-eabi-gcc") | ||
toolchain:set("toolset", "ld", "arm-none-eabi-gcc") | ||
toolchain:set("toolset", "ar", "arm-none-eabi-ar") | ||
toolchain:set("toolset", "as", "arm-none-eabi-gcc") | ||
end | ||
end) | ||
|
||
toolchain_end() | ||
|
||
rule("generate-hex") | ||
after_build(function(target) | ||
local out = target:targetfile() or "" | ||
local gen_fi = "build/" .. target:name() | ||
|
||
-- https://github.com/xmake-io/xmake/discussions/2125 | ||
-- os.exec("arm-none-eabi-objdump -S "..out.." > "..gen_fi..".asm") | ||
-- local asm = os.iorun("arm-none-eabi-objdump -S build/cross/cortex-m4/release/minimal-proj") | ||
-- io.writefile(gen_fi..".asm", asm) | ||
|
||
if target:is_plat("windows") then | ||
os.execv("arm-none-eabi-objcopy.exe", {"-Obinary", out, gen_fi .. ".bin"}) | ||
os.execv("arm-none-eabi-objdump.exe", {"-S", out}, {stdout = gen_fi .. ".asm"}) | ||
os.execv("arm-none-eabi-objcopy.exe", {"-O", "ihex", out, gen_fi .. ".hex"}) | ||
else | ||
os.execv("arm-none-eabi-objcopy", {"-Obinary", out, gen_fi .. ".bin"}) | ||
os.execv("arm-none-eabi-objdump", {"-S", out}, {stdout = gen_fi .. ".asm"}) | ||
os.execv("arm-none-eabi-objcopy", {"-O", "ihex", out, gen_fi .. ".hex"}) | ||
end | ||
|
||
os.mv(out, gen_fi .. ".elf") -- add .elf file | ||
-- -I binary | ||
-- $(Q) $(OBJ_COPY) -O ihex $@ $(BUILD_DIR)/$(TARGET).hex | ||
-- $(Q) $(OBJ_COPY) -O binary $@ $(BUILD_DIR)/$(TARGET).bin | ||
-- os.exec("qemu-system-arm -M stm32-p103 -nographic -kernel"..bin_out) | ||
end) | ||
|
||
after_clean(function(target) | ||
local gen_fi = "build/" .. target:name() | ||
os.rm(gen_fi .. ".*") | ||
end) | ||
|
||
rule_end() | ||
|
||
task("qemu") | ||
|
||
on_run(function() | ||
print("Run binary in Qemu!") | ||
local bin_out = os.files("$(buildir)/*.bin")[1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
if bin_out then | ||
os.exec("qemu-system-arm -M stm32-p103 -nographic -kernel " .. bin_out) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. os.execv |
||
else | ||
print("Do not find bin file in $(buildir)/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use raise() |
||
end | ||
end) | ||
|
||
set_menu { | ||
-- Settings menu usage | ||
usage = "xmake qemu", | ||
|
||
-- Setup menu description | ||
description = "Run binary in Qemu!" | ||
} | ||
|
||
task_end() |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.