-
-
Notifications
You must be signed in to change notification settings - Fork 814
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5376 from Arthapz/fix-module-objectfiles-handling
Improve module objectfiles handling and moduleonly package
- Loading branch information
Showing
28 changed files
with
504 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,69 @@ | ||
inherit(".test_base") | ||
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
import("utils.ci.is_running", {alias = "ci_is_running"}) | ||
|
||
function _build() | ||
local outdata | ||
if ci_is_running() then | ||
outdata = os.iorun("xmake -rvD") | ||
else | ||
outdata = os.iorun("xmake -rv") | ||
end | ||
if outdata then | ||
if outdata:find("culled") then | ||
raise("Modules culling 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 | ||
local clang = find_tool("clang", {version = true}) | ||
if clang and clang.version and semver.compare(clang.version, "17.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 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 --yes") | ||
_build() | ||
os.exec("xmake clean -a") | ||
os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") | ||
_build() | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,69 @@ | ||
inherit(".test_base") | ||
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
import("utils.ci.is_running", {alias = "ci_is_running"}) | ||
|
||
function _build() | ||
local outdata | ||
if ci_is_running() then | ||
outdata = os.iorun("xmake -rvD") | ||
else | ||
outdata = os.iorun("xmake -rv") | ||
end | ||
if outdata then | ||
if outdata:find("culled") then | ||
raise("Modules culling 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 | ||
local clang = find_tool("clang", {version = true}) | ||
if clang and clang.version and semver.compare(clang.version, "17.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 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 --yes") | ||
_build() | ||
os.exec("xmake clean -a") | ||
os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") | ||
_build() | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module; | ||
#include <cstdio> | ||
|
||
export module hello; | ||
|
||
export namespace hello { | ||
void say(const char* str) { | ||
printf("%s\n", str); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
import("utils.ci.is_running", {alias = "ci_is_running"}) | ||
|
||
function _build() | ||
local outdata | ||
if ci_is_running() then | ||
outdata = os.iorun("xmake -rvD") | ||
else | ||
outdata = os.iorun("xmake -rv") | ||
end | ||
if outdata then | ||
if not outdata:find("culled") then | ||
raise("Modules culling 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 | ||
local clang = find_tool("clang", {version = true}) | ||
if clang and clang.version and semver.compare(clang.version, "17.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 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 --yes") | ||
_build() | ||
os.exec("xmake clean -a") | ||
os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") | ||
_build() | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
add_rules("mode.release", "mode.debug") | ||
set_languages("c++20") | ||
|
||
target("culling") | ||
set_kind("static") | ||
add_files("src/*.mpp") |
2 changes: 1 addition & 1 deletion
2
...ojects/c++/modules/link_order/src/bar.mpp → ...ules/duplicate_name_detection/src/bar.mpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export module duplicate; | ||
export module foo; | ||
|
||
export int value() { | ||
return 1; | ||
|
2 changes: 1 addition & 1 deletion
2
...ojects/c++/modules/link_order/src/foo.mpp → ...ules/duplicate_name_detection/src/foo.mpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export module duplicate; | ||
export module foo; | ||
|
||
export int value() { | ||
return 0; | ||
|
2 changes: 1 addition & 1 deletion
2
...jects/c++/modules/link_order/src/main.cpp → ...les/duplicate_name_detection/src/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import duplicate; | ||
import foo; | ||
|
||
int main() { | ||
return value(); | ||
|
75 changes: 75 additions & 0 deletions
75
tests/projects/c++/modules/duplicate_name_detection/test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
import("utils.ci.is_running", {alias = "ci_is_running"}) | ||
|
||
function _build() | ||
try { | ||
function() | ||
if ci_is_running() then | ||
os.run("xmake -rvD") | ||
else | ||
os.run("xmake -r") | ||
end | ||
end, | ||
catch { | ||
function (errors) | ||
errors = tostring(errors) | ||
if not errors:find("duplicate module name detected", 1, true) then | ||
raise("Modules duplicate name detection does not work\n%s", errors) | ||
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 | ||
local clang = find_tool("clang", {version = true}) | ||
if clang and clang.version and semver.compare(clang.version, "17.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 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 --yes") | ||
_build() | ||
os.exec("xmake clean -a") | ||
os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") | ||
_build() | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/projects/c++/modules/packages/my-repo/packages/b/bar2/xmake.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module bar; | ||
|
||
namespace bar { | ||
int hello() { | ||
return 2; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export module bar; | ||
|
||
export namespace bar { | ||
int hello(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module foo; | ||
|
||
import bar; | ||
|
||
namespace foo { | ||
int hello() { | ||
return bar::hello(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export module foo; | ||
|
||
export namespace foo { | ||
int hello(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
import foo; | ||
|
||
int main() { | ||
printf("%d\n", foo::hello()); | ||
return 0; | ||
} | ||
|
File renamed without changes.
Oops, something went wrong.