-
-
Notifications
You must be signed in to change notification settings - Fork 786
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 #5686 from Arthapz/fix-module-scanning
Fix module scanning
- Loading branch information
Showing
19 changed files
with
226 additions
and
42 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
tests/projects/c++/modules/dependency_flag_update/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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module; | ||
|
||
#include <iostream> | ||
|
||
export module bar; | ||
|
||
namespace bar { | ||
export void hello() { std::cout << "Hello world2" << std::endl; } | ||
} // namespace bar |
9 changes: 9 additions & 0 deletions
9
tests/projects/c++/modules/dependency_flag_update/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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module; | ||
|
||
#include <iostream> | ||
|
||
export module foo; | ||
|
||
namespace foo { | ||
export void hello() { std::cout << "Hello world" << std::endl; } | ||
} // namespace foo |
12 changes: 12 additions & 0 deletions
12
tests/projects/c++/modules/dependency_flag_update/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#if defined(FOO) | ||
import foo; | ||
using namespace foo; | ||
#else | ||
import bar; | ||
using namespace bar; | ||
#endif | ||
|
||
int main() { | ||
hello(); | ||
return 0; | ||
} |
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 @@ | ||
inherit(".test_dependency_scanner") |
11 changes: 11 additions & 0 deletions
11
tests/projects/c++/modules/dependency_flag_update/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
add_rules("mode.release", "mode.debug") | ||
set_languages("c++20") | ||
|
||
option("foo") | ||
set_default("true") | ||
add_defines("FOO") | ||
|
||
target("dependency_flag_update") | ||
set_kind("binary") | ||
add_files("src/*.cpp", "src/*.mpp") | ||
add_options("foo") |
9 changes: 9 additions & 0 deletions
9
tests/projects/c++/modules/dependency_flag_update2/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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module; | ||
|
||
#include <iostream> | ||
|
||
export module bar; | ||
|
||
namespace bar { | ||
export void hello() { std::cout << "Hello world2" << std::endl; } | ||
} // namespace bar |
9 changes: 9 additions & 0 deletions
9
tests/projects/c++/modules/dependency_flag_update2/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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module; | ||
|
||
#include <iostream> | ||
|
||
export module foo; | ||
|
||
namespace foo { | ||
export void hello() { std::cout << "Hello world" << std::endl; } | ||
} // namespace foo |
11 changes: 11 additions & 0 deletions
11
tests/projects/c++/modules/dependency_flag_update2/src/foobar.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export module foobar; | ||
|
||
#if defined(FOO) | ||
import foo; | ||
namespace impl = foo; | ||
#else | ||
import bar; | ||
namespace impl = bar; | ||
#endif | ||
|
||
export void hello() { impl::hello(); } |
6 changes: 6 additions & 0 deletions
6
tests/projects/c++/modules/dependency_flag_update2/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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import foobar; | ||
|
||
int main() { | ||
hello(); | ||
return 0; | ||
} |
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 @@ | ||
inherit(".test_dependency_scanner") |
12 changes: 12 additions & 0 deletions
12
tests/projects/c++/modules/dependency_flag_update2/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
add_rules("mode.release", "mode.debug") | ||
set_languages("c++20") | ||
|
||
option("foo") | ||
set_default("true") | ||
add_defines("FOO") | ||
|
||
target("dependency_flag_update3") | ||
set_kind("binary") | ||
add_files("src/*.cpp", "src/*.mpp") | ||
add_options("foo") | ||
|
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,76 @@ | ||
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
import("utils.ci.is_running", {alias = "ci_is_running"}) | ||
|
||
function _build() | ||
os.run("xmake f --foo=n") | ||
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("FOO") then | ||
raise("Modules dependency scanner update does not work\n%s", outdata) | ||
end | ||
end | ||
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 | ||
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
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
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
Oops, something went wrong.