Make build files
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 26 Feb 2022 09:54:19 +0000 (10:54 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 26 Feb 2022 09:54:19 +0000 (10:54 +0100)
ecj.args [new file with mode: 0644]
excludes.txt [new file with mode: 0644]
osgi.mk [new file with mode: 0644]

diff --git a/ecj.args b/ecj.args
new file mode 100644 (file)
index 0000000..852a33d
--- /dev/null
+++ b/ecj.args
@@ -0,0 +1,4 @@
+-source 17
+-target 11
+-nowarn
+-time 
\ No newline at end of file
diff --git a/excludes.txt b/excludes.txt
new file mode 100644 (file)
index 0000000..3f5b4e5
--- /dev/null
@@ -0,0 +1,8 @@
+src
+target
+.*
+bnd.bnd
+pom.xml
+build.properties
+bin
+generated
\ No newline at end of file
diff --git a/osgi.mk b/osgi.mk
new file mode 100644 (file)
index 0000000..bf578ef
--- /dev/null
+++ b/osgi.mk
@@ -0,0 +1,68 @@
+
+
+#
+# GENERIC
+#
+JVM := $(JAVA_HOME)/bin/java
+JAVADOC := $(JAVA_HOME)/bin/javadoc
+ECJ_JAR := $(A2_BASE)/org.argeo.tp.sdk/org.eclipse.jdt.core.compiler.batch.3.28.jar
+BND_TOOL := /usr/bin/bnd
+
+BUILD_BASE = $(SDK_BUILD_BASE)/$(A2_CATEGORY)
+
+WORKSPACE_BNDS := $(shell cd $(SDK_SRC_BASE) && find cnf -name '*.bnd')
+BUILD_WORKSPACE_BNDS := $(WORKSPACE_BNDS:%=$(BUILD_BASE)/%)
+
+A2_JARS = $(foreach category, $(DEP_CATEGORIES), $(shell find $(A2_BASE)/$(category) -name '*.jar'))
+A2_CLASSPATH = $(subst $(space),$(pathsep),$(strip $(A2_JARS)))
+
+A2_BUNDLES = $(foreach bundle, $(BUNDLES),$(A2_OUTPUT)/$(A2_CATEGORY)/$(shell basename $(bundle)).$(MAJOR).$(MINOR).jar)
+
+JAVA_SRCS = $(foreach bundle, $(BUNDLES), $(shell find $(bundle) -name '*.java'))
+BNDS = $(foreach bundle, $(BUNDLES), $(BUILD_BASE)/$(shell basename $(bundle))/bnd.bnd)
+ECJ_SRCS = $(foreach bundle, $(BUNDLES), $(bundle)/src[-d $(BUILD_BASE)/$(shell basename $(bundle))/bin])
+
+JAVADOC_SRCS = $(foreach bundle, $(JAVADOC_BUNDLES),$(bundle)/src)
+
+osgi: $(BUILD_WORKSPACE_BNDS) $(A2_BUNDLES)
+
+javadoc: $(BUILD_BASE)/java-compiled
+       $(JAVADOC) -d $(BUILD_BASE)/api --source-path $(subst $(space),$(pathsep),$(strip $(JAVADOC_SRCS))) -subpackages $(JAVADOC_PACKAGES)
+
+
+# SDK level
+$(BUILD_BASE)/cnf/%.bnd: cnf/%.bnd
+       mkdir -p $(dir $@)
+       cp $< $@
+       
+$(A2_OUTPUT)/$(A2_CATEGORY)/%.$(MAJOR).$(MINOR).jar : $(BUILD_BASE)/%.jar
+       mkdir -p $(dir $@)
+       cp $< $@
+
+$(BUILD_BASE)/%.jar: $(BUILD_BASE)/jars-built
+       mv $(basename $@)/generated/*.jar $(basename $@).jar
+
+# Build level
+$(BUILD_BASE)/jars-built: $(BNDS)
+       cd $(BUILD_BASE) && $(BND_TOOL) build
+       touch $@
+
+$(BUILD_BASE)/%/bnd.bnd : %/bnd.bnd $(BUILD_BASE)/java-compiled 
+       mkdir -p $(dir $@)bin
+       rsync -r --exclude "*.java" $(dir  $<)src/ $(dir $@)bin
+       rsync -r --exclude-from $(SDK_SRC_BASE)/sdk/excludes.txt $(dir  $<) $(dir $@)bin
+       if [ -d "$(dir  $<)OSGI-INF" ]; then rsync -r $(dir  $<)OSGI-INF/ $(dir $@)/OSGI-INF; fi
+       cp $< $@
+       echo "\n-sourcepath:$(SDK_SRC_BASE)/$(dir  $<)src\n" >> $@
+
+$(BUILD_BASE)/java-compiled : $(JAVA_SRCS)
+       $(JVM) -jar $(ECJ_JAR) @$(SDK_SRC_BASE)/sdk/ecj.args -cp $(A2_CLASSPATH) $(ECJ_SRCS)
+       touch $@
+
+# Local manifests
+manifests : osgi
+       $(foreach bundle, $(BUNDLES), cp -v $(BUILD_BASE)/$(shell basename $(bundle))/META-INF/MANIFEST.MF  $(bundle)/META-INF/MANIFEST.MF;)
+
+null  :=
+space := $(null) #
+pathsep := :