xmake-io / xmake-repo

📦 An official xmake package repository
https://xrepo.xmake.io
Apache License 2.0
669 stars 393 forks source link

您好,希望支持工具链镜像路径,国内下载实在太慢 #941

Closed Dozingfiretruck closed 2 years ago

Dozingfiretruck commented 2 years ago

你在什么场景下需要该功能?

您好,拉取远程工具链很方便,但是国内不用科学方式实在太慢,毕竟工具链比较大,希望支持工具链镜像路径

描述可能的解决方案

请尽量清晰精准地描述你期待我们要做的,描述你想到的实现方案。

描述你认为的候选方案

请尽量清晰精准地描述你能接受的候选解决方案。

其他信息

请提供关于该功能建议的其他附加信息。

waruqi commented 2 years ago

这个没办法,我没资金去特地整镜像服务,目前部分二进制是放到 github/xmake-mirror 下,让用户自己配置 fastgit 或者其他 github 镜像下载,但也只是挂挂 python 等一些开源工具链。。

但是像 gnu-rm 这种商业公司的二进制工具链,也不确定是否有其他版权风险,我不敢私自挂到第三方存储上去分发下载。

Dozingfiretruck commented 2 years ago

不是自建,是自定义镜像地址,用户可以自己设置

waruqi commented 2 years ago

原本就可以啊,自己配置下 pac.lua 看下文档 https://xmake.io/#/zh-cn/package/remote_package?id=%e9%95%9c%e5%83%8f%e4%bb%a3%e7%90%86

或者直接自定义 package 覆盖 xmake-repo 里面的包定义,改写 add_urls

Dozingfiretruck commented 2 years ago

您好,我自定义 package了,下载安装都很正常,最后报错找不到工具链 image

image

waruqi commented 2 years ago

set_toolchains("gnu-rm@gnu_rm")

Dozingfiretruck commented 2 years ago

set_toolchains("gnu-rm@gnu_rm")

这样写确实可以了,这有啥区别呢?没看懂和gnu-rm有啥关系,是替换?我们还有一个工程工具链是平头哥的,package还没有,是不是要先提交一个然后再这样用?

waruqi commented 2 years ago

工具链和包绑定 set_toolchains("toolchain@package")

你要像跟之前一样的配法,那就你的包名字改成 gnu-rm ,不要 gnu_rm

waruqi commented 2 years ago

如果是 dev 版本,还可以试下走 set_base 来直接继承改写 现有包的部分配置,比如修改urls

https://github.com/xmake-io/xmake/issues/2011

Dozingfiretruck commented 2 years ago

感谢,我现在另一个工程遇到了同样的问题 image 提示没有工具链 image 这是阿里平头哥的编译工具连,package中还没有,请问我要如何设置才能识别我自己新加的工具链呢?

waruqi commented 2 years ago

你的工具链定义在哪?项目 xmake.lua?

Dozingfiretruck commented 2 years ago

你的工具链定义在哪?项目 xmake.lua?

这部分代码是写在xmake.lua里的

waruqi commented 2 years ago

那应该能找到才对,除非你有包是用 xmake.lua 维护的,走了 tools/xmake.install 才会找不到。。你可以自己加一下 -vD 看下完整错误输出

Dozingfiretruck commented 2 years ago

那应该能找到才对,除非你有包是用 xmake.lua 维护的,走了 tools/xmake.install 才会找不到。。你可以自己加一下 -vD 看下完整错误输出

image

waruqi commented 2 years ago

我这里可以,没啥问题,你确定你的 xmake.lua 定义了 toolchain("csky")? 完整贴下 xmake.lua 呢

Dozingfiretruck commented 2 years ago

我这里可以,没啥问题,你确定你的 xmake.lua 定义了 toolchain("csky")? 完整贴下 xmake.lua 呢

之前的问题解决了,我把定义当成之前自定义的代码注释掉了,现在出现了新问题,工具链编译工程失败,现象和未指定sdk_dir是一样的 xmake.lua代码: `set_project("AIR101") set_xmakever("2.5.8")

-- set_version("0.0.2", {build = "%Y%m%d%H%M"}) add_rules("mode.debug", "mode.release")

local AIR10X_VERSION local luatos = "../LuatOS/" local TARGET_NAME local AIR10X_FLASH_FS_REGION_SIZE

-- local sdk_dir = "D:\csky-elfabiv2-tools-mingw-minilibc\" -- if is_plat("linux") then -- sdk_dir = "/opt/csky-elfabiv2-tools/" -- elseif is_plat("windows") then -- sdk_dir = "E:\csky-elfabiv2-tools-mingw-minilibc\" -- end

-- local flto = " -flto "

-- toolchain("csky_toolchain") -- set_kind("standalone") -- set_sdkdir(sdk_dir) -- toolchain_end()

-- set_toolchains("csky_toolchain")

toolchain("csky") set_kind("standalone") toolchain_end()

package("csky") set_kind("toolchain") set_homepage("https://occ.t-head.cn/community/download?id=3885366095506644992") set_description("GNU Csky Embedded Toolchain")

if is_host("windows") then
    set_urls("http://cdndownload.openluat.com/xmake/toolchains/csky/csky-elfabiv2-tools-mingw-minilibc-$(version).tar.gz")
    add_versions("20210423", "e7d0130df26bcf7b625f7c0818251c04e6be4715ed9b3c8f6303081cea1f058b")
elseif is_host("linux") then
    set_urls("http://cdndownload.openluat.com/xmake/toolchains/csky/csky-elfabiv2-tools-x86_64-minilibc-$(version).tar.gz")
    add_versions("20210423", "8b9a353c157e4d44001a21974254a21cc0f3c7ea2bf3c894f18a905509a7048f")
end
on_install("@windows", "@linux", function (package)
    os.vcp("*", package:installdir())
end)

package_end()

add_requires("csky 20210423") set_toolchains("csky@csky")

local flto = ""

--add macro defination add_defines("GCC_COMPILE=1","TLS_CONFIG_CPU_XT804=1","NIMBLE_FTR=1","LUATOS")

set_warnings("all") set_optimize("smallest") -- set language: c99 set_languages("c99") add_asflags(flto .. "-DTLS_CONFIG_CPU_XT804=1 -DGCC_COMPILE=1 -mcpu=ck804ef -std=gnu99 -c -mhard-float -Wa,--gdwarf2 -fdata-sections -ffunction-sections") add_cflags(flto .. "-DTLS_CONFIG_CPU_XT804=1 -DGCC_COMPILE=1 -mcpu=ck804ef -std=gnu99 -c -mhard-float -Wall -fdata-sections -ffunction-sections") add_cxflags(flto .. "-DTLS_CONFIG_CPU_XT804=1 -DGCC_COMPILE=1 -mcpu=ck804ef -std=gnu99 -c -mhard-float -Wall -fdata-sections -ffunction-sections")

set_dependir("$(buildir)/.deps") set_objectdir("$(buildir)/.objs")

set_policy("build.across_targets_in_parallel", false)

target("app") set_kind("static") set_plat("cross") set_arch("c-sky")

add_includedirs("app/port",{public = true})

add_files("src/app/**.c")
del_files("src/app/btapp/**.c")

add_includedirs(os.dirs(path.join(os.scriptdir(),"src/app/**")))
add_includedirs(os.dirs(path.join(os.scriptdir(),"src/bt/blehost/**")))

add_includedirs("include",{public = true})
add_includedirs("include/app",{public = true})
add_includedirs("include/driver",{public = true})
add_includedirs("include/os",{public = true})
add_includedirs("include/bt",{public = true})
add_includedirs("include/platform",{public = true})
add_includedirs("platform/common/params",{public = true})
add_includedirs("include/wifi",{public = true})
add_includedirs("include/arch/xt804",{public = true})
add_includedirs("include/arch/xt804/csi_core",{public = true})
add_includedirs("include/net",{public = true})
add_includedirs("demo",{public = true})
add_includedirs("platform/inc",{public = true})

target_end()

target("wmarch") set_kind("static") set_plat("cross") set_arch("c-sky") set_targetdir("$(projectdir)/lib")

add_files("platform/arch/**.c")
add_files("platform/arch/**.S")
add_includedirs("include",{public = true})
add_includedirs("include/driver",{public = true})
add_includedirs("include/os",{public = true})
add_includedirs("include/arch/xt804",{public = true})
add_includedirs("include/arch/xt804/csi_core",{public = true})

after_load(function (target)
    for _, sourcebatch in pairs(target:sourcebatches()) do
        if sourcebatch.sourcekind == "as" then -- only asm files
            for idx, objectfile in ipairs(sourcebatch.objectfiles) do
                sourcebatch.objectfiles[idx] = objectfile:gsub("%.S%.o", ".o")
            end
        end
    end
end)

target_end()

target("blehost") set_kind("static") set_plat("cross") set_arch("c-sky")

add_files("src/bt/blehost/**.c")
add_includedirs(os.dirs(path.join(os.scriptdir(),"src/bt/blehost/**")))
add_includedirs("src/app/bleapp",{public = true})
add_includedirs("src/os/rtos/include",{public = true})
add_includedirs("include",{public = true})
add_includedirs("include/bt",{public = true})
add_includedirs("include/platform",{public = true})
add_includedirs("include/os",{public = true})
add_includedirs("include/arch/xt804",{public = true})
add_includedirs("include/arch/xt804/csi_core",{public = true})

target_end()

target("lvgl") set_kind("static") set_plat("cross") set_arch("c-sky")

on_load(function (target)
    local conf_data = io.readfile("$(projectdir)/app/port/luat_conf_bsp.h")
    local LVGL_CONF = conf_data:find("// #define LUAT_USE_LVGL\n")
    if LVGL_CONF == nil then target:set("default", true) else target:set("default", false) end
end)

add_files(luatos.."components/lvgl/**.c")

add_includedirs("app/port",{public = true})
add_includedirs("include",{public = true})
add_includedirs(luatos.."lua/include",{public = true})
add_includedirs(luatos.."luat/include",{public = true})
add_includedirs(luatos.."components/lcd",{public = true})
add_includedirs(luatos.."components/lvgl",{public = true})
add_includedirs(luatos.."components/lvgl/binding",{public = true})
add_includedirs(luatos.."components/lvgl/gen",{public = true})
add_includedirs(luatos.."components/lvgl/src",{public = true})
add_includedirs(luatos.."components/lvgl/font",{public = true})
add_includedirs(luatos.."luat/packages/u8g2")

set_targetdir("$(buildir)/lib")

target_end()

target("u8g2") set_kind("static") set_plat("cross") set_arch("c-sky")

add_files(luatos.."luat/packages/u8g2/*.c")

add_includedirs("app/port",{public = true})
add_includedirs("include",{public = true})
add_includedirs(luatos.."lua/include",{public = true})
add_includedirs(luatos.."luat/include",{public = true})
add_includedirs(luatos.."luat/packages/u8g2",{public = true})
add_includedirs(luatos.."components/gtfont")

set_targetdir("$(buildir)/lib")

target_end()

target("air10x") -- set kind set_kind("binary") set_plat("cross") set_arch("c-sky") set_targetdir("$(buildir)/out") on_load(function (target) local conf_data = io.readfile("$(projectdir)/app/port/luat_conf_bsp.h") AIR10X_FLASH_FS_REGION_SIZE = conf_data:match("#define FLASH_FS_REGION_SIZE (%d+)") AIR10X_VERSION = conf_data:match("#define LUAT_BSP_VERSION \"(%w+)\"") local LVGL_CONF = conf_data:find("// #define LUAT_USE_LVGL\n") if LVGL_CONF == nil then target:add("deps", "lvgl") end local custom_data = io.readfile("$(projectdir)/app/port/luat_conf_bsp.h") local TARGET_CONF = custom_data:find("#define AIR101") if TARGET_CONF == nil then TARGET_NAME = "AIR103" else TARGET_NAME = "AIR101" end local FDB_CONF = conf_data:find("// #define LUAT_USE_FDB ") if FDB_CONF == nil then local ld_data = io.readfile("./ld/"..TARGET_NAME..".ld") local I_SRAM_LENGTH = ld_data:match("I-SRAM : ORIGIN = 0x08010800 , LENGTH = 0x(%x+)") local I_SRAM_LENGTH_N = string.format("%X",tonumber('0X'..I_SRAM_LENGTH)-64*1024) local ld_data_n = ld_data:gsub(I_SRAM_LENGTH,I_SRAM_LENGTH_N) io.writefile("./ld/air101_103.ld", ld_data_n) else os.cp("./ld/"..TARGET_NAME..".ld", "./ld/air101_103.ld") end

    target:set("filename", TARGET_NAME..".elf")
    target:add("ldflags", flto .. "-Wl,--gc-sections -Wl,-zmax-page-size=1024 -Wl,--whole-archive ./lib/libwmarch.a ./lib/libgt.a ./lib/libwlan.a ./lib/libdsp.a ./lib/libbtcontroller.a -Wl,--no-whole-archive -mcpu=ck804ef -nostartfiles -mhard-float -lm -Wl,-T./ld/air101_103.ld -Wl,-ckmap=./build/out/"..TARGET_NAME..".map ",{force = true})
end)

add_deps("app")
-- add_deps("wmarch")
add_deps("blehost")
add_deps("u8g2")

-- add files
add_files("app/*.c")
add_files("app/port/*.c")
add_files("app/custom/*.c")
add_files("platform/sys/*.c")
add_files("platform/drivers/**.c")
add_files("src/os/**.c")
add_files("src/os/**.S")
add_files("platform/common/**.c")

add_includedirs("src/app/mbedtls/include",{public = true})
add_includedirs("platform/arch",{public = true})
add_includedirs("include/os",{public = true})
add_includedirs("include/wifi",{public = true})
add_includedirs("include/arch/xt804",{public = true})
add_includedirs("include/arch/xt804/csi_core",{public = true})
add_includedirs("include/app",{public = true})
add_includedirs("include/net",{public = true})
add_includedirs("demo",{public = true})
add_includedirs("platform/inc",{public = true})

add_includedirs("demo/console")
add_includedirs("include/arch/xt804/csi_dsp")
add_includedirs("platform/sys")
add_includedirs("src/app/mbedtls/ports")
add_includedirs("src/app/fatfs")

add_files(luatos.."lua/src/*.c")
add_files(luatos.."luat/modules/*.c")
add_files(luatos.."luat/vfs/*.c")
del_files(luatos.."luat/vfs/luat_fs_posix.c")

add_files(luatos.."components/lcd/*.c")
add_files(luatos.."components/sfd/*.c")
add_files(luatos.."components/nr_micro_shell/*.c")
add_files(luatos.."components/luf/*.c")
add_files(luatos.."luat/packages/eink/*.c")
add_files(luatos.."luat/packages/epaper/*.c")
del_files(luatos.."luat/packages/epaper/GUI_Paint.c")
add_files(luatos.."luat/packages/iconv/*.c")
add_files(luatos.."luat/packages/lfs/*.c")
add_files(luatos.."luat/packages/lua-cjson/*.c")
add_files(luatos.."luat/packages/minmea/*.c")
add_files(luatos.."luat/packages/qrcode/*.c")
-- add_files(luatos.."luat/packages/u8g2/*.c")
add_files(luatos.."luat/weak/*.c")

add_includedirs(luatos.."lua/include",{public = true})
add_includedirs(luatos.."luat/include",{public = true})
add_includedirs(luatos.."components/lcd",{public = true})
add_includedirs(luatos.."components/lvgl",{public = true})
add_includedirs(luatos.."components/lvgl/binding",{public = true})
add_includedirs(luatos.."components/lvgl/gen",{public = true})
add_includedirs(luatos.."components/lvgl/src",{public = true})
add_includedirs(luatos.."components/lvgl/font",{public = true})

add_includedirs(luatos.."luat/packages/eink")
add_includedirs(luatos.."luat/packages/epaper")
add_includedirs(luatos.."luat/packages/iconv")
add_includedirs(luatos.."luat/packages/lfs")
add_includedirs(luatos.."luat/packages/lua-cjson")
add_includedirs(luatos.."luat/packages/minmea")
add_includedirs(luatos.."luat/packages/qrcode")

add_files(luatos.."components/sfud/*.c")
add_includedirs(luatos.."components/sfud")

add_files(luatos.."components/statem/*.c")
add_includedirs(luatos.."components/statem")

add_files(luatos.."components/coremark/*.c")
add_includedirs(luatos.."components/coremark")

add_files(luatos.."components/cjson/*.c")
add_includedirs(luatos.."components/cjson")

-- gtfont
add_includedirs(luatos.."components/gtfont")
add_files(luatos.."components/gtfont/*.c")

add_files(luatos.."components/luatfonts/*.c")
add_includedirs(luatos.."components/luatfonts")

add_files(luatos.."components/zlib/*.c")
add_includedirs(luatos.."components/zlib")

add_files(luatos.."components/mlx90640-library/*.c")
add_includedirs(luatos.."components/mlx90640-library")

add_files(luatos.."components/i2c-tools/*.c")
add_includedirs(luatos.."components/i2c-tools")

-- ble
add_includedirs("src/app/bleapp", "src/bt/blehost/nimble/include", "src/bt/blehost/nimble/host/include", "include/bt")
add_includedirs("src/bt/blehost/nimble/transport/uart/include", "src/bt/blehost/porting/xt804/include")
add_includedirs("src/bt/blehost/ext/tinycrypt/include", "src/bt/blehost/nimble/host/util/include")

add_includedirs(luatos.."components/nr_micro_shell")

-- flashdb & fal
add_includedirs(luatos.."components/fal/inc")
add_files(luatos.."components/fal/src/*.c")
add_includedirs(luatos.."components/flashdb/inc")
add_files(luatos.."components/flashdb/src/*.c")

after_build(function(target)
    sdk_dir = target:toolchains()[1]:sdkdir().."/"
    os.exec(sdk_dir .. "bin/csky-elfabiv2-objcopy -O binary $(buildir)/out/"..TARGET_NAME..".elf $(buildir)/out/"..TARGET_NAME..".bin")
    io.writefile("$(buildir)/out/"..TARGET_NAME..".asm", os.iorun(sdk_dir .. "bin/csky-elfabiv2-objdump -d $(buildir)/out/"..TARGET_NAME..".elf"))
    io.writefile("$(buildir)/out/"..TARGET_NAME..".list", os.iorun(sdk_dir .. "bin/csky-elfabiv2-objdump -h -S $(buildir)/out/"..TARGET_NAME..".elf"))
    io.writefile("$(buildir)/out/"..TARGET_NAME..".size", os.iorun(sdk_dir .. "bin/csky-elfabiv2-size $(buildir)/out/"..TARGET_NAME..".elf"))
    io.cat("$(buildir)/out/"..TARGET_NAME..".size")
    -- if TARGET_NAME == "AIR101" then
    --     os.exec("./tools/xt804/wm_tool"..(is_plat("windows") and ".exe" or "").." -b $(buildir)/out/"..TARGET_NAME..".bin -fc 0 -it 1 -ih 8020000 -ra 8020400 -ua 8010000 -nh 0 -un 0 -vs G01.00.02 -o $(buildir)/out/"..TARGET_NAME.."")
    --     os.exec("./tools/xt804/wm_tool"..(is_plat("windows") and ".exe" or "").." -b  ./tools/xt804/xt804_secboot.bin -fc 0 -it 0 -ih 8002000 -ra 8002400 -ua 8010000 -nh 8020000 -un 0 -o ./tools/xt804/"..TARGET_NAME.."_secboot")
    -- elseif TARGET_NAME == "AIR103" then
        os.exec("./tools/xt804/wm_tool"..(is_plat("windows") and ".exe" or "").." -b $(buildir)/out/"..TARGET_NAME..".bin -fc 0 -it 1 -ih 8010400 -ra 8010800 -ua 8010000 -nh 0 -un 0 -vs G01.00.02 -o $(buildir)/out/"..TARGET_NAME.."")
        os.exec("./tools/xt804/wm_tool"..(is_plat("windows") and ".exe" or "").." -b  ./tools/xt804/xt804_secboot.bin -fc 0 -it 0 -ih 8002000 -ra 8002400 -ua 8010000 -nh 8010400 -un 0 -o ./tools/xt804/"..TARGET_NAME.."_secboot")
    -- end
    os.cp("./tools/xt804/"..TARGET_NAME.."_secboot.img", "$(buildir)/out/"..TARGET_NAME..".fls")
    local img = io.readfile("$(buildir)/out/"..TARGET_NAME..".img", {encoding = "binary"})
    local fls = io.open("$(buildir)/out/"..TARGET_NAME..".fls", "a+")
    if fls then fls:write(img) fls:close() end
    if is_mode("debug") then
        os.cd("./mklfs")
        os.exec("./luac_536_32bits.exe -s -o ./disk/main.luac ../main.lua")
        os.exec("./mklfs.exe -size 112")
        os.cd("../")
        os.mv("./mklfs/disk.fs", "$(buildir)/out/script.bin")
        if TARGET_NAME == "AIR101" then
            os.exec("./tools/xt804/wm_tool"..(is_plat("windows") and ".exe" or "").." -b  $(buildir)/out/script.bin -it 1 -fc 0 -ih 20008000 -ra 81E0000 -ua 0 -nh 0  -un 0 -o $(buildir)/out/script")
        else
            os.exec("./tools/xt804/wm_tool"..(is_plat("windows") and ".exe" or "").." -b  $(buildir)/out/script.bin -it 1 -fc 0 -ih 20008000 -ra 80E0000 -ua 0 -nh 0  -un 0 -o $(buildir)/out/script")
        end
        local script = io.readfile("$(buildir)/out/script.img", {encoding = "binary"})
        local fls = io.open("$(buildir)/out/"..TARGET_NAME..".fls", "a+")
        if fls then fls:write(script) fls:close() end
    elseif is_mode("release") then
        import("lib.detect.find_file")
        os.cp("$(buildir)/out/"..TARGET_NAME..".fls", "./soc_tools/"..TARGET_NAME..".fls")
        local path7z = "7z.exe"
        if is_plat("windows") then
            path7z = find_file("7z.exe", { "C:/Program Files/7-Zip/", "D:/Program Files/7-Zip/", "E:/Program Files/7-Zip/"})
        elseif is_plat("linux") then
            path7z = find_file("7z", { "/usr/bin/"})
            if not path7z then
                path7z = find_file("7zr", { "/usr/bin/"})
            end
        end
        if path7z then
            if AIR10X_FLASH_FS_REGION_SIZE then
                print("AIR10X_FLASH_FS_REGION_SIZE",AIR10X_FLASH_FS_REGION_SIZE)
                local info_data = io.readfile("./soc_tools/"..TARGET_NAME..".json")
                local LVGL_CONF = info_data:gsub("\"size\" : 112\n","\"size\" : "..AIR10X_FLASH_FS_REGION_SIZE.."\n")
                local offset,LVGL_JSON
                if TARGET_NAME == "AIR101" then
                    offset = string.format("%X",0x81FC000-AIR10X_FLASH_FS_REGION_SIZE*1024)
                    LVGL_JSON = LVGL_CONF:gsub("\"offset\" : \"81E0000\",\n","\"offset\" : \""..offset.."\",\n")
                else
                    offset = string.format("%X",0x80FC000-AIR10X_FLASH_FS_REGION_SIZE*1024)
                    LVGL_JSON = LVGL_CONF:gsub("\"offset\" : \"80E0000\",\n","\"offset\" : \""..offset.."\",\n")
                end
                io.writefile("./soc_tools/info.json", LVGL_JSON)
            else
                os.cp("./soc_tools/"..TARGET_NAME..".json", "./soc_tools/info.json")
            end
            os.exec(path7z.." a LuatOS-SoC_"..AIR10X_VERSION.."_"..TARGET_NAME..".7z ./soc_tools/air101_flash.exe ./soc_tools/info.json ./app/port/luat_conf_bsp.h ./soc_tools/"..TARGET_NAME..".fls")
            os.mv("LuatOS-SoC_"..AIR10X_VERSION.."_"..TARGET_NAME..".7z", "$(buildir)/out/LuatOS-SoC_"..AIR10X_VERSION.."_"..TARGET_NAME..".soc")
            os.rm("./soc_tools/info.json")
            os.rm("./soc_tools/"..TARGET_NAME..".fls")
        else
            print("7z not find")
            os.rm("./soc_tools/"..TARGET_NAME..".fls")
            return
        end

    end
    os.rm("./ld/air101_103.ld")
    -- os.exec("./tools/xt804/wm_tool"..(is_plat("windows") and ".exe" or "").." -b $(buildir)/out/AIR101.img -fc 1 -it 1 -ih 80D0000 -ra 80D0400 -ua 8010000 -nh 0 -un 0 -vs G01.00.02 -o $(buildir)/out/AIR101")
    -- os.mv("$(buildir)/out/AIR101_gz.img", "$(buildir)/out/AIR101_ota.img")
end)

target_end()

` 报错: image image 本地指定工具链编译正常

waruqi commented 2 years ago

你不指定 sdk_dir ,去哪找编译器? 自己 -vD 看下,自己分析下错误

Dozingfiretruck commented 2 years ago

你不指定 sdk_dir ,去哪找编译器? 自己 -vD 看下,自己分析下错误

额我自定义的package下载的工具链,这样不能找到编译器么?因为gnu-rm我是这么写的能正常使用,上面是完整的xmake代码,是哪里还需要定义么? 报错: image image image

waruqi commented 2 years ago

额我自定义的package下载的工具链,这样不能找到编译器么?因为gnu-rm我是这么写的能正常使用,上面是完整的xmake代码,是哪里还需要定义么?

你自定义的package,那只是包而已,不是工具链,仅用于 add_requires("csky") 远程拉取下载。。

工具链是 toolchain("csky") 定义的,它也只是个工具链而已,不是包,你需要指定 sdk 路径,或者其他编译器路径,才能用,不负责包的下载安装集成。。

set_toolchains("foo@bar") 的意思,就是吧 你定义的包 package("bar")绑定到对应的 toolchain("foo") 上去,然后把它们设置到对应的 target 上生效。

只有这个绑定了,你 toolchain() 定义的工具链,才能找到你 package() 定义的包的路径。。不要搞混了

waruqi commented 2 years ago

另外,这个绑定的逻辑,也是 toolchain() 里面指定的,不是所有工具链,默认都会去支持 package 的绑定,目前进 cross 工具链,zig 等才支持。。

gnu-rm 是内置工具链,默认为 cross 工具链类型

https://github.com/xmake-io/xmake/blob/2824e7da1ad5dfef6517739faed7d3d4a5f05e90/xmake/toolchains/gnu-rm/xmake.lua#L29

通过 set_kind 设置了 cross 类型,继承了 cross 工具链的绑定逻辑,才会去绑定 package 定义的工具链 sdk

https://github.com/xmake-io/xmake/blob/2824e7da1ad5dfef6517739faed7d3d4a5f05e90/xmake/toolchains/cross/check.lua#L40-L49

你可以参考 gnu-rm 的定义,自己改下

Dozingfiretruck commented 2 years ago

另外,这个绑定的逻辑,也是 toolchain() 里面指定的,不是所有工具链,默认都会去支持 package 的绑定,目前进 cross 工具链,zig 等才支持。。

gnu-rm 是内置工具链,默认为 cross 工具链类型

https://github.com/xmake-io/xmake/blob/2824e7da1ad5dfef6517739faed7d3d4a5f05e90/xmake/toolchains/gnu-rm/xmake.lua#L29

通过 set_kind 设置了 cross 类型,继承了 cross 工具链的绑定逻辑,才会去绑定 package 定义的工具链 sdk

https://github.com/xmake-io/xmake/blob/2824e7da1ad5dfef6517739faed7d3d4a5f05e90/xmake/toolchains/cross/check.lua#L40-L49

你可以参考 gnu-rm 的定义,自己改下

原来是这样,之前理解错了,非常感谢

Dozingfiretruck commented 2 years ago

已经可以了,哈哈,感谢大佬