summaryrefslogtreecommitdiffstats
path: root/source/compiler-core
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-03-28 22:14:33 -0700
committerGitHub <noreply@github.com>2022-03-28 22:14:33 -0700
commit255fd5873f65a6b01d5385c277d55612dc3cc587 (patch)
tree54eda0ae98bc9c1b30ca75e534ca203d8e03f241 /source/compiler-core
parent79b81083b75dc0abdbb8184568dbe36d082e04f3 (diff)
Allow slangc to generate exe from .slang file. (#2170)
Diffstat (limited to 'source/compiler-core')
-rw-r--r--source/compiler-core/slang-downstream-compiler.h5
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp10
-rw-r--r--source/compiler-core/slang-visual-studio-compiler-util.cpp16
3 files changed, 20 insertions, 11 deletions
diff --git a/source/compiler-core/slang-downstream-compiler.h b/source/compiler-core/slang-downstream-compiler.h
index dc9e29185..e40ffc13a 100644
--- a/source/compiler-core/slang-downstream-compiler.h
+++ b/source/compiler-core/slang-downstream-compiler.h
@@ -274,7 +274,7 @@ public:
OptimizationLevel optimizationLevel = OptimizationLevel::Default;
DebugInfoType debugInfoType = DebugInfoType::Standard;
- SlangCompileTarget targetType = SLANG_EXECUTABLE;
+ SlangCompileTarget targetType = SLANG_HOST_EXECUTABLE;
SlangSourceLanguage sourceLanguage = SLANG_SOURCE_LANGUAGE_CPP;
FloatingPointMode floatingPointMode = FloatingPointMode::Default;
PipelineType pipelineType = PipelineType::Unknown;
@@ -302,6 +302,9 @@ public:
List<String> includePaths;
List<String> libraryPaths;
+ /// Libraries to link against.
+ List<String> libraries;
+
List<CapabilityVersion> requiredCapabilityVersions;
/// For compilers/compiles that require an entry point name, else can be empty
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp
index b5c359247..8d1b87b68 100644
--- a/source/compiler-core/slang-gcc-compiler-util.cpp
+++ b/source/compiler-core/slang-gcc-compiler-util.cpp
@@ -415,12 +415,12 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
switch (options.targetType)
{
- case SLANG_SHARED_LIBRARY:
+ case SLANG_SHADER_SHARED_LIBRARY:
{
outPath << SharedLibrary::calcPlatformPath(options.modulePath.getUnownedSlice());
return SLANG_OK;
}
- case SLANG_EXECUTABLE:
+ case SLANG_HOST_EXECUTABLE:
{
outPath << options.modulePath;
outPath << Process::getExecutableSuffix();
@@ -547,7 +547,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
switch (options.targetType)
{
- case SLANG_SHARED_LIBRARY:
+ case SLANG_SHADER_SHARED_LIBRARY:
{
// Shared library
cmdLine.addArg("-shared");
@@ -559,7 +559,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
}
break;
}
- case SLANG_EXECUTABLE:
+ case SLANG_HOST_EXECUTABLE:
{
break;
}
@@ -601,7 +601,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
//cmdLine.addArg(linkOptions);
}
- if (options.targetType == SLANG_SHARED_LIBRARY)
+ if (options.targetType == SLANG_SHADER_SHARED_LIBRARY)
{
if (!PlatformUtil::isFamily(PlatformFamily::Apple, platformKind))
{
diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp
index 9bdfd406a..2ba69c1ce 100644
--- a/source/compiler-core/slang-visual-studio-compiler-util.cpp
+++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp
@@ -23,12 +23,12 @@ namespace Slang
switch (options.targetType)
{
- case SLANG_SHARED_LIBRARY:
+ case SLANG_SHADER_SHARED_LIBRARY:
{
outPath << options.modulePath << ".dll";
return SLANG_OK;
}
- case SLANG_EXECUTABLE:
+ case SLANG_HOST_EXECUTABLE:
{
outPath << options.modulePath << ".exe";
return SLANG_OK;
@@ -60,7 +60,7 @@ namespace Slang
{
outPaths.add(options.modulePath + ".ilk");
- if (options.targetType == SLANG_SHARED_LIBRARY)
+ if (options.targetType == SLANG_SHADER_SHARED_LIBRARY)
{
outPaths.add(options.modulePath + ".exp");
outPaths.add(options.modulePath + ".lib");
@@ -191,7 +191,7 @@ namespace Slang
switch (options.targetType)
{
- case SLANG_SHARED_LIBRARY:
+ case SLANG_SHADER_SHARED_LIBRARY:
{
// Create dynamic link library
if (options.debugInfoType == DebugInfoType::None)
@@ -206,7 +206,7 @@ namespace Slang
cmdLine.addPrefixPathArg("/Fe", options.modulePath, ".dll");
break;
}
- case SLANG_EXECUTABLE:
+ case SLANG_HOST_EXECUTABLE:
{
cmdLine.addPrefixPathArg("/Fe", options.modulePath, ".exe");
break;
@@ -256,6 +256,12 @@ namespace Slang
cmdLine.addPrefixPathArg("/LIBPATH:", libPath);
}
+ // Link libraries.
+ for (const auto& lib : options.libraries)
+ {
+ cmdLine.addPrefixPathArg("", lib, ".lib");
+ }
+
return SLANG_OK;
}