Skip to content
Snippets Groups Projects
Forked from pregmodfan / fc-pregmod
34438 commits behind the upstream repository.
compile 1.50 KiB
#!/bin/bash

while [[ "$1" ]]
do
	case $1 in
	--insane)
		insane="true"
	;;
	*)
		echo "Unknown argument $1"
		exit 1
	esac
	shift
done

# Find and insert current commit
COMMIT=$(git rev-parse --short HEAD)
sed -Ei "s/build .releaseID/\0 commit $COMMIT/" src/gui/mainMenu/AlphaDisclaimer.tw

if [[ ! "$insane" ]]
then
	# Run sanity check.
	./sanityCheck
fi

export TWEEGO_PATH=devTools/tweeGo/storyFormats
TWEEGO_EXE="tweego"

if hash $TWEEGO_EXE 2>/dev/null; then
	echo "system tweego binary"
else
	case "$(uname -m)" in
	x86_64|amd64)
		echo "x64 arch"
		if [ "$(uname -s)" = "Darwin" ]; then
			TWEEGO_EXE="./devTools/tweeGo/tweego_osx64"
		else
			TWEEGO_EXE="./devTools/tweeGo/tweego_nix64"
		fi
		;;
	x86|i[3-6]86)
		echo "x86 arch"
		if [ "$(uname -s)" = "Darwin" ]; then
			TWEEGO_EXE="./devTools/tweeGo/tweego_osx86"
		else
			TWEEGO_EXE="./devTools/tweeGo/tweego_nix86"
		fi
		;;
	*)
		echo "No system tweego binary found, and no precompiled binary for your platform available"
		echo "Please compile tweego and put the executable in PATH"
		exit 2
	esac
fi

$TWEEGO_EXE -o "bin/FC_pregmod_tmp.html" src/ || build_failed="true"

# Revert AlphaDisclaimer for next compilation
git checkout -- src/gui/mainMenu/AlphaDisclaimer.tw

if [ "$build_failed" = "true" ]
then
	exit 1
fi

#Make the output prettier, replacing \t with a tab and \n with a newline
sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area".*$/s/\\n/\n/g' bin/FC_pregmod_tmp.html \
   && mv bin/FC_pregmod_tmp.html bin/FC_pregmod.html