summaryrefslogtreecommitdiffstats
path: root/source/slang-stdlib/slang-embedded-stdlib.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-11 21:06:23 +0800
committerGitHub <noreply@github.com>2024-10-11 21:06:23 +0800
commite91e1d4d54a14d985626318e5cf46635bfa4006d (patch)
tree18e5d045235b743429821c249b5611b70c8cd02d /source/slang-stdlib/slang-embedded-stdlib.cpp
parentdfab34e4bf508fc517d4d645ebb3b6b1179a5003 (diff)
Restrict stdlib embed macros to single source file (#5251)
* Restrict stdlib embed macros to single source file * Build slang-without-embedded-stdlib with the same target type as libslang To avoid building everything twice
Diffstat (limited to 'source/slang-stdlib/slang-embedded-stdlib.cpp')
-rw-r--r--source/slang-stdlib/slang-embedded-stdlib.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/slang-stdlib/slang-embedded-stdlib.cpp b/source/slang-stdlib/slang-embedded-stdlib.cpp
new file mode 100644
index 000000000..87107fa50
--- /dev/null
+++ b/source/slang-stdlib/slang-embedded-stdlib.cpp
@@ -0,0 +1,26 @@
+#include "../core/slang-basic.h"
+#include "../core/slang-array-view.h"
+#include "../core/slang-blob.h"
+
+#ifdef SLANG_EMBED_STDLIB
+
+static const uint8_t g_stdLib[] =
+{
+# include "slang-stdlib-generated.h"
+};
+
+static Slang::StaticBlob g_stdLibBlob((const void*)g_stdLib, sizeof(g_stdLib));
+
+SLANG_API ISlangBlob* slang_getEmbeddedStdLib()
+{
+ return &g_stdLibBlob;
+}
+
+#else
+
+SLANG_API ISlangBlob* slang_getEmbeddedStdLib()
+{
+ return nullptr;
+}
+
+#endif