# android xmake f -p android -a arm64-v8a xmake b xmake f -p android -a armeabi-v7a xmake b xmake f -p android -a x86_64 xmake b # ios xmake f -p iphoneos -a ... xmake b # macos xmake f -p macosx -a ... xmake b # linux xmake f -p linux -a ... xmake b # windows xmake f -p mingw -a ... xmake b
functionindexOf(array, value) for i, v inipairs(array) do if v == value then return i end end returnnil end
functionxmakeBuild(platf, archf) if platf and archf then print("🔥 ".. platf .. "🌹 " .. archf) end localconfig = { "f" } if platf then table.insert(config, "-p") table.insert(config, platf) end if archf then table.insert(config, "-a") table.insert(config, archf) end os.execv("xmake", config) os.execv("xmake", { "package", "-P", "."}) end
functionbuildForPlatformArch(platf, archf) local hasTarget = false local archs = pari[platf] if archs then if archf then if indexOf(archs, archf) then xmakeBuild(platf, archf) hasTarget = true end else for _, arch inipairs(archs) do xmakeBuild(platf, arch) end hasTarget = true end end ifnot hasTarget then platf = platf or"Unknown platform" archf = archf or"Unknown architecture" print("🍄" .. platf .. "-".. archf .. " not supported!") end end
functionmain() local platf = option.get("platform") local archf = option.get("arch") if platf or arch then buildForPlatformArch(platf, archf) else xmakeBuild() end end
localfunctionindexOf(array, value) for i, v inipairs(array) do if v == value then return i end end returnnil end
localfunctionprintTable(t, indent) indent = indent or0 local indentStr = string.rep(" ", indent) iftype(t) ~= "table"then print(indentStr .. tostring(t)) return end
print(indentStr .. "{") for k, v inpairs(t) do local keyStr = tostring(k) iftype(v) == "table"then print(indentStr .. " " .. keyStr .. " = ") printTable(v, indent + 1) else local valueStr = tostring(v) print(indentStr .. " " .. keyStr .. " = " .. valueStr) end end print(indentStr .. "}") end
localfunctionxmakeBuild(platf, archf, execvFn) if platf and archf then print("🔥 ".. platf .. "🌹 " .. archf) end localconfig = { "f" } if platf then table.insert(config, "-p") table.insert(config, platf) end if archf then table.insert(config, "-a") table.insert(config, archf) end print("⛰️ xmakeBuild: " .. table.concat(config, ", ")) printTable(os) printTable(sudo) execvFn("xmake", config) execvFn("xmake", { "package", "-P", "."}) -- "--verbose" end
localfunctionbuildForPlatformArch(platf, archf, execvFn) local hasTarget = false local archs = pari[platf] if archs then if archf then if indexOf(archs, archf) then xmakeBuild(platf, archf, execvFn) hasTarget = true end else for _, arch inipairs(archs) do xmakeBuild(platf, arch, execvFn) end hasTarget = true end end ifnot hasTarget then platf = platf or"Unknown platform" archf = archf or"Unknown architecture" print("🍄" .. platf .. "-".. archf .. " not supported!") end end
on_run(function() import("core.base.option") local platf = option.get("platform") local archf = option.get("arch") printTable(os) if platf or arch then buildForPlatformArch(platf, archf, os.execv) else xmakeBuild(nil, nil, os.execv) end end)
主要就是在非on_run scope 定义的 local function 中,无法访问到 os 模块的扩展函数 execv, 所以这里通过将 execv function 传递到函数中去. 具体修复方案等待后续排查…
Only some readonly interfaces (for example: os.getenv, os.arch) in the os module can be used in the description scope. Other interfaces can only be used in the script domain, for example: os.cp, os .rmetc.
--rule("xcode.framework") ++rule("xcode.framework2") # do codesign, only for dynamic library --local codesign_skip = target:values("xcode.codesign_skip") ++local codesign_skip = target:values("xcode.codesign_skip") or get_config("xcode_codesign_skip") if target:is_shared() and not codesign_skip then
target("qjs") set_kind("shared") add_files("quickjs.c", "libregexp.c", "libunicode.c", "cutils.c", "quickjs-libc.c", "libbf.c") add_headerfiles("*.h") add_includedirs(".") if is_plat("linux") and get_config("arch") == "x86_64" then -- 使用 add_toolchain 来设置工具链 在 linux x86 上可以编译 arm,x86, linux arm 上只能编译 arm set_arch("x86_64") set_toolchains("gcc") end if is_plat("macosx", "iphoneos", "iphonesimulator") then ++add_rules("xcode.framework2") add_files("Info.plist") ++add_values("xcode.codesign_skip", true) end on_load(function (target) target:add("defines", "_GNU_SOURCE" ) end)