Skip to content

Commit 3692864

Browse files
Merge pull request #51 from Neko-Box-Coder/MSVCFix
Updating MSVC, adding logic for handling escape characters at the end for substitution
2 parents be6b813 + e42f2e0 commit 3692864

File tree

13 files changed

+153
-38
lines changed

13 files changed

+153
-38
lines changed

DefaultYAMLs/DefaultUserConfig.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# List of anchors that will be aliased later
22
Templates:
3-
MSVC_CompileFlags: &MSVC_CompileFlags
4-
Flags: "/nologo /W4 /diagnostics:caret /D NDEBUG /utf-8 /Gm- /MD /EHa /TP /std:c++17 /GR /TP"
3+
vs2022_v17+_CompileFlags: &vs2022_v17+_CompileFlags
4+
Flags: "/nologo /W4 /diagnostics:caret /utf-8 /Gm- /MDd /EHar /TP /std:c++17 /GR /RTC1 /Zc:inline /Zi"
55

66
"g++_CompileRunParts": &g++_CompileRunParts
77
- Type: Once
@@ -28,10 +28,13 @@ Templates:
2828
- Type: Repeats
2929
CommandPart: " /I\"{IncludeDirectoryPath}\""
3030
- Type: Once
31-
CommandPart: " /Fo\"{OutputFileDirectory}{/}{ObjectLinkFile.Prefix}{InputFileName}{ObjectLinkFile.Extension}\" \"{InputFilePath}\""
31+
CommandPart: " /Fo\"{OutputFileDirectory}{/}{ObjectLinkFile.Prefix}{InputFileName}{ObjectLinkFile.Extension}\" \
32+
/Fd\"{OutputFileDirectory}{/}{DebugSymbolFile.Prefix}{InputFileName}{DebugSymbolFile.Extension}\" \
33+
\"{InputFilePath}\""
3234

3335
"vs2022_v17+_CompileExpectedOutputFiles": &vs2022_v17+_CompileExpectedOutputFiles
3436
- "{OutputFileDirectory}{/}{ObjectLinkFile.Prefix}{InputFileName}{ObjectLinkFile.Extension}"
37+
- "{OutputFileDirectory}{/}{DebugSymbolFile.Prefix}{InputFileName}{DebugSymbolFile.Extension}"
3538

3639
# The following fields set the prefixes and extensions for each type of the files
3740
# If the name of an object files are libtest.so and libtest2.so,
@@ -91,13 +94,14 @@ Templates:
9194
Windows: ""
9295
Unix: ""
9396
Extension:
94-
Windows: ""
97+
Windows: ".pdb"
9598
Unix: ""
9699

97100
# WARNING: All command substitutions in this file are passed directly to the shell.
98101
# Exercise caution when using variables or user-provided input in your build commands
99102
# to prevent potential security vulnerabilities.
100103

104+
# TODO(NOW): Make it auto? Or DefaultProfile?
101105
# A profile to be used if not specified while running the build script
102106
PreferredProfile: "g++"
103107

@@ -343,25 +347,25 @@ Profiles:
343347
CompileTypes:
344348
Executable:
345349
Windows:
346-
<<: *MSVC_CompileFlags
350+
<<: *vs2022_v17+_CompileFlags
347351
Executable: "CL.exe"
348352
RunParts: *vs2022_v17+_CompileRunParts
349353
ExpectedOutputFiles: *vs2022_v17+_CompileExpectedOutputFiles
350354
ExecutableShared:
351355
Windows:
352-
<<: *MSVC_CompileFlags
356+
<<: *vs2022_v17+_CompileFlags
353357
Executable: "CL.exe"
354358
RunParts: *vs2022_v17+_CompileRunParts
355359
ExpectedOutputFiles: *vs2022_v17+_CompileExpectedOutputFiles
356360
Static:
357361
Windows:
358-
<<: *MSVC_CompileFlags
362+
<<: *vs2022_v17+_CompileFlags
359363
Executable: "CL.exe"
360364
RunParts: *vs2022_v17+_CompileRunParts
361365
ExpectedOutputFiles: *vs2022_v17+_CompileExpectedOutputFiles
362366
Shared:
363367
Windows:
364-
<<: *MSVC_CompileFlags
368+
<<: *vs2022_v17+_CompileFlags
365369
Executable: "CL.exe"
366370
RunParts: *vs2022_v17+_CompileRunParts
367371
ExpectedOutputFiles: *vs2022_v17+_CompileExpectedOutputFiles
@@ -376,6 +380,7 @@ Profiles:
376380
Flags: >-
377381
/NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
378382
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /manifest:embed /SUBSYSTEM:CONSOLE
383+
/DEBUG /MANIFESTUAC:"level='asInvoker'"
379384
Executable: "link.exe"
380385
RunParts:
381386
- Type: Once
@@ -390,7 +395,7 @@ Profiles:
390395
Flags: >-
391396
/NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
392397
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /manifest:embed /SUBSYSTEM:CONSOLE
393-
/DLL
398+
/DEBUG /DLL /MANIFESTUAC:"level='asInvoker'"
394399
Executable: "link.exe"
395400
RunParts:
396401
- Type: Once
@@ -422,7 +427,7 @@ Profiles:
422427
Flags: >-
423428
/NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
424429
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /manifest:embed /SUBSYSTEM:CONSOLE
425-
/DLL
430+
/DEBUG /DLL /MANIFESTUAC:"level='asInvoker'"
426431
Executable: "link.exe"
427432
RunParts:
428433
- Type: Once

Examples/CivetwebStaticWebServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
DefaultProfile:
1919
SearchLibraryNames: ["civetweb"]
2020
SearchDirectories: ["./output/src"]
21-
Setup: ["mkdir output", "cd output && cmake .."]
21+
Setup: ["mkdir output", "cd output && cmake .. -DCIVETWEB_BUILD_TESTING=OFF -DCIVETWEB_ENABLE_ASAN=OFF"]
2222
Build: ["cd output && cmake --build . -j 16"]
2323
*/
2424

Examples/CppStaticWebServer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
URL: "https://github.com/yhirose/cpp-httplib.git"
99
Branch: "v0.20.0"
1010
LibraryType: Header
11-
IncludePaths:
12-
- "./"
11+
IncludePaths: ["./"]
1312
*/
1413

1514
#include "httplib.h"

Examples/MatplotExample.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/* runcpp2
22
3+
OverrideCompileFlags:
4+
Windows:
5+
msvc:
6+
Append: "/wd4251"
7+
Defines: ["MATPLOT_BUILD_HIGH_RESOLUTION_WORLD_MAP"]
38
Dependencies:
49
- Name: matplotplusplus
510
Platforms: [DefaultPlatform]
@@ -17,12 +22,13 @@
1722
SearchDirectories: ["./build/source/matplot"]
1823
Windows:
1924
DefaultProfile:
20-
SearchLibraryNames: ["libmatplot"]
25+
SearchLibraryNames: ["matplot"]
2126
SearchDirectories: ["./build/source/matplot/debug"]
2227
Setup:
2328
- "mkdir build"
2429
- "cd build && cmake .. -DMATPLOTPP_BUILD_WITH_SANITIZERS=OFF -DMATPLOTPP_BUILD_EXAMPLES=OFF -DMATPLOTPP_BUILD_INSTALLER=OFF -DMATPLOTPP_BUILD_PACKAGE=OFF -DBUILD_SHARED_LIBS=ON"
25-
- "cd build && cmake --build . -j 16"*/
30+
- "cd build && cmake --build . -j 16"
31+
*/
2632

2733
#include "matplot/matplot.h"
2834

@@ -33,9 +39,9 @@ int main()
3339
{
3440
//NOTE: Alternatively, you can put this under "Setup" section in runcpp2 build settings
3541
#ifdef _WIN32
36-
if(system("which gnuplot") != 0)
37-
#else
3842
if(system("where gnuplot") != 0)
43+
#else
44+
if(system("which gnuplot") != 0)
3945
#endif
4046
{
4147
std::cout << "Failed to find gnuplot, please install it on the system" << std::endl;
@@ -45,7 +51,6 @@ int main()
4551
auto f1 = matplot::figure();
4652
matplot::plot(matplot::vector_1d{1., 2., 3.}, matplot::vector_1d{2., 4., 6.});
4753

48-
4954
auto f2 = matplot::figure();
5055
matplot::scatter(matplot::iota(1, 20), matplot::rand(20, 0, 1));
5156

Examples/SDLWindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
DefaultProfile:
1717
SearchLibraryNames: ["SDL2"]
1818
SearchDirectories: ["./build/debug"]
19+
ExcludeLibraryNames: ["SDL2-static", "SDL2_test"]
1920
Unix:
2021
DefaultProfile:
2122
SearchLibraryNames: ["SDL2"]
2223
SearchDirectories: ["./build"]
24+
ExcludeLibraryNames: ["SDL2-static", "SDL2_test"]
2325
Setup: ["mkdir build", "cd build && cmake .."]
2426
Build: ["cd build && cmake --build . -j 16"]
2527
@@ -33,7 +35,7 @@
3335
*/
3436

3537

36-
#include <SDL2/SDL.h>
38+
#include "SDL.h"
3739

3840
#include <iostream>
3941

Examples/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- From https://www.w3schools.com/html/html_basic.asp -->
2+
<!DOCTYPE html>
3+
<html>
4+
<body>
5+
6+
<h1>My First Heading</h1>
7+
<p>My first paragraph.</p>
8+
9+
</body>
10+
</html>

Src/runcpp2/CompilingLinking.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ namespace
312312
i,
313313
&profile,
314314
&currentOutputTypeInfo,
315-
substitutionMap,
315+
substitutionMap, //NOTE: substitutionMap is used by the next source file,
316+
// therefore need to copy it.
316317
&buildDir,
317318
compileAsExecutable,
318319
&scriptInfo,
@@ -437,7 +438,7 @@ namespace
437438

438439
return true;
439440
}
440-
)
441+
) //std::async
441442
); //actions.emplace_back
442443
finished.emplace_back(false);
443444

@@ -491,8 +492,8 @@ namespace
491492

492493
actions.clear();
493494
finished.clear();
494-
}
495-
}
495+
} //if(actions.size() >= maxThreads || i == sourceFiles.size() - 1)
496+
} //for(int i = 0; i < sourceFiles.size(); ++i)
496497

497498
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
498499
return !failedAny;

Src/runcpp2/Data/StageInfo.cpp

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,54 @@ namespace
282282
ssLOG_ERROR("INTERNAL ERROR, missing substitution value for \"" << substitution << "\"");
283283
return false;
284284
}
285-
const std::string& currentValue = substitutionMap.at(substitution).at(substituteValueIndex);
285+
286+
std::string currentValue = substitutionMap.at(substitution).at(substituteValueIndex);
287+
288+
//Escape escapes character at the end if any
289+
{
290+
std::vector<char> escapeChars = {'\\'};
291+
#ifdef _WIN32
292+
escapeChars.emplace_back('^');
293+
#endif
294+
if(!currentValue.empty())
295+
{
296+
int currentValIndex = currentValue.size();
297+
while(currentValIndex > 0)
298+
{
299+
--currentValIndex;
300+
bool found = false;
301+
for(int j = 0; j < escapeChars.size(); ++j)
302+
{
303+
if(currentValue[currentValIndex] == escapeChars[j])
304+
{
305+
found = true;
306+
break;
307+
}
308+
}
309+
310+
if(!found)
311+
{
312+
++currentValIndex;
313+
break;
314+
}
315+
}
316+
317+
if(currentValIndex < currentValue.size())
318+
{
319+
const std::string foundEscapes = currentValue.substr(currentValIndex);
320+
std::string newEndEscapes;
321+
//Just repeat the escape characters
322+
for(int j = 0; j < foundEscapes.size(); ++j)
323+
{
324+
newEndEscapes.push_back(foundEscapes[j]);
325+
newEndEscapes.push_back(foundEscapes[j]);
326+
}
327+
328+
currentValue = currentValue.substr(0, currentValIndex) + newEndEscapes;
329+
}
330+
}
331+
}
332+
286333
ssLOG_DEBUG("Replacing \"" << substitution << "\" with \"" << currentValue <<
287334
"\" in \"" << escapedString << "\"");
288335

@@ -436,8 +483,8 @@ bool runcpp2::Data::StageInfo::ConstructCommand(const SubstitutionMap& substitut
436483
{
437484
if(substitutionMap.count(substitutionsInCurrentPart.at(j)) == 0)
438485
{
439-
ssLOG_DEBUG("No substitution found for " << substitutionsInCurrentPart.at(j) << " in " <<
440-
currentRunParts.at(i).CommandPart);
486+
ssLOG_DEBUG("No substitution found for " << substitutionsInCurrentPart.at(j) <<
487+
" in " << currentRunParts.at(i).CommandPart);
441488

442489
ssLOG_DEBUG("Current run part is type repeat, skipping to next");
443490
continue;

Src/runcpp2/DependenciesHelper.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,16 @@ namespace
234234

235235
dependencies.at(i)
236236
->AbsoluteIncludePaths
237-
.push_back(ghc::filesystem::absolute( dependenciesCopiesPaths.at(i) + "/" +
238-
dependencies.at(i)->IncludePaths.at(j)).string());
237+
.push_back
238+
(
239+
ghc::filesystem::absolute
240+
(
241+
dependenciesCopiesPaths.at(i) +
242+
"/" +
243+
dependencies.at(i)->IncludePaths.at(j)
244+
)
245+
.string()
246+
);
239247

240248
ssLOG_DEBUG("Include path added: " << dependencies.at(i)->AbsoluteIncludePaths.back());
241249
}

Src/runcpp2/runcpp2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
502502
if(result != PipelineResult::SUCCESS)
503503
return result;
504504

505-
//Check if script info has changed if provided
505+
//Check if script info has changed if provided and run setup if needed
506506
bool recompileNeeded = false;
507507
bool relinkNeeded = false;
508508
std::vector<std::string> changedDependencies;

0 commit comments

Comments
 (0)