<commit_before>
.SUFFIXES: .java .class

ifeq ($(NEOTONIC_ROOT),)
NEOTONIC_ROOT = ..
endif

include $(NEOTONIC_ROOT)/rules.mk

NEO_UTIL_SO = libclearsilver-jni.so
ifeq ($(OSTYPE),Darwin)
NEO_UTIL_SO = libclearsilver-jni.jnilib
endif
NEO_UTIL_JAVA_SRC = HDF.java CS.java CSUtil.java CSFileLoader.java # CGI.java
NEO_UTIL_JAVA_CLASS = $(NEO_UTIL_JAVA_SRC:%.java=%)
NEO_UTIL_JAVA_CLASSFILES = $(NEO_UTIL_JAVA_SRC:%.java=%.class)
NEO_UTIL_JAVA_JAR = clearsilver.jar
NEO_UTIL_SRC = j_neo_util.c j_neo_cs.c
NEO_UTIL_OBJ = $(NEO_UTIL_SRC:%.c=%.o)


CFLAGS += $(JAVA_INCLUDE_PATH)
DLIBS += -lneo_cgi -lneo_cs -lneo_utl
LIBS += $(DLIBS)
ifneq ($(OSTYPE),Darwin)
LDFLAGS += -Wl,-soname=$(NEO_UTIL_SO)
endif

TARGETS = org_clearsilver_HDF.h org_clearsilver_CS.h $(NEO_UTIL_SO)

all: $(TARGETS) test

$(NEO_UTIL_JAVA_JAR): $(NEO_UTIL_JAVA_SRC)
	$(JAVAC) $(NEO_UTIL_JAVA_SRC)
	$(MKDIR) org/clearsilver
	cp $(NEO_UTIL_JAVA_CLASSFILES) org/clearsilver
	$(JAR) cf $(NEO_UTIL_JAVA_JAR) org
	$(RM) -r org

org_clearsilver_HDF.h: $(NEO_UTIL_JAVA_JAR)
	$(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.HDF

org_clearsilver_CS.h: $(NEO_UTIL_JAVA_JAR)
	$(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.CS

CSTest.class: CSTest.java
	$(JAVAC) -classpath $(NEO_UTIL_JAVA_JAR) CSTest.java

gold: CSTest.class
	@/bin/sh -c "LD_LIBRARY_PATH=$(NEOTONIC_ROOT)/java-jni; export LD_LIBRARY_PATH; CLASSPATH=$(NEO_UTIL_JAVA_JAR):.; export CLASSPATH; $(JAVA_PATH)/bin/java CSTest" > javatest.gold
	@echo "Generated gold files"

test: CSTest.class
	@echo "Running java test"
	@failed=0; \
	rm -f javatest.out; \
	LD_LIBRARY_PATH=$(NEOTONIC_ROOT)/java-jni; export LD_LIBRARY_PATH; \
	CLASSPATH=$(NEO_UTIL_JAVA_JAR):.; export CLASSPATH; \
	$(JAVA_PATH)/bin/java CSTest > javatest.out; \
	diff javatest.out javatest.gold  > /dev/null 2>&1; \
	return_code=$$?; \
	if [ $$return_code -ne 0 ]; then \
	  diff javatest.out javatest.gold > javatest.err; \
	  echo "Failed Java Test: CSTest"; \
	  echo "    See javatest.out and javatest.err"; \
	  failed=1; \
	fi; \<commit_msg>Reduced chance of ClearSilver JNI wrappers causing JVM to exit. <commit_after>
.SUFFIXES: .java .class

ifeq ($(NEOTONIC_ROOT),)
NEOTONIC_ROOT = ..
endif

include $(NEOTONIC_ROOT)/rules.mk

NEO_UTIL_SO = libclearsilver-jni.so
ifeq ($(OSTYPE),Darwin)
NEO_UTIL_SO = libclearsilver-jni.jnilib
endif
NEO_UTIL_JAVA_SRC = HDF.java CS.java CSUtil.java CSFileLoader.java JNI.java # CGI.java

NEO_UTIL_JAVA_JAR = clearsilver.jar
NEO_UTIL_SRC = j_neo_util.c j_neo_cs.c
NEO_UTIL_OBJ = $(NEO_UTIL_SRC:%.c=%.o)

CFLAGS += $(JAVA_INCLUDE_PATH)
DLIBS += -lneo_cgi -lneo_cs -lneo_utl
LIBS += $(DLIBS)
ifneq ($(OSTYPE),Darwin)
LDFLAGS += -Wl,-soname=$(NEO_UTIL_SO)
endif

TARGETS = org_clearsilver_HDF.h org_clearsilver_CS.h $(NEO_UTIL_SO)

all: $(TARGETS) test

$(NEO_UTIL_JAVA_JAR): $(NEO_UTIL_JAVA_SRC)
	$(MKDIR) org/clearsilver
	$(JAVAC) -d . $(NEO_UTIL_JAVA_SRC)
	$(JAR) cf $(NEO_UTIL_JAVA_JAR) org
	$(RM) -r org

org_clearsilver_HDF.h: $(NEO_UTIL_JAVA_JAR)
	$(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.HDF

org_clearsilver_CS.h: $(NEO_UTIL_JAVA_JAR)
	$(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.CS

CSTest.class: CSTest.java
	$(JAVAC) -classpath $(NEO_UTIL_JAVA_JAR) CSTest.java

gold: CSTest.class
	@/bin/sh -c "LD_LIBRARY_PATH=$(NEOTONIC_ROOT)/java-jni; export LD_LIBRARY_PATH; CLASSPATH=$(NEO_UTIL_JAVA_JAR):.; export CLASSPATH; $(JAVA_PATH)/bin/java CSTest" > javatest.gold
	@echo "Generated gold files"

test: CSTest.class
	@echo "Running java test"
	@failed=0; \
	rm -f javatest.out; \
	LD_LIBRARY_PATH=$(NEOTONIC_ROOT)/java-jni; export LD_LIBRARY_PATH; \
	CLASSPATH=$(NEO_UTIL_JAVA_JAR):.; export CLASSPATH; \
	$(JAVA_PATH)/bin/java CSTest > javatest.out; \
	diff javatest.out javatest.gold  > /dev/null 2>&1; \
	return_code=$$?; \
	if [ $$return_code -ne 0 ]; then \
	  diff javatest.out javatest.gold > javatest.err; \
	  echo "Failed Java Test: CSTest"; \
	  echo "    See javatest.out and javatest.err"; \
	  failed=1; \
	fi; \
{'fraction_non_alphanumeric': 0.1463717693836978, 'fraction_numerical': 0.002485089463220676, 'mean_word_length': 5.117021276595745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7174614', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1913, 'n_words': 311}