Skip to content

Commit 46e5b96

Browse files
committed
feat: allow specifying compiler
1 parent 2597d9f commit 46e5b96

File tree

3 files changed

+130
-71
lines changed

3 files changed

+130
-71
lines changed

build.cmd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,20 @@ if exist "%root_dir%.cache\cpp2\source\_build\cpp2b.ixx" (
6262

6363
setlocal enableextensions disabledelayedexpansion
6464

65-
set "search=@CPP2B_PROJECT_ROOT@"
66-
set "replace=%root_dir%"
6765

6866
set "inputFile=%root_dir%share\cpp2b.cppm.tpl"
6967
set "outputFile=%root_dir%.cache\cpp2\source\_build\cpp2b.ixx"
7068

69+
set "compiler_subst=@CPP2B_COMPILER@"
70+
set "compiler_value=msvc"
71+
set "project_root_subst=@CPP2B_PROJECT_ROOT@"
72+
set "project_root_value=%root_dir%"
7173
for /f "delims=" %%i in ('type "%inputFile%"') do (
7274
set "line=%%i"
7375
setlocal enabledelayedexpansion
74-
>>"%outputFile%" echo(!line:%search%=%replace%!
76+
call set "line=!line:%compiler_subst%=%compiler_value%!"
77+
call set "line=!line:%project_root_subst%=%project_root_value%!"
78+
>>"%outputFile%" echo(!line!
7579
endlocal
7680
)
7781
endlocal

share/cpp2b.cppm.tpl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ constexpr auto target_platform() -> platform {
4141
}
4242

4343
constexpr auto compiler() -> compiler_type {
44-
#if defined(_MSC_VER)
45-
return compiler_type::msvc;
46-
#elif defined(__clang__)
47-
return compiler_type::clang;
48-
#elif defined(__GNUC__)
49-
return compiler_type::gcc;
50-
#else
51-
# error unknown compiler
52-
#endif
44+
return compiler_type::@CPP2B_COMPILER@;
5345
}
5446

5547
constexpr auto build() -> build_type {

0 commit comments

Comments
 (0)