Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build Test

on: [push, pull_request]

Expand All @@ -10,9 +10,9 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-26.04, windows-latest, macOS-latest]
include:
- os: ubuntu-latest
- os: ubuntu-26.04
cmake-args: -G Ninja
package-file: "*-linux_x86_64.tar.xz"
archtitecture: "x86_64"
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
toolchain:p
cmake:p
ninja:p
zlib:p
zlib-ng:p
sdl3:p
freetype:p
opus:p
Expand All @@ -65,30 +65,29 @@ jobs:
curl:p
libspng:p

- name: Checkout SDL3
- name: Checkout zlib-ng
if: contains(matrix.os, 'ubuntu')
uses: actions/checkout@v4
with:
repository: libsdl-org/SDL
ref: release-3.2.28
path: ./SDL
repository: zlib-ng/zlib-ng
ref: 2.3.3
path: ./zlib-ng

- name: Prepare Linux
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y
sudo apt-get install pkg-config ninja-build libfreetype6-dev libopus-dev libopusfile-dev libspng-dev libcurl4-openssl-dev libgl1-mesa-dev -y
sudo apt-get install build-essential git cmake libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev libdbus-1-dev libudev-dev libinput-dev libts-dev libjpeg-dev libwebp-dev -y
cd SDL
cmake . -DCMAKE_BUILD_TYPE=Release -DSDL_TEST=OFF -DSDL_STATIC=OFF
sudo apt install build-essential cmake git libgl1-mesa-dev libfreetype6-dev libsdl3-dev libspng-dev libopus-dev libopusfile-dev python3 libcurl4-openssl-dev -y
cd zlib-ng
cmake . -DCMAKE_BUILD_TYPE=Release
sudo make install
sudo ldconfig

- name: Prepare MacOS
if: contains(matrix.os, 'macOS')
run: |
brew update || true
brew install pkg-config sdl3 python3 ninja opus opusfile openssl curl libspng || true
brew install pkg-config sdl3 python3 ninja opus opusfile openssl curl libspng zlib-ng || true
brew upgrade freetype
sudo rm -rf /Library/Developer/CommandLineTools

Expand Down Expand Up @@ -160,9 +159,9 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-26.04, windows-latest, macOS-latest]
include:
- os: ubuntu-latest
- os: ubuntu-26.04
archtitecture: "x86_64"
shell: "bash"
- os: windows-latest
Expand All @@ -187,14 +186,6 @@ jobs:
ref: a44a2c7dc16caae7ac457f17dfd14a87e7059c57
path: ./bam

- name: Checkout SDL3
if: contains(matrix.os, 'ubuntu')
uses: actions/checkout@v4
with:
repository: libsdl-org/SDL
ref: release-3.2.28
path: ./SDL

- name: Prepare MSYS2 (Windows)
if: contains(matrix.os, 'windows')
uses: msys2/setup-msys2@v2
Expand All @@ -205,7 +196,7 @@ jobs:
toolchain:p
cmake:p
ninja:p
zlib:p
zlib-ng:p
sdl3:p
freetype:p
opus:p
Expand All @@ -214,17 +205,25 @@ jobs:
curl:p
libspng:p

- name: Checkout zlib-ng
if: contains(matrix.os, 'ubuntu')
uses: actions/checkout@v4
with:
repository: zlib-ng/zlib-ng
ref: 2.3.3
path: ./zlib-ng

- name: Prepare Linux
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y
sudo apt-get install libfreetype6-dev libopus-dev libopusfile-dev libspng-dev libcurl4-openssl-dev libgl1-mesa-dev -y
sudo apt-get install build-essential git cmake libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev libdbus-1-dev libudev-dev libinput-dev libts-dev libjpeg-dev libwebp-dev -y
sudo apt install build-essential cmake git libgl1-mesa-dev libfreetype6-dev libsdl3-dev libspng-dev libopus-dev libopusfile-dev python3 libcurl4-openssl-dev -y
cd bam
./make_unix.sh
cd ../SDL
cd ../zlib-ng
cmake . -DCMAKE_BUILD_TYPE=Release
sudo make install
sudo ldconfig

- name: Prepare Windows
if: contains(matrix.os, 'windows')
Expand All @@ -236,7 +235,7 @@ jobs:
if: contains(matrix.os, 'macOS')
run: |
brew update
brew install sdl3 opus opusfile openssl curl libspng || true
brew install sdl3 opus opusfile openssl curl libspng zlib-ng || true
cd bam
./make_unix.sh

Expand Down
21 changes: 10 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ if(NOT MSVC)

if(TARGET_OS STREQUAL "mac")
add_c_compiler_flag_if_supported(OUR_FLAGS -stdlib=libc++)
add_c_compiler_flag_if_supported(OUR_FLAGS -mmacosx-version-min=10.15)
add_c_compiler_flag_if_supported(OUR_FLAGS -mmacosx-version-min=26.0)
endif()

add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wall)
Expand Down Expand Up @@ -231,7 +231,7 @@ if(NOT CMAKE_CROSSCOMPILING)
# quietly.
find_package(PkgConfig)
endif()
find_package(ZLIB)
find_package(zlib-ng)

find_package(OpenSSL)
find_package(CURL)
Expand Down Expand Up @@ -296,7 +296,11 @@ show_dependency_status("Python3" Python3)
show_dependency_status("SDL3" SDL3)
show_dependency_status("Opus" OPUS)
show_dependency_status("Opusfile" OPUSFILE)
show_dependency_status("Zlib" ZLIB)
show_dependency_status("zlib-ng" zlib-ng)

if(NOT(zlib-ng_FOUND))
message(SEND_ERROR "You must install zlib-ng to compile Teeworlds")
endif()

if(NOT(Python3_FOUND))
message(SEND_ERROR "You must install Python to compile Teeworlds")
Expand Down Expand Up @@ -1343,15 +1347,10 @@ set(GAME_GENERATED_SHARED
src/generated/protocol.h
)

set(DEPS ${DEP_JSON} ${DEP_MD5} ${ZLIB_DEP})
set(DEPS ${DEP_JSON} ${DEP_MD5})

# Libraries
set(LIBS ${CMAKE_THREAD_LIBS_INIT} OpenSSL::Crypto CURL::libcurl ${PLATFORM_LIBS})
if(ZLIB_BUNDLED)
list(APPEND LIBS ${ZLIB_LIBRARIES})
else()
list(APPEND LIBS ZLIB::ZLIB)
endif()
set(LIBS ${CMAKE_THREAD_LIBS_INIT} OpenSSL::Crypto CURL::libcurl zlib-ng::zlib ${PLATFORM_LIBS})

# Targets
add_library(engine-shared EXCLUDE_FROM_ALL OBJECT ${ENGINE_INTERFACE} ${ENGINE_SHARED} ${ENGINE_GENERATED_SHARED} ${BASE})
Expand Down Expand Up @@ -1989,7 +1988,7 @@ foreach(target ${TARGETS_OWN})
target_include_directories(${target} PRIVATE src)
target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:CONF_DEBUG>)
target_include_directories(${target} PRIVATE ${CURL_INCLUDE_DIRS})
target_include_directories(${target} PRIVATE ${ZLIB_INCLUDE_DIRS})
target_include_directories(${target} PRIVATE ${zlib-ng_INCLUDE_DIR})
if(OPENSSL_FOUND)
target_compile_definitions(${target} PRIVATE CONF_OPENSSL)
target_include_directories(${target} PRIVATE ${OPENSSL_INCLUDE_DIR})
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ Teeworlds supports two build systems: CMake and bam.
Dependencies
==========================
```bash
# Debian/Ubuntu
sudo apt install build-essential cmake git libfreetype6-dev libsdl3-dev libspng-dev libopus-dev libopusfile-dev python3 libcurl4-openssl-dev
# Debian 13 / Ubuntu 26.04
sudo apt install build-essential cmake git libfreetype6-dev libsdl3-dev libspng-dev libopus-dev libopusfile-dev python3 libcurl4-openssl-dev

# Fedora
sudo dnf install @development-tools cmake gcc-c++ git freetype-devel libspng-devel python3 SDL3-devel opus-devel opusfile-devel openssl-devel libcurl-devel
sudo dnf install @development-tools cmake gcc-c++ git freetype-devel libspng-devel python3 SDL3-devel opus-devel opusfile-devel openssl-devel libcurl-devel zlib-ng-devel

# Arch Linux
sudo pacman -S --needed base-devel cmake freetype2 git python sdl3 opus opusfile openssl curl libspng
sudo pacman -S --needed base-devel cmake freetype2 git python sdl3 opus opusfile openssl curl libspng zlib-ng

# macOS
brew install cmake freetype sdl3 opus opusfile openssl curl libspng
brew install cmake freetype sdl3 opus opusfile openssl curl libspng zlib-ng

# MSYS2 (Windows)
pacman -S mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-openssl mingw-w64-ucrt-x86_64-freetype mingw-w64-ucrt-x86_64-sdl3 mingw-w64-ucrt-x86_64-zlib mingw-w64-ucrt-x86_64-opus mingw-w64-ucrt-x86_64-opusfile mingw-w64-ucrt-x86_64-curl mingw-w64-ucrt-x86_64-libspng
Expand Down
46 changes: 17 additions & 29 deletions bam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ Import("bamfind/freetype.lua")
Import("bamfind/opus.lua")
Import("bamfind/opusfile.lua")
Import("bamfind/spng.lua")
Import("bamfind/zlib-ng.lua")

--- Setup Config -------
config = NewConfig()
config:Add(OptCCompiler("compiler"))
config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.15 -isysroot /Developer/SDKs/MacOSX10.15.sdk"))
config:Add(OptTestCompileC("buildwithoutsseflag", "#include <immintrin.h>\nint main(){_mm_pause();return 0;}", ""))
config:Add(OptLibrary("zlib", "zlib.h", false))
config:Add(Curl.OptFind("libcurl", true))
config:Add(SDL.OptFind("sdl", true))
config:Add(FreeType.OptFind("freetype", true))
config:Add(Opus.OptFind("opus", true))
config:Add(Opusfile.OptFind("opusfile", true))
config:Add(SPNG.OptFind("spng", true))
config:Add(ZLIB.OptFind("zlib", true))
config:Finalize("config.lua")

generated_src_dir = "build/src"
Expand Down Expand Up @@ -95,30 +96,18 @@ function GenerateCommonSettings(settings, conf, arch, compiler)
settings.cc.flags:Add("-Wall", "-fno-exceptions")
end

-- Compile zlib if needed
local zlib = nil
if config.zlib.value == 1 then -- there's a issue need to fix, this should be true instead of 1, but if we do the correct way, we would get error.
settings.link.libs:Add("z")
if config.zlib.include_path then
settings.cc.includes:Add(config.zlib.include_path)
end
else
settings.cc.includes:Add("src/engine/external/zlib")
zlib = Compile(settings, Collect("src/engine/external/zlib/*.c"))
end
-- Apply zlib-ng
settings.cc.includes:Add(config.zlib.include_path)
config.zlib:Apply(settings)

if config.opus.value == true then
if config.opus.include_path then
settings.cc.includes:Add(config.opus.include_path)
end
end
settings.cc.includes:Add(config.opus.include_path)

local md5 = Compile(settings, Collect("src/engine/external/md5/*.c"))
local json = Compile(settings, Collect("src/engine/external/json-parser/*.c"))
local glad = Compile(settings, Collect("src/engine/external/glad/gl.c"))

-- globally available libs
libs = {zlib=zlib, md5=md5, json=json, glad=glad}
libs = {md5=md5, json=json, glad=glad}
end

function GenerateMacOSSettings(settings, conf, arch, compiler)
Expand All @@ -145,14 +134,14 @@ function GenerateMacOSSettings(settings, conf, arch, compiler)
-- c++ stdlib needed
settings.cc.flags:Add("-stdlib=libc++")
settings.link.flags:Add("-stdlib=libc++")
-- this also needs the macOS min SDK version to be at least 10.15
-- this also needs the macOS min SDK version to be at least 26.0

settings.cc.flags:Add("-mmacosx-version-min=10.15")
settings.link.flags:Add("-mmacosx-version-min=10.15")
settings.cc.flags:Add("-mmacosx-version-min=26.0")
settings.link.flags:Add("-mmacosx-version-min=26.0")

if config.minmacosxsdk.value == 1 then
settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX10.15.sdk")
settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX10.15.sdk")
settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX26.0.sdk")
settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX26.0.sdk")
end

settings.link.frameworks:Add("Carbon")
Expand All @@ -179,7 +168,6 @@ function GenerateMacOSSettings(settings, conf, arch, compiler)

-- Client
settings.link.frameworks:Add("OpenGL")
settings.link.frameworks:Add("AGL")
-- FIXME: the SDL config is applied in BuildClient too but is needed here before so the launcher will compile
config.sdl:Apply(settings)
settings.link.extrafiles:Merge(Compile(settings, "src/macoslaunch/client.m"))
Expand Down Expand Up @@ -386,32 +374,32 @@ function BuildClient(settings, family, platform)
local game_client = Compile(settings, CollectRecursive("src/game/client/*.cpp"), SharedClientFiles())
local game_editor = Compile(settings, Collect("src/game/editor/*.cpp"))

Link(settings, "ArchiveClient", libs["zlib"], libs["json"], libs["md5"], libs["glad"], client, game_client, game_editor)
Link(settings, "ArchiveClient", libs["json"], libs["md5"], libs["glad"], client, game_client, game_editor)
end

function BuildServer(settings, family, platform)
local server = Compile(settings, Collect("src/engine/server/*.cpp"))

local game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), SharedServerFiles())

return Link(settings, "ArchiveServer", libs["zlib"], libs["json"], libs["md5"], server, game_server)
return Link(settings, "ArchiveServer", libs["json"], libs["md5"], server, game_server)
end

function BuildTools(settings)
local tools = {}
for i,v in ipairs(Collect("src/tools/*.cpp", "src/tools/*.c")) do
local toolname = PathFilename(PathBase(v))
tools[i] = Link(settings, toolname, Compile(settings, v), libs["zlib"], libs["md5"], libs["json"])
tools[i] = Link(settings, toolname, Compile(settings, v), libs["md5"], libs["json"])
end
PseudoTarget(settings.link.Output(settings, "pseudo_tools") .. settings.link.extension, tools)
end

function BuildMasterserver(settings)
return Link(settings, "mastersrv", Compile(settings, Collect("src/mastersrv/*.cpp")), libs["zlib"], libs["md5"], libs["json"])
return Link(settings, "mastersrv", Compile(settings, Collect("src/mastersrv/*.cpp")), libs["md5"], libs["json"])
end

function BuildVersionserver(settings)
return Link(settings, "versionsrv", Compile(settings, Collect("src/versionsrv/*.cpp")), libs["zlib"], libs["md5"], libs["json"])
return Link(settings, "versionsrv", Compile(settings, Collect("src/versionsrv/*.cpp")), libs["md5"], libs["json"])
end

function BuildContent(settings, arch, conf)
Expand Down
48 changes: 48 additions & 0 deletions bamfind/zlib-ng.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
ZLIB = {
basepath = PathDir(ModuleFilename()),

OptFind = function (name, required)
local check = function(option, settings)
option.value = false
option.use_pkgconfig = false
option.lib_path = nil

if ExecuteSilent("pkg-config --exists zlib-ng") == 0 then
option.value = true
option.use_pkgconfig = true
end
end

local apply = function(option, settings)
if option.use_pkgconfig == true then
settings.cc.flags:Add(RunCommand("pkg-config --cflags zlib-ng"))
settings.link.flags:Add(RunCommand("pkg-config --libs zlib-ng"))
end
end

local save = function(option, output)
output:option(option, "value")
output:option(option, "use_pkgconfig")
end

local display = function(option)
if option.value == true then
if option.use_pkgconfig == true then return "using pkg-config" end
return "using unknown method"
else
if option.required then
return "not found (required)"
else
return "not found (optional)"
end
end
end

local o = MakeOption(name, 0, check, save, display)
o.Apply = apply
o.include_path = nil
o.lib_path = nil
o.required = required
return o
end
}
Loading
Loading