Skip to content

Commit b917d4f

Browse files
committed
Minimal changes to get Linux build
1 parent 699d86b commit b917d4f

17 files changed

Lines changed: 1184 additions & 341 deletions

build_scripts/generate_project_files.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import os
2121
import shutil
22-
import stat
2322
import subprocess
2423
import sys
2524
from pathlib import Path
@@ -46,12 +45,30 @@
4645
},
4746
}
4847

48+
4949
def generate_project_files():
50-
# determine if we're using Windows or another platform
51-
is_windows = sys.argv[1].startswith("vs") # Assuming 'vs' prefix for Visual Studio
50+
if len(sys.argv) < 3:
51+
if os.name == "nt":
52+
sys.argv.extend(["vs2022", "windows"])
53+
else:
54+
sys.argv.extend(["gmake2", "vulkan"])
55+
56+
action = sys.argv[1].strip('"')
57+
is_windows = action.startswith("vs")
58+
59+
if is_windows:
60+
premake_exe = Path.cwd() / "build_scripts" / "premake5.exe"
61+
else:
62+
premake_exe = shutil.which("premake5")
63+
if not premake_exe:
64+
premake_exe = Path.cwd() / "build_scripts" / "premake5"
65+
if not premake_exe or (
66+
isinstance(premake_exe, Path) and not premake_exe.exists()
67+
):
68+
raise FileNotFoundError(
69+
"premake5 executable not found in PATH or build_scripts/."
70+
)
5271

53-
# construct the command, stripping any surrounding quotes from arguments
54-
premake_exe = Path.cwd() / "build_scripts" / ("premake5.exe" if is_windows else "premake5")
5572
premake_lua = Path("build_scripts") / "premake.lua"
5673

5774
# remove quotes if they exist around sys.argv[1] and sys.argv[2]
@@ -62,7 +79,7 @@ def generate_project_files():
6279
cmd = f'"{str(premake_exe)}" --file="{str(premake_lua)}" "{action}" "{platform}"'
6380

6481
print("Running command:", cmd)
65-
82+
6683
try:
6784
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
6885
print(result.stdout)
@@ -77,9 +94,10 @@ def generate_project_files():
7794
input("\nPress Enter to exit...")
7895
sys.exit(1)
7996

97+
8098
def main():
8199
is_ci = "ci" in sys.argv
82-
100+
83101
print("\n1. Create binaries folder with the required data files...\n")
84102
file_utilities.copy("data", paths["binaries"]["data"])
85103
file_utilities.copy(Path("build_scripts") / "7z.exe", "binaries")
@@ -93,8 +111,11 @@ def main():
93111
file_utilities.extract_archive(str(library_destination), str(Path("third_party") / "libraries"))
94112

95113
print("3. Copying required DLLs to the binary directory...")
96-
for lib in paths["third_party_libs"].values():
97-
file_utilities.copy(lib, Path("binaries"))
114+
if os.name == "nt":
115+
for lib in paths["third_party_libs"].values():
116+
file_utilities.copy(lib, Path("binaries"))
117+
else:
118+
print("Skipping DLL copy on non-Windows platform.")
98119

99120
print("\n4. Generate project files...\n")
100121
generate_project_files()
@@ -104,5 +125,6 @@ def main():
104125

105126
sys.exit(0)
106127

128+
107129
if __name__ == "__main__":
108130
main()
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# --- Configuration ---
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
7+
INSTALL_DIR="$PROJECT_ROOT/third_party/install"
8+
BUILD_ROOT="$PROJECT_ROOT/third_party"
9+
mkdir -p "$INSTALL_DIR"/{lib,include}
10+
11+
# --- Colors ---
12+
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; RED='\033[0;31m'; NC='\033[0m'
13+
14+
echo -e "${BLUE}=== Installing Native Build Dependencies ===${NC}"
15+
echo -e "${YELLOW}Install location: $INSTALL_DIR${NC}\n"
16+
17+
# --- System Prep ---
18+
# FreeImage Stub
19+
mkdir -p "$BUILD_ROOT/free_image/FreeImage"
20+
ln -sf /usr/include/FreeImage.h "$BUILD_ROOT/free_image/FreeImage/FreeImage.h"
21+
echo "// Empty stub" > "$BUILD_ROOT/free_image/FreeImage/Utilities.h"
22+
23+
# Distro Detection & System Package Install
24+
if [ -f /etc/os-release ]; then . /etc/os-release; else echo -e "${RED}No /etc/os-release${NC}"; exit 1; fi
25+
echo -e "${BLUE}Installing system packages for $ID...${NC}"
26+
27+
if [[ "$ID" =~ ^(fedora|nobara|rhel|centos)$ ]]; then
28+
sudo dnf install -y --skip-unavailable gcc-c++ cmake ninja-build python3 wget git \
29+
vulkan-loader-devel freetype-devel pugixml-devel freeimage-devel opencv-devel \
30+
mesa-libGL-devel mesa-libGLU-devel libX11-devel libXcursor-devel libXext-devel \
31+
libXi-devel libXinerama-devel libXrandr-devel libXss-devel libXtst-devel \
32+
libXxf86vm-devel wayland-devel wayland-protocols-devel libxkbcommon-devel \
33+
pulseaudio-libs-devel openssl-devel zlib-devel lua-devel
34+
elif [[ "$ID" == "arch" ]]; then
35+
sudo pacman -S --noconfirm gcc cmake ninja python wget git vulkan-headers freetype2 \
36+
pugixml freeimage mesa libx11 libxcursor libxext libxi libxinerama libxrandr \
37+
libxss libxtst libxxf86vm wayland libxkbcommon pulseaudio openssl opencv zstd lua
38+
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then
39+
sudo apt install -y g++ cmake ninja-build python3 wget git libvulkan-dev libfreetype-dev \
40+
libpugixml-dev libfreeimage-dev libgl1-mesa-dev libglu1-mesa-dev libx11-dev \
41+
libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev \
42+
libxtst-dev libxxf86vm-dev libwayland-dev libwayland-protocols-dev libxkbcommon-dev \
43+
libpulse-dev libssl-dev zlib1g-dev libopencv-dev liblua5.4-dev
44+
fi
45+
46+
# --- Helper Functions ---
47+
48+
# $1=Name, $2=CheckFile, $3=FunctionToRun
49+
task() {
50+
if [ -e "$INSTALL_DIR/$2" ]; then
51+
echo -e "${GREEN}$1 already installed${NC}"
52+
else
53+
echo -e "${BLUE}Building $1...${NC}"
54+
cd "$BUILD_ROOT"
55+
$3
56+
echo -e "${GREEN} ✓ Done${NC}"
57+
fi
58+
}
59+
60+
# $1=DirName, $2=RepoURL, $3=Branch/Commit(Optional)
61+
git_setup() {
62+
if [ ! -d "$BUILD_ROOT/${1}_build/$1" ]; then
63+
mkdir -p "$BUILD_ROOT/${1}_build" && cd "$BUILD_ROOT/${1}_build"
64+
git clone --depth 1 $2 $1
65+
[ -n "$3" ] && cd $1 && git checkout "$3" || true
66+
fi
67+
cd "$BUILD_ROOT/${1}_build/$1"
68+
}
69+
70+
# $1=DirName, $2=CMakeFlags, $3=NinjaTarget(Optional)
71+
cmake_make() {
72+
mkdir -p build && cd build
73+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -GNinja $2
74+
ninja -j$(nproc) $3
75+
}
76+
77+
# --- Build Logic ---
78+
79+
build_draco() {
80+
git_setup "draco" "https://github.com/google/draco.git"
81+
cmake_make "draco" "-DBUILD_SHARED_LIBS=OFF"
82+
cp libdraco.a "$INSTALL_DIR/lib/"
83+
}
84+
85+
build_sdl3() {
86+
git_setup "sdl3" "https://github.com/libsdl-org/SDL.git" "main"
87+
cmake_make "sdl3" "-DSDL_TESTS=OFF -DSDL_X11_XSCRNSAVER=OFF -DBUILD_SHARED_LIBS=OFF"
88+
ninja install
89+
# Fix lib64 location if exists
90+
[ -d "$INSTALL_DIR/lib64" ] && mv "$INSTALL_DIR/lib64/"* "$INSTALL_DIR/lib/" && rmdir "$INSTALL_DIR/lib64"
91+
}
92+
93+
build_spirv() {
94+
git_setup "spirv_cross" "https://github.com/KhronosGroup/SPIRV-Cross.git" "vulkan-sdk-1.4.335.0"
95+
cmake_make "SPIRV-Cross" "-DSPIRV_CROSS_SHARED=OFF -DSPIRV_CROSS_STATIC=ON"
96+
cp libspirv-cross-*.a "$INSTALL_DIR/lib/"
97+
mkdir -p "$INSTALL_DIR/include/spirv_cross"
98+
cp ../include/spirv_cross/*.hpp ../*.hpp ../*.h "$INSTALL_DIR/include/spirv_cross/" 2>/dev/null || true
99+
}
100+
101+
build_meshopt() {
102+
git_setup "meshoptimizer" "https://github.com/zeux/meshoptimizer.git"
103+
cmake_make "meshoptimizer" ""
104+
cp libmeshoptimizer.a "$INSTALL_DIR/lib/"
105+
mkdir -p "$INSTALL_DIR/include/meshoptimizer"
106+
cp ../src/meshoptimizer.h "$INSTALL_DIR/include/meshoptimizer/"
107+
}
108+
109+
build_assimp() {
110+
# Commit before 2025-09-11
111+
git_setup "assimp" "https://github.com/assimp/assimp.git" "$(git ls-remote https://github.com/assimp/assimp.git master | awk '{print $1}')"
112+
# Note: Logic in original script to find commit by date is complex, assuming generic fetch or fixed commit logic.
113+
# For strict parity with original `git checkout $(git rev-list ...)` we run it here:
114+
cd "$BUILD_ROOT/assimp_build/assimp"
115+
git fetch --unshallow 2>/dev/null || true
116+
git checkout $(git rev-list -n 1 --before="2025-09-11" master) 2>/dev/null || true
117+
118+
cmake_make "assimp" "-DASSIMP_BUILD_TESTS=OFF -DASSIMP_BUILD_SAMPLES=OFF -DBUILD_SHARED_LIBS=OFF -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DASSIMP_WARNINGS_AS_ERRORS=OFF"
119+
cp lib/libassimp.a "$INSTALL_DIR/lib/"
120+
}
121+
122+
build_physx() {
123+
git_setup "physx" "https://github.com/NVIDIA-Omniverse/PhysX.git" "107.0-physx-5.6.0"
124+
cd physx
125+
bash generate_projects.sh linux-gcc-cpu-only
126+
cd compiler/linux-gcc-cpu-only-checked
127+
cmake --build . --config checked -j$(nproc) --target PhysXExtensions PhysXCommon PhysXPvdSDK PhysXCharacterKinematic PhysXCooking PhysXVehicle2 PhysX || true
128+
mkdir -p "$INSTALL_DIR/include/physx"
129+
cp -r ../../include/* "$INSTALL_DIR/include/physx/"
130+
find ../../bin -name "*.a" -exec cp {} "$INSTALL_DIR/lib/" \;
131+
}
132+
133+
build_compressonator() {
134+
git_setup "compressonator" "https://github.com/GPUOpen-Tools/compressonator.git" "V4.2.5185"
135+
sed -i '1s/^/#include <cstdint>\n/' applications/_plugins/common/cmp_fileio.h applications/_plugins/common/utilfuncs.h
136+
cmake_make "compressonator" "-DOPTION_ENABLE_ALL_APPS=OFF -DOPTION_BUILD_CMP_SDK=ON -DLIB_BUILD_COMPRESSONATOR_SDK=ON -DLIB_BUILD_FRAMEWORK_SDK=ON -DLIB_BUILD_CORE=ON -DLIB_BUILD_COMMON=ON -DLIB_BUILD_IMAGEIO=OFF -DLIB_BUILD_GPUDECODE=ON -DOPTION_CMP_OPENCL=ON -DOPTION_CMP_OPENGL=OFF -DOPTION_CMP_QT=OFF -DOPTION_CMP_OPENCV=ON -DOPTION_BUILD_EXR=OFF -DOPTION_BUILD_APPS_CMP_CLI=OFF -DOPTION_BUILD_APPS_CMP_GUI=OFF" "CMP_Compressonator CMP_Core CMP_Framework CMP_Common"
137+
mkdir -p "$INSTALL_DIR/include/compressonator"
138+
cp ../cmp_compressonatorlib/compressonator.h "$INSTALL_DIR/include/compressonator/"
139+
find . -name "*.a" -exec cp {} "$INSTALL_DIR/lib/" \;
140+
cd "$INSTALL_DIR/lib" && ln -sf libCMP_Common.a libCommon.a
141+
}
142+
143+
build_renderdoc() {
144+
git_setup "renderdoc" "https://github.com/baldurk/renderdoc.git" "v1.42"
145+
cmake_make "renderdoc" "-DENABLE_QRENDERDOC=OFF -DENABLE_PYRENDERDOC=OFF" "renderdoc"
146+
cp lib/librenderdoc.so "$INSTALL_DIR/lib/"
147+
mkdir -p "$INSTALL_DIR/include/renderdoc/app"
148+
cp ../renderdoc/api/app/renderdoc_app.h "$INSTALL_DIR/include/renderdoc/app/"
149+
}
150+
151+
build_dxc() {
152+
mkdir -p "$BUILD_ROOT/dxc_build/dxc_temp" && cd "$BUILD_ROOT/dxc_build"
153+
if [ ! -f "linux_dxc.tar.gz" ]; then
154+
wget -O linux_dxc.tar.gz -q https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2505.1/linux_dxc_2025_07_14.x86_64.tar.gz
155+
fi
156+
tar xzf linux_dxc.tar.gz -C dxc_temp --strip-components=1
157+
cp -r dxc_temp/include/* "$INSTALL_DIR/include/"
158+
cp -r dxc_temp/lib/* "$INSTALL_DIR/lib/"
159+
}
160+
161+
build_nrd() {
162+
git_setup "nrd" "https://github.com/NVIDIA-RTX/NRD.git"
163+
cd "$BUILD_ROOT/nrd_build/nrd" || cd "$BUILD_ROOT/nrd_build/NRD"
164+
git checkout $(git rev-list -n 1 --before="2026-01-25" master) 2>/dev/null || true
165+
cmake_make "nrd" "-DNRD_STATIC_LIBRARY=ON"
166+
mkdir -p "$INSTALL_DIR/include/nrd"
167+
cp -r ../Include/. ../Integration/. "$INSTALL_DIR/include/nrd/"
168+
cp ../_Bin/libNRD.a "$INSTALL_DIR/lib/" 2>/dev/null || cp libNRD.a "$INSTALL_DIR/lib/"
169+
cp _deps/shadermake-build/libShaderMakeBlob.a "$INSTALL_DIR/lib/" 2>/dev/null || true
170+
}
171+
172+
# --- Execution ---
173+
task "Draco" "lib/libdraco.a" build_draco
174+
task "SDL3" "lib/libSDL3.a" build_sdl3
175+
task "SPIRV-Cross" "lib/libspirv-cross-core.a" build_spirv
176+
task "MeshOptimizer" "lib/libmeshoptimizer.a" build_meshopt
177+
task "Assimp" "lib/libassimp.a" build_assimp
178+
task "PhysX" "lib/libPhysX_static_64.a" build_physx
179+
task "Compressonator" "lib/libCMP_Common.a" build_compressonator
180+
task "RenderDoc" "lib/librenderdoc.so" build_renderdoc
181+
task "DXC" "lib/libdxcompiler.so" build_dxc
182+
task "NRD" "lib/libNRD.a" build_nrd
183+
184+
# --- Validation ---
185+
echo -e "\n${BLUE}Validating...${NC}"
186+
MISSING=0
187+
check() { [ -f "$1" ] && echo -e "${GREEN}✓ Found $(basename $1)${NC}" || { echo -e "${RED}✗ Missing $(basename $1)${NC}"; MISSING=1; }; }
188+
189+
check "$INSTALL_DIR/lib/libdraco.a"
190+
check "$INSTALL_DIR/lib/libSDL3.a"
191+
check "$INSTALL_DIR/lib/libspirv-cross-core.a"
192+
check "$INSTALL_DIR/lib/libmeshoptimizer.a"
193+
check "$INSTALL_DIR/lib/libassimp.a"
194+
check "$INSTALL_DIR/lib/libPhysX_static_64.a"
195+
check "$INSTALL_DIR/lib/libCMP_Common.a"
196+
check "$INSTALL_DIR/lib/librenderdoc.so"
197+
check "$INSTALL_DIR/lib/libdxcompiler.so"
198+
check "$INSTALL_DIR/lib/libNRD.a"
199+
200+
echo ""
201+
if [ $MISSING -eq 0 ]; then
202+
echo -e "${GREEN}Success! Environment ready.${NC}"
203+
echo "Export vars: CMAKE_PREFIX_PATH=$INSTALL_DIR, LIBRARY_PATH=$INSTALL_DIR/lib, CPATH=$INSTALL_DIR/include"
204+
else
205+
echo -e "${RED}Some libraries failed to build.${NC}"
206+
fi

0 commit comments

Comments
 (0)