mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
fxconv: add support for script mode (-s)
This commit is contained in:
parent
c9dd9fad18
commit
ce78d4814c
2 changed files with 30 additions and 10 deletions
15
Makefile
15
Makefile
|
@ -18,8 +18,8 @@ dflags = -MT $@ -MMD -MP -MF $(@:%.o=%.d)
|
||||||
# $TARGETS is provided by Makefile.cfg.
|
# $TARGETS is provided by Makefile.cfg.
|
||||||
#
|
#
|
||||||
|
|
||||||
TARGETS := $(filter-out fxconv,$(TARGETS))
|
|
||||||
TARGETS := $(TARGETS:fxsdk=fxsdk.sh)
|
TARGETS := $(TARGETS:fxsdk=fxsdk.sh)
|
||||||
|
TARGETS := $(TARGETS:fxconv=fxconv-main.py)
|
||||||
bin = $(TARGETS:%=bin/%)
|
bin = $(TARGETS:%=bin/%)
|
||||||
|
|
||||||
# fxconv has no sources files because it's written in Python, and fxsdk has no
|
# fxconv has no sources files because it's written in Python, and fxsdk has no
|
||||||
|
@ -30,9 +30,9 @@ obj-fxg1a := $(src-fxg1a:%=build/%.o)
|
||||||
# Sed command to copy install path to fxsdk.sh. On Mac OS, BSD sed is used so
|
# Sed command to copy install path to fxsdk.sh. On Mac OS, BSD sed is used so
|
||||||
# we need to do it a bit differently with a printf helper to insert a literal
|
# we need to do it a bit differently with a printf helper to insert a literal
|
||||||
# newline into the command.
|
# newline into the command.
|
||||||
sed := '/^PREFIX=\\$$/ a \$(PREFIX)'
|
sed := -E -e '/^PREFIX=.?.?.?\\$$/ a \$(PREFIX)'
|
||||||
ifeq "$(shell uname)" "Darwin"
|
ifeq "$(shell uname)" "Darwin"
|
||||||
sed := "$$(printf '/^PREFIX=/ a \\\n$(PREFIX)')"
|
sed := -e "$$(printf '/^PREFIX=.?.?.?/ a \\\n$(PREFIX)')"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Symbolic targets
|
# Symbolic targets
|
||||||
|
@ -41,11 +41,14 @@ all: $(bin)
|
||||||
|
|
||||||
all-fxsdk: bin/fxsdk.sh
|
all-fxsdk: bin/fxsdk.sh
|
||||||
all-fxg1a: bin/fxg1a
|
all-fxg1a: bin/fxg1a
|
||||||
|
all-fxconv: bin/fxconv-main.py
|
||||||
|
|
||||||
# Explicit targets
|
# Explicit targets
|
||||||
|
|
||||||
bin/fxsdk.sh: fxsdk/fxsdk.sh | bin/
|
bin/fxsdk.sh: fxsdk/fxsdk.sh | bin/
|
||||||
sed -e $(sed) $< > $@
|
sed $(sed) $< > $@
|
||||||
|
bin/fxconv-main.py: fxconv/fxconv-main.py | bin/
|
||||||
|
sed $(sed) $< > $@
|
||||||
bin/fxg1a: $(obj-fxg1a) | bin/
|
bin/fxg1a: $(obj-fxg1a) | bin/
|
||||||
gcc $^ -o $@ $(lflags)
|
gcc $^ -o $@ $(lflags)
|
||||||
|
|
||||||
|
@ -91,11 +94,11 @@ endif
|
||||||
install: $(bin)
|
install: $(bin)
|
||||||
install -d $(PREFIX)/bin
|
install -d $(PREFIX)/bin
|
||||||
install -d $(PREFIX)/share/fxsdk
|
install -d $(PREFIX)/share/fxsdk
|
||||||
install $(bin:bin/fxsdk.sh=) $(m755) $(PREFIX)/bin
|
install $(filter bin/fxg1a,$(bin)) $(m755) $(PREFIX)/bin
|
||||||
install -d $(PREFIX)/share/fxsdk/assets
|
install -d $(PREFIX)/share/fxsdk/assets
|
||||||
install fxsdk/assets/* $(m644) $(PREFIX)/share/fxsdk/assets
|
install fxsdk/assets/* $(m644) $(PREFIX)/share/fxsdk/assets
|
||||||
install bin/fxsdk.sh $(m755) $(PREFIX)/bin/fxsdk
|
install bin/fxsdk.sh $(m755) $(PREFIX)/bin/fxsdk
|
||||||
install fxconv/fxconv-main.py $(m755) $(PREFIX)/bin/fxconv
|
install bin/fxconv-main.py $(m755) $(PREFIX)/bin/fxconv
|
||||||
install fxconv/fxconv.py $(m644) $(PREFIX)/bin
|
install fxconv/fxconv.py $(m644) $(PREFIX)/bin
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
|
|
|
@ -4,8 +4,13 @@ import getopt
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import fxconv
|
import fxconv
|
||||||
|
import subprocess
|
||||||
|
|
||||||
help_string = """
|
# Note: this line is edited at compile time to insert the install folder
|
||||||
|
PREFIX="""\
|
||||||
|
""".strip()
|
||||||
|
|
||||||
|
help_string = f"""
|
||||||
usage: fxconv [-s] <python script> [files...]
|
usage: fxconv [-s] <python script> [files...]
|
||||||
fxconv -b <bin file> -o <object file> [parameters...]
|
fxconv -b <bin file> -o <object file> [parameters...]
|
||||||
fxconv -i <png file> -o <object file> (--fx|--cg) [parameters...]
|
fxconv -i <png file> -o <object file> (--fx|--cg) [parameters...]
|
||||||
|
@ -31,6 +36,8 @@ script. They accept parameters with a "category.key:value" syntax, for example:
|
||||||
|
|
||||||
When converting images, use --fx (black-and-white calculators) or --cg (16-bit
|
When converting images, use --fx (black-and-white calculators) or --cg (16-bit
|
||||||
color calculators) to specify the target machine.
|
color calculators) to specify the target machine.
|
||||||
|
|
||||||
|
Install PREFIX is set to '{PREFIX}'.
|
||||||
""".strip()
|
""".strip()
|
||||||
|
|
||||||
# Simple error-warnings system
|
# Simple error-warnings system
|
||||||
|
@ -93,10 +100,20 @@ def main():
|
||||||
if mode == "s":
|
if mode == "s":
|
||||||
if output is not None:
|
if output is not None:
|
||||||
warn("option --output is ignored in script mode")
|
warn("option --output is ignored in script mode")
|
||||||
args = None if args == [] else args
|
|
||||||
|
|
||||||
err("script mode not currently implemented (TODO) x_x")
|
if PREFIX == "":
|
||||||
sys.exit(1)
|
err("unknown or invalid install path x_x")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
env = os.environ.copy()
|
||||||
|
if "PYTHONPATH" in env:
|
||||||
|
env["PYTHONPATH"] += f":{PREFIX}/bin"
|
||||||
|
else:
|
||||||
|
env["PYTHONPATH"] = f"{PREFIX}/bin"
|
||||||
|
|
||||||
|
p = subprocess.run([ sys.executable, input ], env=env)
|
||||||
|
if p.returncode != 0:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# In shortcut conversion modes, read parameters from the command-line
|
# In shortcut conversion modes, read parameters from the command-line
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue