mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-28 04:23:37 +01:00
fxsdk: command-line interface for fxSDK 2.3
* Add the CMake build system * Use CMake as the default for new projects * Change [fxsdk new] but continue supporting the previous signature * Automatically configure in [fxsdk build-fx] and [fxsdk build-cg] * Improve help screen
This commit is contained in:
parent
d5759423db
commit
e2ba617405
7 changed files with 149 additions and 57 deletions
2
Makefile
2
Makefile
|
@ -93,7 +93,7 @@ install-fxsdk: all-fxsdk
|
|||
install -d $(PREFIX)/bin
|
||||
install bin/fxsdk.sh $(PREFIX)/bin/fxsdk
|
||||
install -d $(PREFIX)/share/fxsdk/assets
|
||||
install fxsdk/assets/* $(m644) $(PREFIX)/share/fxsdk/assets
|
||||
cp -ra fxsdk/assets $(PREFIX)/share/fxsdk/
|
||||
install bin/fxsdk.sh $(m755) $(PREFIX)/bin/fxsdk
|
||||
install -d $(PREFIX)/lib/cmake/fxsdk
|
||||
install fxsdk/cmake/* $(m644) $(PREFIX)/lib/cmake/fxsdk
|
||||
|
|
48
fxsdk/assets/CMakeLists.txt
Normal file
48
fxsdk/assets/CMakeLists.txt
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the
|
||||
# toolchain file and module path of the fxSDK
|
||||
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(MyAddin)
|
||||
|
||||
include(GenerateG1A)
|
||||
include(GenerateG3A)
|
||||
include(Fxconv)
|
||||
find_package(Gint 2.1 REQUIRED)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
# ...
|
||||
)
|
||||
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
|
||||
set(ASSETS
|
||||
# ...
|
||||
)
|
||||
set(ASSETS_fx
|
||||
assets-fx/example.png
|
||||
# ...
|
||||
)
|
||||
set(ASSETS_cg
|
||||
assets-cg/example.png
|
||||
# ...
|
||||
)
|
||||
|
||||
set_source_files_properties(${ASSETS} PROPERTIES
|
||||
OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets/fxconv-metadata.txt")
|
||||
set_source_files_properties(${ASSETS_fx} PROPERTIES
|
||||
OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets-fx/fxconv-metadata.txt")
|
||||
set_source_files_properties(${ASSETS_cg} PROPERTIES
|
||||
OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets-cg/fxconv-metadata.txt")
|
||||
|
||||
set_source_files_properties(${ASSETS} ${ASSETS_fx} ${ASSETS_cg}
|
||||
PROPERTIES LANGUAGE FXCONV)
|
||||
|
||||
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
|
||||
target_link_libraries(myaddin Gint::Gint)
|
||||
|
||||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||
generate_g1a(TARGET myaddin OUTPUT "MyAddin.g1a"
|
||||
NAME "MyAddin" ICON assets-fx/icon.png)
|
||||
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
||||
generate_g3a(TARGET myaddin OUTPUT "MyAddin.g3a"
|
||||
NAME "MyAddin" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
|
||||
endif()
|
BIN
fxsdk/assets/assets-cg/example.png
Normal file
BIN
fxsdk/assets/assets-cg/example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
3
fxsdk/assets/assets-cg/fxconv-metadata.txt
Normal file
3
fxsdk/assets/assets-cg/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
example.png:
|
||||
type: bopti-image
|
||||
name: img_example
|
BIN
fxsdk/assets/assets-fx/example.png
Normal file
BIN
fxsdk/assets/assets-fx/example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
3
fxsdk/assets/assets-fx/fxconv-metadata.txt
Normal file
3
fxsdk/assets/assets-fx/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
example.png:
|
||||
type: bopti-image
|
||||
name: img_example
|
150
fxsdk/fxsdk.sh
150
fxsdk/fxsdk.sh
|
@ -5,44 +5,39 @@ set -e
|
|||
# Note: this line is edited at compile time to insert the install folder
|
||||
PREFIX=\
|
||||
|
||||
R=$(printf "\e[31;1m")
|
||||
g=$(printf "\e[32m\e[3m")
|
||||
n=$(printf "\e[0m")
|
||||
|
||||
usage_string=$(cat << EOF
|
||||
usage: fxsdk new <folder>
|
||||
fxsdk (build|build-fx|build-cg) [-s]
|
||||
fxsdk (send|send-fx|send-cg)
|
||||
usage: ${R}fxsdk${n} (${R}new${n}|${R}build${n}|${R}build-fx${n}|${R}build-\
|
||||
cg${n}|${R}send${n}|${R}send-fx${n}|${R}send-cg${n}) [${g}ARGUMENTS${n}...]
|
||||
|
||||
This program is a command-line helper for the fxSDK, a set of tools used in
|
||||
conjunction with gint to develop add-ins for CASIO fx-9860G and fx-CG 50.
|
||||
|
||||
Project creation:
|
||||
fxsdk new <folder>
|
||||
${R}fxsdk new${n} ${g}<FOLDER>${n} [${R}--makefile${n}|${R}--cmake${n}] \
|
||||
[${g}<NAME>${n}]
|
||||
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.
|
||||
|
||||
Creates a new project in the specified folder. Project info is input
|
||||
interactively. Creates <folder name> and populates it with default project
|
||||
data.
|
||||
|
||||
Compilation:
|
||||
fxsdk build [-s]
|
||||
fxsdk build-fx [-s]
|
||||
fxsdk build-cg [-s]
|
||||
|
||||
Compiles the current project for fx-9860G (.g1a target) or fx-CG 50 (.g3a
|
||||
${R}fxsdk build${n} [${g}-s${n}]
|
||||
${R}fxsdk build-fx${n} [${g}-s${n}]
|
||||
${R}fxsdk build-cg${n} [${g}-s${n}]
|
||||
Build the current project for fx-9860G (.g1a target) or fx-CG 50 (.g3a
|
||||
target). With 'fxsdk build', compiles every existing build folder, and ask
|
||||
interactively if none is found.
|
||||
|
||||
With '-s', also sends the resulting program to the calculator.
|
||||
|
||||
Installation:
|
||||
fxsdk send
|
||||
fxsdk send-fx
|
||||
fxsdk send-cg
|
||||
|
||||
${R}fxsdk send${n}
|
||||
${R}fxsdk send-fx${n}
|
||||
${R}fxsdk send-cg${n}
|
||||
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
|
||||
requires detecting and mounting the calculator (same for the Graph 35+E II).
|
||||
|
||||
Project update:
|
||||
fxsdk update
|
||||
|
||||
${R}fxsdk update${n}
|
||||
Copies the latest version of the Makefile to your project. *This will
|
||||
discard any changes made to your Makefile.* If you have edited your
|
||||
Makefile, make a backup and merge the changes after updating.
|
||||
|
@ -55,9 +50,8 @@ usage() {
|
|||
}
|
||||
|
||||
error() {
|
||||
echo -n "error: " >&2
|
||||
echo "$@" >&2
|
||||
echo "Try 'fxsdk --help' for more information." >&2
|
||||
echo "error:" "$@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
status() {
|
||||
|
@ -66,34 +60,62 @@ status() {
|
|||
echo -e "\e[0m\n"
|
||||
}
|
||||
|
||||
fxsdk_new_project_interactive() {
|
||||
[[ -z "$1" ]] && error "please specify the project folder" && return 1
|
||||
[[ -e "$1" ]] && error "'$1' exists, I don't dare touch it" && return 1
|
||||
fxsdk_new_project() {
|
||||
# Generator to use, output folder and project name
|
||||
generator="CMake"
|
||||
folder=""
|
||||
name=""
|
||||
|
||||
echo -e "Creating a new project in folder '$1'.\n"
|
||||
# Parse options, then skip to positional arguments
|
||||
TEMP=$(getopt -o "" -l "makefile,cmake" -n "$0" -- "$@")
|
||||
eval set -- "$TEMP"
|
||||
for arg; do case "$arg" in
|
||||
"--makefile") generator="Makefile";;
|
||||
"--cmake") generator="CMake";;
|
||||
*) break;;
|
||||
esac; done
|
||||
while [[ "$1" != "--" ]]; do shift; done; shift
|
||||
|
||||
echo -ne "Full project name ? (at most 8 characters)\n> "
|
||||
read NAME
|
||||
if [[ -z "$1" ]]; then
|
||||
usage 1
|
||||
fi
|
||||
if [[ -e "$1" && "$1" != "." ]]; then
|
||||
error "$1 exists, I don't dare touch it"
|
||||
fi
|
||||
|
||||
echo "Internal name ? ('@' followed by at most 7 uppercase letters)"
|
||||
echo -ne "(Add-in might not appear on calc if format is wrong)\n> "
|
||||
read INTERNAL
|
||||
# Determine name and internal name
|
||||
if [[ ! -z "$2" ]]; then
|
||||
NAME=${2::8}
|
||||
upper=${2^^}
|
||||
else
|
||||
cap=${1^}
|
||||
NAME=${cap::8}
|
||||
upper=${1^^}
|
||||
fi
|
||||
INTERNAL=@${upper::7}
|
||||
|
||||
# Copy initial files to project folder
|
||||
assets="$PREFIX/share/fxsdk/assets"
|
||||
mkdir -p "$1"/{,src,assets-fx,assets-cg}
|
||||
|
||||
assets="$PREFIX/share/fxsdk/assets"
|
||||
case "$generator" in
|
||||
"Makefile")
|
||||
sed -e "s/@NAME@/$NAME/g" -e "s/@INTERNAL@/$INTERNAL/g" \
|
||||
"$assets/project.cfg" > "$1/project.cfg"
|
||||
cp "$assets/Makefile" "$1";;
|
||||
"CMake")
|
||||
cp "$assets/CMakeLists.txt" "$1";;
|
||||
esac
|
||||
|
||||
sed -e "s/@NAME@/$NAME/g" -e "s/@INTERNAL@/$INTERNAL/g" \
|
||||
"$assets/project.cfg" > "$1/project.cfg"
|
||||
|
||||
cp "$assets"/Makefile "$1"
|
||||
cp "$assets"/gitignore "$1"/.gitignore
|
||||
cp "$assets"/main.c "$1"/src
|
||||
cp "$assets"/icon-fx.png "$1"/assets-fx
|
||||
cp "$assets"/icon-cg-uns.png "$1"/assets-cg
|
||||
cp "$assets"/icon-cg-sel.png "$1"/assets-cg
|
||||
cp "$assets"/icon-fx.png "$1"/assets-fx/icon.png
|
||||
cp "$assets"/icon-cg-uns.png "$1"/assets-cg/icon-uns.png
|
||||
cp "$assets"/icon-cg-sel.png "$1"/assets-cg/icon-sel.png
|
||||
cp -r "$assets"/assets-fx "$1"/
|
||||
cp -r "$assets"/assets-cg "$1"/
|
||||
|
||||
echo -e "\nYour project '$NAME' has been created.\n"
|
||||
echo "Created a new project $NAME (build system: $generator)."
|
||||
echo "Type 'fxsdk build-fx' or 'fxsdk build-cg' to compile the program."
|
||||
}
|
||||
|
||||
|
@ -135,14 +157,12 @@ fxsdk_build() {
|
|||
[[ -z $platform ]] && return
|
||||
|
||||
if [[ $platform == "fx" ]]; then
|
||||
status "Making into build-fx"
|
||||
make all-fx
|
||||
fxsdk_build_fx
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $platform == "cg" ]]; then
|
||||
status "Making into build-fx"
|
||||
make all-cg
|
||||
fxsdk_build_ch
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -151,13 +171,33 @@ fxsdk_build() {
|
|||
}
|
||||
|
||||
fxsdk_build_fx() {
|
||||
status "Making into build-fx"
|
||||
make all-fx
|
||||
# CMake version; automatically configure
|
||||
if [[ -e "CMakeLists.txt" ]]; then
|
||||
if [[ ! -e "build-fx" ]]; then
|
||||
cmake -B build-fx \
|
||||
-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() {
|
||||
status "Making into build-cg"
|
||||
make all-cg
|
||||
# CMake version; automatically configure
|
||||
if [[ -e "CMakeLists.txt" ]]; then
|
||||
if [[ ! -e "build-cg" ]]; then
|
||||
cmake -B build-cg \
|
||||
-DCMAKE_MODULE_PATH="$PREFIX/lib/cmake/fxsdk" \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$PREFIX/lib/cmake/fxsdk/FXCG50.cmake"
|
||||
fi
|
||||
make --no-print-directory -C build-cg
|
||||
# Makefile version
|
||||
else
|
||||
make all-cg
|
||||
fi
|
||||
}
|
||||
|
||||
fxsdk_send() {
|
||||
|
@ -196,12 +236,10 @@ fxsdk_update() {
|
|||
|
||||
# Parse command name
|
||||
|
||||
case $1 in
|
||||
|
||||
case "$1" in
|
||||
# Project creation
|
||||
"new")
|
||||
shift
|
||||
fxsdk_new_project_interactive "$@";;
|
||||
fxsdk_new_project "${@:2}";;
|
||||
|
||||
# Project compilation
|
||||
"build"|"b")
|
||||
|
|
Loading…
Reference in a new issue