Skip to content

Commit

Permalink
add SDL_shadercross build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozeiko committed Nov 17, 2024
1 parent 8c9ffcc commit 8f7ebc5
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 31 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/build-sdl3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ jobs:
arch: [x64, arm64]

outputs:
OUTPUT_DATE: ${{ steps.build.outputs.OUTPUT_DATE }}
SDL_COMMIT: ${{ steps.build.outputs.SDL_COMMIT }}
SDL_IMAGE_COMMIT: ${{ steps.build.outputs.SDL_IMAGE_COMMIT }}
SDL_MIXER_COMMIT: ${{ steps.build.outputs.SDL_MIXER_COMMIT }}
SDL_TTF_COMMIT: ${{ steps.build.outputs.SDL_TTF_COMMIT }}
SDL_RTF_COMMIT: ${{ steps.build.outputs.SDL_RTF_COMMIT }}
SDL_NET_COMMIT: ${{ steps.build.outputs.SDL_NET_COMMIT }}
SDL2_COMPAT_COMMIT: ${{ steps.build.outputs.SDL2_COMPAT_COMMIT }}
OUTPUT_DATE: ${{ steps.build.outputs.OUTPUT_DATE }}
SDL_COMMIT: ${{ steps.build.outputs.SDL_COMMIT }}
SDL_IMAGE_COMMIT: ${{ steps.build.outputs.SDL_IMAGE_COMMIT }}
SDL_MIXER_COMMIT: ${{ steps.build.outputs.SDL_MIXER_COMMIT }}
SDL_TTF_COMMIT: ${{ steps.build.outputs.SDL_TTF_COMMIT }}
SDL_RTF_COMMIT: ${{ steps.build.outputs.SDL_RTF_COMMIT }}
SDL_NET_COMMIT: ${{ steps.build.outputs.SDL_NET_COMMIT }}
SDL_SHADERCROSS_COMMIT: ${{ steps.build.outputs.SDL_SHADERCROSS_COMMIT }}
SDL2_COMPAT_COMMIT: ${{ steps.build.outputs.SDL2_COMPAT_COMMIT }}

steps:

Expand Down Expand Up @@ -54,13 +55,14 @@ jobs:

- name: release
run: |
echo '[SDL commit](https://github.com/libsdl-org/SDL/commit/${{ needs.build.outputs.SDL_COMMIT }})' >>notes.txt
echo '[SDL_image commit](https://github.com/libsdl-org/SDL_image/commit/${{ needs.build.outputs.SDL_IMAGE_COMMIT }})' >>notes.txt
echo '[SDL_mixer commit](https://github.com/libsdl-org/SDL_mixer/commit/${{ needs.build.outputs.SDL_MIXER_COMMIT }})' >>notes.txt
echo '[SDL_ttf commit](https://github.com/libsdl-org/SDL_ttf/commit/${{ needs.build.outputs.SDL_TTF_COMMIT }})' >>notes.txt
echo '[SDL_rtf commit](https://github.com/libsdl-org/SDL_rtf/commit/${{ needs.build.outputs.SDL_RTF_COMMIT }})' >>notes.txt
echo '[SDL_net commit](https://github.com/libsdl-org/SDL_net/commit/${{ needs.build.outputs.SDL_NET_COMMIT }})' >>notes.txt
echo '[SDL2_compat commit](https://github.com/libsdl-org/sdl2-compat/commit/${{ needs.build.outputs.SDL2_COMPAT_COMMIT }})' >>notes.txt
echo '[SDL commit](https://github.com/libsdl-org/SDL/commit/${{ needs.build.outputs.SDL_COMMIT }})' >>notes.txt
echo '[SDL_image commit](https://github.com/libsdl-org/SDL_image/commit/${{ needs.build.outputs.SDL_IMAGE_COMMIT }})' >>notes.txt
echo '[SDL_mixer commit](https://github.com/libsdl-org/SDL_mixer/commit/${{ needs.build.outputs.SDL_MIXER_COMMIT }})' >>notes.txt
echo '[SDL_ttf commit](https://github.com/libsdl-org/SDL_ttf/commit/${{ needs.build.outputs.SDL_TTF_COMMIT }})' >>notes.txt
echo '[SDL_rtf commit](https://github.com/libsdl-org/SDL_rtf/commit/${{ needs.build.outputs.SDL_RTF_COMMIT }})' >>notes.txt
echo '[SDL_net commit](https://github.com/libsdl-org/SDL_net/commit/${{ needs.build.outputs.SDL_NET_COMMIT }})' >>notes.txt
echo '[SDL_shadercross commit](https://github.com/libsdl-org/SDL_shadercross/commit/${{ needs.build.outputs.SDL_SHADERCROSS_COMMIT }})' >>notes.txt
echo '[SDL2_compat commit](https://github.com/libsdl-org/sdl2-compat/commit/${{ needs.build.outputs.SDL2_COMPAT_COMMIT }})' >>notes.txt
gh release create ${{ needs.build.outputs.OUTPUT_DATE }} -R "${GITHUB_REPOSITORY}" -t '${{ needs.build.outputs.OUTPUT_DATE }}' -F notes.txt
- name: get artifacts
Expand Down
85 changes: 69 additions & 16 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,19 @@ call :get "https://skia.googlesource.com/skcms/+archive/%SKCMS_COMMIT%.tar.gz" s
move %SOURCE%\google-brotli-%BROTLI_COMMIT% %SOURCE%\libjxl-%LIBJXL_VERSION%\third_party\brotli 1>nul 2>nul
move %SOURCE%\google-highway-%HIGHWAY_COMMIT% %SOURCE%\libjxl-%LIBJXL_VERSION%\third_party\highway 1>nul 2>nul

call :clone SDL "https://github.com/libsdl-org/SDL" main || exit /b 1
call :clone SDL_image "https://github.com/libsdl-org/SDL_image" main || exit /b 1
call :clone SDL_mixer "https://github.com/libsdl-org/SDL_mixer" main || exit /b 1
call :clone SDL_ttf "https://github.com/libsdl-org/SDL_ttf" main || exit /b 1
call :clone SDL_rtf "https://github.com/libsdl-org/SDL_rtf" main || exit /b 1
call :clone SDL_net "https://github.com/libsdl-org/SDL_net" main || exit /b 1
call :clone SDL2_compat "https://github.com/libsdl-org/sdl2-compat" main || exit /b 1
call :clone SDL "https://github.com/libsdl-org/SDL" main || exit /b 1
call :clone SDL_image "https://github.com/libsdl-org/SDL_image" main || exit /b 1
call :clone SDL_mixer "https://github.com/libsdl-org/SDL_mixer" main || exit /b 1
call :clone SDL_ttf "https://github.com/libsdl-org/SDL_ttf" main || exit /b 1
call :clone SDL_rtf "https://github.com/libsdl-org/SDL_rtf" main || exit /b 1
call :clone SDL_net "https://github.com/libsdl-org/SDL_net" main || exit /b 1
call :clone SDL_shadercross "https://github.com/libsdl-org/SDL_shadercross" main || exit /b 1
call :clone SDL2_compat "https://github.com/libsdl-org/sdl2-compat" main || exit /b 1

echo Updating SDL_shadercross submodules
call git -C source\SDL_shadercross submodule update --init --recursive --quiet || exit /b 1
call git -C source\SDL_shadercross submodule foreach git reset --quiet --hard HEAD || exit /b 1
call git apply -p1 --directory=source/SDL_shadercross/external/DirectXShaderCompiler dxc.patch || exit /b 1

pushd %SOURCE%\libyuv-%LIBYUV_VERSION%
echo CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) > "CMakeLists.txt.correct"
Expand All @@ -261,6 +267,8 @@ rem
rem MSVC Environment
rem

set OLD_PATH=%PATH%

where /Q cl.exe || (
for /f "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i
if "!VS!" equ "" (
Expand Down Expand Up @@ -288,7 +296,7 @@ if "%TARGET_ARCH%" equ "arm64" (
-DCMAKE_SYSTEM_NAME=Windows ^
-DCMAKE_SYSTEM_PROCESSOR=arm64

where clang-cl.exe || (
where /q clang-cl.exe || (
echo ERROR: "clang-cl.exe" not found, required to build "dav1d" and "libjxl" with neon intrinsic optimizations
exit /b 1
)
Expand Down Expand Up @@ -1039,6 +1047,48 @@ ninja.exe -C %BUILD%\SDL_net install || exit /b 1

set CL=

rem
rem SDL_shadercross
rem

if "%HOST_ARCH%" neq "%TARGET_ARCH%" (
set PATH=!OLD_PATH!
call "!VS!\Common7\Tools\VsDevCmd.bat" -arch=!HOST_ARCH! -host_arch=!HOST_ARCH! -startdir=none -no_logo || exit /b 1

cmake.exe ^
-G Ninja ^
-S %SOURCE%\SDL_shadercross\external\DirectXShaderCompiler ^
-B %BUILD%\SDL_shadercross\external\DirectXShaderCompiler-native ^
-D CMAKE_BUILD_TYPE=Release ^
-D BUILD_SHARED_LIBS=OFF ^
-D LLVM_TARGETS_TO_BUILD=None ^
-D LLVM_ENABLE_WARNINGS=OFF ^
-D LLVM_ENABLE_EH=ON ^
-D LLVM_ENABLE_RTTI=ON ^
|| exit /b 1
ninja.exe -C %BUILD%\SDL_shadercross\external\DirectXShaderCompiler-native llvm-tblgen clang-tblgen || exit /b 1

set PATH=!OLD_PATH!
call "!VS!\Common7\Tools\VsDevCmd.bat" -arch=!TARGET_ARCH! -host_arch=!HOST_ARCH! -startdir=none -no_logo || exit /b 1
set PATH=%BUILD%\SDL_shadercross\external\DirectXShaderCompiler-native\bin;!PATH!
)

cmake.exe %CMAKE_COMMON_ARGS% ^
-S %SOURCE%\SDL_shadercross ^
-B %BUILD%\SDL_shadercross ^
-D CMAKE_INSTALL_PREFIX=%OUTPUT% ^
-D CMAKE_PREFIX_PATH=%DEPEND% ^
-D SDL3_ROOT=%OUTPUT% ^
-D SDLSHADERCROSS_CLI=ON ^
-D SDLSHADERCROSS_VENDORED=ON ^
-D SDLSHADERCROSS_SHARED=ON ^
-D SDLSHADERCROSS_STATIC=OFF ^
-D SDLSHADERCROSS_SPIRVCROSS_SHARED=OFF ^
-D SDLSHADERCROSS_INSTALL=ON ^
-D SDLSHADERCROSS_INSTALL_CPACK=OFF ^
|| exit /b 1
ninja.exe -C %BUILD%\SDL_shadercross install || exit /b 1

rem
rem SDL2_compat
rem
Expand Down Expand Up @@ -1072,17 +1122,19 @@ set /p SDL_MIXER_COMMIT=<%SOURCE%\SDL_mixer\.git\refs\heads\main
set /p SDL_TTF_COMMIT=<%SOURCE%\SDL_ttf\.git\refs\heads\main
set /p SDL_RTF_COMMIT=<%SOURCE%\SDL_rtf\.git\refs\heads\main
set /p SDL_NET_COMMIT=<%SOURCE%\SDL_net\.git\refs\heads\main
set /p SDL_SHADERCROSS_COMMIT=<%SOURCE%\SDL_shadercross\.git\refs\heads\main
set /p SDL2_COMPAT_COMMIT=<%SOURCE%\SDL2_compat\.git\refs\heads\main

echo SDL %SDL_COMMIT% > %OUTPUT%\commits.txt
echo SDL_image %SDL_IMAGE_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_mixer %SDL_MIXER_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_ttf %SDL_TTF_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_rtf %SDL_RTF_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_net %SDL_NET_COMMIT% >> %OUTPUT%\commits.txt
echo SDL2_compat %SDL2_COMPAT_COMMIT% >> %OUTPUT%\commits.txt
echo SDL %SDL_COMMIT% > %OUTPUT%\commits.txt
echo SDL_image %SDL_IMAGE_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_mixer %SDL_MIXER_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_ttf %SDL_TTF_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_rtf %SDL_RTF_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_net %SDL_NET_COMMIT% >> %OUTPUT%\commits.txt
echo SDL_shadercross %SDL_SHADERCROSS_COMMIT% >> %OUTPUT%\commits.txt
echo SDL2_compat %SDL2_COMPAT_COMMIT% >> %OUTPUT%\commits.txt

for %%F in (SDL3_mixer SDL3_image SDL3_mixer SDL3_net SDL3_rtf SDL3_ttf) do (
for %%F in (SDL3_mixer SDL3_image SDL3_mixer SDL3_net SDL3_rtf SDL3_ttf SDL3_shadercross) do (
move %OUTPUT%\include\%%F\*.h %OUTPUT%\include\SDL3\ 1>nul 2>nul
rd /s /q %OUTPUT%\include\%%F 1>nul 2>nul
)
Expand Down Expand Up @@ -1112,6 +1164,7 @@ if "%GITHUB_WORKFLOW%" neq "" (
echo SDL_TTF_COMMIT=%SDL_TTF_COMMIT%>>%GITHUB_OUTPUT%
echo SDL_RTF_COMMIT=%SDL_RTF_COMMIT%>>%GITHUB_OUTPUT%
echo SDL_NET_COMMIT=%SDL_NET_COMMIT%>>%GITHUB_OUTPUT%
echo SDL_SHADERCROSS_COMMIT=%SDL_SHADERCROSS_COMMIT%>>%GITHUB_OUTPUT%
echo SDL2_COMPAT_COMMIT=%SDL2_COMPAT_COMMIT%>>%GITHUB_OUTPUT%
)

Expand Down
58 changes: 58 additions & 0 deletions dxc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f7db9978..db538e1fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -633,11 +633,6 @@ include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})

include_directories( ${LLVM_INCLUDE_DIR}/dxc/Tracing) # HLSL Change

-# when crosscompiling import the executable targets from a file
-if(LLVM_USE_HOST_TOOLS)
- include(CrossCompile)
-endif(LLVM_USE_HOST_TOOLS)
-
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
# On FreeBSD, /usr/local/* is not used by default. In order to build LLVM
# with libxml2, iconv.h, etc., we must add /usr/local paths.
diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake
index 85d720e91..579061e0c 100644
--- a/cmake/modules/TableGen.cmake
+++ b/cmake/modules/TableGen.cmake
@@ -92,25 +92,6 @@ macro(add_tablegen target project)
set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE)
set(${project}_TABLEGEN_TARGET ${${project}_TABLEGEN} PARENT_SCOPE)

- if(LLVM_USE_HOST_TOOLS)
- if( ${${project}_TABLEGEN} STREQUAL "${target}" )
- if (NOT CMAKE_CONFIGURATION_TYPES)
- set(${project}_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/bin/${target}")
- else()
- set(${project}_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/Release/bin/${target}")
- endif()
- set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN_EXE} PARENT_SCOPE)
-
- add_custom_command(OUTPUT ${${project}_TABLEGEN_EXE}
- COMMAND ${CMAKE_COMMAND} --build . --target ${target} --config Release
- DEPENDS CONFIGURE_LLVM_NATIVE ${target}
- WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
- COMMENT "Building native TableGen...")
- add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE})
- set(${project}_TABLEGEN_TARGET ${project}-tablegen-host PARENT_SCOPE)
- endif()
- endif()
-
if( MINGW )
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
set_target_properties(${target} PROPERTIES LINK_FLAGS -Wl,--stack,16777216)
diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt
index edbd8c950..c7ee5f107 100644
--- a/tools/llvm-config/CMakeLists.txt
+++ b/tools/llvm-config/CMakeLists.txt
@@ -47,7 +47,6 @@ if(CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
COMMENT "Building native llvm-config...")
add_custom_target(${project}NativeLLVMConfig DEPENDS ${${project}_LLVM_CONFIG_EXE})
- add_dependencies(${project}NativeLLVMConfig CONFIGURE_LLVM_NATIVE)

add_dependencies(llvm-config ${project}NativeLLVMConfig)
endif(CMAKE_CROSSCOMPILING)

0 comments on commit 8f7ebc5

Please sign in to comment.