Skip to content

Commit

Permalink
Merge pull request #2623 from Arthapz/cxx20-modules-support
Browse files Browse the repository at this point in the history
[Draft] Improve C++20 modules support
  • Loading branch information
waruqi committed Aug 3, 2022
2 parents 67a3575 + 728126b commit d1de4d4
Show file tree
Hide file tree
Showing 17 changed files with 1,697 additions and 570 deletions.
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

0 comments on commit d1de4d4

Please sign in to comment.