set_toolchains(xx@xx)绑定远程工具链的路径问题 #5585
-
package("rpi_toolchain")
set_kind("toolchain")
set_homepage("https://github.com/raspberrypi/tools")
set_description("raspberrypi toolchain")
if is_host("linux") then
set_urls("https://github.com/raspberrypi/tools.git")
add_versions("2021.11", "439b6198a9b340de5998dd14a26a0d9d38a6bcac")
end
on_install("@linux", function (package)
os.cp("arm-bcm2708/arm-linux-gnueabihf", package:installdir() .. "/arm-linux-gnueabihf")
end)
on_test(function (package)
local gcc = "arm-linux-gnueabihf-gcc"
os.exec("pwd")
os.vrunv(gcc, {"--version"})
end) 下面的xmake.lua通过定义toolchain并绑定包的方式使用它: set_plat("cross")
-- set_arch("arm")
add_requires("rpi_toolchain")
toolchain("rpi_cc")
set_kind("cross")
toolchain_end()
set_toolchains("rpi_cc@rpi_toolchain")
target("demo")
set_kind("binary")
add_files("src/*.c") 但是找不到,报错: ~/explore/demo 255 20:56:56
> xmake -rvD
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
/usr/bin/git rev-parse HEAD
checking for rpi_toolchain ... no
error: @programdir/core/main.lua:329: @programdir/core/sandbox/modules/import/core/base/task.lua:65: @programdir/core/tool/toolchain.lua:284: @programdir/toolchains/cross/check.lua:61: cross toolchain not found!
stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:1004]:
[@programdir/toolchains/cross/check.lua:61]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:241]:
[@programdir/core/tool/toolchain.lua:280]: in function 'check'
[@programdir/actions/config/main.lua:144]: in function '_check_target_toolchains'
[@programdir/actions/config/main.lua:403]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:241]:
[@programdir/core/base/task.lua:491]: in function 'run'
[@programdir/core/sandbox/modules/import/core/base/task.lua:63]: in function 'run'
[@programdir/actions/build/main.lua:191]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:241]:
[@programdir/core/base/task.lua:491]: in function 'run'
[@programdir/core/main.lua:327]: in function 'cotask'
[@programdir/core/base/scheduler.lua:406]:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:1004: in function 'base/os.raiselevel'
(...tail calls...)
@programdir/core/main.lua:329: in upvalue 'cotask'
@programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399> 把包的路径修改一下就可以了: ~/explore/demo 20:57:52
> ls -l /home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e
total 8
drwxr-xr-x 8 none none 4096 Sep 8 20:56 arm-linux-gnueabihf
-rw-r--r-- 1 none none 891 Sep 8 20:56 manifest.txt
~/explore/demo 20:57:57
> mv /home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/arm-linux-gnueabihf . -f
~/explore/demo 20:58:17
> mv arm-linux-gnueabihf/* /home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/ -f
~/explore/demo 20:58:32
> xmake -v
checking for gcc ... /usr/bin/gcc
checking for zig ... no
checking for zig ... no
checking for nim ... no
checking for nim ... no
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
/usr/bin/git rev-parse HEAD
checking for rpi_toolchain ... no
checking for arm-linux-gnueabihf-gcc ... /home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/bin/arm-linux-gnueabihf-gcc
checking for the c compiler (cc) ... arm-linux-gnueabihf-gcc
checking for /home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/bin/arm-linux-gnueabihf-gcc ... ok
checking for flags (-fPIC) ... ok
[ 50%]: cache compiling.release src/main.c
/home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/bin/arm-linux-gnueabihf-gcc -c -o build/.objs/demo/cross/x86_64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for arm-linux-gnueabihf-g++ ... /home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/bin/arm-linux-gnueabihf-g++
checking for the linker (ld) ... arm-linux-gnueabihf-g++
checking for /home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/bin/arm-linux-gnueabihf-g++ ... ok
checking for flags (-fPIC) ... ok
[ 75%]: linking.release demo
/home/none/.xmake/packages/r/rpi_toolchain/2021.11/e5318445f6494a29a6b40ad3e3afe33e/bin/arm-linux-gnueabihf-g++ -o build/cross/x86_64/release/demo build/.objs/demo/cross/x86_64/release/src/main.c.o
[100%]: build ok, spent 0.419s 好奇set_toolchains(toolchain@pkg)这种方式如何绑定pkg?查找路径是怎样的? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
toolchain 里要自己处理对 package 的绑定,没处理 就绑定不了 xmake/xmake/toolchains/cross/check.lua Line 40 in 7ae40eb xmake/xmake/toolchains/muslcc/xmake.lua Line 31 in 7ae40eb |
Beta Was this translation helpful? Give feedback.
-
可以,只能在 on_load 里面调用,其他地方不要瞎用
包装的路径也不对, https://github.com/xmake-io/xmake/blob/dev/tests/projects/package/toolchain_muslcc/xmake.lua |
Beta Was this translation helpful? Give feedback.
toolchain 里要自己处理对 package 的绑定,没处理 就绑定不了
xmake/xmake/toolchains/cross/check.lua
Line 40 in 7ae40eb
xmake/xmake/toolchains/muslcc/xmake.lua
Line 31 in 7ae40eb