Merge pull request 'Python build script updates' (#6) from build-python into main

Reviewed-on: MartinFouilleul/milepost#6
This commit is contained in:
MartinFouilleul 2023-08-08 09:32:41 +00:00
commit c103c001f7
3 changed files with 1 additions and 112 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
.DS_Store .DS_Store
*.dSYM *.dSYM
bin bin
build
*.metallib *.metallib
*.pdb *.pdb

View File

@ -1,14 +0,0 @@
@echo off
setlocal EnableDelayedExpansion
if not exist bin mkdir bin
set glsl_shaders=src\glsl_shaders\common.glsl src\glsl_shaders\blit_vertex.glsl src\glsl_shaders\blit_fragment.glsl src\glsl_shaders\path_setup.glsl src\glsl_shaders\segment_setup.glsl src\glsl_shaders\backprop.glsl src\glsl_shaders\merge.glsl src\glsl_shaders\raster.glsl src\glsl_shaders\balance_workgroups.glsl
call python3 scripts\embed_text.py %glsl_shaders% --prefix=glsl_ --output src\glsl_shaders.h
set INCLUDES=/I src /I src/util /I src/platform /I ext /I ext/angle_headers
set LIBS=user32.lib opengl32.lib gdi32.lib shcore.lib delayimp.lib dwmapi.lib comctl32.lib ole32.lib shell32.lib shlwapi.lib /LIBPATH:./bin libEGL.dll.lib libGLESv2.dll.lib /DELAYLOAD:libEGL.dll /DELAYLOAD:libGLESv2.dll
cl /we4013 /Zi /Zc:preprocessor /DMP_BUILD_DLL /std:c11 /experimental:c11atomics %INCLUDES% src/milepost.c /Fo:bin/milepost.o /LD /link /MANIFEST:EMBED /MANIFESTINPUT:src/win32_manifest.xml %LIBS% /OUT:bin/milepost.dll /IMPLIB:bin/milepost.dll.lib

View File

@ -1,98 +0,0 @@
#!/bin/bash
set -euo pipefail
DEBUG_FLAGS="-g -DDEBUG -DLOG_COMPILE_DEBUG"
#DEBUG_FLAGS="-O3"
#--------------------------------------------------------------
# set target
#--------------------------------------------------------------
target="${1:-}"
if [ -z $target ] ; then
target='lib'
fi
shaderFlagParam="${2:-}"
#--------------------------------------------------------------
# Detect OS and set environment variables accordingly
#--------------------------------------------------------------
OS=$(uname -s)
if [ $OS = "Darwin" ] ; then
#echo "Target '$target' for macOS"
CC=clang
CXX=clang++
DYLIB_SUFFIX='dylib'
SYS_LIBS=''
FLAGS="-mmacos-version-min=10.15.4 -maes"
CFLAGS="-std=c11"
SDKDIR=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
LDFLAGS="-L$SDKDIR/usr/lib -F$SDKDIR/System/Library/Frameworks/"
elif [ $OS = "Linux" ] ; then
echo "Error: Linux is not supported yet"
exit -1
else
echo "Error: Unsupported OS $OS"
exit -1
fi
#--------------------------------------------------------------
# Set paths
#--------------------------------------------------------------
BINDIR="./bin"
SRCDIR="./src"
EXTDIR="./ext"
RESDIR="./resources"
INCLUDES="-I$SRCDIR -I$SRCDIR/util -I$SRCDIR/platform -I$EXTDIR -I$EXTDIR/angle_headers"
#--------------------------------------------------------------
# Build
#--------------------------------------------------------------
if [ ! \( -e bin \) ] ; then
mkdir ./bin
fi
if [ ! \( -e resources \) ] ; then
mkdir ./resources
fi
if [ $target = 'lib' ] ; then
# compile metal shader
xcrun -sdk macosx metal $shaderFlagParam -fno-fast-math -c -o $BINDIR/mtl_renderer.air $SRCDIR/mtl_renderer.metal
xcrun -sdk macosx metallib -o $BINDIR/mtl_renderer.metallib $BINDIR/mtl_renderer.air
# compile milepost. We use one compilation unit for all C code, and one compilation
# unit for all ObjectiveC code
$CC $DEBUG_FLAGS -c -o $BINDIR/milepost_c.o $CFLAGS $FLAGS $INCLUDES $SRCDIR/milepost.c
$CC $DEBUG_FLAGS -c -o $BINDIR/milepost_objc.o $FLAGS $INCLUDES $SRCDIR/milepost.m
# build dynamic library
ld $LDFLAGS -dylib -o $BINDIR/libmilepost.dylib $BINDIR/milepost_c.o $BINDIR/milepost_objc.o -L$BINDIR -lc -framework Carbon -framework Cocoa -framework Metal -framework QuartzCore -weak-lEGL -weak-lGLESv2
# change dependent libs path to @rpath.
install_name_tool -change "./libEGL.dylib" '@rpath/libEGL.dylib' $BINDIR/libmilepost.dylib
install_name_tool -change "./libGLESv2.dylib" '@rpath/libGLESv2.dylib' $BINDIR/libmilepost.dylib
# add executable path to rpath. Client executable can still add its own rpaths if needed, e.g. @executable_path/libs/ etc.
install_name_tool -id "@rpath/libmilepost.dylib" $BINDIR/libmilepost.dylib
else
# additional targets
if [ $target = 'test' ] ; then
pushd examples/test_app
./build.sh
popd
elif [ $target = 'clean' ] ; then
rm -r ./bin
else
echo "unrecognized target $target"
exit -1
fi
fi