Add macOS support

master
MoNTE48 2021-02-12 19:15:39 +01:00
parent ea2ddf2be7
commit 0e39b9c715
23 changed files with 2760 additions and 0 deletions

8
build/macOS/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
locale
Pods
Podfile.lock
deps/*
!deps/*.sh
xcshareddata
xcuserdata
*.xcworkspace

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "AppIcon-16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "AppIcon-32.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "AppIcon-32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "AppIcon-64.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "AppIcon-128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "AppIcon-256.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "AppIcon-256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "AppIcon-512.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "AppIcon-512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "AppIcon-1024.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.adventure-games</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 Maksym Hamarnyk. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>

26
build/macOS/Podfile Executable file
View File

@ -0,0 +1,26 @@
project 'MultiCraft/MultiCraft.xcodeproj'
platform :osx, '10.10'
use_frameworks!
target 'MultiCraft' do
pod 'leveldb-library'
pod 'libvorbis'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_FAST_MATH'] = 'YES'
config.build_settings['GCC_OPTIMIZATION_LEVEL'] = 'fast'
config.build_settings['GCC_SYMBOL_PRIVATE_EXTERN'] = 'YES'
config.build_settings['GCC_UNROLL_LOOPS'] = 'YES'
config.build_settings['LLVM_LTO'] = 'YES'
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
config.build_settings['OTHER_CFLAGS'] = ['$(inherited)', '-fvisibility-inlines-hidden', '-fdata-sections', '-ffunction-sections', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables']
config.build_settings['OTHER_CPLUSPLUSFLAGS'] = ['$(inherited)', '$(OTHER_CFLAGS)']
config.build_settings['OTHER_LDFLAGS'] = ['$(inherited)', '-Wl,-dead_strip']
config.build_settings.delete('ARCHS')
end
end
end

31
build/macOS/Start.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash -e
echo
echo "Starting build MultiCraft for macOS..."
echo
echo "Build Libraries:"
cd deps
sh libraries.sh
cd ..
echo
echo "Preparing Locales:"
sh locale.sh
echo
echo "Creating App Icon:"
echo "Skipping..."
#sh appicon.sh
echo
echo "Install CocoaPods:"
pod install
echo
echo "All done! You can continue in Xcode!"
open MultiCraft.xcworkspace

15
build/macOS/appicon.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash -e
# Generates different AppIcon images with correct dimensions
# (brew package: imagemagick)
# (install: brew install imagemagick)
SIZES="16 32 64 128 256 512 1024"
SRCFILE=icon.png
DSTDIR=MultiCraft/MultiCraft/Assets.xcassets/AppIcon.appiconset
for sz in $SIZES; do
echo "Creating ${sz}x${sz} icon"
convert -resize ${sz}x${sz} $SRCFILE $DSTDIR/AppIcon-${sz}.png
done
echo "App Icon create successful"

25
build/macOS/deps/freetype.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash -e
. sdk.sh
FREETYPE_VERSION=2.10.4
if [ ! -d freetype-src ]; then
wget http://download.savannah.gnu.org/releases/freetype/freetype-$FREETYPE_VERSION.tar.gz
tar -xzvf freetype-$FREETYPE_VERSION.tar.gz
mv freetype-$FREETYPE_VERSION freetype-src
rm freetype-$FREETYPE_VERSION.tar.gz
fi
cd freetype-src
CFLAGS=$OSX_FLAGS \
PKG_CONFIG=/bin/false \
./configure --prefix=/ \
--disable-shared --enable-static \
--with-bzip2=no --with-png=no
make -j
mkdir -p ../freetype
make DESTDIR=$PWD/../freetype install
echo "FreeType build successful"

26
build/macOS/deps/irrlicht.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash -e
. sdk.sh
[ ! -d irrlicht-src ] && \
git clone --depth 1 -b ogl-es https://github.com/MoNTE48/Irrlicht irrlicht-src
cd irrlicht-src/source/Irrlicht
xcodebuild build \
ARCHS="$OSX_ARCHES" \
-project Irrlicht.xcodeproj \
-configuration Release \
-scheme Irrlicht_OSX
BUILD_FOLDER=$(xcodebuild -project Irrlicht.xcodeproj -scheme \
Irrlicht_OSX -showBuildSettings | \
grep TARGET_BUILD_DIR | sed -n -e 's/^.*TARGET_BUILD_DIR = //p')
cd ../..
[ -d ../irrlicht ] && rm -r ../irrlicht
mkdir -p ../irrlicht
cp "${BUILD_FOLDER}/libIrrlicht.a" ../irrlicht
cp -r include ../irrlicht/include
echo "Irrlicht build successful"

10
build/macOS/deps/libintl.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash -e
if [ ! -d libintl ]; then
wget https://github.com/MoNTE48/libintl-lite/archive/master.zip
unzip master.zip
mv libintl-lite-master libintl
rm master.zip
fi
echo "libintl-lite downloaded successful"

9
build/macOS/deps/libraries.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash -e
sh irrlicht.sh
sh freetype.sh
sh openal.sh
sh libintl.sh
echo
echo "All libraries were built!"

27
build/macOS/deps/openal.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash -e
. sdk.sh
OPENAL_VERSION=1.21.1
if [ ! -d openal-src ]; then
wget https://github.com/kcat/openal-soft/archive/$OPENAL_VERSION.tar.gz
tar -xzvf $OPENAL_VERSION.tar.gz
mv openal-soft-$OPENAL_VERSION openal-src
rm $OPENAL_VERSION.tar.gz
fi
cd openal-src
cmake -S . \
-DCMAKE_CXX_EXTENSIONS=OFF -DALSOFT_REQUIRE_COREAUDIO=ON \
-DALSOFT_EMBED_HRTF_DATA=YES -DALSOFT_UTILS=OFF \
-DALSOFT_EXAMPLES=OFF -DALSOFT_INSTALL=OFF -DALSOFT_BACKEND_WAVE=NO \
-DCMAKE_C_FLAGS_RELEASE="$OSX_FLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$OSX_FLAGS" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 \
"-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64"
cmake --build .
mkdir -p ../openal
mv libopenal.$OPENAL_VERSION.dylib ../openal/libopenal.1.dylib
echo "OpenAL-Soft build successful"

13
build/macOS/deps/sdk.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash -e
# This file sets the appropriate compiler and flags for compiling for macOS without XCode
sdk=macosx
osver=10.10
export OSX_ARCHES="x86_64 arm64"
arches="-arch x86_64 -arch arm64"
export OSX_COMPILER=$(xcrun --sdk $sdk --find clang)
export OSX_CC=$OSX_COMPILER
export OSX_CXX=$OSX_COMPILER
export OSX_FLAGS="-isysroot $(xcrun --sdk $sdk --show-sdk-path) $arches -mmacosx-version-min=$osver -fvisibility=hidden -fdata-sections -ffunction-sections -fno-unwind-tables -fno-asynchronous-unwind-tables -Ofast"

31
build/macOS/locale.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash -e
if [ ! -d MultiCraft/MultiCraft.xcodeproj ]; then
echo "Run this in build/macOS"
exit 1
fi
DEST=$(pwd)
pushd ../../po
for lang in *; do
[ ${#lang} -ne 2 ] && continue
mopath=$DEST/locale/$lang/LC_MESSAGES
mkdir -p $mopath
pushd $lang
for fn in *.po; do
# brew install gettext
/usr/local/Cellar/gettext/*/bin/msgfmt -o $mopath/${fn/.po/.mo} $fn
done
popd
done
popd
find $DEST -type d -name '.git' -print0 | xargs -0 -- rm -r
find $DEST -type f -name '.git*' -delete
find $DEST -type f -name '.DS_Store' -delete
# remove broken languages
for broken_lang in ja ko he; do
find $DEST -type d -name $broken_lang -print0 | xargs -0 -- rm -r
done