From cc6bd51661dd4fcc453a1f960eb779e23626a160 Mon Sep 17 00:00:00 2001 From: Vasileios Pasialiokis <whiterocket@outlook.com> Date: Sat, 25 May 2019 19:08:54 +0300 Subject: [PATCH] port to make --- compile.sh | 157 ----------------------------------------------------- makefile | 42 ++++++++++++++ 2 files changed, 42 insertions(+), 157 deletions(-) delete mode 100755 compile.sh create mode 100644 makefile diff --git a/compile.sh b/compile.sh deleted file mode 100755 index 2c4a6fc90af..00000000000 --- a/compile.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/bash - -output=/dev/stdout - -# displays help text -function displayHelp { - cat << HelpText -Usage: compile.sh [OPTION]... - -Options: - -d, --dry Do not compile - -g, --git Add hash of HEAD to filename - -h, --help Show this help text - -j, --java Run sanityCheck based on java (recommended) - -p, --python Run sanityCheck based on python - -q, --quiet Suppress terminal output -HelpText -} - -#display an error message -function echoError { - echo -e "\033[0;31m$@\033[0m" -} - -#display message -function echoMessage { - echo "$1" > "${output}" -} - -#compile the HTML file -function compile { - - mkdir -p bin - - export TWEEGO_PATH=devTools/tweeGo/storyFormats - TWEEGO_EXE="tweego" - - if hash $TWEEGO_EXE 2>/dev/null; then - echoMessage "system tweego binary" - else - case "$(uname -m)" in - x86_64|amd64) - echoMessage "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) - echoMessage "x86 arch" - if [ "$(uname -s)" = "Darwin" ]; then - TWEEGO_EXE="./devTools/tweeGo/tweego_osx86" - else - TWEEGO_EXE="./devTools/tweeGo/tweego_nix86" - fi - ;; - *) - echoError "No system tweego binary found, and no precompiled binary for your platform available." - echoError "Please compile tweego and put the executable in PATH." - exit 2 - esac - fi - - if [[ "$usehash" ]]; then - HASH="$(git rev-list -n 1 --abbrev-commit HEAD)" - - $TWEEGO_EXE -o "bin/FC_pregmod_${HASH}_tmp.html" src/ --head devTools/head.html || build_failed="true" - - if [ "$build_failed" = "true" ] - then - echoError "Build failed." - 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_${HASH}_tmp.html" \ - && mv "bin/FC_pregmod_${HASH}_tmp.html" "bin/FC_pregmod_${HASH}.html" - - ln -s ../resources bin/ 2> /dev/null - - echoMessage "Saved to bin/FC_pregmod_$HASH.html." - - else - # Find and insert current commit - COMMIT=$(git rev-parse --short HEAD) - sed -Ei "s/build .releaseID/\0 commit $COMMIT/" src/gui/mainMenu/AlphaDisclaimer.tw - - $TWEEGO_EXE -o "bin/FC_pregmod_tmp.html" src/ --head devTools/head.html || build_failed="true" - - # Revert AlphaDisclaimer for next compilation - git checkout -- src/gui/mainMenu/AlphaDisclaimer.tw - - if [ "$build_failed" = "true" ] - then - echoError "Build failed." - 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 - - ln -s ../resources bin/ 2> /dev/null - - echoMessage "Saved to bin/FC_pregmod.html." - fi -} - -if [[ "$1" == "" ]]; then - #tip if no option - echoMessage "For more options see compile.sh -h." -else - #parse options - while [[ "$1" ]] - do - case $1 in - -d|--dry) - dry="true" - ;; - -g|--git) - usehash="true" - ;; - -h|--help) - displayHelp - exit 0 - ;; - -j|--java) - java="true" - ;; - -p|--python) - python="true" - ;; - -q|--quiet) - output=/dev/null - ;; - *) - echoError "Unknown argument $1." - displayHelp - exit 1 - esac - shift - done -fi - -# Run sanity check. -[ -n "$java" ] && ./sanityCheck.sh java - -[ -n "$python" ] && ./sanityCheck.sh - -#compile -if [[ "$dry" ]]; then - echoMessage "Dry run finished." -else - compile - echoMessage "Compilation finished." -fi diff --git a/makefile b/makefile new file mode 100644 index 00000000000..fd8fb7c15e8 --- /dev/null +++ b/makefile @@ -0,0 +1,42 @@ +MAKEFLAGS += -r +TWEEGO := "" +uname := $(shell uname -s) +arch := $(shell uname -m) +ifeq ($(uname),Linux) + ifeq ($(arch),x86_64) + TWEEGO := ./devTools/tweeGo/tweego_nix64 + else + TWEEGO := ./devTools/tweeGo/tweego_nix86 + endif +else ifeq ($(uname),Darwin) + ifeq ($(arch),x86_64) + TWEEGO := ./devTools/tweeGo/tweego_osx64 + else + TWEEGO := ./devTools/tweeGo/tweego_osx86 + endif +endif + +all: bin/FC_pregmod.html bin/resources + +bin/resources: ./resources + ln -s $< $@ + +bin/FC_pregmod.html: bin/FC_pregmod_tmp + ./devTools/embed_favicon.py $@ + git checkout -- src/gui/mainMenu/AlphaDisclaimer.tw + mv $< $@ + +bin/FC_pregmod_tmp: src/gui/mainMenu/AlphaDisclaimer.tw + $(TWEEGO) -o $@ src/ --head devTools/head.html + +src/gui/mainMenu/AlphaDisclaimer.tw: + sed -Ei "s/build .releaseID/\0 commit $(COMMIT)/" src/gui/mainMenu/AlphaDisclaimer.tw" + sed -Ei "s/build .releaseID/\0 commit $(COMMIT)/" $< + +sanity: + ./sanityCheck.sh + +jsanity: + ./sanityCheck java + +.PHONY: all sanity jsanity \ No newline at end of file -- GitLab