mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
fxsdk: add options to fxsdk build
This commit is contained in:
parent
1992aac4bd
commit
53ea134c62
1 changed files with 64 additions and 87 deletions
151
fxsdk/fxsdk.sh
151
fxsdk/fxsdk.sh
|
@ -1,13 +1,12 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Note: this line is edited at compile time to insert the install folder
|
# Note: this line is edited at compile time to insert the install folder
|
||||||
PREFIX=\
|
PREFIX=\
|
||||||
|
|
||||||
R=$(printf "\e[31;1m")
|
R=$(printf "\e[31;1m")
|
||||||
g=$(printf "\e[32m\e[3m")
|
g=$(printf "\e[32m\e[3m")
|
||||||
n=$(printf "\e[0m")
|
n=$(printf "\e[0m")
|
||||||
|
TAG=$(printf "\e[36m<fxSDK>\e[0m")
|
||||||
|
|
||||||
usage_string=$(cat << EOF
|
usage_string=$(cat << EOF
|
||||||
usage: ${R}fxsdk${n} (${R}new${n}|${R}build${n}|${R}build-fx${n}|${R}build-\
|
usage: ${R}fxsdk${n} (${R}new${n}|${R}build${n}|${R}build-fx${n}|${R}build-\
|
||||||
|
@ -21,18 +20,18 @@ ${R}fxsdk new${n} ${g}<FOLDER>${n} [${R}--makefile${n}|${R}--cmake${n}] \
|
||||||
Create a new project in the specified folder. The default build system is
|
Create a new project in the specified folder. The default build system is
|
||||||
CMake. Project name can be specified now or in the project files later.
|
CMake. Project name can be specified now or in the project files later.
|
||||||
|
|
||||||
${R}fxsdk build${n} [${g}-s${n}]
|
${R}fxsdk${n} (${R}build${n}|${R}build-fx${n}|${R}build-cg${n}) [${R}-c${n}] \
|
||||||
${R}fxsdk build-fx${n} [${g}-s${n}]
|
[${R}-s${n}] [${R}--${n}] [${g}<ARGS>${n}...]
|
||||||
${R}fxsdk build-cg${n} [${g}-s${n}]
|
Build the current project for fx-9860G (usually for .g1a add-ins) or fx-CG 50
|
||||||
Build the current project for fx-9860G (.g1a target) or fx-CG 50 (.g3a
|
(usually for .g3a add-ins). The first form compiles in every existing build
|
||||||
target). With 'fxsdk build', compiles every existing build folder, and ask
|
folder, and configures for both if none exists.
|
||||||
interactively if none is found.
|
|
||||||
|
|
||||||
With '-s', also sends the resulting program to the calculator.
|
With -c, reconfigure but don't build (CMake only).
|
||||||
|
With -s, also sends the resulting program to the calculator.
|
||||||
|
Other arguments are passed to CMake (if using -c) or make (otherwise). You
|
||||||
|
can pass -c or -s to CMake/make by specifying --.
|
||||||
|
|
||||||
${R}fxsdk send${n}
|
${R}fxsdk${n} (${R}send${n}|${R}send-fx${n}|${R}send-cg${n})
|
||||||
${R}fxsdk send-fx${n}
|
|
||||||
${R}fxsdk send-cg${n}
|
|
||||||
Sends the target file to the calculator. Uses p7 (which must be installed
|
Sends the target file to the calculator. Uses p7 (which must be installed
|
||||||
externally) for fx-9860G. Currently not implemented for fx-CG 50, as it
|
externally) for fx-9860G. Currently not implemented for fx-CG 50, as it
|
||||||
requires detecting and mounting the calculator (same for the Graph 35+E II).
|
requires detecting and mounting the calculator (same for the Graph 35+E II).
|
||||||
|
@ -49,12 +48,6 @@ error() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
status() {
|
|
||||||
echo -ne "\n\e[34;1m::\e[39;1m "
|
|
||||||
echo -n "$@"
|
|
||||||
echo -e "\e[0m\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
fxsdk_new_project() {
|
fxsdk_new_project() {
|
||||||
# Generator to use, output folder and project name
|
# Generator to use, output folder and project name
|
||||||
generator="CMake"
|
generator="CMake"
|
||||||
|
@ -122,76 +115,69 @@ fxsdk_load_config() {
|
||||||
|
|
||||||
|
|
||||||
fxsdk_build() {
|
fxsdk_build() {
|
||||||
built=
|
[[ ! -e build-fx && ! -e build-cg ]]
|
||||||
|
none_exists=$?
|
||||||
|
|
||||||
if [[ -e build-fx ]]; then
|
if [[ -e build-fx || $none_exists == 0 ]]; then
|
||||||
status "Making into build-fx"
|
echo "$TAG Making into build-fx"
|
||||||
make all-fx
|
fxsdk_build_fx "$@"
|
||||||
built=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e build-cg ]]; then
|
if [[ -e build-cg || $none_exists == 0 ]]; then
|
||||||
status "Making into build-cg"
|
echo "$TAG Making into build-cg"
|
||||||
make all-cg
|
fxsdk_build_cg "$@"
|
||||||
built=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ $built ]] && return
|
|
||||||
|
|
||||||
echo "No build files currently exist. Which platform do I compile for?"
|
|
||||||
echo ""
|
|
||||||
echo '"fx": fx-9860G II, Graph 35+ USB/E/E II, Graph 75+'
|
|
||||||
echo '"cg": fx-CG 10/20/50, Graph 90+E'
|
|
||||||
echo ""
|
|
||||||
echo "Leave blank to cancel."
|
|
||||||
|
|
||||||
platform=
|
|
||||||
while true; do
|
|
||||||
echo -n '> '
|
|
||||||
read platform
|
|
||||||
[[ -z $platform ]] && return
|
|
||||||
|
|
||||||
if [[ $platform == "fx" ]]; then
|
|
||||||
fxsdk_build_fx
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $platform == "cg" ]]; then
|
|
||||||
fxsdk_build_ch
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e 'Unknown platform (valid names are "fx" and "cg")!'
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fxsdk_build_fx() {
|
fxsdk_build_fx() {
|
||||||
# CMake version; automatically configure
|
fxsdk_build_in "fx" "FX9860G" "$@"
|
||||||
if [[ -e "CMakeLists.txt" ]]; then
|
}
|
||||||
if [[ ! -e "build-fx/Makefile" ]]; then
|
fxsdk_build_cg() {
|
||||||
cmake -B build-fx \
|
fxsdk_build_in "cg" "FXCG50" "$@"
|
||||||
-DCMAKE_MODULE_PATH="$PREFIX/lib/cmake/fxsdk" \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$PREFIX/lib/cmake/fxsdk/FX9860G.cmake"
|
|
||||||
fi
|
|
||||||
make --no-print-directory -C build-fx
|
|
||||||
# Makefile version
|
|
||||||
else
|
|
||||||
make all-fx
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fxsdk_build_cg() {
|
fxsdk_build_in() {
|
||||||
|
platform="$1"
|
||||||
|
toolchain="$2"
|
||||||
|
shift 2
|
||||||
|
|
||||||
|
# Read -s, -c and -- to isolate arguments to CMake and make
|
||||||
|
while true; do
|
||||||
|
case "$1" in
|
||||||
|
"-s") send=1;;
|
||||||
|
"-c") configure=1;;
|
||||||
|
"--") shift; break;;
|
||||||
|
*) break;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
# CMake version; automatically configure
|
# CMake version; automatically configure
|
||||||
if [[ -e "CMakeLists.txt" ]]; then
|
if [[ -e "CMakeLists.txt" ]]; then
|
||||||
if [[ ! -e "build-cg/Makefile" ]]; then
|
cmake_extra_args=()
|
||||||
cmake -B build-cg \
|
make_extra_args=()
|
||||||
-DCMAKE_MODULE_PATH="$PREFIX/lib/cmake/fxsdk" \
|
if [[ ! -z "$configure" ]]; then
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$PREFIX/lib/cmake/fxsdk/FXCG50.cmake"
|
cmake_extra_args=( "$@" )
|
||||||
|
else
|
||||||
|
make_extra_args=( "$@" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -e "build-$platform/Makefile" || ! -z "$configure" ]]; then
|
||||||
|
cmake -B "build-$platform" \
|
||||||
|
-DCMAKE_MODULE_PATH="$PREFIX/lib/cmake/fxsdk" \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="$PREFIX/lib/cmake/fxsdk/$toolchain.cmake" \
|
||||||
|
"${cmake_extra_args[@]}"
|
||||||
|
fi
|
||||||
|
if [[ -z "$configure" ]]; then
|
||||||
|
make --no-print-directory -C "build-$platform" "${make_extra_args[@]}"
|
||||||
fi
|
fi
|
||||||
make --no-print-directory -C build-cg
|
|
||||||
# Makefile version
|
# Makefile version
|
||||||
else
|
else
|
||||||
make all-cg
|
make "all-$platform" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -z "$send" ]]; then
|
||||||
|
fxsdk_send_$platform
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +195,7 @@ fxsdk_send() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fxsdk_send_fx() {
|
fxsdk_send_fx() {
|
||||||
status "Installing for fx9860g using p7"
|
echo "$TAG Installing for fx9860g using p7"
|
||||||
make install-fx
|
make install-fx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,20 +213,11 @@ case "$1" in
|
||||||
|
|
||||||
# Project compilation
|
# Project compilation
|
||||||
"build"|"b")
|
"build"|"b")
|
||||||
fxsdk_build
|
fxsdk_build "${@:2}";;
|
||||||
if [[ "$2" == "-s" ]]; then
|
|
||||||
fxsdk_send
|
|
||||||
fi;;
|
|
||||||
"build-fx"|"bf"|"bfx")
|
"build-fx"|"bf"|"bfx")
|
||||||
fxsdk_build_fx
|
fxsdk_build_fx "${@:2}";;
|
||||||
if [[ "$2" == "-s" ]]; then
|
|
||||||
fxsdk_send_fx
|
|
||||||
fi;;
|
|
||||||
"build-cg"|"bc"|"bcg")
|
"build-cg"|"bc"|"bcg")
|
||||||
fxsdk_build_cg
|
fxsdk_build_cg "${@:2}";;
|
||||||
if [[ "$2" == "-s" ]]; then
|
|
||||||
fxsdk_send_cg
|
|
||||||
fi;;
|
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
"send"|"s")
|
"send"|"s")
|
||||||
|
|
Loading…
Reference in a new issue