diff options
| -rw-r--r-- | premake5.lua | 251 | ||||
| -rw-r--r-- | slang.sln | 18 | ||||
| -rw-r--r-- | source/slang/run-generators.vcxproj | 203 | ||||
| -rw-r--r-- | source/slang/run-generators.vcxproj.filters | 27 | ||||
| -rw-r--r-- | source/slang/slang.vcxproj | 42 | ||||
| -rw-r--r-- | source/slang/slang.vcxproj.filters | 14 | ||||
| -rw-r--r-- | tools/slang-generate/main.cpp | 19 |
7 files changed, 427 insertions, 147 deletions
diff --git a/premake5.lua b/premake5.lua index b963d44df..0b4f4bd42 100644 --- a/premake5.lua +++ b/premake5.lua @@ -264,6 +264,9 @@ end -- First, we will define a helper routine for adding all -- the relevant files from a given directory path: -- +-- Note that this does not work recursively +-- so projects that spread their source over multiple +-- directories will need to take more steps. function addSourceDir(path) files { @@ -287,6 +290,10 @@ end -- -- baseSlangProject("slangc", "source/slangc") -- +-- NOTE! This function does not add any source from the sourceDir +-- add the source after calling this function with 'addSourceDir', or +-- use `baseSlangProjectAddFiles` +-- function baseSlangProject(name, sourceDir) -- Start a new project in premake. This switches @@ -331,15 +338,6 @@ function baseSlangProject(name, sourceDir) -- language "C++" - -- Since we know the project directory, we can go ahead - -- and add any source files locate there. - -- - -- Note that we do *not* recurse into subdirectories, - -- so projects that spread their source over multiple - -- directories will need to take more steps. - -- - addSourceDir(sourceDir) - -- By default, Premake generates VS project files that -- reflect the directory structure of the source code. -- While this is nice in principle, it creates messy @@ -372,7 +370,23 @@ function baseSlangProject(name, sourceDir) end end --- We can now use the `baseSlangProject()` subroutine to +function baseSlangProjectAddFiles(name, sourceDir) + + -- + -- Set up the base project + -- + + baseSlangProject(name, sourceDir) + + -- + -- Add the files in the sourceDir + -- NOTE! This doesn't recursively add files in subdirectories + -- + + addSourceDir(sourceDir) +end + +-- We can now use the `baseSlangProjectAddFiles()` subroutine to -- define helpers for the different categories of project -- in our source tree. -- @@ -395,8 +409,8 @@ function tool(name) -- Now we invoke our shared project configuration logic, -- specifying that the project lives under the `tools/` path. -- - baseSlangProject(name, "tools/" .. name) - + baseSlangProjectAddFiles(name, "tools/" .. name) + -- Finally, we set the project "kind" to produce a console -- application. This is a reasonable default for tools, -- and it can be overriden because Premake is stateful, @@ -420,14 +434,14 @@ function standardProject(name) -- A standard project has its code under `source/` -- - baseSlangProject(name, "source/" .. name) + baseSlangProjectAddFiles(name, "source/" .. name) end function toolSharedLibrary(name) group "test-tool" -- specifying that the project lives under the `tools/` path. -- - baseSlangProject(name .. "-tool", "tools/" .. name) + baseSlangProjectAddFiles(name .. "-tool", "tools/" .. name) defines { "SLANG_SHARED_LIBRARY_TOOL" } @@ -441,7 +455,7 @@ function example(name) group "examples" -- They have their source code under `examples/<project-name>/` - baseSlangProject(name, "examples/" .. name) + baseSlangProjectAddFiles(name, "examples/" .. name) -- By default, all of our examples are GUI applications. One some -- platforms there is no meaningful distinction between GUI and @@ -465,6 +479,30 @@ function example(name) links { "slang", "core", "gfx" } end +-- +-- Create a project that is used as a build step, typically to +-- build items needed for other dependencies +--- + +function generatorProject(name, sourcePath) + -- We use the `group` command here to specify that the + -- next project we create shold be placed into a group + -- named "generator" in a generated IDE solution/workspace. + -- + -- This is used in the generated Visual Studio solution + -- to group all the tools projects together in a logical + -- sub-directory of the solution. + -- + group "generator" + + -- Set up the project, but do NOT add any source files. + baseSlangProject(name, sourcePath) + + -- For now we just use static lib to force something + -- to build. + kind "StaticLib" +end + if isTargetWindows then -- -- With all of these helper routines defined, we can now define the @@ -521,7 +559,7 @@ standardProject "core" -- We need the core library to be relocatable to be able to link with slang.so filter { "system:linux" } buildoptions{"-fPIC"} - + -- -- The cpp extractor is a tool that scans C++ header files to extract -- reflection like information, and generate files to handle @@ -696,78 +734,41 @@ standardProject "slangc" uuid "D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7" kind "ConsoleApp" links { "core", "slang" } - --- --- TODO: Slang's current `Makefile` build does some careful incantations --- to make sure that the binaries it generates use a "relative `RPATH`" --- for loading shared libraries, so that Slang is not dependent on --- being installed to a fixed path on end-user machines. Before we --- can use Premake for the Linux build (or eventually MacOS) we would --- need to figure out how to replicate this incantation in premake. --- - --- --- Now that we've gotten all the simple projects out of the way, it is time --- to get into the more serious build steps. --- --- First up is the `slang` dynamic library project: --- - -standardProject "slang" - uuid "DB00DA62-0533-4AFD-B59F-A67D5B3A0808" - kind "SharedLib" - links { "core" } - warnings "Extra" - flags { "FatalWarnings" } - - -- The way that we currently configure things through `slang.h`, - -- we need to set a preprocessor definitions to ensure that - -- we declare the Slang API functions for *export* and not *import*. - -- - defines { "SLANG_DYNAMIC_EXPORT" } - - includedirs { "external/spirv-headers/include" } - - -- On some tests with MSBuild disabling these made build work. - -- flags { "NoIncrementalLink", "NoPCH", "NoMinimalRebuild" } - - -- The `standardProject` operation already added all the code in - -- `source/slang/*`, but we also want to incldue the umbrella - -- `slang.h` header in this prject, so we do that manually here. - files { "slang.h" } - - files { "source/core/core.natvis" } - - -- - -- The most challenging part of building `slang` is that we need - -- to invoke the `slang-generate`tools to generate the version - -- of the Slang standard library that we embed into the compiler. - -- We need to build the `slang-cpp-extractor` for similar reasons. - -- + + +generatorProject("run-generators", "source/slang/") + + -- We make 'source/slang' the location of the source, to make paths to source + -- relative to that + + -- We include these, even though they are not really part of the dummy + -- build, so that the filters below can pick up the appropriate locations. + + files + { + "source/slang/*.meta.slang", -- The stdlib files + "source/slang/slang-ast-reflect.h", -- The C++ reflection + + -- + -- To build we need to have some source! It has to be a source file that + -- does not depend on anything that is generated, so we take something + -- from core that will compile without any generation. + -- + + "source/core/slang-string.cpp", + } + -- First, we need to ensure that `slang-generate`/`slang-cpp-extactor` -- gets built before `slang`, so we declare a non-linking dependency between -- the projects here: -- dependson { "slang-cpp-extractor", "slang-generate" } - -- If we are not building glslang from source, then be - -- sure to copy a binary copy over to the output directory - if not buildGlslang then - filter { "system:windows" } - postbuildcommands { - "{COPY} ../../external/slang-binaries/bin/" .. targetName .. "/slang-glslang.dll %{cfg.targetdir}" - } - - filter { "system:linux" } - postbuildcommands { - "{COPY} ../../../external/slang-binaries/bin/" .. targetName .. "/libslang-glslang.so %{cfg.targetdir}" - } + local executableSuffix = ""; + if(os.target() == "windows") then + executableSuffix = ".exe"; end - - filter { "system:linux" } - -- might be able to do pic(true) - buildoptions{"-fPIC"} - + -- We need to run the C++ extractor to generate some include files if executeBinary then filter "files:**/slang-ast-reflect.h" @@ -795,11 +796,6 @@ standardProject "slang" -- buildoutputs { sourcePath .. "slang-ast-generated.h", sourcePath .. "slang-ast-generated-macro.h"} - local executableSuffix = ""; - if(os.target() == "windows") then - executableSuffix = ".exe"; - end - -- Make it depend on the extractor tool itself local buildInputTable = { "%{cfg.targetdir}/slang-cpp-extractor" .. executableSuffix } for key, inputFile in ipairs(inputFiles) do @@ -820,7 +816,7 @@ standardProject "slang" filter "files:**.meta.slang" -- Specify the "friendly" message that should print to the build log for the action buildmessage "slang-generate %{file.relpath}" - + -- Specify the actual command to run for this action. -- -- Note that we use a single-quoted Lua string and wrap the path @@ -835,7 +831,15 @@ standardProject "slang" -- This needs to be specified because the custom action will only -- run when this file needs to be generated. -- - buildoutputs { "%{file.relpath}.h" } + -- Note the use of abspath here, this ensures windows tests the correct file, otherwise + -- triggering doesn't work. The problem still remains on linux, because abspath *isn't* an + -- absolute path, it remains relative. + -- + -- TODO(JS): + -- It's not clear how to determine how to create the absolute path on linux, using + -- path.absolutepath, requires knowing the path to be relative to, and it's neither + -- the current path, the source path or the targetpath. + buildoutputs { "%{file.abspath}.h" } -- We will specify an additional build input dependency on the `slang-generate` -- tool itself, so that changes to the code for the tool cause the generation @@ -845,16 +849,79 @@ standardProject "slang" -- that the target platform will use. Premake might have a built-in way to -- query this, but I couldn't find it, so I am just winging it for now: -- - local executableSuffix = ""; - if(os.target() == "windows") then - executableSuffix = ".exe"; - end -- buildinputs { "%{cfg.targetdir}/slang-generate" .. executableSuffix } end + + +-- +-- TODO: Slang's current `Makefile` build does some careful incantations +-- to make sure that the binaries it generates use a "relative `RPATH`" +-- for loading shared libraries, so that Slang is not dependent on +-- being installed to a fixed path on end-user machines. Before we +-- can use Premake for the Linux build (or eventually MacOS) we would +-- need to figure out how to replicate this incantation in premake. +-- +-- +-- Now that we've gotten all the simple projects out of the way, it is time +-- to get into the more serious build steps. +-- +-- First up is the `slang` dynamic library project: +-- +standardProject "slang" + uuid "DB00DA62-0533-4AFD-B59F-A67D5B3A0808" + kind "SharedLib" + links { "core" } + warnings "Extra" + flags { "FatalWarnings" } + + -- The way that we currently configure things through `slang.h`, + -- we need to set a preprocessor definitions to ensure that + -- we declare the Slang API functions for *export* and not *import*. + -- + defines { "SLANG_DYNAMIC_EXPORT" } + + includedirs { "external/spirv-headers/include" } + + -- On some tests with MSBuild disabling these made build work. + -- flags { "NoIncrementalLink", "NoPCH", "NoMinimalRebuild" } + + -- The `standardProject` operation already added all the code in + -- `source/slang/*`, but we also want to incldue the umbrella + -- `slang.h` header in this prject, so we do that manually here. + files { "slang.h" } + + files { "source/core/core.natvis" } + + -- + -- The most challenging part of building `slang` is that we need + -- to invoke generators such as slang-cpp-extractor and slang-generate + -- to generate. We do this by executing the run-generators 'dummy' project + -- which produces the appropriate source + + dependson { "run-generators" } + + -- If we are not building glslang from source, then be + -- sure to copy a binary copy over to the output directory + if not buildGlslang then + filter { "system:windows" } + postbuildcommands { + "{COPY} ../../external/slang-binaries/bin/" .. targetName .. "/slang-glslang.dll %{cfg.targetdir}" + } + filter { "system:linux" } + postbuildcommands { + "{COPY} ../../../external/slang-binaries/bin/" .. targetName .. "/libslang-glslang.so %{cfg.targetdir}" + } + end + + filter { "system:linux" } + -- might be able to do pic(true) + buildoptions{"-fPIC"} + + if enableProfile then tool "slang-profile" uuid "375CC87D-F34A-4DF1-9607-C5C990FD6227" @@ -15,12 +15,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "heterogeneous-hello-world", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "model-viewer", "examples\model-viewer\model-viewer.vcxproj", "{2F8724C6-1BC3-2730-84D5-3F277030D04A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang", "source\slang\slang.vcxproj", "{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "generator", "generator", "{F3AB4ED5-5F37-BC99-6848-3F8ED452189A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "run-generators", "source\slang\run-generators.vcxproj", "{811F1997-6DDA-0843-1692-818D022C53D3}" ProjectSection(ProjectDependencies) = postProject {CA8A30D1-8FA9-4330-B7F7-84709246D8DC} = {CA8A30D1-8FA9-4330-B7F7-84709246D8DC} {66174227-8541-41FC-A6DF-4764FC66F78E} = {66174227-8541-41FC-A6DF-4764FC66F78E} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang", "source\slang\slang.vcxproj", "{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}" + ProjectSection(ProjectDependencies) = postProject + {811F1997-6DDA-0843-1692-818D022C53D3} = {811F1997-6DDA-0843-1692-818D022C53D3} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slangc", "source\slangc\slangc.vcxproj", "{D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test-tool", "test-tool", "{57B5AA5E-C340-1823-CC51-9B17385C7423}" @@ -95,6 +102,14 @@ Global {2F8724C6-1BC3-2730-84D5-3F277030D04A}.Release|Win32.Build.0 = Release|Win32 {2F8724C6-1BC3-2730-84D5-3F277030D04A}.Release|x64.ActiveCfg = Release|x64 {2F8724C6-1BC3-2730-84D5-3F277030D04A}.Release|x64.Build.0 = Release|x64 + {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|Win32.Build.0 = Debug|Win32 + {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|x64.ActiveCfg = Debug|x64 + {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|x64.Build.0 = Debug|x64 + {811F1997-6DDA-0843-1692-818D022C53D3}.Release|Win32.ActiveCfg = Release|Win32 + {811F1997-6DDA-0843-1692-818D022C53D3}.Release|Win32.Build.0 = Release|Win32 + {811F1997-6DDA-0843-1692-818D022C53D3}.Release|x64.ActiveCfg = Release|x64 + {811F1997-6DDA-0843-1692-818D022C53D3}.Release|x64.Build.0 = Release|x64 {DB00DA62-0533-4AFD-B59F-A67D5B3A0808}.Debug|Win32.ActiveCfg = Debug|Win32 {DB00DA62-0533-4AFD-B59F-A67D5B3A0808}.Debug|Win32.Build.0 = Debug|Win32 {DB00DA62-0533-4AFD-B59F-A67D5B3A0808}.Debug|x64.ActiveCfg = Debug|x64 @@ -169,6 +184,7 @@ Global {010BE414-ED5B-CF56-16C0-BD18027062C0} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231} {150CAA5A-0177-6A66-AA92-CFCB96DC2D49} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231} {2F8724C6-1BC3-2730-84D5-3F277030D04A} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231} + {811F1997-6DDA-0843-1692-818D022C53D3} = {F3AB4ED5-5F37-BC99-6848-3F8ED452189A} {61F7EB00-7281-4BF3-9470-7C2EA92620C3} = {57B5AA5E-C340-1823-CC51-9B17385C7423} {C5ACCA6E-C04D-4B36-8516-3752B3C13C2F} = {57B5AA5E-C340-1823-CC51-9B17385C7423} {222F7498-B40C-4F3F-A704-DDEB91A4484A} = {FD47AE19-69FD-260F-F2F1-20E65EA61D13} diff --git a/source/slang/run-generators.vcxproj b/source/slang/run-generators.vcxproj new file mode 100644 index 000000000..620d43039 --- /dev/null +++ b/source/slang/run-generators.vcxproj @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{811F1997-6DDA-0843-1692-818D022C53D3}</ProjectGuid> + <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> + <Keyword>Win32Proj</Keyword> + <RootNamespace>run-generators</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <OutDir>..\..\bin\windows-x86\debug\</OutDir> + <IntDir>..\..\intermediate\windows-x86\debug\run-generators\</IntDir> + <TargetName>run-generators</TargetName> + <TargetExt>.lib</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <OutDir>..\..\bin\windows-x64\debug\</OutDir> + <IntDir>..\..\intermediate\windows-x64\debug\run-generators\</IntDir> + <TargetName>run-generators</TargetName> + <TargetExt>.lib</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <OutDir>..\..\bin\windows-x86\release\</OutDir> + <IntDir>..\..\intermediate\windows-x86\release\run-generators\</IntDir> + <TargetName>run-generators</TargetName> + <TargetExt>.lib</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <OutDir>..\..\bin\windows-x64\release\</OutDir> + <IntDir>..\..\intermediate\windows-x64\release\run-generators\</IntDir> + <TargetName>run-generators</TargetName> + <TargetExt>.lib</TargetExt> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <Optimization>Disabled</Optimization> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <Optimization>Disabled</Optimization> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\core\slang-string.cpp" /> + </ItemGroup> + <ItemGroup> + <CustomBuild Include="core.meta.slang"> + <FileType>Document</FileType> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"../../bin/windows-x86/debug/slang-generate" %(Identity)</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"../../bin/windows-x64/debug/slang-generate" %(Identity)</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"../../bin/windows-x86/release/slang-generate" %(Identity)</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"../../bin/windows-x64/release/slang-generate" %(Identity)</Command> + <Outputs>core.meta.slang.h</Outputs> + <Message>slang-generate %(Identity)</Message> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/windows-x86/debug/slang-generate.exe</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../bin/windows-x64/debug/slang-generate.exe</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/windows-x86/release/slang-generate.exe</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../bin/windows-x64/release/slang-generate.exe</AdditionalInputs> + </CustomBuild> + <CustomBuild Include="hlsl.meta.slang"> + <FileType>Document</FileType> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"../../bin/windows-x86/debug/slang-generate" %(Identity)</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"../../bin/windows-x64/debug/slang-generate" %(Identity)</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"../../bin/windows-x86/release/slang-generate" %(Identity)</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"../../bin/windows-x64/release/slang-generate" %(Identity)</Command> + <Outputs>hlsl.meta.slang.h</Outputs> + <Message>slang-generate %(Identity)</Message> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/windows-x86/debug/slang-generate.exe</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../bin/windows-x64/debug/slang-generate.exe</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/windows-x86/release/slang-generate.exe</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../bin/windows-x64/release/slang-generate.exe</AdditionalInputs> + </CustomBuild> + <CustomBuild Include="slang-ast-reflect.h"> + <FileType>Document</FileType> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> + <Outputs>slang-ast-generated.h;slang-ast-generated-macro.h</Outputs> + <Message>slang-cpp-extractor AST %(Identity)</Message> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/windows-x86/debug/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../bin/windows-x64/debug/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/windows-x86/release/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../bin/windows-x64/release/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> + </CustomBuild> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/source/slang/run-generators.vcxproj.filters b/source/slang/run-generators.vcxproj.filters new file mode 100644 index 000000000..45b6e00b1 --- /dev/null +++ b/source/slang/run-generators.vcxproj.filters @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Header Files"> + <UniqueIdentifier>{21EB8090-0D4E-1035-B6D3-48EBA215DCB7}</UniqueIdentifier> + </Filter> + <Filter Include="Source Files"> + <UniqueIdentifier>{E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\core\slang-string.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <CustomBuild Include="core.meta.slang"> + <Filter>Source Files</Filter> + </CustomBuild> + <CustomBuild Include="hlsl.meta.slang"> + <Filter>Source Files</Filter> + </CustomBuild> + <CustomBuild Include="slang-ast-reflect.h"> + <Filter>Header Files</Filter> + </CustomBuild> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/source/slang/slang.vcxproj b/source/slang/slang.vcxproj index b92fb5967..65e0ba4aa 100644 --- a/source/slang/slang.vcxproj +++ b/source/slang/slang.vcxproj @@ -198,6 +198,7 @@ <ClInclude Include="slang-ast-generated-macro.h" /> <ClInclude Include="slang-ast-generated.h" /> <ClInclude Include="slang-ast-modifier.h" /> + <ClInclude Include="slang-ast-reflect.h" /> <ClInclude Include="slang-ast-serialize.h" /> <ClInclude Include="slang-ast-stmt.h" /> <ClInclude Include="slang-ast-support-types.h" /> @@ -384,45 +385,8 @@ <ClCompile Include="slang.cpp" /> </ItemGroup> <ItemGroup> - <CustomBuild Include="core.meta.slang"> - <FileType>Document</FileType> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"../../bin/windows-x86/debug/slang-generate" %(Identity)</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"../../bin/windows-x64/debug/slang-generate" %(Identity)</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"../../bin/windows-x86/release/slang-generate" %(Identity)</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"../../bin/windows-x64/release/slang-generate" %(Identity)</Command> - <Outputs>../../core.meta.slang.h</Outputs> - <Message>slang-generate %(Identity)</Message> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/windows-x86/debug/slang-generate.exe</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../bin/windows-x64/debug/slang-generate.exe</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/windows-x86/release/slang-generate.exe</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../bin/windows-x64/release/slang-generate.exe</AdditionalInputs> - </CustomBuild> - <CustomBuild Include="hlsl.meta.slang"> - <FileType>Document</FileType> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"../../bin/windows-x86/debug/slang-generate" %(Identity)</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"../../bin/windows-x64/debug/slang-generate" %(Identity)</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"../../bin/windows-x86/release/slang-generate" %(Identity)</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"../../bin/windows-x64/release/slang-generate" %(Identity)</Command> - <Outputs>../../hlsl.meta.slang.h</Outputs> - <Message>slang-generate %(Identity)</Message> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/windows-x86/debug/slang-generate.exe</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../bin/windows-x64/debug/slang-generate.exe</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/windows-x86/release/slang-generate.exe</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../bin/windows-x64/release/slang-generate.exe</AdditionalInputs> - </CustomBuild> - <CustomBuild Include="slang-ast-reflect.h"> - <FileType>Document</FileType> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory)/ slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang-ast- -o slang-ast-generated -output-fields</Command> - <Outputs>slang-ast-generated.h;slang-ast-generated-macro.h</Outputs> - <Message>slang-cpp-extractor AST %(Identity)</Message> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../bin/windows-x86/debug/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../bin/windows-x64/debug/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../bin/windows-x86/release/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../bin/windows-x64/release/slang-cpp-extractor.exe;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h</AdditionalInputs> - </CustomBuild> + <None Include="core.meta.slang" /> + <None Include="hlsl.meta.slang" /> </ItemGroup> <ItemGroup> <Natvis Include="..\core\core.natvis" /> diff --git a/source/slang/slang.vcxproj.filters b/source/slang/slang.vcxproj.filters index 855b3fb7b..7b26d8ee1 100644 --- a/source/slang/slang.vcxproj.filters +++ b/source/slang/slang.vcxproj.filters @@ -45,6 +45,9 @@ <ClInclude Include="slang-ast-modifier.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="slang-ast-reflect.h"> + <Filter>Header Files</Filter> + </ClInclude> <ClInclude Include="slang-ast-serialize.h"> <Filter>Header Files</Filter> </ClInclude> @@ -595,15 +598,12 @@ </ClCompile> </ItemGroup> <ItemGroup> - <CustomBuild Include="core.meta.slang"> + <None Include="core.meta.slang"> <Filter>Source Files</Filter> - </CustomBuild> - <CustomBuild Include="hlsl.meta.slang"> + </None> + <None Include="hlsl.meta.slang"> <Filter>Source Files</Filter> - </CustomBuild> - <CustomBuild Include="slang-ast-reflect.h"> - <Filter>Header Files</Filter> - </CustomBuild> + </None> </ItemGroup> <ItemGroup> <Natvis Include="..\core\core.natvis"> diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp index 979127f8d..5fca7c21a 100644 --- a/tools/slang-generate/main.cpp +++ b/tools/slang-generate/main.cpp @@ -8,6 +8,7 @@ #include "../../source/core/slang-list.h" #include "../../source/core/slang-string.h" #include "../../source/core/slang-string-util.h" +#include "../../source/core/slang-io.h" using namespace Slang; @@ -38,7 +39,7 @@ struct Node // Information about a source file struct SourceFile { - char const* inputPath; + String inputPath; StringSpan text; Node* node; }; @@ -761,7 +762,7 @@ Node* parseSourceFile(SourceFile* file) for (auto hh : kHandlers) { - if (UnownedTerminatedStringSlice(path).endsWith(hh.extension)) + if (path.endsWith(hh.extension)) { return hh.handler(text); } @@ -772,10 +773,10 @@ Node* parseSourceFile(SourceFile* file) -SourceFile* parseSourceFile(char const* path) +SourceFile* parseSourceFile(const String& path) { FILE* inputStream; - fopen_s(&inputStream, path, "rb"); + fopen_s(&inputStream, path.getBuffer(), "rb"); fseek(inputStream, 0, SEEK_END); size_t inputSize = ftell(inputStream); fseek(inputStream, 0, SEEK_SET); @@ -804,7 +805,7 @@ int main( const char*const* argv) { // Parse command-line arguments. - List<const char*> inputPaths; + List<String> inputPaths; char const* appName = "slang-generate"; { @@ -818,7 +819,9 @@ int main( // Copy the input paths for (; argCursor != argEnd; ++argCursor) { - inputPaths.add(*argCursor); + // We simplify here because doing so also means paths separators are set to / + // and that makes path emitting work correctly + inputPaths.add(Path::simplify(UnownedStringSlice(*argCursor))); } } @@ -830,7 +833,7 @@ int main( // Read each input file and process it according // to the type of treatment it requires. - for (const char* inputPath: inputPaths) + for (auto& inputPath: inputPaths) { SourceFile* sourceFile = parseSourceFile(inputPath); if (sourceFile) @@ -866,7 +869,7 @@ int main( readAllText(outputPath.getBuffer(), allTextNew); if (allTextOld != allTextNew) { - writeAllText(inputPath, outputPathFinal.getBuffer(), allTextNew.getBuffer()); + writeAllText(inputPath.getBuffer(), outputPathFinal.getBuffer(), allTextNew.getBuffer()); } remove(outputPath.getBuffer()); } |
