forked from kgrgreer/foam3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Makefile for a simpler mechanism of building FOAM/nanos
- Loading branch information
Showing
6 changed files
with
434 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FOAM2_HOME ?= . | ||
|
||
foam2_SRC_DIR = src | ||
foam2_CLASSES = tools/classes.js | ||
|
||
# Format for dependencies from maven is | ||
# <groupId>:<artifactId>:<version> | ||
foam2_MAVEN_DEPS = \ | ||
javax.json:javax.json-api:1.0 \ | ||
javax.mail:mail:1.4.7 \ | ||
javax.mail:javax.mail-api:1.5.5 \ | ||
javax.servlet:javax.servlet-api:3.1.0 \ | ||
javax.websocket:javax.websocket-api:1.1 \ | ||
jstl:jstl:1.2 \ | ||
org.apache.commons:commons-text:1.1 \ | ||
org.apache.commons:commons-dbcp2:2.0.1 \ | ||
org.apache.commons:commons-lang3:3.6 \ | ||
commons-io:commons-io:2.6 \ | ||
org.apache-extras.beanshell:bsh:2.0b6 \ | ||
com.google.api-client:google-api-client:1.22.0 \ | ||
org.jtwig:jtwig-core:5.86.1.RELEASE \ | ||
org.mongodb:mongodb-driver:3.4.2 \ | ||
org.mongodb:mongodb-driver-core:3.4.2 \ | ||
org.mongodb:bson:3.4.2 \ | ||
org.postgresql:postgresql:42.0.0 \ | ||
org.java-websocket:Java-WebSocket:1.3.4 \ | ||
com.authy:authy-java:1.1.0 \ | ||
org.bouncycastle:bcpkix-jdk15on:1.57 \ | ||
org.bouncycastle:bcprov-jdk15on:1.57 \ | ||
org.java-websocket:Java-WebSocket:1.3.7 \ | ||
com.google.guava:guava:23.6-jre \ | ||
com.google.appengine:appengine-api-1.0-sdk:1.9.24 | ||
|
||
java_JARS = foam2 | ||
|
||
include build-aux/tools.mk | ||
include build-aux/java.mk | ||
|
||
nanos: nanos.in | ||
sed -e 's,@CLASSPATH[@],$(foam2_CLASSPATH):$(abspath $(foam2_JAR)),g' $< > $@ | ||
chmod +x $@ | ||
|
||
all: nanos | ||
|
||
.PHONY: run | ||
|
||
run: nanos $(foam2_JAR) | ||
./$< --datadir src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
MAVEN_BASE_URL=http://central.maven.org/maven2 | ||
|
||
JAVA_DEP_DIR ?= lib | ||
|
||
.DELETE_ON_ERROR: | ||
|
||
empty := | ||
space := $(empty) $(empty) | ||
#split <string> <separator> | ||
split = $(subst $(2),$(space),$(1)) | ||
|
||
java_dep_version = $(word 3,$(call split,$(1),:)) | ||
java_dep_artifact = $(word 2,$(call split,$(1),:)) | ||
java_dep_group = $(word 1,$(call split,$(1),:)) | ||
java_dep_jar = $(call java_dep_artifact,$(1))-$(call java_dep_version,$(1)).jar | ||
java_dep_sha1 = $(call java_dep_jar,$(1)).sha1 | ||
java_dep_jar_url = $(MAVEN_BASE_URL)/$(subst .,/,$(call java_dep_group,$(1)))/$(call java_dep_artifact,$(1))/$(call java_dep_version,$(1))/$(call java_dep_jar,$(1)) | ||
java_dep_sha1_url = $(MAVEN_BASE_URL)/$(subst .,/,$(call java_dep_group,$(1)))/$(call java_dep_artifact,$(1))/$(call java_dep_version,$(1))/$(call java_dep_sha1,$(1)) | ||
|
||
foam_genjava = $(NODE) $(FOAM2_HOME)/tools/genjava2.js | ||
|
||
define JAVA_MAVEN_LIB_template = | ||
$(2)_JAVA_LIBS += $(JAVA_DEP_DIR)/$(call java_dep_jar,$(1)) | ||
$(JAVA_DEP_DIR)/$(call java_dep_jar,$(1)): | ||
@echo Downloading $(call java_dep_jar,$(1)) | ||
$$(WGET) -O $(JAVA_DEP_DIR)/$(call java_dep_sha1,$(1)) $(call java_dep_sha1_url,$(1)) | ||
$$(WGET) -O $$@ $(call java_dep_jar_url,$(1)) | ||
@echo Verifying | ||
@if test "$$$$(sha1sum $(JAVA_DEP_DIR)/$(call java_dep_jar,$(1)) | cut -d' ' -f1)" != "$$$$(cat $(JAVA_DEP_DIR)/$(call java_dep_sha1,$(1)))" ; then \ | ||
echo "ERROR: Download did not match sha1 checksum." ; \ | ||
exit 1 ; \ | ||
fi | ||
|
||
|
||
endef | ||
|
||
|
||
define JAVA_JAR_template = | ||
$(1)_CLASSPATH = $$(subst $$(space),:,$$(foreach lib,$$($(1)_JAVA_LIBS),$$(abspath $$(lib)))) | ||
$(1)_JAVA_SRCS ?= $$(shell find $$($(1)_SRC_DIR) -type f -iname '*.java') | ||
$(1)_JS_SRCS ?= $$(shell find $$($(1)_SRC_DIR) -type f -iname '*.js') | ||
$(1)_ALL_SRCS = $$($(1)_JAVA_SRCS) $$($(1)_JS_SRCS) | ||
$(1)_GEN_SRC_DIR = .$(1)-gensrcs | ||
$(1)_BUILD_DIR = .$(1)-build | ||
$(1)_GEN_SRCS = $$(shell find $$($(1)_GEN_SRC_DIR) -type f -iname '*.java') | ||
$(1)_JAR = $$($(1)_BUILD_DIR)/$(1).jar | ||
|
||
.PHONY: $(1)-gensrcs $(1)-java-deps $(1)-list-deps | ||
|
||
all: $(1) | ||
|
||
$(1)-list-deps: | ||
$$(foreach dep,$$($(1)_JAVA_LIBS),$$(info $$(dep))) | ||
|
||
$$($(1)_GEN_SRC_DIR): | ||
$$(MKDIR_P) $$@ | ||
|
||
$$($(1)_BUILD_DIR): | ||
$$(MKDIR_P) $$@ | ||
|
||
$(1)_SRC_HASH:=$$($(1)_GEN_SRC_DIR)/.$$(shell cat $$($(1)_JS_SRCS) $$($(1)_CLASSES) | sha256sum | cut -d" " -f1) | ||
|
||
$$($(1)_JAR): $$($(1)_SRC_HASH) | ||
|
||
$$($(1)_SRC_HASH): | $$($(1)_GEN_SRC_DIR) | ||
find $$($(1)_GEN_SRC_DIR) -type f -iname '*.java' -delete | ||
$$(foam_genjava) $$($(1)_CLASSES) $$($(1)_GEN_SRC_DIR) $$($(1)_SRC_DIR) | ||
touch $$@ | ||
|
||
clean-$(1)-gensrcs: | ||
-rm -rf $$($(1)_GEN_SRC_DIR) | ||
|
||
clean-$(1): | ||
-rm -f $$($(1)_BUILD_DIR)/$(1).jar | ||
|
||
clean: clean-$(1) clean-$(1)-gensrcs | ||
|
||
.PHONY: $(1) | ||
|
||
$(1): $$($(1)_BUILD_DIR)/$(1).jar $(1).classpath.txt | ||
|
||
$(1).classpath.txt: $$($(1)_JAR) | ||
echo $$($(1)_CLASSPATH):$$(abspath $$($(1)_JAR)) > $$@ | ||
|
||
$(foreach dep,$($(1)_MAVEN_DEPS),$(call JAVA_MAVEN_LIB_template,$(dep),$(1))) | ||
|
||
$(1)-java-deps: $$($(1)_JAVA_LIBS) | ||
|
||
clean-$(1)-java-deps: | ||
-rm -f $$($(1)_JAVA_LIBS) | ||
|
||
$$($(1)_JAR): $$($(1)_JAVA_SRCS) $$($(1)_JAVA_LIBS) | $$($(1)_BUILD_DIR) | ||
find $$($(1)_BUILD_DIR) -type f -iname '*.class' -delete | ||
@echo "Compiling..." | ||
@$$(JAVAC) -d $$($(1)_BUILD_DIR) -cp $$($(1)_CLASSPATH) $$($(1)_JAVA_SRCS) $$($(1)_GEN_SRCS) | ||
@echo "Packaging..." | ||
$$(JAR) cvf $$@ -C $$($(1)_BUILD_DIR) . | ||
|
||
.PHONY: run-$(1) | ||
|
||
endef | ||
|
||
$(foreach prog,$(java_JARS),$(eval $(call JAVA_JAR_template,$(prog)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
JAVAC ?= javac | ||
JAVA ?= java | ||
JAR ?= jar | ||
NODE ?= node | ||
WGET ?= wget | ||
MKDIR_P ?= mkdir -p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The Makefile will download dependencies from maven and put them here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
java -cp @CLASSPATH@ foam.nanos.boot.Boot $@ |
Oops, something went wrong.