diff options
| author | ruki <[email protected]> | 2020-10-29 00:12:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-29 00:12:54 +0800 |
| commit | 83104b07b4511c5f592173cfd4a261a5d2373146 (patch) | |
| tree | 35e5a68f4c28721c976f98d3d4eb39b16cb3e344 | |
| parent | 140d675280a6cb46c02ed48c925fb0f694f70f21 (diff) | |
add target os for cross-compilation
| -rw-r--r-- | xmake/actions/config/xmake.lua | 17 | ||||
| -rw-r--r-- | xmake/actions/require/impl/package.lua | 1 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 19 | ||||
| -rw-r--r-- | xmake/core/platform/platform.lua | 4 |
4 files changed, 31 insertions, 10 deletions
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua index 871070821..652e034b9 100644 --- a/xmake/actions/config/xmake.lua +++ b/xmake/actions/config/xmake.lua @@ -44,7 +44,7 @@ task("config") {'c', "clean", "k", nil , "Clean the cached configure and configure all again." } , {nil, "menu", "k", nil , "Configure project with a menu-driven user interface." } , {category = "."} - , {'p', "plat", "kv", "$(subhost)" , "Compile for the given platform." + , {'p', "plat", "kv", "$(subhost)", "Compile for the given platform." , values = function (complete, opt) -- imports @@ -115,7 +115,7 @@ task("config") end } , {'k', "kind", "kv", "static" , "Compile for the given target kind." , values = {"static", "shared", "binary"} } - , {nil, "host", "kv", "$(host)" , "The Current Host Environment." } + , {nil, "host", "kv", "$(host)" , "Set the current host environment." } -- package configuration , {category = "Package Configuration"} @@ -142,19 +142,20 @@ task("config") end , {category = "Cross Complation Configuration"} - , {nil, "cross", "kv", nil, "The Cross Toolchains Prefix" + , {nil, "cross", "kv", nil, "Set cross toolchains prefix" , "e.g." , " - i386-mingw32-" , " - arm-linux-androideabi-" } - , {nil, "bin", "kv", nil, "The Cross Toolchains Bin Directory" + , {nil, "target_os", "kv", "linux", "Set target os only for cross-complation" } + , {nil, "bin", "kv", nil, "Set cross toolchains bin directory" , "e.g." , " - sdk/bin (/arm-linux-gcc ..)" } - , {nil, "sdk", "kv", nil, "The Cross SDK Directory" + , {nil, "sdk", "kv", nil, "Set cross SDK directory" , "e.g." , " - sdk/bin" , " - sdk/lib" , " - sdk/include" } - , {nil, "toolchain", "kv", nil, "The Toolchain Name" + , {nil, "toolchain", "kv", nil, "Set toolchain name" , "e.g. " , " - xmake f --toolchain=clang" , " - xmake f --toolchain=[cross|llvm|sdcc ..] --sdk=/xxx" @@ -187,7 +188,7 @@ task("config") end , {category = "Other Configuration"} - , {nil, "debugger", "kv", "auto" , "The Debugger" } + , {nil, "debugger", "kv", "auto" , "Set debugger" } , {nil, "ccache", "kv", true , "Enable or disable the c/c++ compiler cache." } , {nil, "trybuild", "kv", nil , "Enable try-build mode and set the third-party buildsystem tool.", "e.g.", @@ -199,7 +200,7 @@ task("config") , {nil, "tryconfigs", "kv", nil , "Set the extra configurations of the third-party buildsystem for the try-build mode.", "e.g.", " - xmake f --trybuild=autotools --tryconfigs='--enable-shared=no'"} - , {'o', "buildir", "kv", "build" , "Set the build directory." } + , {'o', "buildir", "kv", "build" , "Set build directory." } , {} , {nil, "target", "v" , nil , "Configure for the given target." diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua index b1177fb8a..d8261ebcc 100644 --- a/xmake/actions/require/impl/package.lua +++ b/xmake/actions/require/impl/package.lua @@ -159,6 +159,7 @@ function _parse_require(require_str, requires_extra, parentinfo) version = version, plat = require_extra.plat, -- require package in the given platform arch = require_extra.arch, -- require package in the given architecture + ["os"] = require_extra.os -- require package in the given target os kind = require_extra.kind, -- default: library, set package kind, e.g. binary, library, we can set `kind = "binary"` to only detect binary program and ignore library. alias = require_extra.alias, -- set package alias name group = require_extra.group, -- only uses the first package in same group diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 398c89285..459b1e573 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -113,6 +113,15 @@ function _instance:arch() return config.get("arch") or os.arch() end +-- get the target os +function _instance:os() + local requireinfo = self:requireinfo() + if requireinfo and requireinfo.os then + return requireinfo.os + end + return platform.os() +end + -- get the build mode function _instance:mode() return self:debug() and "debug" or "release" @@ -143,6 +152,16 @@ function _instance:is_arch(...) end end +-- the current platform is belong to the given target os? +function _instance:is_os(...) + local os = self:os() + for _, v in ipairs(table.join(...)) do + if v and os == v then + return true + end + end +end + -- get the package alias function _instance:alias() local requireinfo = self:requireinfo() diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 7cf7c88e4..4b366fceb 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -89,7 +89,7 @@ end -- get the platform os function _instance:os() - return self._INFO:get("os") + return self._INFO:get("os") or config.get("target_os") end -- get the platform menu @@ -605,7 +605,7 @@ end -- get the platform os function platform.os(plat, arch) - return platform.get("os", plat, arch) + return platform.get("os", plat, arch) or config.get("target_os") end -- get the platform archs |
