diff options
| -rw-r--r-- | tests/actions/package/localpkg/libfoo/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/actions/package/local/main.lua | 38 | ||||
| -rw-r--r-- | xmake/actions/package/remote/main.lua | 25 |
3 files changed, 40 insertions, 24 deletions
diff --git a/tests/actions/package/localpkg/libfoo/xmake.lua b/tests/actions/package/localpkg/libfoo/xmake.lua index 1b1dd5a41..a6e5c7cb0 100644 --- a/tests/actions/package/localpkg/libfoo/xmake.lua +++ b/tests/actions/package/localpkg/libfoo/xmake.lua @@ -1,4 +1,5 @@ add_rules("mode.debug", "mode.release") +set_license("Apache-2.0") target("sub") set_kind("static") diff --git a/xmake/actions/package/local/main.lua b/xmake/actions/package/local/main.lua index aa6654fc1..33aed24b7 100644 --- a/xmake/actions/package/local/main.lua +++ b/xmake/actions/package/local/main.lua @@ -52,18 +52,23 @@ function _package_binary(target) for _, dep in ipairs(target:orderdeps()) do table.insert(deps, dep:name()) end - file:print([[package("%s") - set_kind("binary") - set_description("%s") - %s + file:print("package(\"%s\")", packagename) + file:print(" set_description(\"%s\")", "The " .. packagename .. " package") + if target:license() then + file:print(" set_license(\"%s\")", target:license()) + end + if #deps > 0 then + file:print(" set_deps(\"%s\")", table.concat(deps, "\", \"")) + end + file:print("") + file:print([[ on_load(function (package) package:set("installdir", path.join(os.scriptdir(), package:plat(), package:arch(), package:mode())) end) + on_fetch(function (package) return {program = path.join(package:installdir("bin"), "%s")} - end)]], packagename, - "The " .. packagename .. " package", - #deps > 0 and ("add_deps(\"" .. table.concat(deps, "\", \"") .. "\")") or "", + end)]], #deps > 0 and ("add_deps(\"" .. table.concat(deps, "\", \"") .. "\")") or "", path.filename(targetfile)) file:close() end @@ -124,22 +129,27 @@ function _package_library(target) for _, dep in ipairs(target:orderdeps()) do table.insert(deps, dep:name()) end - file:print([[package("%s") - set_description("%s") - %s + file:print("package(\"%s\")", packagename) + file:print(" set_description(\"%s\")", "The " .. packagename .. " package") + if target:license() then + file:print(" set_license(\"%s\")", target:license()) + end + if #deps > 0 then + file:print(" set_deps(\"%s\")", table.concat(deps, "\", \"")) + end + file:print("") + file:print([[ on_load(function (package) package:set("installdir", path.join(os.scriptdir(), package:plat(), package:arch(), package:mode())) end) + on_fetch(function (package) local result = {} result.links = "%s" result.linkdirs = package:installdir("lib") result.includedirs = package:installdir("include") return result - end)]], packagename, - "The " .. packagename .. " package", - #deps > 0 and ("add_deps(\"" .. table.concat(deps, "\", \"") .. "\")") or "", - target:linkname(), + end)]], target:linkname(), path.filename(targetfile)) file:close() end diff --git a/xmake/actions/package/remote/main.lua b/xmake/actions/package/remote/main.lua index 917d89226..3d46d10ba 100644 --- a/xmake/actions/package/remote/main.lua +++ b/xmake/actions/package/remote/main.lua @@ -45,13 +45,22 @@ function _package_remote(target) for _, dep in ipairs(target:orderdeps()) do table.insert(deps, dep:name()) end - file:print([[package("%s") - %s - set_description("%s") - + file:print("package(\"%s\")", packagename) + if target:is_binary() then + file:print(" set_kind(\"binary\")") + end + file:print(" set_description(\"%s\")", "The " .. packagename .. " package") + if target:license() then + file:print(" set_license(\"%s\")", target:license()) + end + if #deps > 0 then + file:print(" set_deps(\"%s\")", table.concat(deps, "\", \"")) + end + file:print("") + file:print([[ add_urls("https://github.com/myrepo/foo.git") add_versions("%s", "<shasum256 or gitcommit>") - %s + on_install(function (package) local configs = {} if package:config("shared") then @@ -63,11 +72,7 @@ function _package_remote(target) on_test(function (package) -- TODO check includes and interfaces -- assert(package:has_cfuncs("foo", {includes = "foo.h"}) - end)]], packagename, - target:is_binary() and "set_kind(\"binary\")" or "", - "The " .. packagename .. " package", - target:version() and (target:version()) or "1.0", - #deps > 0 and ("add_deps(\"" .. table.concat(deps, "\", \"") .. "\")") or "") + end)]], target:version() and (target:version()) or "1.0") file:close() end |
