Skip to content

Commit

Permalink
Clean a bit the native build part
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 26, 2020
1 parent 3ac28bb commit 71b5164
Show file tree
Hide file tree
Showing 27 changed files with 196 additions and 527 deletions.
97 changes: 29 additions & 68 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,52 +1,29 @@

include Makefile.common

RESOURCE_DIR = src/main/resources

.phony: all package native native-all deploy

all: jni-header package

deploy:
mvn package deploy -DperformRelease=true
all: package

MVN:=mvn
SRC:=src/main/native
JANSI_OUT:=$(TARGET)/native-$(OS_NAME)-$(OS_ARCH)
JANSI_OUT:=target/native-$(OS_NAME)-$(OS_ARCH)

CCFLAGS:= -I$(JANSI_OUT) $(CCFLAGS)

$(JANSI_ARCHIVE):
# @mkdir -p $(@D)
# curl -L --max-redirs 0 -f -o$@ https://www.JANSI.org/2020/$(JANSI_AMAL_PREFIX).zip || \
# curl -L --max-redirs 0 -f -o$@ https://www.JANSI.org/$(JANSI_AMAL_PREFIX).zip || \
# curl -L --max-redirs 0 -f -o$@ https://www.JANSI.org/$(JANSI_OLD_AMAL_PREFIX).zip

$(JANSI_UNPACKED): $(JANSI_ARCHIVE)
# unzip -qo $< -d $(TARGET)/tmp.$(version)
# (mv $(TARGET)/tmp.$(version)/$(JANSI_AMAL_PREFIX) $(TARGET) && rmdir $(TARGET)/tmp.$(version)) || mv $(TARGET)/tmp.$(version)/ $(TARGET)/$(JANSI_AMAL_PREFIX)
# touch $@


test:
mvn test

clean: clean-native clean-java clean-tests

jni-header:
clean-native:
rm -rf $(JANSI_OUT)

$(JANSI_OUT)/%.o: $(SRC)/%.c
$(JANSI_OUT)/%.o: src/main/native/%.c
@mkdir -p $(@D)
$(info running: $(CC) $(CCFLAGS) -c $< -o $@)
$(CC) $(CCFLAGS) -c $< -o $@

$(JANSI_OUT)/$(LIBNAME): $(JANSI_OUT)/hawtjni.o $(JANSI_OUT)/jansi.o $(JANSI_OUT)/jansi_isatty.o $(JANSI_OUT)/jansi_structs.o $(JANSI_OUT)/jansi_ttyname.o
$(JANSI_OUT)/$(LIBNAME): $(JANSI_OUT)/jansi.o $(JANSI_OUT)/jansi_isatty.o $(JANSI_OUT)/jansi_structs.o $(JANSI_OUT)/jansi_ttyname.o
@mkdir -p $(@D)
$(CC) $(CCFLAGS) -o $@ $(JANSI_OUT)/hawtjni.o $(JANSI_OUT)/jansi.o $(JANSI_OUT)/jansi_isatty.o $(JANSI_OUT)/jansi_structs.o $(JANSI_OUT)/jansi_ttyname.o $(LINKFLAGS)
$(STRIP) $@
$(CC) $(CCFLAGS) -o $@ $(JANSI_OUT)/jansi.o $(JANSI_OUT)/jansi_isatty.o $(JANSI_OUT)/jansi_structs.o $(JANSI_OUT)/jansi_ttyname.o $(LINKFLAGS)

NATIVE_DIR=src/main/resources/org/fusesource/jansi/internal/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_TARGET_DIR:=$(TARGET)/classes/org/fusesource/jansi/internal/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_TARGET_DIR:=target/classes/org/fusesource/jansi/internal/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)

# For cross-compilation, install docker. See also https://github.com/dockcross/dockcross
Expand All @@ -62,60 +39,44 @@ $(NATIVE_DLL): $(JANSI_OUT)/$(LIBNAME)
@mkdir -p $(NATIVE_TARGET_DIR)
cp $< $(NATIVE_TARGET_DIR)/$(LIBNAME)

DOCKER_RUN_OPTS=--rm

linux-x86: $(JANSI_UNPACKED) jni-header
linux-x86:
./docker/dockcross-linux-x86 bash -c 'make clean-native native OS_NAME=Linux OS_ARCH=x86'

linux-x86_64: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-linux-gnu multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=x86_64
linux-x86_64:
docker run -it --rm -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-linux-gnu multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=x86_64

linux-arm: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=arm-linux-gnueabi multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=arm
linux-arm:
docker run -it --rm -v $$PWD:/workdir -e CROSS_TRIPLE=arm-linux-gnueabi multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=arm

linux-armv7: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=arm-linux-gnueabihf multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=armv7
linux-armv7:
docker run -it --rm -v $$PWD:/workdir -e CROSS_TRIPLE=arm-linux-gnueabihf multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=armv7

linux-arm64: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=aarch64-linux-gnu multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=arm64
linux-arm64:
docker run -it --rm -v $$PWD:/workdir -e CROSS_TRIPLE=aarch64-linux-gnu multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=arm64

linux-ppc64: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=powerpc64le-linux-gnu multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=ppc64
linux-ppc64:
docker run -it --rm -v $$PWD:/workdir -e CROSS_TRIPLE=powerpc64le-linux-gnu multiarch/crossbuild make clean-native native OS_NAME=Linux OS_ARCH=ppc64

win-x86: $(JANSI_UNPACKED) jni-header
win-x86:
./docker/dockcross-windows-static-x86 bash -c 'make clean-native native CROSS_PREFIX=i686-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86'

win-x86_64: $(JANSI_UNPACKED) jni-header
win-x86_64:
./docker/dockcross-windows-static-x64 bash -c 'make clean-native native CROSS_PREFIX=x86_64-w64-mingw32.static- OS_NAME=Windows OS_ARCH=x86_64'

mac-x86: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=i386-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86
mac-x86:
docker run -it --rm -v $$PWD:/workdir -e CROSS_TRIPLE=i386-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86

mac-x86_64: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86_64
mac-x86_64:
docker run -it --rm -v $$PWD:/workdir -e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild make clean-native native OS_NAME=Mac OS_ARCH=x86_64

freebsd-x86: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/build empterdose/freebsd-cross-build:9.3 make -C /build clean-native native CROSS_PREFIX=i386-freebsd9- OS_NAME=FreeBSD OS_ARCH=x86
freebsd-x86:
docker run -it --rm -v $$PWD:/build empterdose/freebsd-cross-build:9.3 make -C /build clean-native native CROSS_PREFIX=i386-freebsd9- OS_NAME=FreeBSD OS_ARCH=x86

freebsd-x86_64: $(JANSI_UNPACKED) jni-header
docker run -it $(DOCKER_RUN_OPTS) -v $$PWD:/build empterdose/freebsd-cross-build:9.3 make -C /build clean-native native CROSS_PREFIX=x86_64-freebsd9- OS_NAME=FreeBSD OS_ARCH=x86_64
freebsd-x86_64:
docker run -it --rm -v $$PWD:/build empterdose/freebsd-cross-build:9.3 make -C /build clean-native native CROSS_PREFIX=x86_64-freebsd9- OS_NAME=FreeBSD OS_ARCH=x86_64

#sparcv9:
# $(MAKE) native OS_NAME=SunOS OS_ARCH=sparcv9


package: native-all
rm -rf target/dependency-maven-plugin-markers
$(MVN) package

clean-native:
rm -rf $(JANSI_OUT)

clean-java:
rm -rf $(TARGET)/*classes
rm -rf $(TARGET)/common-lib/*
rm -rf $(TARGET)/JANSI-jdbc-*jar

clean-tests:
rm -rf $(TARGET)/{surefire*,testdb.jar*}

50 changes: 0 additions & 50 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
ifndef JAVA_HOME
$(warning Set JAVA_HOME environment variable)
endif

JAVA := "$$JAVA_HOME/bin/java"
JAVAC := "$$JAVA_HOME/bin/javac"
JAVAH := "$$JAVA_HOME/bin/javah"

TARGET := target

# building OSInfo.java
#$(info compiling OSInfo.java)
#$(shell mkdir -p target/lib)
#$(shell $(JAVAC) lib/OSInfo.java -d target/lib)

#ifndef OS_NAME
#OS_NAME := $(shell $(JAVA) -cp target/lib org.fusesource.jansi.OSInfo --os)
#endif
#ifndef OS_ARCH
#OS_ARCH := $(shell $(JAVA) -cp target/lib org.fusesource.jansi.OSInfo --arch)
#endif

# Windows uses different path separators
ifeq ($(OS_NAME),Windows)
sep := ;
else
sep := :
endif

jansi := jansi-native-$(version)

ifdef JAVA_HOME
jni_h := $(shell find -L "$(JAVA_HOME)" -name jni.h)
ifneq ($(jni_h),)
jni_include := $(shell dirname "$(jni_h)")
endif

jni_md := $(shell find -L "$(JAVA_HOME)" -name jni_md.h)
ifneq ($(jni_md),)
jni_md_include := $(shell dirname "$(jni_md)")
endif
endif

# os=Default is meant to be generic unix/linux

known_targets := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-ppc64 Mac-x86 Mac-x86_64 DragonFly-x86_64 FreeBSD-x86_64 OpenBSD-x86_64 Windows-x86 Windows-x86_64 SunOS-sparcv9 HPUX-ia64_32
Expand Down Expand Up @@ -190,10 +147,3 @@ CCFLAGS := $($(target)_CCFLAGS)
LINKFLAGS := $($(target)_LINKFLAGS)
LIBNAME := $($(target)_LIBNAME)
CCFLAGS := $(CCFLAGS)
ifneq ($(jni_include),)
CCFLAGS := $(CCFLAGS) -I"$(jni_include)"
endif
ifneq ($(jni_md_include),)
CCFLAGS := $(CCFLAGS) -I"$(jni_md_include)"
endif
$(info CCFLAGS=$(CCFLAGS))
32 changes: 0 additions & 32 deletions src/main/native/hawtjni.c

This file was deleted.

136 changes: 0 additions & 136 deletions src/main/native/hawtjni.h

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 71b5164

Please sign in to comment.