clean out

add interface/InterfaceName target to create a template interface
move generate_newclass.sh to generate_new.sh and take class or interface as argument

Signed-off-by: philippe lhardy <philippe@pavilionartlogiciel>
This commit is contained in:
philippe lhardy
2015-02-19 22:21:44 +01:00
parent 7d8ce42c15
commit 0b33e56e0a
5 changed files with 53 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ clean:
rm -f build.xml
rm -f dist/lib/$(DISTPREFIX)*.jar
rm -rf build
cd java; make clean
cleanall: clean
rm -rf debian

View File

@@ -32,7 +32,7 @@ cat <<EOF
<!-- Create the distribution directory -->
<mkdir dir="\${dist}/lib"/>
<!-- Put everything in \${build} into the ${project_name}-${project_version}}-${DSTAMP}.jar file -->
<!-- Put everything in \${build} into the ${project_name}-${project_version}.jar file ( \${DSTAMP} not used yet )-->
<jar jarfile="\${dist}/lib/${project_name}-${project_version}.jar" basedir="\${build}">
<manifest>
<attribute name="Main-Class" value="$project_mainclass"/>

View File

@@ -1,12 +1,13 @@
PACKAGE=org.artisanlogiciel.games
PACKAGE_DIR=$(subst .,/,$(PACKAGE))
OUT=out
EDITOR=emacs
$(OUT):
mkdir -p $(OUT)
clean:
find $(OUT) -name "*.class" -type f -print0|xargs -0 rm
@find $(OUT) -name "*.class" -type f -print0|xargs -0 rm 2>/dev/null || echo "nothing to clean"
test:
javac -d $(OUT) $(PACKAGE_DIR)/LabyModel.java
@@ -29,17 +30,21 @@ compile/%:
javac -d $(OUT) $(PACKAGE_DIR)/$(subst compile/,,$@).java
$(PACKAGE_DIR)/%.java:
./generate_newclass.sh $(subst .java,,$(subst $(PACKAGE_DIR)/,,$@))
./generate_new.sh class $(subst .java,,$(subst $(PACKAGE_DIR)/,,$@))
interface/%:
./generate_new.sh interface package_dir=$(PACKAGE_DIR) $(subst interface/,,$@)
$(EDITOR) $(PACKAGE_DIR)/$(subst interface/,,$@).java
work/%: $(PACKAGE_DIR)/$(subst work/,,%).java
emacs $<
$(EDITOR) $<
work: work/LabyModel
save:
git citool
.PHONY: clean test work display work/% run/% save compile/%
.PHONY: clean test work display work/% run/% save compile/% interface/%
# tried to avoid intermediate file removal : does not work
# .SECONDARY: $(PACKAGE_DIR)/%.java

View File

@@ -19,3 +19,6 @@ make run/Display
#save work with git (ie git citool )
make save
# create an interface
make interface/InterfaceName

View File

@@ -1,13 +1,25 @@
#!/bin/bash
#TODO : support "like=" to copy/renaming an existing class
PACKAGE=org.artisanlogiciel.games
TOOLP="$0 $*"
ctype=class
while [[ $# > 0 ]]
do
case $1 in
class|interface)
ctype=$1
;;
package=*)
PACKAGE=${1/package=/}
;;
package_dir=*)
PACKAGE_DIR=${1/package=/}
PACKAGE=${PACKAGE//\//\.}
;;
*)
CLASS=${1}
;;
@@ -36,13 +48,15 @@ then
exit 1
else
if [[ $ctype == class ]]
then
cat <<EOF >$JAVA_FILE
package $PACKAGE;
/**
$CLASS was autogenerated by $0
$CLASS was autogenerated by $TOOLP
**/
public class $CLASS
public $ctype $CLASS
{
Object param;
@@ -69,6 +83,27 @@ public class $CLASS
}
}
EOF
else
cat <<EOF >$JAVA_FILE
package $PACKAGE;
/**
$CLASS was autogenerated by $TOOLP
**/
public $ctype $CLASS
{
/**
@return X
*/
int getX();
/**
@return Y
*/
int getY();
}
EOF
fi
fi
echo "$JAVA_FILE generated"