summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-06-01 20:37:43 -0400
committerGitHub <noreply@github.com>2022-06-01 17:37:43 -0700
commit4f14efc9752d9ebc8538a2e29ed154a00dc99682 (patch)
treef7d46fdc611349ade0b5cc39c23fb83e00412598
parent17e3b88b541ed7f45d575f0f9caaa808cd0a6619 (diff)
Disable stdlib source via premake (#2259)
* #include an absolute path didn't work - because paths were taken to always be relative. * Added ability to compile slang without stdlib source. It's not requried if stdlib is available if embedded, or is a binary on the file system. Co-authored-by: Yong He <yonghe@outlook.com>
-rw-r--r--premake5.lua20
-rw-r--r--source/slang/slang-stdlib.cpp5
2 files changed, 22 insertions, 3 deletions
diff --git a/premake5.lua b/premake5.lua
index a1661e611..8b4348cfa 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -150,15 +150,23 @@ newoption {
value = "bool",
default = "true",
allowed = { { "true", "True"}, { "false", "False" } }
- }
+ }
- newoption {
+ newoption {
trigger = "enable-experimental-projects",
description = "(Optional) If true include experimental projects in build.",
value = "bool",
default = "false",
allowed = { { "true", "True"}, { "false", "False" } }
- }
+ }
+
+ newoption {
+ trigger = "disable-stdlib-source",
+ description = "(Optional) If true stdlib source will not be included in binary.",
+ value = "bool",
+ default = "false",
+ allowed = { { "true", "True"}, { "false", "False" } }
+ }
buildLocation = _OPTIONS["build-location"]
executeBinary = (_OPTIONS["execute-binary"] == "true")
@@ -171,6 +179,8 @@ newoption {
enableEmbedStdLib = (_OPTIONS["enable-embed-stdlib"] == "true")
enableXlib = (_OPTIONS["enable-xlib"] == "true")
enableExperimental = (_OPTIONS["enable-experimental-projects"] == "true")
+ disableStdlibSource = (_OPTIONS["disable-stdlib-source"] == "true")
+
-- Determine the target info
targetInfo = slangUtil.getTargetInfo()
@@ -1304,6 +1314,10 @@ tool "slangd"
--
defines { "SLANG_DYNAMIC_EXPORT" }
+ if disableStdlibSource then
+ defines { "SLANG_DISABLE_STDLIB_SOURCE" }
+ end
+
if enableEmbedStdLib then
-- We only have this dependency if we are embedding stdlib
dependson { "embed-stdlib-generator" }
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp
index e0727f19a..2bbf3c1c0 100644
--- a/source/slang/slang-stdlib.cpp
+++ b/source/slang/slang-stdlib.cpp
@@ -225,6 +225,7 @@ namespace Slang
String Session::getCoreLibraryCode()
{
+#if !defined(SLANG_DISABLE_STDLIB_SOURCE)
if (coreLibraryCode.getLength() > 0)
return coreLibraryCode;
@@ -235,11 +236,14 @@ namespace Slang
#include "core.meta.slang.h"
coreLibraryCode = sb.ProduceString();
+#endif
+
return coreLibraryCode;
}
String Session::getHLSLLibraryCode()
{
+#if !defined(SLANG_DISABLE_STDLIB_SOURCE)
if (hlslLibraryCode.getLength() > 0)
return hlslLibraryCode;
@@ -250,6 +254,7 @@ namespace Slang
#include "hlsl.meta.slang.h"
hlslLibraryCode = sb.ProduceString();
+#endif
return hlslLibraryCode;
}
}