From 941b834f3ba15eba9bfa80eb370077ec9c845efd Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 25 Jul 2017 16:21:23 -0700 Subject: Add a `-o` option to command-line `slangc` Fixes #11 - This adds a `-o` command-line option for specifying an output file. - The code tries to be a bit smart, to glean an output format from a file extension, and also to associate multiple `-o` options with multiple `-entry` options if needed. - There is a restriction that all the output files need to agree on the code generation target. This is reasonable for now, but might be something to lift eventualy - There is a restriction that only one output file is allowed per entry point - Together with the previous item this means you can't output both a `.spv` and a `.spv.asm` in one pass, even though both should be possible - There is currently a restriction that output paths only apply to entry points - This means there is no way to output reflection JSON to a file with `-o` (but that is mostly just a debugging feature for now) - This also means we don't support any "container" formats that can encapsulate multiple compiled entry points --- source/slangc/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/slangc') diff --git a/source/slangc/main.cpp b/source/slangc/main.cpp index a97c38685..6fb394cce 100644 --- a/source/slangc/main.cpp +++ b/source/slangc/main.cpp @@ -3,6 +3,8 @@ #define SLANG_DYNAMIC #include "../slang.h" +SLANG_API void spSetCommandLineCompilerMode(SlangCompileRequest* request); + #include "core/slang-io.h" using namespace Slang; @@ -32,6 +34,8 @@ int MAIN(int argc, char** argv) SlangSession* session = spCreateSession(nullptr); SlangCompileRequest* compileRequest = spCreateCompileRequest(session); + spSetCommandLineCompilerMode(compileRequest); + char const* appName = "slangc"; if(argc > 0) appName = argv[0]; @@ -62,6 +66,9 @@ int MAIN(int argc, char** argv) exit(-1); } +#if 0 + // Produce output as the command-line compiler driver should. + // Now dump the output from the compilation to stdout. // // TODO: Need a way to control where output goes so that @@ -76,6 +83,7 @@ int MAIN(int argc, char** argv) fputs(output, stdout); } fflush(stdout); +#endif // Now that we are done, clean up after ourselves -- cgit v1.2.3