Files
funnygame/shadercompiler/build.cpp
2026-02-05 11:10:40 +02:00

89 lines
2.9 KiB
C++

#include "c.h"
#include "helper.h"
#include "ld.h"
#include "target.h"
ADD_DEPENDENCY_BUILD_FILE(tier0, "../external/funnystdlib/tier0/build.cpp")
ADD_DEPENDENCY_BUILD_FILE(tier1, "../external/funnystdlib/tier1/build.cpp")
ADD_DEPENDENCY_BUILD_FILE(tier2, "../external/funnystdlib/tier2/build.cpp")
DECLARE_BUILD_STAGE(libshadercompiler)
{
CProject_t stProject;
LinkProject_t stLinkProject;
CUtlString szOutput;
stProject.m_szName = "ShaderCompiler";
stProject.bFPIC = true;
stProject.includeDirectories = {
"../public",
"../external/funnystdlib/public",
"../external/slang/include",
"../external/Vulkan-Headers/include",
};
stProject.files = {
"slang/vulkan_spirv.cpp",
"../materialsystem/compiledshader.cpp",
};
stLinkProject = ccompiler->Compile(&stProject);
stLinkProject.libraryObjects = {
GET_PROJECT_LIBRARY(tier0, "tier0"),
};
stLinkProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier1, "tier1")});
stLinkProject.linkType = ELINK_DYNAMIC_LIBRARY;
szOutput = linker->Link(&stLinkProject);
ADD_OUTPUT_OBJECT("lib", szOutput);
return 0;
}
DECLARE_BUILD_STAGE(shadercompiler)
{
CProject_t stProject;
LinkProject_t stLinkProject;
CUtlString szOutput;
stProject.m_szName = "fsc";
stProject.includeDirectories = {"../public", "../external/funnystdlib/public"};
stProject.files = {
"main.cpp",
"../materialsystem/compiledshader.cpp",
};
stLinkProject = ccompiler->Compile(&stProject);
stLinkProject.linkType = ELINK_EXECUTABLE;
stLinkProject.libraryObjects = {
GET_PROJECT_LIBRARY(tier0, "tier0"),
};
stLinkProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier1, "tier1")});
stLinkProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier2, "tier2")});
stLinkProject.libraries = {"slang-compiler","slang-glslang-2025.24.2"};
stLinkProject.libraryDirectories = {"../external/linux"};
szOutput = linker->Link(&stLinkProject);
filesystem2->MakeDirectory(CUtlString("../build/tools"));
filesystem2->CopyFile(CUtlString("../build/tools"), szOutput);
filesystem2->CopyFile(CUtlString("../build/tools"), GET_PROJECT_LIBRARY(tier0, "tier0"));
filesystem2->CopyFile(CUtlString("../build/tools"), GET_PROJECT_LIBRARY(filesystem_std, "fs"));
filesystem2->CopyFile(CUtlString("../build/tools"), GET_PROJECT_LIBRARY(libshadercompiler, "lib"));
filesystem2->CopyFile(CUtlString("../build/tools"), "../external/linux/libslang-compiler.so.0.2025.24.2");
filesystem2->CopyFile(CUtlString("../build/tools"), "../external/linux/libslang-glslang-2025.24.2.so");
ADD_OUTPUT_OBJECT("compiler", szOutput);
return 1;
}
DECLARE_BUILD_STAGE(compileshaders)
{
CUtlString szShaderCompiler = "../build/tools/fsc";
if (CommandLine()->CheckParam("-nofsc"))
return 0;
filesystem2->MakeDirectory(CUtlString("../build/funnygame/assets"));
CUtlVector<CUtlString> args = {"-i", "../funnyassets", "-o", "../build/funnygame/assets"};
runner->Run(szShaderCompiler, args);
runner->Wait();
V_printf("Cool\n");
return 0;
};