Skip to content

Commit

Permalink
Add Docker image for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
botder committed May 22, 2023
1 parent 0e7abac commit 24dea64
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
39 changes: 39 additions & 0 deletions Dockerfile.osx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM jetbrains/teamcity-minimal-agent:latest

# This is important for using apt-get
USER root

# Install cross-build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates subversion ncftp \
git autoconf wget make patch cmake clang llvm-dev uuid-dev libssl-dev lzma-dev libxml2-dev python3

# Prepare cross-build environment
ENV MACOSX_DEPLOYMENT_TARGET=10.15 \
PATH="${PATH}:/opt/osxcross/bin" \
OSXCROSS_MP_INC=1

RUN mkdir -p /opt/osxcross && \
git clone https://github.com/tpoechtrager/osxcross.git /opt/osxcross/setup_files && \
cd /opt/osxcross/setup_files && \
wget -P tarballs https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz && \
UNATTENDED=1 TARGET_DIR=/opt/osxcross ./build.sh && \
UNATTENDED=1 ../bin/osxcross-macports install mysql8 libidn2

# Default build configuration
ENV AS_BUILDAGENT=0 \
BUILD_ARCHITECTURE=x64 \
BUILD_CONFIG=release \
AR=x86_64-apple-darwin20.4-ar \
CC=x86_64-apple-darwin20.4-clang \
CXX=x86_64-apple-darwin20.4-clang++

# Set build directory
VOLUME /build
WORKDIR /build

# Copy entrypoint script
COPY utils/docker-entrypoint-osx.sh /docker-entrypoint.sh

# Set entrypoint
ENTRYPOINT /docker-entrypoint.sh
10 changes: 9 additions & 1 deletion Server/dbconmy/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ project "Dbconmy"
links { "rt" }

filter "system:macosx"
includedirs { os.findheader("mysql.h", "/usr/local/opt/mysql/include/mysql") }
includedirs {
os.findheader("mysql.h", {
"/usr/local/opt/mysql/include/mysql",
"/opt/osxcross/macports/pkgs/opt/local/include/mysql8/mysql",
})
}
libdirs {
os.findlib("libmysqlclient.a", "/opt/osxcross/macports/pkgs/opt/local/lib/mysql8/mysql")
}

if GLIBC_COMPAT then
filter { "system:linux" }
Expand Down
2 changes: 1 addition & 1 deletion Shared/mods/deathmatch/logic/lua/LuaBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace lua

inline void Push(lua_State* L, bool value) { lua_pushboolean(L, value); }

inline void Push(lua_State* L, nullptr_t) { lua_pushnil(L); }
inline void Push(lua_State* L, std::nullptr_t) { lua_pushnil(L); }

inline void Push(lua_State* L, const char* value) { lua_pushstring(L, value); }

Expand Down
7 changes: 5 additions & 2 deletions linux-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash -e

# Set variable defaults
: ${BUILD_OS:=linux}
: ${BUILD_ARCHITECTURE:=x64}
: ${BUILD_CONFIG:=release}

Expand All @@ -21,6 +22,7 @@ fi
# Read script arguments
while [ $# -gt 0 ]; do
case "$1" in
--os=*) BUILD_OS="${1#*=}" ;;
--arch=*) BUILD_ARCHITECTURE="${1#*=}" ;;
--config=*) BUILD_CONFIG="${1#*=}" ;;
*)
Expand Down Expand Up @@ -58,6 +60,7 @@ case $BUILD_ARCHITECTURE in
exit 1
esac

echo " OS = $BUILD_OS"
echo " CONFIG = $CONFIG"
echo " AR = ${AR:=ar}"
echo " CC = ${CC:=gcc}"
Expand All @@ -69,9 +72,9 @@ rm -Rf Bin/

# Generate Makefiles
if [[ -n "$GCC_PREFIX" ]]; then
$PREMAKE5 --gccprefix="$GCC_PREFIX" gmake
$PREMAKE5 --gccprefix="$GCC_PREFIX" --os="$BUILD_OS" gmake
else
$PREMAKE5 gmake
$PREMAKE5 --os="$BUILD_OS" gmake
fi

# Build!
Expand Down
16 changes: 16 additions & 0 deletions utils/docker-entrypoint-osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# If configurede as a build agent, start Teamcity agent
if [[ $AS_BUILDAGENT = "1" ]]; then
# https://github.com/JetBrains/teamcity-docker-minimal-agent/blob/master/Dockerfile#L17
exec /run-services.sh
fi

# Manually invoke build process
# So, first make a shallow clone of the repository if it not exists
umask 000
if [ ! -f ./premake5.lua ]; then
git clone --depth=1 https://github.com/multitheftauto/mtasa-blue.git .
fi

./linux-build.sh --os=macosx --arch=$BUILD_ARCHITECTURE --config=$BUILD_CONFIG

0 comments on commit 24dea64

Please sign in to comment.