Skip to content

add feature: add support in windows platform#1

Open
Robinsssson wants to merge 7 commits intoxmake-examples:masterfrom
Robinsssson:master
Open

add feature: add support in windows platform#1
Robinsssson wants to merge 7 commits intoxmake-examples:masterfrom
Robinsssson:master

Conversation

@Robinsssson
Copy link
Copy Markdown

Hi, I noticed that your project does not currently support the Windows platform, so I have created this pull request to address the issue. I hope it will be helpful to you. 😄

Comment thread armgcc.lua Outdated
set_toolset("ar", "arm-none-eabi-ar")
set_toolset("as", "arm-none-eabi-gcc")
if is_plat("windows") then
set_toolset("cc", "arm-none-eabi-gcc.exe")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 4 spaces instead of tab

Comment thread armgcc.lua Outdated
set_toolset("ld", "arm-none-eabi-gcc")
set_toolset("ar", "arm-none-eabi-ar")
set_toolset("as", "arm-none-eabi-gcc")
if is_plat("windows") then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should set toolset and call toolchain:is_plat in on_load.

https://github.com/xmake-io/xmake/blob/2c973f5431c7fc907ed52a01698f1dd51804507d/xmake/toolchains/armcc/xmake.lua#L46

on_load(function (toolchain)
    if toolchain:is_plat("windows") then
        toolchain:set("toolset", "cc", "...")
    end
end)

Comment thread armgcc.lua Outdated
-- io.writefile(gen_fi..".asm", asm)
os.execv("arm-none-eabi-objdump", {"-S", out}, {stdout=gen_fi..".asm"})
os.exec("arm-none-eabi-objcopy -O ihex "..out.." "..gen_fi..".hex")
if is_plat("windows") then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toolchain:is_plat

Comment thread armgcc.lua Outdated
os.execv("arm-none-eabi-objdump", {"-S", out}, {stdout=gen_fi..".asm"})
os.exec("arm-none-eabi-objcopy -O ihex "..out.." "..gen_fi..".hex")
if is_plat("windows") then
os.exec("arm-none-eabi-objcopy.exe -Obinary "..out.." "..gen_fi..".bin")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add spaces .. out ..

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and please use os.execv

Comment thread armgcc.lua Outdated
-- 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)
os.execv("arm-none-eabi-objdump.exe", {"-S", out}, {stdout=gen_fi..".asm"})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add spaces =

@Robinsssson
Copy link
Copy Markdown
Author

Thank you, I will address the issues you've mentioned.

Comment thread arm-gcc.lua Outdated
-- 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 is_plat("windows") then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target:is_plat

Comment thread .vscode/compile_commands.json Outdated
"directory": "d:\\project\\stm32-example-project",
"arguments": ["arm-none-eabi-gcc.exe", "-c", "-specs=nano.specs", "-mcpu=cortex-m4", "-mthumb", "-mfloat-abi=hard", "-mfpu=fpv4-sp-d16", "-fdata-sections", "-ffunction-sections", "-nostartfiles", "-Os", "-o", "build\\.objs\\minimal-proj\\cross\\cortex-m4\\release\\src\\startup.c.o", "src\\startup.c"],
"file": "src\\startup.c"
}]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this file

Comment thread arm-gcc.lua Outdated
rule("generate-hex")
after_build(function(target)
print("$(env ARM_TOOL)")
print("after_build: generate hex files")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove log

Comment thread arm-gcc.lua
Comment thread arm-gcc.lua Outdated
Comment thread arm-gcc.lua

on_run(function()
print("Run binary in Qemu!")
local bin_out = os.files("$(buildir)/*.bin")[1]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use import("lib.detect.find_file") instead of os.files, and use core.project.config + config.buildir() instead of $(buildir)

Comment thread arm-gcc.lua
print("Run binary in Qemu!")
local bin_out = os.files("$(buildir)/*.bin")[1]
if bin_out then
os.exec("qemu-system-arm -M stm32-p103 -nographic -kernel " .. bin_out)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.execv

Comment thread arm-gcc.lua
if bin_out then
os.exec("qemu-system-arm -M stm32-p103 -nographic -kernel " .. bin_out)
else
print("Do not find bin file in $(buildir)/")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use raise()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants