dep_rules.add(o)
end
+ var java_files = new Array[ExternFile]
+
# Compile each required extern body into a specific .o
for f in compiler.extern_bodies do
var o = f.makefile_rule_name
makefile.write("{o}: {ff}\n")
makefile.write("\t{f.makefile_rule_content}\n\n")
dep_rules.add(f.makefile_rule_name)
- ofiles.add(o)
+
+ if f.compiles_to_o_file then ofiles.add(o)
+ if f.add_to_jar then java_files.add(f)
+ end
+
+ if not java_files.is_empty then
+ var jar_file = "{outpath}.jar"
+
+ var class_files_array = new Array[String]
+ for f in java_files do class_files_array.add(f.makefile_rule_name)
+ var class_files = class_files_array.join(" ")
+
+ makefile.write("{jar_file}: {class_files}\n")
+ makefile.write("\tjar cf {jar_file} {class_files}\n\n")
+ dep_rules.add jar_file
end
# Link edition
# The content of the rule in the make
# Usually the one-line shell command after the tabulation
fun makefile_rule_content: String is abstract
+
+ fun compiles_to_o_file: Bool do return false
+
+ fun add_to_jar: Bool do return false
end
# An extern C file to compile
var o = makefile_rule_name
return "$(CC) $(CFLAGS) {self.cflags} -c -o {o} {ff}"
end
+
+ redef fun compiles_to_o_file do return true
end
redef fun makefile_rule_name do return "{filename.basename("")}.o"
redef fun makefile_rule_content do return "g++ {mmodule.cpp_compiler_options} -c {filename.basename("")} -o {filename.basename("")}.o"
+ redef fun compiles_to_o_file do return true
end
class ForeignCppType
# Tell the C compiler where to find jni.h and how to link with libjvm
private fun insert_compiler_options
do
- c_compiler_options = "{c_compiler_options} -I $(JAVA_HOME)/include/"
- c_linker_options = "{c_linker_options} -L $(JNI_LIB_PATH) -ljvm"
+ mmodule.c_compiler_options = "{mmodule.c_compiler_options} -I $(JAVA_HOME)/include/"
+ mmodule.c_linker_options = "{mmodule.c_linker_options} -L $(JNI_LIB_PATH) -ljvm"
end
end
redef fun makefile_rule_name do return "{filename.basename(".java")}.class"
redef fun makefile_rule_content do return "javac {filename} -d ."
+ redef fun add_to_jar do return true
end
# Context in pure Java code