diff options
| -rw-r--r-- | .github/workflows/c-cpp.yml | 3 | ||||
| -rw-r--r-- | .github/workflows/release-linux.yml | 10 | ||||
| -rw-r--r-- | .github/workflows/release-windows.yml | 13 | ||||
| -rw-r--r-- | .github/workflows/windows.yml | 3 | ||||
| -rw-r--r-- | deps/target-deps.json | 78 | ||||
| -rw-r--r-- | github_build.sh | 2 | ||||
| -rw-r--r-- | premake5.lua | 92 |
7 files changed, 146 insertions, 55 deletions
diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 2bffa36ed..e848b8170 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -14,6 +14,7 @@ jobs: matrix: configuration: ['debug', 'release'] compiler: ['gcc', 'clang'] + platform: ['x64'] steps: - uses: actions/checkout@v2.3.4 with: @@ -23,9 +24,11 @@ jobs: run: CC=${{matrix.compiler}} CONFIGURATION=${{matrix.configuration}} + ARCH=${{matrix.platform}} source ./github_build.sh - name: test run: CONFIGURATION=${{matrix.configuration}} CC=${{matrix.compiler}} + ARCH=${{matrix.platform}} source ./github_test.sh
\ No newline at end of file diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index ec9dd54b1..8f31dc510 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -10,6 +10,11 @@ jobs: build: name: Upload Release Asset runs-on: ubuntu-latest + strategy: + matrix: + configuration: ['release'] + compiler: ['gcc'] + platform: ['x64'] steps: - name: Checkout code uses: actions/checkout@v2 @@ -20,8 +25,9 @@ jobs: id: build run: | echo "starting to build..." - export CC=gcc - export CONFIGURATION=release + export CC=${{matrix.compiler}} + export CONFIGURATION=${{matrix.configuration}} + export ARCH=${{matrix.platform}} echo "building..." source ./github_build.sh echo "creating binary archieves..." diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 3b70947a0..8079b2519 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -21,13 +21,18 @@ jobs: fetch-depth: '0' - name: setup-msbuild uses: microsoft/setup-msbuild@v1 - - name: premake - run: - .\premake.bat vs2017 --enable-embed-stdlib=true + + # If we are building for aarch64 we want to build x64 first, so that all generated files are produced - name: msbuild (x64 tools) if: ${{ matrix.platform == 'aarch64' }} - run: + run: | + .\premake.bat vs2017 --arch=x64 --ignore-deps=slang-llvm MSBuild.exe slang.sln -v:m -m -property:Configuration=Release -property:Platform=x64 -property:WindowsTargetPlatformVersion=10.0.19041.0 + + # Do the premake for the actual target, downloading dependencies if necessary + - name: premake + run: + .\premake.bat vs2017 --enable-embed-stdlib=true --arch=${{matrix.platform}} --deps=true - name: msbuild run: MSBuild.exe slang.sln -v:m -m -property:Configuration=${{matrix.configuration}} -property:Platform=${{matrix.platform}} -property:WindowsTargetPlatformVersion=10.0.19041.0 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b3e575780..1637640e8 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -22,9 +22,10 @@ jobs: fetch-depth: '0' - name: setup-msbuild uses: microsoft/setup-msbuild@v1 + - name: premake run: - .\premake.bat vs2017 --enable-embed-stdlib=true + .\premake.bat vs2017 --enable-embed-stdlib=true --arch=${{matrix.platform}} --deps=true - name: build run: MSBuild.exe slang.sln -v:m -m -property:Configuration=${{matrix.configuration}} -property:Platform=${{matrix.platform}} -property:WindowsTargetPlatformVersion=10.0.19041.0 diff --git a/deps/target-deps.json b/deps/target-deps.json new file mode 100644 index 000000000..987bbc6c3 --- /dev/null +++ b/deps/target-deps.json @@ -0,0 +1,78 @@ +{ + "project": { + "name" : "slang", + "dependencies" : [ + { + "name" : "slang-llvm", + "baseUrl" : "https://github.com/shader-slang/slang-llvm/releases/download/v13.x-18/", + "optional" : true, + "packages" : + { + "windows-x86_64" : { "type" : "unavailable", "path" : "slang-llvm-13.x-18-win64.zip" }, + "windows-x86" : { "type": "unavailable", "path" : "slang-llvm-13.x-18-win32.zip" }, + "linux-x86_64" : { "type": "unavailable", "path" : "slang-llvm-v13.x-18-linux-x86_64-release.zip" } + } + }, + { + "name" : "dxc", + "type" : "submodule" + }, + { + "name" : "vulkan", + "type" : "submodule" + }, + { + "name" : "tinyobjloader", + "type" : "submodule" + }, + { + "name" : "stb", + "type" : "submodule" + }, + { + "name" : "spirv-tools-generated", + "type" : "submodule" + }, + { + "name" : "spirv-tools", + "type" : "submodule" + }, + { + "name" : "spirv-headers", + "type" : "submodule" + }, + { + "name" : "spirv", + "type" : "submodule" + }, + { + "name" : "slang-binaries", + "type" : "submodule" + }, + { + "name" : "miniz", + "type" : "submodule" + }, + { + "name" : "lz4", + "type" : "submodule" + }, + { + "name" : "imgui", + "type" : "submodule" + }, + { + "name" : "glslang-generated", + "type" : "submodule" + }, + { + "name" : "glslang", + "type" : "submodule" + }, + { + "name" : "glm", + "type" : "submodule" + } + ] + } +} diff --git a/github_build.sh b/github_build.sh index 82ab0be98..8a0fd8b79 100644 --- a/github_build.sh +++ b/github_build.sh @@ -8,7 +8,7 @@ git describe --tags | sed -e "s/\(.*\)/\#define SLANG_TAG_VERSION \"\1\"/" > sla cat slang-tag-version.h # Create the makefile -./premake5 gmake --cc=${CC} --enable-embed-stdlib=true +./premake5 gmake --cc=${CC} --enable-embed-stdlib=true --arch=${ARCH} --deps=true # Build the configuration make config=${CONFIGURATION}_x64 -j`nproc` diff --git a/premake5.lua b/premake5.lua index f6f2fc22f..2643a1b6c 100644 --- a/premake5.lua +++ b/premake5.lua @@ -48,6 +48,22 @@ -- From in the build directory you can use -- % premake5 --file=../premake5.lua --os=linux gmake +-- +-- Add the package path for slang-pack/slang-util +-- The question mark is there the name of the module is inserted. +--- + +local modulePath = "external/slang-binaries/lua-modules/?.lua" + +package.path = package.path .. ";" .. modulePath + +-- Load the slack package manager module +slangPack = require("slang-pack") +slangUtil = require("slang-util") + +-- Load the dependencies from the json file +deps = slangPack.loadDependencies("deps/target-deps.json") + newoption { trigger = "override-module", description = "(Optional) Specify a lua file that can override functions", @@ -69,13 +85,6 @@ newoption { } newoption { - trigger = "target-detail", - description = "(Optional) More specific target information", - value = "string", - allowed = { {"cygwin"}, {"mingw"} } - } - - newoption { trigger = "build-glslang", description = "(Optional) If true glslang and spirv-opt will be built", value = "bool", @@ -145,7 +154,6 @@ newoption { buildLocation = _OPTIONS["build-location"] executeBinary = (_OPTIONS["execute-binary"] == "true") - targetDetail = _OPTIONS["target-detail"] buildGlslang = (_OPTIONS["build-glslang"] == "true") enableCuda = not not (_OPTIONS["enable-cuda"] == "true" or _OPTIONS["cuda-sdk-path"]) enableProfile = (_OPTIONS["enable-profile"] == "true") @@ -155,13 +163,27 @@ newoption { enableEmbedStdLib = (_OPTIONS["enable-embed-stdlib"] == "true") enableXlib = (_OPTIONS["enable-xlib"] == "true") + -- Determine the target info + + targetInfo = slangUtil.getTargetInfo() + + -- + -- Update the dependencies for the target + -- + + deps:update(targetInfo.name) + + -- Get the target name that can be used as paths that generate for different configurations (ie contains premake Tokens) + + targetName = targetInfo.tokenName + -- This is the path where nvapi is expected to be found nvapiPath = "external/nvapi" if enableOptix then optixPath = optixPath or "C:/ProgramData/NVIDIA Corporation/OptiX SDK 7.0.0/" - enableCuda = true; + enableCuda = true end -- cudaPath is only set if cuda is enabled, and CUDA_PATH enviromental variable is set @@ -171,35 +193,29 @@ newoption { cudaPath = (_OPTIONS["cuda-sdk-path"] or os.getenv("CUDA_PATH")) end - -- Is true when the target is really windows (ie not something on top of windows like cygwin) - isTargetWindows = (os.target() == "windows") and not (targetDetail == "mingw" or targetDetail == "cygwin") + -- TODO(JS): What's the point in the enable-xlib command line option if it's just overridden here? - if isTargetWindows then + if targetInfo.isWindows then enableXlib = false end - -- Even if we have the nvapi path, we only want to currently enable on windows targets - enableNvapi = not not (os.isdir(nvapiPath) and isTargetWindows and _OPTIONS["enable-nvapi"] == "true") + enableNvapi = not not (os.isdir(nvapiPath) and targetInfo.isWindows and _OPTIONS["enable-nvapi"] == "true") if enableNvapi then printf("Enabled NVAPI") end + overrideModule = {} local overrideModulePath = _OPTIONS["override-module"] if overrideModulePath then overrideModule = require(overrideModulePath) end - targetName = "%{cfg.system}-%{cfg.platform:lower()}" - - if not (targetDetail == nil) then - targetName = targetDetail .. "-%{cfg.platform:lower()}" - end -- This is needed for gcc, for the 'fileno' functions on cygwin -- _GNU_SOURCE makes realpath available in gcc - if targetDetail == "cygwin" then + if targetInfo.os == "cygwin" then buildoptions { "-D_POSIX_SOURCE" } filter { "toolset:gcc*" } buildoptions { "-D_GNU_SOURCE" } @@ -345,27 +361,9 @@ newoption { } end - -- - -- A function to return a name to place project files under - -- in build directory - -- - -- This is complicated in so far as when this is used (with location for example) - -- we can't use Tokens - -- https://github.com/premake/premake-core/wiki/Tokens - - function getBuildLocationName() - if not not targetDetail then - return targetDetail - elseif isTargetWindows then - return "visual-studio" - else - return os.target() - end - end - -- Adds CUDA dependency to a project function addCUDAIfEnabled() - if type(cudaPath) == "string" and isTargetWindows then + if type(cudaPath) == "string" and targetInfo.isWindows then filter {} includedirs { cudaPath .. "/include" } includedirs { cudaPath .. "/include", cudaPath .. "/common/inc" } @@ -443,7 +441,7 @@ newoption { -- Location could do with a better name than 'other' - but it seems as if %{cfg.buildcfg:lower()} and similar variables -- is not available for location to expand. - location("build/" .. getBuildLocationName() .. "/" .. name) + location("build/" .. slangUtil.getBuildLocationName(targetInfo) .. "/" .. name) -- The intermediate ("object") directory will use a similar @@ -604,7 +602,7 @@ newoption { -- rather than in each example. links { "example-base", "slang", "gfx", "gfx-util", "platform", "core" } - if isTargetWindows then + if targetInfo.isWindows then else if enableXlib then defines { "SLANG_ENABLE_XLIB" } @@ -706,7 +704,7 @@ newoption { warnings "Extra" flags { "FatalWarnings" } - if isTargetWindows then + if targetInfo.isWindows then addSourceDir "source/core/windows" else addSourceDir "source/core/unix" @@ -728,7 +726,7 @@ newoption { warnings "Extra" flags { "FatalWarnings" } - if isTargetWindows then + if targetInfo.isWindows then addSourceDir "source/compiler-core/windows" else addSourceDir "source/compiler-core/unix" @@ -810,7 +808,7 @@ newoption { includedirs { ".", "external", "source", "tools/gfx", "tools/platform" } links { "core", "compiler-core", "slang", "gfx", "gfx-util", "platform" } - if isTargetWindows then + if targetInfo.isWindows then addSourceDir "tools/render-test/windows" systemversion "latest" @@ -853,7 +851,7 @@ newoption { -- To special case that we may be building using cygwin on windows. If 'true windows' we build for dx12/vk and run the script -- If not we assume it's a cygwin/mingw type situation and remove files that aren't appropriate - if isTargetWindows then + if targetInfo.isWindows then systemversion "latest" -- For Windows targets, we want to copy @@ -867,7 +865,7 @@ newoption { addSourceDir "tools/gfx/d3d" addSourceDir "tools/gfx/d3d11" addSourceDir "tools/gfx/d3d12" - elseif targetDetail == "mingw" or targetDetail == "cygwin" then + elseif targetInfo.os == "mingw" or targetInfo.os == "cygwin" then -- Don't support any render techs... elseif os.target() == "macosx" then --addSourceDir "tools/gfx/open-gl" @@ -932,7 +930,7 @@ newoption { addSourceDir "tools/platform/windows" addSourceDir "tools/platform/placeholder" -- Include windowing support on Windows. - if isTargetWindows then + if targetInfo.isWindows then systemversion "latest" else if enableXlib then |
