Add support for building jars from Java projects (`make jar').

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@38254 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Niels Grewe 2014-12-21 07:16:04 +00:00
parent c571c609a9
commit 0223c11597
9 changed files with 117 additions and 4 deletions

View file

@ -1,3 +1,15 @@
2014-12-21: Niels Grewe <niels.grewe@halbordnung.de>
* Instance/Shared/java.make
* Instance/java.make
* Instance/rules.make
* Master/java.make
* Master/rules.make
* common.make
* messages.make:
Add a `jar' target to the java project type that allows jars to
be built from all classes in the project.
* Documentation/gnustep-make.texi: Document Java project variables.
2014-06-29 Nicolas Boulenguez <nicolas@debian.org> (tiny change)
* common.make (INTERNAL_CFLAGS): Do not ignore user-specified

View file

@ -241,6 +241,48 @@ respects it is similar to a Bundle.
This project provides rules for building java programs. It also makes it
easy to make java projects that interact with the GNUstep libraries.
@subsubsection Project Variables
@defvr {Java project} JAVA_PACKAGE_NAME
@code{JAVA_PACKAGE_NAME} is the reverse DNS style Java package name that
resides in this project.
@end defvr
@defvr {Java project} JAVA_FILES
@code{xxx_JAVA_FILES} is the list of Java source code files, with a
@file{.java} extension, that are compiled for the @strong{xxx} project.
@strong{xxx} should be replaced with the name of the Java package
specified in @code{JAVA_PACKAGE_NAME}.
@end defvr
@defvr {Java project} JAVA_JNI_FILES
@code{xxx_JAVA_JNI_FILES} is the list of Java source code files for
which @code{javah} should produce header files for integration with
Objective-C code.
@strong{xxx} should be replaced with the name of the Java package
specified in @code{JAVA_PACKAGE_NAME}.
@end defvr
@defvr {Java project} JAVA_PROPERTIES_FILES
@code{xxx_JAVA_PROPERTIES_FILES} can be used to specify properties files
to install.
@strong{xxx} should be replaced with the name of the Java package
specified in @code{JAVA_PACKAGE_NAME}.
@end defvr
@defvr {Java project} JAVA_MANIFEST_FILE
@code{xxx_JAVA_MANIFEST_FILE} can be used to specify a manifest fragment
that is used when building a jar file for the @strong{xxx} package.
@strong{xxx} should be replaced with the name of the Java package
specified in @code{JAVA_PACKAGE_NAME}.
@end defvr
@defvr {Java project} JAVA_JAR_NAME
@code{xxx_JAVA_JAR_NAME} can be used to specify a custom name for the jar
built by @code{make jar}. The default would be the package name (@strong{xxx})
with all dots replaced by hyphens.
@end defvr
@node library.make, native-library.make, java.make, Project Types
@subsection Libraries (@file{library.make})
@menu

View file

@ -64,12 +64,27 @@ shared-instance-java-all \
shared-instance-java-install \
shared-instance-java-install-dirs \
shared-instance-java-uninstall \
shared-instance-java-jar \
shared-instance-java-clean
shared-instance-java-all: $(JAVA_OBJ_FILES) \
$(JAVA_JNI_OBJ_FILES) \
$(SUBPROJECT_OBJ_FILES)
ifeq ($(strip $($(GNUSTEP_INSTANCE)_JAVA_JAR_NAME)),)
JAVA_JAR_FILE = $(subst .,-,$(GNUSTEP_INSTANCE)).jar
else
JAVA_JAR_FILE = $($(GNUSTEP_INSTANCE)_JAVA_JAR_NAME).jar
endif
JAVA_MANIFEST_FILE = $($(GNUSTEP_INSTANCE)_JAVA_MANIFEST_FILE)
ifeq ($(strip $(JAVA_MANIFEST_FILE)),)
JAVA_JAR_FLAGS = cf
else
JAVA_JAR_FLAGS = cmf
endif
# By default, we enable "batch compilation" of Java files. This means
# that whenever make determines that a Java files needs recompilation,
# the command that recompiles that files will actually recompile all
@ -124,6 +139,19 @@ ADDITIONAL_JAVA_OBJ_FILES = $(subst $$,\$$,$(UNESCAPED_ADD_JAVA_OBJ_FILES))
JAVA_PROPERTIES_FILES = $($(GNUSTEP_INSTANCE)_JAVA_PROPERTIES_FILES)
$(JAVA_JAR_FILE): $(JAVA_MANIFEST_FILE) \
$(JAVA_OBJ_FILES) \
$(ADDITIONAL_JAVA_OBJ_FILES) \
$(JAVA_PROPERTIES_FILES)
$(ECHO_CREATING_JAR_FILE)$(JAR) $(JAVA_JAR_FLAGS) $(JAVA_MANIFEST_FILE) \
$(JAVA_JAR_FILE) $(filter-out $(JAVA_MANIFEST_FILE),$^);\
$(END_ECHO)
shared-instance-java-jar-manifest: $(JAVA_JAR_MANIFEST_FILE)
shared-instance-java-jar: $(JAVA_JAR_FILE)
shared-instance-java-install: shared-instance-java-install-dirs
ifneq ($(JAVA_OBJ_FILES),)
$(ECHO_INSTALLING_CLASS_FILES)for file in $(JAVA_OBJ_FILES) __done; do \
@ -162,6 +190,7 @@ $(GNUSTEP_SHARED_JAVA_INSTALLATION_DIR):
shared-instance-java-clean:
$(ECHO_NOTHING)rm -f $(JAVA_OBJ_FILES) \
$(ADDITIONAL_JAVA_OBJ_FILES) \
$(JAVA_JAR_FILE) \
$(JAVA_JNI_OBJ_FILES)$(END_ECHO)
shared-instance-java-uninstall:

View file

@ -58,6 +58,7 @@ endif
# xxx_JAVA_PROPERTIES_FILES
.PHONY: internal-java_package-all_ \
internal-java_package-jar \
internal-java_package-clean \
internal-java_package-distclean \
internal-java_package-install_ \
@ -86,6 +87,8 @@ include $(GNUSTEP_MAKEFILES)/Instance/Shared/java.make
internal-java_package-all_:: shared-instance-java-all
internal-java_package-jar:: shared-instance-java-jar
internal-java_package-install_:: shared-instance-java-install
internal-java_package-clean:: shared-instance-java-clean

View file

@ -38,6 +38,8 @@
internal-precompile-headers \
before-$(GNUSTEP_INSTANCE)-all after-$(GNUSTEP_INSTANCE)-all \
internal-$(GNUSTEP_TYPE)-all \
before-$(GNUSTEP_INSTANCE)-jar after-$(GNUSTEP_INSTANCE)-jar \
internal-$(GNUSTEP_TYPE)-jar \
before-$(GNUSTEP_INSTANCE)-install after-$(GNUSTEP_INSTANCE)-install \
internal-$(GNUSTEP_TYPE)-install \
before-$(GNUSTEP_INSTANCE)-uninstall after-$(GNUSTEP_INSTANCE)-uninstall \
@ -86,7 +88,6 @@ internal-$(GNUSTEP_TYPE)-all:: internal-precompile-headers \
internal-$(GNUSTEP_TYPE)-all_ \
after-$(GNUSTEP_INSTANCE)-all \
internal-$(GNUSTEP_TYPE)-copy_into_dir
# To copy into a dir, we always have to first make sure the dir exists :-)
$(COPY_INTO_DIR):
$(ECHO_CREATING)$(MKDIRS) $@$(END_ECHO)
@ -95,6 +96,10 @@ $(COPY_INTO_DIR):
internal-$(GNUSTEP_TYPE)-copy_into_dir:: $(COPY_INTO_DIR)
endif
before-$(GNUSTEP_INSTANCE)-jar::
after-$(GNUSTEP_INSTANCE)-jar::
before-$(GNUSTEP_INSTANCE)-install::
after-$(GNUSTEP_INSTANCE)-install::

View file

@ -26,11 +26,14 @@ endif
JAVA_PACKAGE_NAME := $(strip $(JAVA_PACKAGE_NAME))
# Parallel building here is probably of little help since most
# GNUmakefiles will have a single java package. There is no point in
# having more than one.
internal-all:: $(JAVA_PACKAGE_NAME:=.all.java-package.variables)
internal-jar:: $(JAVA_PACKAGE_NAME:=.jar.java-package.variables)
internal-install:: $(JAVA_PACKAGE_NAME:=.install.java-package.variables)
internal-uninstall:: $(JAVA_PACKAGE_NAME:=.uninstall.java-package.variables)

View file

@ -53,10 +53,15 @@ all:: before-all internal-all after-all
else
all:: $(GNUSTEP_BUILD_DIR) before-all internal-all after-all
$(GNUSTEP_BUILD_DIR):
$(ECHO_CREATING)$(MKDIRS) $(GNUSTEP_BUILD_DIR)$(END_ECHO)
endif
jar:: all before-jar internal-jar after-jar
# The rule to create the objects file directory. This should be done
# in the Master invocation before any parallel stuff is started (to
# avoid race conditions in trying to create it).
@ -115,6 +120,13 @@ internal-all::
after-all::
before-jar::
internal-jar::
after-jar::
ifneq ($(GNUSTEP_INSTALLATION_DIR),)
internal-check-install-permissions:
@if [ -d "$(GNUSTEP_INSTALLATION_DIR)" \
@ -190,6 +202,7 @@ after-strings::
.PHONY: \
all before-all internal-all after-all \
jar before-jar internal-jar after-jar \
install before-install internal-install after-install \
internal-after-install \
uninstall before-uninstall internal-uninstall after-uninstall \

View file

@ -800,6 +800,12 @@ ifeq ($(JAVAH),)
endif
#
# The java jar tool.
#
ifeq ($(JAR),)
JAR = $(JAVA_HOME)/bin/jar
endif
# Common variables - default values
#
# Because this file is included at the beginning of the user's

View file

@ -78,7 +78,7 @@ ifneq ($(messages),yes)
ECHO_INSTALLING_CLASS_FILES = @(echo " Installing class files...";
ECHO_INSTALLING_ADD_CLASS_FILES = @(echo " Installing nested class files...";
ECHO_INSTALLING_PROPERTIES_FILES = @(echo " Installing property files...";
ECHO_CREATING_JAR_FILE = @(echo " Creating jar file...";
# Instance/Shared/stamp-string.make
ECHO_CREATING_STAMP_FILE = @(echo " Creating stamp file...";
@ -118,7 +118,7 @@ else
ECHO_UNINSTALLING =
ECHO_COPYING_INTO_DIR =
ECHO_CREATING =
ECHO_NOTHING =
ECHO_NOTHING =
ECHO_UPDATING_VERSION_SYMLINK =
@ -140,7 +140,7 @@ else
ECHO_INSTALLING_CLASS_FILES =
ECHO_INSTALLING_ADD_CLASS_FILES =
ECHO_INSTALLING_PROPERTIES_FILES =
ECHO_CREATING_JAR_FILE =
ECHO_CREATING_STAMP_FILE =
ECHO_MAKING_STRINGS =