Browse Source

build.sh: build SDL3 with CMake (#2060)

* build.sh: support building SDL3 with cmake

* ci: install cmake

* ci: make msvc use bash to build again

* ci: use get-command to get link.exe

* build.sh: revert back to CMAKE_INSTALL_PREFIX

* ci: hardcode CMAKE_INSTALL_LIBDIR

* ci: set cc_ld to not step on cmake

* build.sh: less messing with cwd

* build.sh: fix prefix once and for all

* ci: skip installing cmake on macos to avoid warnings

* build.sh: pass MACOSX_DEPLOYMENT_TARGET to cmake

* build.sh: remove extra .. in configure command

* build.sh: remove unused variable

* build.sh: allow SIMD runtime detection

* build.sh: propagate LTO to SDL3
pull/2082/head
Takase 2 months ago
committed by GitHub
parent
commit
ee7f3383a0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 21
      .github/workflows/build.yml
  2. 39
      scripts/build.sh

21
.github/workflows/build.yml

@ -99,7 +99,7 @@ jobs:
- name: Install Dependencies
run: |
brew install bash sdl3
brew install bash
pip3 install meson ninja
- name: Build & Package Mac (Bundle)
@ -221,10 +221,10 @@ jobs:
pacboy: >-
gcc:p
meson:p
ca-certificates:p
cmake:p
ninja:p
pkg-config:p
sdl3:p
ca-certificates:p
- uses: actions/checkout@v4
@ -254,6 +254,7 @@ jobs:
- uses: actions/checkout@v4
- name: Setup MSVC
id: msvc-dev-cmd
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86_64
@ -272,20 +273,18 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install SDL
- name: Install pkgconf
env: { VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" }
run: vcpkg install sdl3:x64-windows-static pkgconf:x64-windows-release
run: vcpkg install pkgconf:x64-windows-release
- name: Add environment variables
# https://github.com/ilammy/msvc-dev-cmd?tab=readme-ov-file#name-conflicts-with-shell-bash
- name: Set environment variables
run: |
echo "PKG_CONFIG_PATH=C:\vcpkg\installed\x64-windows-static\lib\pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "PKG_CONFIG=C:\vcpkg\installed\x64-windows-release\tools\pkgconf\pkgconf.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Configure
run: meson setup --wrap-mode=forcefallback --buildtype=${{ needs.version.outputs.buildtype }} build
echo "CC_LD=$((Get-Command link.exe).Source)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Build
run: meson install -C build --skip-subprojects --destdir="lite-xl"
run: bash scripts/build.sh --addons --debug --forcefallback --lto --portable --mode ${{ needs.version.outputs.buildtype }} -b build
- name: Package
run: cd build && 7z a -mx=9 "..\lite-xl-${{ needs.version.outputs.ref }}-x86_64-windows.zip" lite-xl && cd ..

39
scripts/build.sh

@ -52,6 +52,9 @@ main() {
local plugins="-Dbundle_plugins="
local prefix=/
local build_type="release"
local sdl3_version="${SDL3_VERSION:-3.2.8}"
local pkg_config_path
local cmake_build_type
local force_fallback
local bundle="-Dbundle=false"
local portable="-Dportable=false"
@ -191,10 +194,10 @@ main() {
arch="${cross_arch:-$arch}"
cross_file="--cross-file ${cross_file:-resources/cross/$platform-$arch.txt}"
# reload build_dir because platform and arch might change
if [[ "$build_dir" == "" ]]; then
if [[ "${build_dir}" == "" ]]; then
build_dir="$(get_default_build_dir "$platform" "$arch")"
fi
elif [[ "$build_dir" == "" ]]; then
elif [[ "${build_dir}" == "" ]]; then
build_dir="$(get_default_build_dir)"
fi
@ -217,9 +220,36 @@ main() {
rm -rf "${build_dir}"
fi
mkdir -p "${build_dir}"
if [[ -n "$force_fallback" ]]; then
# download, build and add SDL3 to the pkgconfig search path
pushd "${build_dir}"
[[ ! -f "SDL3-$sdl3_version.tar.gz" ]] && curl --insecure -L -o "SDL3-$sdl3_version.tar.gz" \
"https://github.com/libsdl-org/SDL/releases/download/release-$sdl3_version/SDL3-$sdl3_version.tar.gz"
[[ ! -f "SDL3-$sdl3_version/CMakeLists.txt" ]] && tar -xzf "SDL3-$sdl3_version.tar.gz"
case "$build_type" in
"release"|"debug") cmake_build_type="$build_type";;
"debugoptimized") cmake_build_type="RelWithDebInfo";;
"minsize") cmake_build_type="MinSizeRel";;
*) cmake_build_type="Release";;
esac
# use -DCMAKE_INSTALL_LIBDIR to work around possibility of cmake using lib64 instead of lib
cmake -S "SDL3-$sdl3_version" -B "SDL3-$sdl3_version/build" -GNinja \
-DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOSX_DEPLOYMENT_TARGET" -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=$([[ -n $lto ]] && echo ON || echo OFF) \
-DCMAKE_BUILD_TYPE=$cmake_build_type -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX="$(pwd -P)/prefix" \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSDL_INSTALL=ON -DSDL_INSTALL_DOCS=OFF -DSDL_DEPS_SHARED=ON \
-DSDL_DBUS=ON -DSDL_IBUS=ON -DSDL_AUDIO=OFF -DSDL_GPU=OFF -DSDL_RPATH=OFF -DSDL_PIPEWIRE=OFF \
-DSDL_CAMERA=OFF -DSDL_JOYSTICK=OFF -DSDL_HAPTIC=OFF -DSDL_HIDAPI=OFF -DSDL_DIALOG=OFF \
-DSDL_POWER=OFF -DSDL_SENSOR=OFF -DSDL_VULKAN=OFF -DSDL_LIBUDEV=OFF -DSDL_SHARED=OFF -DSDL_STATIC=ON \
-DSDL_X11=ON -DSDL_WAYLAND=ON -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF -DSDL_VENDOR_INFO=lite-xl
cmake --build "SDL3-$sdl3_version/build" && cmake --install "SDL3-$sdl3_version/build"
pkg_config_path="--pkg-config-path=$(pwd -P)/prefix/lib/pkgconfig"
popd
fi
if [[ -n "$plugins" ]] && [[ -z `command -v lpm` ]]; then
mkdir -p "${build_dir}"
lpm_path="$(pwd)/${build_dir}/lpm$(get_executable_extension)"
lpm_path="$(pwd -P)/${build_dir}/lpm$(get_executable_extension)"
if [[ ! -e "$lpm_path" ]]; then
curl --insecure -L -o "$lpm_path" \
"https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/${LPM_VERSION:-latest}/lpm.$(get_platform_tuple)$(get_executable_extension)"
@ -240,7 +270,8 @@ main() {
$lto \
$lto_mode \
$plugins \
$reconfigure
$reconfigure \
$pkg_config_path
meson compile -C "${build_dir}"

Loading…
Cancel
Save