@@ -62,7 +62,8 @@ void usage()
62
62
~ " ARGS: set to execute all combinations of\n "
63
63
~ " REQUIRED_ARGS: arguments always passed to the compiler\n "
64
64
~ " DMD: compiler to use, ex: ../src/dmd (required)\n "
65
- ~ " CC: C++ compiler to use, ex: dmc, g++\n "
65
+ ~ " CC: C compiler to use, ex: dmc, cc\n "
66
+ ~ " CXX: C++ compiler to use, ex: dmc, g++\n "
66
67
~ " OS: windows, linux, freebsd, osx, netbsd, dragonflybsd\n "
67
68
~ " RESULTS_DIR: base directory for test results\n "
68
69
~ " MODEL: 32 or 64 (required)\n "
@@ -95,7 +96,7 @@ struct TestArgs
95
96
bool link; // / `LINK`: force linking for `fail_compilation` & `compilable` tests
96
97
bool clearDflags; // / `DFLAGS`: whether DFLAGS should be cleared before invoking dmd
97
98
string executeArgs; // / `EXECUTE_ARGS`: arguments passed to the compiled executable (for `runnable[_cxx]`)
98
- string cxxflags; // / `CXXFLAGS`: arguments passed to $CC when compiling `EXTRA_CPP_SOURCES`
99
+ string cxxflags; // / `CXXFLAGS`: arguments passed to $CXX when compiling `EXTRA_CPP_SOURCES`
99
100
string [] sources; // / `EXTRA_SOURCES`: additional D sources (+ main source file)
100
101
string [] compiledImports; // / `COMPILED_IMPORTS`: files compiled alongside the main source
101
102
string [] cppSources; // / `EXTRA_CPP_SOURCES`: additional C++ sources
@@ -132,7 +133,8 @@ struct EnvData
132
133
string exe; // / `EXE`: executable file extension (none or `.exe`)
133
134
string os; // / `OS`: host operating system (`linux`, `windows`, ...)
134
135
string compiler; // / `HOST_DMD`: host D compiler
135
- string ccompiler; // / `CC`: host C++ compiler
136
+ string ccompiler; // / `CC`: host C compiler
137
+ string cxxcompiler; // / `CXX`: host C++ compiler
136
138
string model; // / `MODEL`: target model (`32` or `64`)
137
139
string required_args; // / `REQUIRED_ARGS`: flags added to the tests `REQUIRED_ARGS` parameter
138
140
string cxxCompatFlags; // / Additional flags passed to $(compiler) when `EXTRA_CPP_SOURCES` is present
@@ -174,6 +176,7 @@ immutable(EnvData) processEnvironment()
174
176
envData.dmd = replace(envGetRequired(" DMD" ), " /" , envData.sep);
175
177
envData.compiler = " dmd" ; // should be replaced for other compilers
176
178
envData.ccompiler = environment.get (" CC" );
179
+ envData.cxxcompiler = environment.get (" CXX" );
177
180
envData.model = envGetRequired(" MODEL" );
178
181
if (envData.os == " windows" && envData.model == " 32" )
179
182
{
@@ -198,7 +201,7 @@ immutable(EnvData) processEnvironment()
198
201
if (envData.ccompiler.empty)
199
202
{
200
203
if (envData.os != " windows" )
201
- envData.ccompiler = " c++ " ;
204
+ envData.ccompiler = " cc " ;
202
205
else if (envData.model == " 32omf" )
203
206
envData.ccompiler = " dmc" ;
204
207
else if (envData.model == " 64" )
@@ -207,7 +210,23 @@ immutable(EnvData) processEnvironment()
207
210
envData.ccompiler = " cl" ;
208
211
else
209
212
{
210
- writeln(" Unknown $OS$MODEL combination: " , envData.os, envData.model);
213
+ writeln(" Can't determine C compiler (CC). Unknown $OS$MODEL combination: " , envData.os, envData.model);
214
+ throw new SilentQuit();
215
+ }
216
+ }
217
+ if (envData.cxxcompiler.empty)
218
+ {
219
+ if (envData.os != " windows" )
220
+ envData.cxxcompiler = " c++" ;
221
+ else if (envData.model == " 32omf" )
222
+ envData.cxxcompiler = " dmc" ;
223
+ else if (envData.model == " 64" )
224
+ envData.cxxcompiler = " cl" ;
225
+ else if (envData.model == " 32mscoff" )
226
+ envData.cxxcompiler = " cl" ;
227
+ else
228
+ {
229
+ writeln(" Can't determine C++ compiler (CXX). Unknown $OS$MODEL combination: " , envData.os, envData.model);
211
230
throw new SilentQuit();
212
231
}
213
232
}
@@ -1160,14 +1179,15 @@ unittest
1160
1179
* Returns: false if a compilation error occurred
1161
1180
*/
1162
1181
bool collectExtraSources (in string input_dir, in string output_dir, in string [] extraSources,
1163
- ref string [] sources, in EnvData envData, in string compiler ,
1164
- const (char )[] cxxflags, ref File logfile, /* LDC*/ in bool objC = false )
1182
+ ref string [] sources, in EnvData envData, in string ccompiler ,
1183
+ in string cxxcompiler, const (char )[] cxxflags, ref File logfile, /* LDC*/ in bool objC = false )
1165
1184
{
1166
1185
foreach (cur; extraSources)
1167
1186
{
1168
1187
auto curSrc = input_dir ~ envData.sep ~ " extra-files" ~ envData.sep ~ cur;
1169
1188
auto curObj = output_dir ~ envData.sep ~ cur ~ envData.obj;
1170
- string command = quoteSpaces(compiler);
1189
+ bool is_cpp_file = cur.extension() == " .cpp" ;
1190
+ string command = quoteSpaces(is_cpp_file ? cxxcompiler : ccompiler);
1171
1191
if (envData.model == " 32omf" ) // dmc.exe
1172
1192
{
1173
1193
command ~= " -c " ~ curSrc~ " -o" ~ curObj;
@@ -1779,10 +1799,10 @@ int tryMain(string[] args)
1779
1799
1780
1800
if (
1781
1801
// prepare cpp extra sources
1782
- ! collectExtraSources(input_dir, output_dir, testArgs.cppSources, testArgs.sources, envData, envData.ccompiler, testArgs.cxxflags, f) ||
1802
+ ! collectExtraSources(input_dir, output_dir, testArgs.cppSources, testArgs.sources, envData, envData.ccompiler, envData.cxxcompiler, testArgs.cxxflags, f) ||
1783
1803
1784
1804
// prepare objc extra sources
1785
- ! collectExtraSources(input_dir, output_dir, testArgs.objcSources, testArgs.sources, envData, " clang" , null , f, /* LDC, objC=*/ true )
1805
+ ! collectExtraSources(input_dir, output_dir, testArgs.objcSources, testArgs.sources, envData, " clang" , " clang++ " , null , f, /* LDC, objC=*/ true )
1786
1806
)
1787
1807
{
1788
1808
writeln();
@@ -2245,9 +2265,9 @@ static this()
2245
2265
const runTest = [testScriptExe];
2246
2266
outfile.writeln(" \n [RUN_TEST] " , escapeShellCommand(runTest));
2247
2267
outfile.flush();
2248
- // LDC: propagate C(++) compiler from envData as CC env var (required by cpp_header_gen test)
2268
+ // LDC: propagate C(++) compiler from envData as CC/CXX env var (required by cpp_header_gen test)
2249
2269
version (LDC )
2250
- const string [string ] runEnv = [" CC" : envData.ccompiler];
2270
+ const string [string ] runEnv = [" CC" : envData.ccompiler, " CXX " : envData.cxxcompiler ];
2251
2271
else
2252
2272
const string [string ] runEnv = null ;
2253
2273
auto runTestProc = std.process.spawnProcess (runTest, stdin, outfile, outfile, runEnv, keepFilesOpen);
0 commit comments