From 2a633219a16a1b72a5269621f41dd6f1189a9b24 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 28 Sep 2022 12:44:21 -0700 Subject: [PATCH] fix. --- .github/workflows/release-macos.yml | 30 +++++++++--------- .github/workflows/release-windows.yml | 2 +- github_build.sh | 18 ++++++++++- github_macos_build.sh | 17 +++++++++- premake5.lua | 45 ++++++++++++++++++++++----- 5 files changed, 87 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 8f0ec2892d..663230f5f6 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -17,6 +17,21 @@ jobs: platform: ['x64'] targetPlatform: ['x64', 'aarch64'] steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'true' + fetch-depth: '0' + - name: Build release project + id: build + run: | + echo "starting to build..." + export CC=${{matrix.compiler}} + export CONFIGURATION=${{matrix.configuration}} + export ARCH=${{matrix.platform}} + export TARGETARCH=${{matrix.targetPlatform}} + echo "building..." + source ./github_macos_build.sh - name: "Import signing certificate" env: BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} @@ -46,21 +61,6 @@ jobs: brew install mitchellh/gon/gon security find-identity -v brew install coreutils - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'true' - fetch-depth: '0' - - name: Build release project - id: build - run: | - echo "starting to build..." - export CC=${{matrix.compiler}} - export CONFIGURATION=${{matrix.configuration}} - export ARCH=${{matrix.platform}} - export TARGETARCH=${{matrix.targetPlatform}} - echo "building..." - source ./github_macos_build.sh - name: Sign binaries env: IDENTITY_ID: d6ada82a113e4204aaad914e1013e9548ffd30d0 diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 4d40304d2a..1b186b1876 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -28,7 +28,7 @@ jobs: run: | .\premake.bat vs2019 --arch=x64 --ignore-deps=slang-llvm,slang-glslang --no-progress=true MSBuild.exe slang.sln -v:m -m -property:Configuration=Release -property:Platform=x64 -property:WindowsTargetPlatformVersion=10.0.19041.0 - .\premake.bat vs2019 --arch=${{matrix.platform}} --ignore-deps=slang-llvm,slang-glslang --no-progress=true --skip-source-generation=true + .\premake.bat vs2019 --arch=${{matrix.platform}} --ignore-deps=slang-llvm,slang-glslang --no-progress=true --skip-source-generation=true --deploy-slang-llvm=false --deploy-slang-glslang=false # Do the premake for the actual target, downloading dependencies if necessary - name: premake if: ${{ matrix.platform != 'aarch64' }} diff --git a/github_build.sh b/github_build.sh index 7e23294a61..bd07da2bb6 100644 --- a/github_build.sh +++ b/github_build.sh @@ -7,10 +7,26 @@ chmod u+x premake5 git describe --tags | sed -e "s/\(.*\)/\#define SLANG_TAG_VERSION \"\1\"/" > slang-tag-version.h cat slang-tag-version.h +if [[ "" == "${TARGETARCH}" ]]; then +TARGETARCH=${ARCH} +fi + +if [[ "${ARCH}" != "${TARGETARCH}" ]]; then + # Create the makefile ./premake5 gmake --cc=${CC} --enable-embed-stdlib=true --arch=${ARCH} --deps=true --no-progress=true # Build the configuration -make config=${CONFIGURATION}_x64 -j`nproc` +make config=${CONFIGURATION}_${ARCH} -j`nproc` + +# Create the makefile +./premake5 gmake --cc=${CC} --enable-embed-stdlib=true --arch=${TARGETARCH} --deps=true --no-progress=true --skip-source-generation=true --deploy-slang-llvm=false --deploy-slang-glslang=false +else +# Create the makefile +./premake5 gmake --cc=${CC} --enable-embed-stdlib=true --arch=${TARGETARCH} --deps=true --no-progress=true +fi + +# Build the configuration +make config=${CONFIGURATION}_${TARGETARCH} -j`nproc` diff --git a/github_macos_build.sh b/github_macos_build.sh index 5b8305a025..2fc9fce05f 100644 --- a/github_macos_build.sh +++ b/github_macos_build.sh @@ -7,10 +7,25 @@ chmod u+x premake5 git describe --tags | sed -e "s/\(.*\)/\#define SLANG_TAG_VERSION \"\1\"/" > slang-tag-version.h cat slang-tag-version.h +if [[ "" == "${TARGETARCH}" ]]; then +TARGETARCH=${ARCH} +fi + +if [[ "${ARCH}" != "${TARGETARCH}" ]]; then + # Create the makefile ./premake5 gmake --cc=${CC} --enable-xlib=false --enable-embed-stdlib=true --arch=${ARCH} --deps=true --no-progress=true # Build the configuration -make config=${CONFIGURATION}_x64 -j`sysctl -n hw.ncpu` +make config=${CONFIGURATION}_${ARCH} -j`sysctl -n hw.ncpu` + +# Create the makefile +./premake5 gmake --cc=${CC} --enable-xlib=false --enable-embed-stdlib=true --arch=${TARGETARCH} --deps=true --no-progress=true --skip-source-generation=true --deploy-slang-llvm=false --deploy-slang-glslang=false +else +# Create the makefile +./premake5 gmake --cc=${CC} --enable-xlib=false --enable-embed-stdlib=true --arch=${TARGETARCH} --deps=true --no-progress=true +fi +# Build the configuration +make config=${CONFIGURATION}_${TARGETARCH} -j`sysctl -n hw.ncpu` \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index 02875fc892..7b0adbc716 100644 --- a/premake5.lua +++ b/premake5.lua @@ -167,6 +167,29 @@ newoption { allowed = { { "true", "True"}, { "false", "False" } } } + newoption { + trigger = "skip-source-generation", + description = "(Optional) If true will skip source generation steps.", + value = "bool", + default = "false", + allowed = { { "true", "True"}, { "false", "False" } } + } + + newoption { + trigger = "deploy-slang-llvm", + description = "(Optional) If true will copy slang-llvm to output directory.", + value = "bool", + default = "true", + allowed = { { "true", "True"}, { "false", "False" } } + } + newoption { + trigger = "deploy-slang-glslang", + description = "(Optional) If true will copy slang-glslang to output directory.", + value = "bool", + default = "true", + allowed = { { "true", "True"}, { "false", "False" } } + } + buildLocation = _OPTIONS["build-location"] executeBinary = (_OPTIONS["execute-binary"] == "true") buildGlslang = (_OPTIONS["build-glslang"] == "true") @@ -177,7 +200,9 @@ newoption { enableProfile = (_OPTIONS["enable-profile"] == "true") enableEmbedStdLib = (_OPTIONS["enable-embed-stdlib"] == "true") enableXlib = (_OPTIONS["enable-xlib"] == "true") - enableExperimental = (_OPTIONS["enable-experimental-projects"] == "true") + skipSourceGeneration = (_OPTIONS["skip-source-generation"] == "true") + deployLLVM = (_OPTIONS["deploy-slang-llvm"] == "true") + deployGLSLang = (_OPTIONS["deploy-slang-glslang"] == "true") -- If stdlib embedding is enabled, disable stdlib source embedding by default disableStdlibSource = enableEmbedStdLib @@ -1181,6 +1206,8 @@ tool "slangd" buildinputs { builddir .. "/slang-embed" .. getExecutableSuffix() } end + if not skipSourceGeneration then + generatorProject("run-generators", nil) -- We make 'source/slang' the location of the source, to make paths to source @@ -1323,7 +1350,7 @@ tool "slangd" buildinputs { "%{cfg.targetdir}/slangc-bootstrap" .. executableSuffix } buildcommands { '"%{cfg.targetdir}/slangc-bootstrap" -archive-type riff-lz4 -save-stdlib-bin-source "%{file.directory}/slang-stdlib-generated.h"' } end - + end -- not skipSourceGeneration -- -- TODO: Slang's current `Makefile` build does some careful incantations @@ -1360,7 +1387,9 @@ tool "slangd" if enableEmbedStdLib then -- We only have this dependency if we are embedding stdlib - dependson { "embed-stdlib-generator" } + if not skipSourceGeneration then + dependson { "embed-stdlib-generator" } + end else -- Disable StdLib embedding defines { "SLANG_WITHOUT_EMBEDDED_STD_LIB" } @@ -1395,12 +1424,14 @@ tool "slangd" -- to generate. We do this by executing the run-generators 'dummy' project -- which produces the appropriate source - dependson { "run-generators" } - + if not skipSourceGeneration then + dependson { "run-generators" } + end + -- If we have slang-llvm copy it local slangLLVMPath = deps:getProjectRelativePath("slang-llvm", "../../..") - if slangLLVMPath then + if slangLLVMPath and deployLLVM then filter { "system:linux or macosx or windows" } local sharedLibName = slangUtil.getSharedLibraryFileName(targetInfo, "slang-llvm") postbuildcommands { @@ -1412,7 +1443,7 @@ tool "slangd" -- 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 + if not buildGlslang and slangGlslangPath~=nil and deployGLSLang then filter { "system:linux or macosx or windows" } local sharedLibName = slangUtil.getSharedLibraryFileName(targetInfo, "slang-glslang") postbuildcommands {