Fix for issue #17.

Added cross build script for macOS ecode.
This commit is contained in:
Martín Lucas Golini
2023-03-31 19:47:17 -03:00
parent fae5ec0c3a
commit 7c49f79756
5 changed files with 79 additions and 7 deletions

View File

@@ -746,7 +746,8 @@ end
function set_xcode_config()
if is_xcode() or _OPTIONS["use-frameworks"] then
linkoptions { "-F/Library/Frameworks" }
linkoptions { "-F /Library/Frameworks" }
buildoptions { "-F /Library/Frameworks" }
includedirs { "/Library/Frameworks/SDL2.framework/Headers" }
defines { "EE_SDL2_FROM_ROOTPATH" }
end

View File

@@ -486,6 +486,7 @@ end
function set_xcode_config()
if is_xcode() or _OPTIONS["use-frameworks"] then
linkoptions { "-F /Library/Frameworks" }
buildoptions { "-F /Library/Frameworks" }
incdirs { "/Library/Frameworks/SDL2.framework/Headers" }
defines { "EE_SDL2_FROM_ROOTPATH" }
end
@@ -704,10 +705,12 @@ workspace "eepp"
filter "platforms:x86"
architecture "x86"
filter "platforms:arm64 or configurations:debug-arm64 or configurations:release-arm64"
architecture "arm64"
filter "platforms:arm64"
architecture "ARM64"
buildoptions { "-arch arm64" }
linkoptions { "-arch arm64" }
filter "platforms:x86_64 or configurations:debug-x64 or configurations:release-x64"
filter "platforms:x86_64"
architecture "x86_64"
filter "system:macosx"

View File

@@ -1,5 +1,13 @@
#!/bin/sh
../make_no_fw.sh config=release ecode
SDL2_CONFIG=$(which sdl2-config)
if [ -z $SDL2_CONFIG ]; then
echo "Building using frameworks"
../make.sh config=release ecode || exit
else
echo "Building using sdl2-config"
../make_no_fw.sh config=release ecode || exit
fi
rm -rf ./ecode.app
mkdir -p ecode.app/Contents/MacOS/
mkdir -p ecode.app/Contents/Resources/
@@ -16,8 +24,18 @@ chmod +x run.sh
cp run.sh ecode.app/Contents/MacOS
cp ../../../libs/macosx/libeepp.dylib ecode.app/Contents/MacOS
cp ../../../bin/ecode ecode.app/Contents/MacOS
cp /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib ecode.app/Contents/MacOS
install_name_tool -change /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib @executable_path/libSDL2-2.0.0.dylib ecode.app/Contents/MacOS/libeepp.dylib
if [ -z $SDL2_CONFIG ]; then
SDL2_LIB_PATH="/Library/SDL2.framework/Versions/A/"
cp "$SDL2_LIB_PATH/SDL2" ecode.app/Contents/MacOS/SDL2
install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/SDL2 ecode.app/Contents/MacOS/libeepp.dylib
codesign --force -s - ecode.app/Contents/MacOS/SDL2
else
SDL2_LIB_PATH=$(sdl2-config --libs | awk '{ print $1 }' | cut -b 3-)
cp $SDL2_LIB_PATH/libSDL2-2.0.0.dylib ecode.app/Contents/MacOS
install_name_tool -change $SDL2_LIB_PATH/libSDL2-2.0.0.dylib @executable_path/libSDL2-2.0.0.dylib ecode.app/Contents/MacOS/libeepp.dylib
fi
install_name_tool -change libeepp.dylib @executable_path/libeepp.dylib ecode.app/Contents/MacOS/ecode
#cp -r ../../../bin/assets ecode.app/Contents/MacOS/assets
mkdir -p ecode.app/Contents/MacOS/assets/colorschemes

View File

@@ -0,0 +1,45 @@
#!/bin/sh
premake5 --file=../../../premake5.lua --with-mojoal --use-frameworks gmake2 || exit
make -C ../../../make/macosx/ -j$(nproc) -e verbose=true -e config=release_arm64 ecode || exit
rm -rf ./ecode.app
mkdir -p ecode.app/Contents/MacOS/
mkdir -p ecode.app/Contents/Resources/
cp ../../../bin/assets/icon/ecode.icns ecode.app/Contents/Resources/ecode.icns
VERSIONPATH=../../../src/tools/ecode/version.hpp
ECODE_MAJOR_VERSION=$(grep "define ECODE_MAJOR_VERSION" $VERSIONPATH | awk '{print $3}')
ECODE_MINOR_VERSION=$(grep "define ECODE_MINOR_VERSION" $VERSIONPATH | awk '{print $3}')
ECODE_PATCH_LEVEL=$(grep "define ECODE_PATCH_LEVEL" $VERSIONPATH | awk '{print $3}')
ECODE_VERSION_STRING="$ECODE_MAJOR_VERSION"."$ECODE_MINOR_VERSION"."$ECODE_PATCH_LEVEL"
cat Info.plist.tpl | sed "s/ECODE_VERSION_STRING/${ECODE_VERSION_STRING}/g" | sed "s/ECODE_MAJOR_VERSION/${ECODE_MAJOR_VERSION}/g" | sed "s/ECODE_MINOR_VERSION/${ECODE_MINOR_VERSION}/g" > Info.plist
cp Info.plist ecode.app/Contents/
rm Info.plist
chmod +x run.sh
cp run.sh ecode.app/Contents/MacOS
cp ../../../libs/macosx/libeepp.dylib ecode.app/Contents/MacOS
cp ../../../bin/ecode ecode.app/Contents/MacOS
SDL2_LIB_PATH="/Library/SDL2.framework/Versions/A/"
cp "$SDL2_LIB_PATH/SDL2" ecode.app/Contents/MacOS/SDL2
install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/SDL2 ecode.app/Contents/MacOS/libeepp.dylib
codesign --force -s - ecode.app/Contents/MacOS/SDL2
install_name_tool -change libeepp.dylib @executable_path/libeepp.dylib ecode.app/Contents/MacOS/ecode
#cp -r ../../../bin/assets ecode.app/Contents/MacOS/assets
mkdir -p ecode.app/Contents/MacOS/assets/colorschemes
cp -r ../../../bin/assets/colorschemes/ ecode.app/Contents/MacOS/assets/colorschemes/
#cp -r ../../../bin/assets/fonts ecode.app/Contents/MacOS/assets/
mkdir -p ecode.app/Contents/MacOS/assets/fonts
cp -r ../../../bin/assets/fonts/DejaVuSansMono.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/DejaVuSansMonoNerdFontComplete.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/nonicons.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/codicon.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/NotoSans-Regular.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/remixicon.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/NotoEmoji-Regular.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/NotoColorEmoji.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/fonts/DroidSansFallbackFull.ttf ecode.app/Contents/MacOS/assets/fonts/
cp -r ../../../bin/assets/plugins ecode.app/Contents/MacOS/assets/
# cp -r ../../../bin/assets/icon ecode.app/Contents/MacOS/assets/
mkdir -p ecode.app/Contents/MacOS/assets/icon
cp ../../../bin/assets/icon/ecode.png ecode.app/Contents/MacOS/assets/icon
cp ../../../bin/assets/ca-bundle.pem ecode.app/Contents/MacOS/assets/ca-bundle.pem
mkdir ecode.app/Contents/MacOS/assets/ui
cp ../../../bin/assets/ui/breeze.css ecode.app/Contents/MacOS/assets/ui/

View File

@@ -2900,7 +2900,12 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe
winSettings.Icon = mResPath + winSettings.Icon;
}
#if EE_PLATFORM == EE_PLATFORM_MACOSX
mConfig.context = engine->createContextSettings( &mConfig.ini, "window", true );
#else
mConfig.context = engine->createContextSettings( &mConfig.ini, "window", false );
#endif
mConfig.context.SharedGLContext = true;
mWindow = engine->createWindow( winSettings, mConfig.context );