Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Improve C++20 modules support #2623

Merged
merged 13 commits into from
Aug 3, 2022
Merged
11 changes: 11 additions & 0 deletions tests/projects/c++/modules/stl_headerunit/src/hello.mpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module;

export module hello;

import <iostream>;

export namespace hello {
void say(const char* str) {
std::cout << str << std::endl;
}
}
6 changes: 6 additions & 0 deletions tests/projects/c++/modules/stl_headerunit/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import hello;

int main() {
hello::say("hello module!");
return 0;
}
4 changes: 4 additions & 0 deletions tests/projects/c++/modules/stl_headerunit/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set_languages("c++20")
target("stl_headerunit")
set_kind("binary")
add_files("src/*.cpp", "src/*.mpp")
5 changes: 5 additions & 0 deletions tests/projects/c++/modules/user_headerunit/src/header.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace hello {
extern constexpr auto FOO = "Hello";
}
10 changes: 10 additions & 0 deletions tests/projects/c++/modules/user_headerunit/src/hello.mpp
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 *arg) {
printf("%s\n", arg);
}
}
7 changes: 7 additions & 0 deletions tests/projects/c++/modules/user_headerunit/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import hello;
import "header.hpp";

int main() {
hello::say(hello::FOO);
return 0;
}
5 changes: 5 additions & 0 deletions tests/projects/c++/modules/user_headerunit/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set_languages("c++20")
target("user_headerunit")
set_kind("binary")
add_headerfiles("src/*.hpp")
add_files("src/*.cpp", "src/*.mpp")
128 changes: 0 additions & 128 deletions xmake/rules/c++/modules/build_modules/clang.lua

This file was deleted.

84 changes: 0 additions & 84 deletions xmake/rules/c++/modules/build_modules/gcc.lua

This file was deleted.

Loading