diff options
| author | ruki <[email protected]> | 2024-02-18 21:41:52 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-18 21:41:52 +0800 |
| commit | 3c1163b36e0817dbd5b62ec1ff495dc2e830d6ac (patch) | |
| tree | 16f6cb664c031d80b1841e6978fc1d8753eb6761 /tests/projects/c++/modules/test_base.lua | |
| parent | cda48025005f9aa23bdd582e29bb0f1f1ca24d27 (diff) | |
| parent | bc1a30db6041c2c14ca79ccf0aa35b2d550e64e5 (diff) | |
Merge pull request #4673 from xmake-io/modules
Refactor modules support
Diffstat (limited to 'tests/projects/c++/modules/test_base.lua')
| -rw-r--r-- | tests/projects/c++/modules/test_base.lua | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index efef15520..219901c63 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -1,32 +1,68 @@ import("lib.detect.find_tool") import("core.base.semver") +import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() - local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() - if ci == "true" then - os.exec("xmake -rvD") + if ci_is_running() then + os.run("xmake -rvD") else - os.exec("xmake -r") + os.run("xmake -r") + end + local outdata = os.iorun("xmake") + if outdata then + if outdata:find("compiling") or outdata:find("linking") or outdata:find("generating") then + raise("Modules incremental compilation does not work\n%s", outdata) + end + end +end + +function can_build() + if is_subhost("windows") then + return true + elseif is_subhost("msys") then + return true + elseif is_host("linux") then + local gcc = find_tool("gcc", {version = true}) + if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + return true + end + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + return true + end end end function main(t) if is_subhost("windows") then - os.exec("xmake f -c") + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + os.exec("xmake f --toolchain=clang -c --yes") + _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") + _build() + end + + os.exec("xmake clean -a") + os.exec("xmake f -c --yes") + _build() + elseif is_subhost("msys") then + os.exec("xmake f -c -p mingw --yes") _build() elseif is_host("linux") then local gcc = find_tool("gcc", {version = true}) - if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then - os.exec("xmake f -c") + if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + os.exec("xmake f -c --yes") _build() end local clang = find_tool("clang", {version = true}) if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang -c") + os.exec("xmake f --toolchain=clang -c --yes") _build() os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") _build() end end |
