mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
fxsdk: basic script, project creation and build (#1)
This commit is contained in:
parent
86a9350a17
commit
32239c3dfe
8 changed files with 274 additions and 15 deletions
17
Makefile
17
Makefile
|
@ -21,32 +21,27 @@ dflags = -MT $@ -MMD -MP -MF $(@:%.o=%.d)
|
||||||
TARGETS := $(filter-out fxconv,$(TARGETS))
|
TARGETS := $(filter-out fxconv,$(TARGETS))
|
||||||
bin = $(TARGETS:%=bin/%)
|
bin = $(TARGETS:%=bin/%)
|
||||||
|
|
||||||
# fxconv has no sources files because it's written in Python
|
# fxconv has no sources files because it's written in Python, and fxsdk has no
|
||||||
|
# source either because it's written in Bash.
|
||||||
src = $(wildcard $1/*.c)
|
src = $(wildcard $1/*.c)
|
||||||
src-fxsdk := $(call src,fxsdk)
|
|
||||||
src-fxg1a := $(call src,fxg1a)
|
src-fxg1a := $(call src,fxg1a)
|
||||||
src-fxos := $(call src,fxos)
|
src-fxos := $(call src,fxos)
|
||||||
lex-fxos := $(wildcard fxos/*.l)
|
lex-fxos := $(wildcard fxos/*.l)
|
||||||
|
|
||||||
obj = $($1:%=build/%.o)
|
obj = $($1:%=build/%.o)
|
||||||
lex = $($1:%.l=build/%.yy.c.o)
|
lex = $($1:%.l=build/%.yy.c.o)
|
||||||
obj-fxsdk := $(call obj,src-fxsdk)
|
|
||||||
obj-fxg1a := $(call obj,src-fxg1a)
|
obj-fxg1a := $(call obj,src-fxg1a)
|
||||||
obj-fxos := $(call obj,src-fxos) $(call lex,lex-fxos)
|
obj-fxos := $(call obj,src-fxos) $(call lex,lex-fxos)
|
||||||
|
|
||||||
# Symbolic targets
|
# Symbolic targets
|
||||||
|
|
||||||
all: $(bin)
|
all: $(bin)
|
||||||
@echo $(lex-fxos)
|
|
||||||
|
|
||||||
all-fxsdk: bin/fxsdk
|
|
||||||
all-fxg1a: bin/fxg1a
|
all-fxg1a: bin/fxg1a
|
||||||
all-fxos: bin/fxos
|
all-fxos: bin/fxos
|
||||||
|
|
||||||
# Explicit targets
|
# Explicit targets
|
||||||
|
|
||||||
bin/fxsdk: $(obj-fxsdk) | bin/
|
|
||||||
gcc $^ -o $@ $(lflags)
|
|
||||||
bin/fxg1a: $(obj-fxg1a) | bin/
|
bin/fxg1a: $(obj-fxg1a) | bin/
|
||||||
gcc $^ -o $@ $(lflags)
|
gcc $^ -o $@ $(lflags)
|
||||||
bin/fxos: $(obj-fxos) | bin/
|
bin/fxos: $(obj-fxos) | bin/
|
||||||
|
@ -93,6 +88,10 @@ install: $(bin)
|
||||||
install -d $(PREFIX)/share/fxsdk
|
install -d $(PREFIX)/share/fxsdk
|
||||||
install $(bin) -m 755 $(PREFIX)/bin
|
install $(bin) -m 755 $(PREFIX)/bin
|
||||||
install fxos/*.txt -m 644 $(PREFIX)/share/fxsdk
|
install fxos/*.txt -m 644 $(PREFIX)/share/fxsdk
|
||||||
|
install -d $(PREFIX)/share/fxsdk/assets
|
||||||
|
install fxsdk/assets/* -m 644 $(PREFIX)/share/fxsdk/assets
|
||||||
|
install fxsdk/fxsdk.sh -m 755 $(PREFIX)/bin/fxsdk
|
||||||
|
sed -i '/^PREFIX=\\$$/ a $(PREFIX)' $(PREFIX)/bin/fxsdk
|
||||||
install fxconv/fxconv-main.py -m 755 $(PREFIX)/bin/fxconv
|
install fxconv/fxconv-main.py -m 755 $(PREFIX)/bin/fxconv
|
||||||
install fxconv/fxconv.py -m 644 $(PREFIX)/bin
|
install fxconv/fxconv.py -m 644 $(PREFIX)/bin
|
||||||
|
|
||||||
|
@ -104,10 +103,6 @@ uninstall:
|
||||||
# Cleaning
|
# Cleaning
|
||||||
#
|
#
|
||||||
|
|
||||||
clean-fxsdk:
|
|
||||||
@rm -rf build/fxsdk
|
|
||||||
clean-fxconv:
|
|
||||||
@rm -rf build/fxconv
|
|
||||||
clean-fxg1a:
|
clean-fxg1a:
|
||||||
@rm -rf build/fxg1a
|
@rm -rf build/fxg1a
|
||||||
clean-fxos:
|
clean-fxos:
|
||||||
|
|
129
fxsdk/assets/Makefile
Executable file
129
fxsdk/assets/Makefile
Executable file
|
@ -0,0 +1,129 @@
|
||||||
|
#! /usr/bin/make -f
|
||||||
|
# Default Makefile for fxSDK add-ins. This file was probably copied there by
|
||||||
|
# the [fxsdk] program.
|
||||||
|
#---
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configuration
|
||||||
|
#
|
||||||
|
|
||||||
|
include project.cfg
|
||||||
|
|
||||||
|
# Compiler flags
|
||||||
|
cf := -mb -ffreestanding -nostdlib -Wall -Wextra \
|
||||||
|
-fstrict-volatile-bitfields $(CFLAGS)
|
||||||
|
cf-fx := $(cf) -m3 -DFX9860G
|
||||||
|
cf-cg := $(cf) -m4-nofpu -DFXCG50
|
||||||
|
|
||||||
|
# Linker flags
|
||||||
|
lf-fx := $(LDFLAGS) -Tfx9860g.ld -lgint-fx -lgcc -Wl,-Map=build-fx/map
|
||||||
|
lf-cg := $(LDFLAGS) -Tfxcg50.ld -lgint-cg -lgcc -Wl,-Map=build-cg/map
|
||||||
|
|
||||||
|
dflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
|
||||||
|
cpflags := -R .bss -R .gint_bss
|
||||||
|
|
||||||
|
g1af := -i "$(ICON_FX)" -n "$(NAME)" --internal="$(INTERNAL)"
|
||||||
|
g3af := -n basic:"$(NAME)" -i uns:"$(ICON_CG_UNS)" -i sel:"$(ICON_CG_SEL)"
|
||||||
|
|
||||||
|
#
|
||||||
|
# File listings
|
||||||
|
#
|
||||||
|
|
||||||
|
null :=
|
||||||
|
filename := $(subst $(null) $(null),-,$(NAME))
|
||||||
|
|
||||||
|
elf = $(dir $<)$(filename).elf
|
||||||
|
bin = $(dir $<)$(filename).bin
|
||||||
|
target-fx := $(filename).g1a
|
||||||
|
target-cg := $(filename).g3a
|
||||||
|
|
||||||
|
# Source files
|
||||||
|
src := $(wildcard src/*.c)
|
||||||
|
img-fx := $(wildcard assets-fx/img/**/*)
|
||||||
|
fonts-fx := $(wildcard assets-fx/fonts/**/*)
|
||||||
|
img-cg := $(wildcard assets-cg/img/**/*)
|
||||||
|
fonts-cg := $(wildcard assets-cg/fonts/**/*)
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
obj-fx := $(src:%.c=build-fx/%.o) $(res:assets-fx/%=build-fx/assets/%.o)
|
||||||
|
obj-cg := $(src:%.c=build-cg/%.o) $(res:assets-cg/%=build-cg/assets/%.o)
|
||||||
|
|
||||||
|
# Additional dependencies
|
||||||
|
deps-fx := $(ICON_FX)
|
||||||
|
deps-cg := $(ICON_CG_UNS) $(ICON_CG_SEL)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build rules
|
||||||
|
#
|
||||||
|
|
||||||
|
all: all-fx all-cg
|
||||||
|
|
||||||
|
all-fx: $(target-fx)
|
||||||
|
all-cg: $(target-cg)
|
||||||
|
|
||||||
|
$(target-fx): $(obj-fx) $(deps-fx)
|
||||||
|
|
||||||
|
sh3eb-elf-gcc -o $(elf) $(obj-fx) $(cf-fx) $(lf-fx)
|
||||||
|
sh3eb-elf-objcopy -O binary $(cpflags) $(elf) $(bin)
|
||||||
|
fxg1a $(bin) -o $@ $(g1af)
|
||||||
|
|
||||||
|
$(target-cg): $(obj-cg) $(deps-cg)
|
||||||
|
|
||||||
|
sh4eb-elf-gcc -o $(elf) $(obj-cg) $(cf-cg) $(lf-cg)
|
||||||
|
sh4eb-elf-objcopy -O binary $(cpflags) $(elf) $(bin)
|
||||||
|
mkg3a $(g3af) $(bin) $@
|
||||||
|
|
||||||
|
# C sources
|
||||||
|
build-fx/%.o: %.c
|
||||||
|
@ mkdir -p $(dir $@)
|
||||||
|
sh3eb-elf-gcc -c $< -o $@ $(cf-fx) $(dflags)
|
||||||
|
build-cg/%.o: %.c
|
||||||
|
@ mkdir -p $(dir $@)
|
||||||
|
sh4eb-elf-gcc -c $< -o $@ $(cf-cg) $(dflags)
|
||||||
|
|
||||||
|
# Images
|
||||||
|
build-fx/assets/img/%.o: assets-fx/img/%
|
||||||
|
@ mkdir -p $(dir $@)
|
||||||
|
fxconv -i $< -o $@ name:$*
|
||||||
|
|
||||||
|
build-cg/assets/img/%.o: assets-cg/img/%
|
||||||
|
@ echo -ne "\e[31;1mWARNING: image conversion for fxcg50 is not "
|
||||||
|
@ echo -ne "supported yet\e[0m"
|
||||||
|
@ mkdir -p $(dir $@)
|
||||||
|
fxconv -i $< -o $@ name:$*
|
||||||
|
|
||||||
|
# Fonts
|
||||||
|
build-fx/assets/fonts/%.o: assets-fx/fonts/%
|
||||||
|
@ mkdir -p $(dir $@)
|
||||||
|
fxconv -f $< -o $@ name:$*
|
||||||
|
|
||||||
|
build-cg/assets/fonts/%.o: assets-cg/fonts/%
|
||||||
|
@ mkdir -p $(dir $@)
|
||||||
|
fxconv -f $< -o $@ name:$*
|
||||||
|
|
||||||
|
#
|
||||||
|
# Cleaning and utilities
|
||||||
|
#
|
||||||
|
|
||||||
|
# Dependency information
|
||||||
|
-include $(shell find build* -name *.d 2> /dev/null)
|
||||||
|
build-fx/%.d: ;
|
||||||
|
build-cg/%.d: ;
|
||||||
|
.PRECIOUS: build-fx build-cg build-fx/%.d build-cg/%.d %/
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@ rm -rf build*
|
||||||
|
distclean: clean
|
||||||
|
@ rm -f $(target-fx) $(target-cg)
|
||||||
|
|
||||||
|
install-fx: $(target-fx)
|
||||||
|
p7 send -f $<
|
||||||
|
install-cg: $(target-cg)
|
||||||
|
@ while [[ ! -h /dev/Prizm1 ]]; do sleep 1; done
|
||||||
|
@ mount /dev/Prizm1
|
||||||
|
@ rm -f /mnt/prizm/$<
|
||||||
|
@ cp $< /mnt/prizm
|
||||||
|
@ umount /dev/Prizm1
|
||||||
|
@- eject /dev/Prizm1
|
||||||
|
|
||||||
|
.PHONY: all all-fx all-cg clean distclean install-fx install-cg
|
BIN
fxsdk/assets/icon-cg-sel.png
Normal file
BIN
fxsdk/assets/icon-cg-sel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
BIN
fxsdk/assets/icon-cg-uns.png
Normal file
BIN
fxsdk/assets/icon-cg-uns.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
fxsdk/assets/icon-fx.png
Normal file
BIN
fxsdk/assets/icon-fx.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
12
fxsdk/assets/main.c
Normal file
12
fxsdk/assets/main.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include <gint/display.h>
|
||||||
|
#include <gint/keyboard.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
dclear(color_white);
|
||||||
|
dtext(4, 4, "Sample fxSDK add-in.", color_black, color_none);
|
||||||
|
dupdate();
|
||||||
|
|
||||||
|
getkey();
|
||||||
|
return 1;
|
||||||
|
}
|
127
fxsdk/fxsdk.sh
Executable file
127
fxsdk/fxsdk.sh
Executable file
|
@ -0,0 +1,127 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
# Note: this line is edited at install time to insert the install folder
|
||||||
|
PREFIX=\
|
||||||
|
|
||||||
|
usage_string=$(cat << EOF
|
||||||
|
usage: fxsdk new [<folder name>] [options...]
|
||||||
|
fxsdk build [fx|cg]
|
||||||
|
fxsdk send [fx|cg]
|
||||||
|
|
||||||
|
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 name>] [options...]
|
||||||
|
-@ <name>, --internal=<name> Internal project name
|
||||||
|
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "$usage_string"
|
||||||
|
exit ${1:-1}
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo -n "error: " >&2
|
||||||
|
echo "$@" >&2
|
||||||
|
echo "Try 'fxsdk --help' for more information." >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: Finish this interface
|
||||||
|
fxsdk_new_project_cli() {
|
||||||
|
internal=
|
||||||
|
|
||||||
|
while [[ "$@" ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help|-\?)
|
||||||
|
usage 0;;
|
||||||
|
|
||||||
|
-@|--internal)
|
||||||
|
[[ -z "$2" ]] && error "$1 requires an argument" && return 1
|
||||||
|
internal="$2"
|
||||||
|
shift;;
|
||||||
|
|
||||||
|
--internal=*)
|
||||||
|
internal="${1#*=}";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "internal=$internal"
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
echo -e "Creating a new project in folder '$1'.\n"
|
||||||
|
|
||||||
|
echo -ne "Full project name ? (at most 8 characters)\n> "
|
||||||
|
read NAME
|
||||||
|
|
||||||
|
echo -ne "Internal name ? ('@' followed by at most 7 uppercase letters)\n> "
|
||||||
|
read INTERNAL
|
||||||
|
|
||||||
|
mkdir -p "$1"/{,src,assets-fx,assets-cg}
|
||||||
|
fxsdk_create_config > "$1/project.cfg"
|
||||||
|
|
||||||
|
echo -e "\nYour project '$NAME' has been created.\n"
|
||||||
|
echo "Type 'fxsdk build-fx' or 'fxsdk build-cg' to compile the program."
|
||||||
|
|
||||||
|
assets="$PREFIX/share/fxsdk/assets"
|
||||||
|
cp "$assets"/Makefile "$1"
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
fxsdk_load_config() {
|
||||||
|
sed -E 's/^([A-Z_]+)\s*=\s*(.*)/\1="\2"' project.cfg | source /dev/stdin
|
||||||
|
}
|
||||||
|
|
||||||
|
fxsdk_create_config() {
|
||||||
|
cat << EOF
|
||||||
|
#---
|
||||||
|
# fxSDK project configuration file for $NAME
|
||||||
|
#---
|
||||||
|
|
||||||
|
# Project name, should be at most 8 bytes long.
|
||||||
|
NAME = $NAME
|
||||||
|
# Internal name, should be '@' followed by at most 7 uppercase letters.
|
||||||
|
INTERNAL = $INTERNAL
|
||||||
|
|
||||||
|
# fx-9860G icon location
|
||||||
|
ICON_FX = assets-fx/icon-fx.png
|
||||||
|
# fx-CG 50 icon locations
|
||||||
|
ICON_CG_UNS = assets-cg/icon-cg-uns.png
|
||||||
|
ICON_CG_SEL = assets-cg/icon-cg-sel.png
|
||||||
|
|
||||||
|
# Additional compiler flags
|
||||||
|
CFLAGS = -std=c11 -Os
|
||||||
|
# Additional linker flags
|
||||||
|
LDFLAGS =
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
fxsdk_build() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command name
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
new)
|
||||||
|
shift
|
||||||
|
fxsdk_new_project_interactive "$@";;
|
||||||
|
-h|--help|-\?)
|
||||||
|
usage 0;;
|
||||||
|
?*)
|
||||||
|
error "unknown command '$1'"
|
||||||
|
exit 1;;
|
||||||
|
*)
|
||||||
|
usage 0;;
|
||||||
|
esac
|
|
@ -1,4 +0,0 @@
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in a new issue