Skip to content

Commit

Permalink
build(makefile): add slf4j dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Oct 3, 2023
1 parent 77339ed commit 1663cfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ DOCKER_RUN_OPTS=--rm
MVN:=mvn
CODESIGN:=docker run $(DOCKER_RUN_OPTS) -v $$PWD:/workdir gotson/rcodesign sign
SRC:=src/main/java
JAVA_CLASSPATH:=$(TARGET)/classpath/slf4j-api.jar
SQLITE_OUT:=$(TARGET)/$(sqlite)-$(OS_NAME)-$(OS_ARCH)
SQLITE_OBJ?=$(SQLITE_OUT)/sqlite3.o
SQLITE_ARCHIVE:=$(TARGET)/$(sqlite)-amal.zip
Expand Down Expand Up @@ -42,16 +43,19 @@ $(SQLITE_UNPACKED): $(SQLITE_ARCHIVE)
(mv $(TARGET)/tmp.$(version)/$(SQLITE_AMAL_PREFIX) $(TARGET) && rmdir $(TARGET)/tmp.$(version)) || mv $(TARGET)/tmp.$(version)/ $(TARGET)/$(SQLITE_AMAL_PREFIX)
touch $@

$(JAVA_CLASSPATH):
@mkdir -p $(@D)
curl -L -f -o$@ https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar

$(TARGET)/common-lib/org/sqlite/%.class: src/main/java/org/sqlite/%.java
@mkdir -p $(@D)
$(JAVAC) -source 1.6 -target 1.6 -sourcepath $(SRC) -d $(TARGET)/common-lib $<

jni-header: $(TARGET)/common-lib/NativeDB.h

$(TARGET)/common-lib/NativeDB.h: src/main/java/org/sqlite/core/NativeDB.java
$(TARGET)/common-lib/NativeDB.h: src/main/java/org/sqlite/core/NativeDB.java $(JAVA_CLASSPATH)
@mkdir -p $(TARGET)/common-lib
$(JAVAC) -d $(TARGET)/common-lib -sourcepath $(SRC) -h $(TARGET)/common-lib src/main/java/org/sqlite/core/NativeDB.java
$(JAVAC) -cp $(JAVA_CLASSPATH) -d $(TARGET)/common-lib -sourcepath $(SRC) -h $(TARGET)/common-lib src/main/java/org/sqlite/core/NativeDB.java
mv target/common-lib/org_sqlite_core_NativeDB.h target/common-lib/NativeDB.h

test:
Expand Down
12 changes: 8 additions & 4 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ JAVAC := "$$JAVA_HOME/bin/javac"
JAVAH := "$$JAVA_HOME/bin/javah"

TARGET := target
SRC:=src/main/java
OSINFO_CLASS := org.sqlite.util.OSInfo
OSINFO_PROG := lib/org/sqlite/util/OSInfo.class
JAVA_CLASSPATH:=$(TARGET)/classpath/slf4j-api.jar

## building OSInfo.java
ifeq ("$(wildcard $(OSINFO_PROG))","")
$(info Building OSInfo tool)
$(shell $(JAVAC) -cp src/main/java -d lib src/main/java/org/sqlite/util/OSInfo.java)
$(shell mkdir -p $(TARGET)/classpath)
$(shell curl -L -f -o$(JAVA_CLASSPATH) https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar)
$(shell $(JAVAC) -cp $(JAVA_CLASSPATH) -sourcepath $(SRC) -d lib src/main/java/org/sqlite/util/OSInfo.java)
endif

ifndef OS_NAME
OS_NAME := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --os)
OS_NAME := $(shell $(JAVA) -cp lib:$(JAVA_CLASSPATH) $(OSINFO_CLASS) --os)
endif
ifndef OS_ARCH
OS_ARCH := $(shell $(JAVA) -cp lib $(OSINFO_CLASS) --arch)
OS_ARCH := $(shell $(JAVA) -cp lib:$(JAVA_CLASSPATH) $(OSINFO_CLASS) --arch)
endif

# Windows uses different path separators
Expand Down Expand Up @@ -55,7 +59,7 @@ ifeq (,$(findstring $(strip $(target)),$(known_targets)))
target := Default
endif

$(info Will build using target: $(target) (detected os: $(OS_NAME) arch: $(OS_ARCH)))
$(info Will build using target: $(target) (detected os: $(OS_NAME), arch: $(OS_ARCH)))

# cross-compilation toolchain prefix (e.g. "arm-linux-gnueabi-")
CROSS_PREFIX :=
Expand Down

0 comments on commit 1663cfe

Please sign in to comment.