diff options
| author | ruki <[email protected]> | 2020-12-16 23:34:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-16 23:34:31 +0800 |
| commit | f3b3357ddad20367ff94e8b984a525a703d5947f (patch) | |
| tree | 622250f644c638340b77579aff16153a8f8e58ce | |
| parent | b3d4c235f88fb14f0aa42c2704727a104ab33fd2 (diff) | |
improve check platform
| -rw-r--r-- | tests/projects/other/multiplats/src/main.c | 7 | ||||
| -rw-r--r-- | tests/projects/other/multiplats/test.lua | 8 | ||||
| -rw-r--r-- | tests/projects/other/multiplats/xmake.lua | 15 | ||||
| -rw-r--r-- | xmake/actions/config/main.lua | 22 | ||||
| -rw-r--r-- | xmake/core/platform/platform.lua | 10 | ||||
| -rw-r--r-- | xmake/platforms/iphoneos/xmake.lua | 1 |
6 files changed, 52 insertions, 11 deletions
diff --git a/tests/projects/other/multiplats/src/main.c b/tests/projects/other/multiplats/src/main.c new file mode 100644 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/other/multiplats/src/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char** argv) +{ + printf("hello world!\n"); + return 0; +} diff --git a/tests/projects/other/multiplats/test.lua b/tests/projects/other/multiplats/test.lua new file mode 100644 index 000000000..196797077 --- /dev/null +++ b/tests/projects/other/multiplats/test.lua @@ -0,0 +1,8 @@ +function main(t) + if is_host("macosx") then + os.exec("xmake f -c -vD") + os.exec("xmake -rvD") + os.exec("xmake f -c -vD -p iphoneos") + os.exec("xmake -rvD") + end +end diff --git a/tests/projects/other/multiplats/xmake.lua b/tests/projects/other/multiplats/xmake.lua new file mode 100644 index 000000000..e8fbbb372 --- /dev/null +++ b/tests/projects/other/multiplats/xmake.lua @@ -0,0 +1,15 @@ +add_rules("mode.debug", "mode.release") +target("test_host") + set_kind("binary") + add_files("src/*.c") + +target("test_iphoneos") + set_kind("binary") + add_files("src/*.c") + set_plat("iphoneos") + +target("test_iphoneos_armv7") + set_kind("binary") + add_files("src/*.c") + set_plat("iphoneos") + set_arch("armv7") diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 8490dd4e3..b3aeeb9a3 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -141,23 +141,23 @@ function _check_target_toolchains() -- check toolchains configuration for all target in the current project -- @note we must check targets after loading options for _, target in pairs(project.targets()) do - if target:get("enabled") ~= false and (target:get("toolchains") or not target:is_plat(config.get("plat"))) then + if target:get("enabled") ~= false and (target:get("toolchains") or + not target:is_plat(config.get("plat")) or + not target:is_arch(config.get("arch"))) then local target_toolchains = target:get("toolchains") if target_toolchains then target_toolchains = hashset.from(table.wrap(target_toolchains)) - end - for _, toolchain_inst in pairs(target:toolchains()) do - -- check toolchains for `target/set_toolchains()` - if target_toolchains then + for _, toolchain_inst in pairs(target:toolchains()) do + -- check toolchains for `target/set_toolchains()` if not toolchain_inst:check() and target_toolchains:has(toolchain_inst:name()) then raise("toolchain(\"%s\"): not found!", toolchain_inst:name()) end - else - -- check platform toolchains for `target/set_plat()` - local ok, errors = target:platform():check() - if not ok then - raise(errors) - end + end + else + -- check platform toolchains for `target/set_plat()` + local ok, errors = target:platform():check() + if not ok then + raise(errors) end end end diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index dda45956d..4d0aa8fd0 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -52,6 +52,16 @@ function _instance:arch() return self._ARCH or config.get("arch") end +-- set platform architecture +function _instance:arch_set(arch) + if self:arch() ~= arch then + -- we need clean the dirty cache if architecture has been changed + platform._PLATFORMS[self:name() .. "_" .. self:arch()] = nil + platform._PLATFORMS[self:name() .. "_" .. arch] = self + self._ARCH = arch + end +end + -- set the value to the platform configuration function _instance:set(name, ...) self._INFO:apival_set(name, ...) diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua index 4fbb4e2b2..af6eb8e18 100644 --- a/xmake/platforms/iphoneos/xmake.lua +++ b/xmake/platforms/iphoneos/xmake.lua @@ -42,6 +42,7 @@ platform("iphoneos") local arch = config.get("arch") if not arch then config.set("arch", "arm64") + platform:arch_set("arm64") cprint("checking for architecture ... ${color.success}%s", config.get("arch")) end end) |
