add starter shell script and cleanup jar CLI options

This commit is contained in:
Eyck Jentzsch 2021-09-27 20:41:51 +02:00
parent 7f09cd6907
commit 6c353eb77c
2 changed files with 51 additions and 6 deletions

View File

@ -89,6 +89,7 @@ class GeneratorMain {
throw new ParseException("error validating " + resource.URI) throw new ParseException("error validating " + resource.URI)
} }
// Configure and start the generator // Configure and start the generator
resource.runGenerator(params.outputFile)
logger.info('Code generation for ' + file + ' finished') logger.info('Code generation for ' + file + ' finished')
} }
} catch (MalformedParametersException | IllegalArgumentException | ParseException e) { } catch (MalformedParametersException | IllegalArgumentException | ParseException e) {
@ -98,14 +99,14 @@ class GeneratorMain {
return 0 return 0
} }
def runGenerator(Resource resource, File template, File outputFile){ def runGenerator(Resource resource, File outputFile){
logger.info('Running generator to generate '+outputFile+' using template '+template)
if(template !== null) System.properties.put("template", template)
if(outputFile !== null){ if(outputFile !== null){
System.properties.put("outputFile", outputFile.name) logger.info('Running generator to generate files in '+outputFile)
fsa.outputPath = outputFile.parentFile.absolutePath fsa.outputPath = outputFile.absolutePath
} else } else {
logger.info('Running generator to generate files')
fsa.outputPath = './' fsa.outputPath = './'
}
val outputCfg = fsa.outputConfigurations.get(IFileSystemAccess.DEFAULT_OUTPUT) val outputCfg = fsa.outputConfigurations.get(IFileSystemAccess.DEFAULT_OUTPUT)
outputCfg.setOverrideExistingResources(true) outputCfg.setOverrideExistingResources(true)
val context = new GeneratorContext => [cancelIndicator = CancelIndicator.NullImpl] val context = new GeneratorContext => [cancelIndicator = CancelIndicator.NullImpl]

44
generate.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
##
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f "$0"`
# Absolute path this script is in, thus /home/user/bin
SCRIPTDIR=`dirname "$SCRIPT"`
SCRIPTNAME=`basename "$SCRIPT"`
function print_help {
echo "Usage: $SCRIPTNAME [options] <core_desc input file>"
echo "Generate ISS sources for TGC cores. Supported options are:"
echo " -r <dir name> CoreDSL repository (aka include dir)"
echo " -o <dir name> output directory"
echo " -v verbose output"
echo " -h print this help"
exit 0
}
REPO_OPT=
while getopts 'c:b:r:o:vh' c
do
case $c in
r) REPO_OPT="-r $OPTARG" ;;
o) OUTPUT_OPT="-o $OPTARG" ;;
v) VERBOSE=-v
h) print_help ;;
esac
done
shift $((OPTIND-1))
if [ $# -ne 1 ]; then
echo "Missing input file"
fi
INPUT_FILE=$1
JAVA_OPTS="--add-modules ALL-SYSTEM --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.annotation=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.module=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.net.spi=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.channels=ALL-UNNAMED --add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.nio.charset.spi=ALL-UNNAMED --add-opens=java.base/java.nio.file=ALL-UNNAMED --add-opens=java.base/java.nio.file.attribute=ALL-UNNAMED --add-opens=java.base/java.nio.file.spi=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.security.acl=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.security.interfaces=ALL-UNNAMED --add-opens=java.base/java.security.spec=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.text.spi=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.time.chrono=ALL-UNNAMED --add-opens=java.base/java.time.format=ALL-UNNAMED --add-opens=java.base/java.time.temporal=ALL-UNNAMED --add-opens=java.base/java.time.zone=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/java.util.function=ALL-UNNAMED --add-opens=java.base/java.util.jar=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.util.spi=ALL-UNNAMED --add-opens=java.base/java.util.stream=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.datatransfer/java.awt.datatransfer=ALL-UNNAMED --add-opens=java.desktop/java.applet=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.color=ALL-UNNAMED --add-opens=java.desktop/java.awt.desktop=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/java.awt.geom=ALL-UNNAMED --add-opens=java.desktop/java.awt.im=ALL-UNNAMED --add-opens=java.desktop/java.awt.im.spi=ALL-UNNAMED --add-opens=java.desktop/java.awt.image=ALL-UNNAMED --add-opens=java.desktop/java.awt.image.renderable=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.print=ALL-UNNAMED --add-opens=java.desktop/java.beans=ALL-UNNAMED --add-opens=java.desktop/java.beans.beancontext=ALL-UNNAMED --add-opens=java.instrument/java.lang.instrument=ALL-UNNAMED --add-opens=java.logging/java.util.logging=ALL-UNNAMED --add-opens=java.management/java.lang.management=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.rmi/java.rmi=ALL-UNNAMED --add-opens=java.rmi/java.rmi.activation=ALL-UNNAMED --add-opens=java.rmi/java.rmi.dgc=ALL-UNNAMED --add-opens=java.rmi/java.rmi.registry=ALL-UNNAMED --add-opens=java.rmi/java.rmi.server=ALL-UNNAMED --add-opens=java.sql/java.sql=ALL-UNNAMED"
GENERATOR="java $JAVA_OPTS -jar ${SCRIPTDIR}/com.minres.coredsl.json.repository/target/com.minres.coredsl.generator-2.0.0-SNAPSHOT.jar "
[ -f c${SCRIPTDIR}/com.minres.coredsl.json.repository/target/com.minres.coredsl.generator-2.0.0-SNAPSHOT.jar ] || (cd $SCRIPTDIR; mvn package)
$GENERATOR $VERBOSE $OUTPUT_OPT $REPO_OPT $INPUT_FILE