diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-07-16 16:55:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-16 16:55:31 -0400 |
| commit | ee755589356f77ef0a01540ba464f9a87d16fce4 (patch) | |
| tree | 2f23b6b050328ad785cb2b3979bc54f541942177 /tools | |
| parent | 62079c534407abe300d24a6d759641779e48bc67 (diff) | |
Running generators as separate premake project step (#1441)
* Put the running of generators into a separate project, to try and sure the generated products are available for other dependencies when compiling with multiple threads on linux.
* Made paths Strings in slang-generate. Made paths use / for path separators (rather than \ on windows which causes some problems with #line).
* Make the run-generators proj a utility step.
* Made run-generators a StaticLib.
* Fix problem with generating when not necessary.
* Trying to get abspath to work on linux.
* Add run-generator-main.cpp dummy file.
* Add comment about the issues around linux and correct build triggering.
* Add updated projects.
* Remove the run-generators-main.cpp as no longer needed for 'run-generators' tool.
Removed the adding of files by default from baseSlangProject
Made the run generators project use slang-string.cpp as the file it builds from core.
* Add the run-generators VS project.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-generate/main.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp index 979127f8d..5fca7c21a 100644 --- a/tools/slang-generate/main.cpp +++ b/tools/slang-generate/main.cpp @@ -8,6 +8,7 @@ #include "../../source/core/slang-list.h" #include "../../source/core/slang-string.h" #include "../../source/core/slang-string-util.h" +#include "../../source/core/slang-io.h" using namespace Slang; @@ -38,7 +39,7 @@ struct Node // Information about a source file struct SourceFile { - char const* inputPath; + String inputPath; StringSpan text; Node* node; }; @@ -761,7 +762,7 @@ Node* parseSourceFile(SourceFile* file) for (auto hh : kHandlers) { - if (UnownedTerminatedStringSlice(path).endsWith(hh.extension)) + if (path.endsWith(hh.extension)) { return hh.handler(text); } @@ -772,10 +773,10 @@ Node* parseSourceFile(SourceFile* file) -SourceFile* parseSourceFile(char const* path) +SourceFile* parseSourceFile(const String& path) { FILE* inputStream; - fopen_s(&inputStream, path, "rb"); + fopen_s(&inputStream, path.getBuffer(), "rb"); fseek(inputStream, 0, SEEK_END); size_t inputSize = ftell(inputStream); fseek(inputStream, 0, SEEK_SET); @@ -804,7 +805,7 @@ int main( const char*const* argv) { // Parse command-line arguments. - List<const char*> inputPaths; + List<String> inputPaths; char const* appName = "slang-generate"; { @@ -818,7 +819,9 @@ int main( // Copy the input paths for (; argCursor != argEnd; ++argCursor) { - inputPaths.add(*argCursor); + // We simplify here because doing so also means paths separators are set to / + // and that makes path emitting work correctly + inputPaths.add(Path::simplify(UnownedStringSlice(*argCursor))); } } @@ -830,7 +833,7 @@ int main( // Read each input file and process it according // to the type of treatment it requires. - for (const char* inputPath: inputPaths) + for (auto& inputPath: inputPaths) { SourceFile* sourceFile = parseSourceFile(inputPath); if (sourceFile) @@ -866,7 +869,7 @@ int main( readAllText(outputPath.getBuffer(), allTextNew); if (allTextOld != allTextNew) { - writeAllText(inputPath, outputPathFinal.getBuffer(), allTextNew.getBuffer()); + writeAllText(inputPath.getBuffer(), outputPathFinal.getBuffer(), allTextNew.getBuffer()); } remove(outputPath.getBuffer()); } |
