diff options
| author | ruki <[email protected]> | 2023-09-01 23:39:17 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-09-01 23:39:17 +0800 |
| commit | 17caad10c82710499126fab573f0df6f884bb219 (patch) | |
| tree | 92d3fb93e4011818142ae29e3fedcaafb6100fa5 | |
| parent | 0d5cd5fa52b63e398283a0f1e8f10462d8cb4f6a (diff) | |
improve package
| -rw-r--r-- | xmake/actions/package/local/main.lua | 6 | ||||
| -rw-r--r-- | xmake/plugins/macro/macros/package.lua | 45 |
2 files changed, 43 insertions, 8 deletions
diff --git a/xmake/actions/package/local/main.lua b/xmake/actions/package/local/main.lua index e40aa3b47..0f0758bed 100644 --- a/xmake/actions/package/local/main.lua +++ b/xmake/actions/package/local/main.lua @@ -252,8 +252,10 @@ function _do_package_target(target) , headeronly = _package_headeronly } local kind = target:kind() - assert(scripts[kind], "this target(%s) with kind(%s) can not be packaged!", target:name(), kind) - scripts[kind](target) + local script = scripts[kind] + if script then + script(target) + end end end diff --git a/xmake/plugins/macro/macros/package.lua b/xmake/plugins/macro/macros/package.lua index 173eff5fa..2b9ce8d6b 100644 --- a/xmake/plugins/macro/macros/package.lua +++ b/xmake/plugins/macro/macros/package.lua @@ -31,6 +31,7 @@ local options = , {'a', "arch", "kv", nil, "Set the architectures. e.g. 'armv7, arm64'" } , {'f', "config", "kv", nil, "Pass the config arguments to \"xmake config\" .." } , {'o', "outputdir", "kv", nil, "Set the output directory of the package." } +, {nil, "target", "v", nil, "The target name. It will package all default targets if this parameter is not specified."} } -- package all @@ -53,12 +54,32 @@ function main(argv) local plat = args.plat local archs = args.arch and args.arch:split(',') or platform.archs(plat) for _, arch in ipairs(archs) do - os.exec("xmake f -p %s -a %s %s -c %s", plat, arch, args.config or "", option.get("verbose") and "-v" or "") + local argv = {"f", "-cy", "-p", plat, "-a", arch} + if args.config then + table.insert(argv, args.config) + end + if option.get("verbose") then + table.insert(argv, "-v") + end + if option.get("diagnosis") then + table.insert(argv, "-D") + end + os.execv(os.programfile(), argv) + argv = {"p", "-f", "oldpkg"} if args.outputdir then - os.exec("xmake p -f oldpkg -o %s %s", args.outputdir, option.get("verbose") and "-v" or "") - else - os.exec("xmake p -f oldpkg %s", option.get("verbose") and "-v" or "") + table.insert(argv, "-o") + table.insert(argv, args.outputdir) + end + if option.get("verbose") then + table.insert(argv, "-v") + end + if option.get("diagnosis") then + table.insert(argv, "-D") end + if option.get("target") then + table.insert(argv, option.get("target")) + end + os.execv(os.programfile(), argv) end -- package universal for iphoneos, watchos ... @@ -68,7 +89,19 @@ function main(argv) os.cd(project.directory()) local outputdir = args.outputdir or config.get("buildir") - for _, target in pairs(project.targets()) do + local targets = {} + if option.get("target") then + local target = project.target(option.get("target")) + if target then + table.insert(targets, target) + end + else + for _, target in pairs(project.targets()) do + table.insert(targets, target) + end + end + for _, target in ipairs(targets) do + print("target", target:name()) local modes = {} for _, modedir in ipairs(os.dirs(format("%s/%s.pkg/*/*/lib/*", outputdir, target:name()))) do table.insert(modes, path.basename(modedir)) @@ -84,7 +117,7 @@ function main(argv) if lipoargs then lipoargs = format("-create %s -output %s/%s.pkg/%s/universal/lib/%s/%s", lipoargs, outputdir, target:name(), plat, mode, path.filename(target:targetfile())) os.mkdir(format("%s/%s.pkg/%s/universal/lib/%s", outputdir, target:name(), plat, mode)) - os.execv("xmake", {"l", "lipo", lipoargs}) + os.execv(os.programfile(), {"l", "lipo", lipoargs}) end end end |
