Skip to content

Commit

Permalink
build scripts revised, defs autodiscover from compiler macros
Browse files Browse the repository at this point in the history
  • Loading branch information
ctlcltd committed Feb 9, 2024
1 parent f75ede2 commit 1c7cf2a
Show file tree
Hide file tree
Showing 10 changed files with 567 additions and 833 deletions.
6 changes: 3 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Generic instructions to help with compiling e2 SAT Editor on different platforms

Utils scripts in **scripts** folder.

- For Linux or BSD or Unix use `scripts/build.sh`
- For Linux or BSD or Unix use `scripts/build-qmake.sh`

- For macOS with Xcode use `scripts/darwin.sh`
- For macOS with Xcode use `scripts/build-darwin.sh`

- For Windows with MinGW-64 use `scripts/mingw.sh`
- For Windows with MinGW-64 use `scripts/build-mingw.sh`


### Required dependencies
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ Same languages as `qt-base`, new languages could be added using the website app.

```git clone https://github.com/ctlcltd/e2-sat-editor.git```

 

Instructions on how to compile in [INSTALL.md](https://github.com/ctlcltd/e2-sat-editor/blob/main/INSTALL.md) file.


Expand Down
225 changes: 225 additions & 0 deletions scripts/build-darwin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
#!/bin/bash
# Build or initialize an xcodeproj with QMake
#

usage () {
if [[ -z "$1" ]]; then
printf "%s\n\n" "Build or initialize an xcodeproj with QMake"
fi

printf "%s\n\n" "bash build-darwin.sh [OPTIONS] [-b debug | release]"
printf "%s\n" "-q --qmake QMake executable."
printf "%s\n" "-c --cleanup Task: cleanup"
printf "%s\n" "-p --prepare Task: prepare"
printf "%s\n" "-b --build Task: build"
printf "%s\n" "-x --xcodeproj Task: xcodeproj"
printf "%s\n" "-d --default Task: default"
printf "%s\n" "-r --release Task: release"
printf "%s\n" "-h --help Display this help and exit."
}

#TODO improve
src () {
if [[ $(basename $PWD) != "src" ]]; then
cd src

if [[ $(basename $PWD) != "src" ]]; then
echo "Directory \"src\" not found.";

exit 1;
fi
fi
}

init () {
if [[ -z "$QMAKE" ]]; then
if [[ -n $(type -t qmake) ]]; then
QMAKE="qmake"
fi
fi

if [[ -z $(type -t qmake) ]]; then
echo "QMake not found."

exit 1;
fi
if [[ -z $(type -t make) ]]; then
echo "Make not found."

exit 1;
fi

if [[ "$TARGET" == "debug" ]]; then
TARGET="debug"
else
TARGET="release"
fi
}

compiler () {
local compiler="QMake"

if [[ -n "$TARGET" ]]; then
compiler="$compiler $TARGET"
fi

printf "%s\n\n" "$compiler"

$QMAKE --version
}

cleanup () {
printf "%s\n\n" "cleanup."

src
rm -R *.o
rm -R moc_*.cpp
rm -R moc_predefs.h
rm Makefile
rm Makefile.Debug
rm Makefile.Release
rm .qmake.stash
rm qrc_resources*.cpp
rm -R debug
rm -R release
}

prepare () {
printf "%s\n\n" "prepare."
compiler
printf "%s\n\n" "preparing QMake ..."

src
$QMAKE -spec macx-clang e2-sat-editor.pro
}

build () {
printf "%s\n\n" "build."
compiler
printf "%s\n\n" "compiling ..."

src
make $TARGET && $QMAKE
}

xcodeproj () {
printf "%s\n\n" "xcodeproj."
compiler
printf "%s\n\n" "preparing xcodeproj ..."

src
$QMAKE -spec macx-xcode
}

release () {
printf "%s\n\n" "release."

src

cp -R "e2 SAT Editor.app" "build/e2 SAT Editor.app"

printf "%s\n\n" "pre actions ..."

QMDIR="build/e2 SAT Editor.app/Contents/Resources/translations"

mkdir -p "$QMDIR"
cp ../dist/translations/*.qm "$QMDIR"
cp /usr/local/share/qt/translations/qt_*.qm "$QMDIR"
cp /usr/local/share/qt/translations/qtbase_*.qm "$QMDIR"
rm -R "$QMDIR"/qt_help_*.qm

cp "../dist/macos/Info.plist.in" "build/e2 SAT Editor.app/Contents/Info.plist"
cp "../dist/macos/PkgInfo.in" "build/e2 SAT Editor.app/Contents/PkgInfo"

printf "%s\n\n" "run deploy script ..."

bash ../scripts/deployqtmacx.sh "build/e2 SAT Editor.app" --verbose

printf "%s\n\n" "copying e2se files ..."

cp ../dist/common/Readme.txt.in build/Readme.txt
cp COPYING build/License.txt
}

default () {
printf "%s\n\n" "default."

init
prepare
build
xcodeproj
}

complete () {
printf "\n%s\n" "done."
}


if [[ -z "$@" ]]; then
usage

exit 0
fi

for SRG in "$@"; do
case "$SRG" in
-q*|--qmake*)
QMAKE="$2"
init
shift
shift
;;
-c|--cleanup)
cleanup
shift
;;
-p|--prepare)
init
prepare
shift
;;
-b*|--build*)
TARGET="$2"
init
build
shift
shift
;;
-x|--xcodeproj)
init
prepare
xcodeproj
shift
;;
-d|--default)
default
shift
;;
-r|--release)
init
prepare
build
release
shift
;;
-h|--help)
usage

exit 0
;;
-*)
[[ "$1" == "-"* ]] && shift
printf "%s: %s %s\n\n" "$0" "Illegal option" "$2"

usage 1

exit 1
;;
*)
[[ "$1" != -* ]] && usage
;;
esac
done

complete

Loading

0 comments on commit 1c7cf2a

Please sign in to comment.