Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
109 additions
and
216 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
bin/* | ||
_build/* | ||
**/.merlin |
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
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
(jbuild_version 1) | ||
(library | ||
((name ppx) | ||
(libraries (compiler-libs.common ocaml-migrate-parsetree ppx_tools_versioned)) | ||
(kind ppx_rewriter) | ||
(ppx_runtime_libraries (java)) | ||
(preprocess (pps (ppx_tools_versioned.metaquot_406))) | ||
(flags (:standard -open Migrate_parsetree -open Ast_406)))) |
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
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,11 @@ | ||
let () = | ||
let w file_name fmt = | ||
Printf.kfprintf close_out (open_out file_name) fmt | ||
in | ||
match Sys.getenv "JAVA_HOME" with | ||
| exception Not_found -> | ||
failwith "Environment variable JAVA_HOME is not set." | ||
| java_home -> | ||
w "c_flags.sexp" "(-I \"%s/include\" -I \"%s/include/linux\")" java_home java_home; | ||
let lpath = java_home ^ "/jre/lib/amd64/server" in | ||
w "c_library_flags.sexp" "(-dllpath \"%s/libjvm.so\" \"-L%s\")" lpath lpath |
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,2 @@ | ||
(jbuild_version 1) | ||
(executable ((name discover))) |
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,11 @@ | ||
(jbuild_version 1) | ||
(library | ||
((name stubs) | ||
(c_names (classes java_stubs string_convertions caml)) | ||
(c_flags (:standard (:include c_flags.sexp) -DTARGET_CAMLJAVA)) | ||
(c_library_flags (:standard (:include c_library_flags.sexp) -ljvm)))) | ||
|
||
(rule | ||
((targets (c_flags.sexp c_library_flags.sexp)) | ||
(deps (config/discover.exe)) | ||
(action (run ${<})))) |
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,24 @@ | ||
BUILD_DIR = bin | ||
|
||
JAVAC = javac | ||
|
||
JAVA_FILES = $(wildcard juloo/javacaml/*.java) | ||
CLASS_FILES_REL = $(JAVA_FILES:%.java=%.class) | ||
CLASS_FILES = $(addprefix $(BUILD_DIR)/,$(CLASS_FILES_REL)) | ||
|
||
all: $(BUILD_DIR)/ocaml-java.jar | ||
|
||
$(BUILD_DIR)/ocaml-java.jar: $(CLASS_FILES) | $(BUILD_DIR) | ||
cd $(@D); jar cf $(@F) $(CLASS_FILES_REL) | ||
|
||
$(BUILD_DIR)/%.class: %.java | $(BUILD_DIR) | ||
$(JAVAC) -sourcepath . -d $(BUILD_DIR) $< | ||
|
||
$(BUILD_DIR): | ||
mkdir -p $@ | ||
|
||
clean: | ||
rm -f $(BUILD_DIR)/ocaml-java.jar | ||
rm -f $(CLASS_FILES) | ||
|
||
.PHONY: all clean |
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,4 @@ | ||
(jbuild_version 1) | ||
(rule ((targets (ocaml-java.jar)) | ||
(deps (Makefile (glob_files juloo/javacaml/*.java))) | ||
(action (run make BUILD_DIR=. ${@})))) |
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,5 @@ | ||
(jbuild_version 1) | ||
(library | ||
((name java) | ||
(wrapped false) | ||
(libraries (stubs)))) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,49 +1,3 @@ | ||
# - | ||
|
||
OCAMLJAVA_DIR = .. | ||
|
||
OCAMLJAVA_JAR = $(OCAMLJAVA_DIR)/bin/ocaml-java.jar | ||
|
||
ML_FILES := test_caml.ml test_java.ml test_ppx.ml test.ml | ||
|
||
run: camljava javacaml | ||
|
||
camljava: test_camljava test_javacaml.jar | ||
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/amd64/server \ | ||
OCAMLRUNPARAM=b \ | ||
./test_camljava | ||
|
||
test_camljava: $(ML_FILES) | libs | ||
ocamlopt \ | ||
-ppx $(OCAMLJAVA_DIR)/bin/ocaml-java-ppx \ | ||
-I $(OCAMLJAVA_DIR)/bin/camljava camljava.cmxa \ | ||
unix.cmxa -g -o $@ $^ | ||
|
||
javacaml: libtest_javacaml.so test_javacaml.jar | ||
CP=test_javacaml.jar:$(OCAMLJAVA_JAR); \ | ||
LD_LIBRARY_PATH=. java -ea -cp "$$CP" ocamljava.test.TestJava | ||
|
||
libtest_javacaml.so: $(ML_FILES) | libs | ||
ocamlfind ocamlopt -linkpkg -output-obj \ | ||
-ppx $(OCAMLJAVA_DIR)/bin/ocaml-java-ppx \ | ||
-runtime-variant _pic \ | ||
-ccopt "-shared" \ | ||
-I $(OCAMLJAVA_DIR)/bin/javacaml javacaml.cmxa \ | ||
unix.cmxa -I . -g -o $@ $^ | ||
|
||
test_javacaml.jar: $(wildcard ocamljava/test/*.java) | ||
javac -encoding UTF8 -cp $(OCAMLJAVA_JAR) $^ | ||
javac -encoding UTF8 -cp "$(CLASS_PATH)" $^ | ||
jar cf $@ ocamljava/test/*.class | ||
|
||
libs: | ||
make -C $(OCAMLJAVA_DIR) | ||
|
||
clean: | ||
rm -f $(wildcard *.o *.cmo *.cmi *.cmx ocamljava/test/*.class) | ||
rm -f test_camljava libtest_javacaml.so test_javacaml.jar | ||
make -C $(OCAMLJAVA_DIR) clean | ||
|
||
re: clean | ||
make run | ||
|
||
.PHONY: run camljava javacaml libs clean re |
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,14 @@ | ||
(jbuild_version 1) | ||
(executable | ||
((name test) | ||
(libraries (java unix)) | ||
(preprocess (pps (ppx))))) | ||
|
||
(alias | ||
((name runtest) | ||
(deps (../srcs/java/ocaml-java.jar test_javacaml.jar)) | ||
(action (run ${exe:test.exe} ${^})))) | ||
|
||
(rule ((targets (test_javacaml.jar)) | ||
(deps (Makefile (glob_files ocamljava/test/*.java))) | ||
(action (run make CLASS_PATH=${path:../srcs/java/ocaml-java.jar} ${@})))) |
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 |
---|---|---|
@@ -1,25 +1,24 @@ | ||
let jar_files = [ | ||
"test_javacaml.jar"; | ||
"../bin/ocaml-java.jar" | ||
] | ||
|
||
let () = Printexc.record_backtrace true | ||
let run () = | ||
let class_path = match Array.to_list Sys.argv with | ||
| _ :: (_ :: _ as cp) -> String.concat ":" cp | ||
| _ -> failwith "Missing argument: class path" | ||
in | ||
Java.init [| | ||
"-Djava.class.path=" ^ class_path; | ||
"-ea"; | ||
"-Xcheck:jni" | ||
|]; | ||
try | ||
for i = 0 to 10 do | ||
Test_caml.run (); | ||
Test_java.run (); | ||
Test_ppx.run () | ||
done | ||
with Java.Exception e -> | ||
Jthrowable.print_stack_trace e; | ||
failwith "" | ||
|
||
let () = | ||
(* quick check if executed from javacaml's tests *) | ||
if Sys.argv.(0) <> "" then begin | ||
Java.init [| | ||
"-Djava.class.path=" ^ String.concat ":" jar_files; | ||
"-ea"; | ||
"-Xcheck:jni" | ||
|]; | ||
try | ||
for i = 0 to 10 do | ||
Test_caml.run (); | ||
Test_java.run (); | ||
Test_ppx.run () | ||
done | ||
with Java.Exception e -> | ||
Jthrowable.print_stack_trace e; | ||
failwith "" | ||
end | ||
Printexc.record_backtrace true; | ||
(* quick check if executed from java *) | ||
(if Sys.argv.(0) <> "" then run ()) |