#!/bin/bash
set -e

cd "$(dirname $0)/../.."

./build.sh

cd build

mkdir mac
mkdir mac/Luan_Editor.app
mkdir mac/Luan_Editor.app/Contents
mkdir mac/Luan_Editor.app/Contents/MacOS
mkdir mac/Luan_Editor.app/Contents/Resources

cp ../scripts/mac/Info.plist mac/Luan_Editor.app/Contents
cp ../scripts/mac/launcher mac/Luan_Editor.app/Contents/MacOS
cp ../scripts/install.sh mac/Luan_Editor.app/Contents/Resources
cp ../scripts/uninstall.sh mac/Luan_Editor.app/Contents/Resources
cp -r luan_editor/jars mac/Luan_Editor.app/Contents/Resources
cp -r luan_editor/dictionaries mac/Luan_Editor.app/Contents/Resources

# brew install create-dmg
create-dmg \
	--volname "Luan Editor" \
	--window-pos 200 120 \
	--window-size 500 300 \
	--icon-size 100 \
	--icon "Luan_Editor.app" 100 100 \
	--app-drop-link 380 100 \
	"Luan_Editor.dmg" \
	"mac/"

cp Luan_Editor.dmg ../website/src/download

echo "finished mac build"
