nitni_ccu.write_as_nitni(self, v.compiler.modelbuilder.compile_dir)
for file in nitni_ccu.files do
- var f = new ExternCFile(file, c_compiler_options)
+ var f = new ExternCFile(file, cflags)
f.pkgconfigs.add_all pkgconfigs
v.compiler.extern_bodies.add(f)
end
redef fun collect_linker_libs
do
- var s = c_linker_options
+ var s = ldflags
if s.is_empty then return null
var res = new ArraySet[String]
res.add s
end
redef class MModule
- var c_compiler_options = "" is writable
- var c_linker_options = "" is writable
+ var cflags = "" is writable
+ var ldflags = "" is writable
# Additional libraries needed for the compilation
# Will be used with pkg-config
# See the License for the specific language governing permissions and
# limitations under the License.
-# Offers the annotations `c_compiler_option` and `c_linker_option` to specify
+# Offers the annotations `cflags` and `ldflags` to specify
# options for the C compiler directly or indirectly. Differs from the `pkgconfig`
# annotation by the separation of the options between the compiler and linker.
module c_compiler_options
private import annotation
redef class ToolContext
- var c_compiler_options_phase: Phase = new CCompilerOptionsPhase(self, null)
+ var cflags_phase: Phase = new CCompilerOptionsPhase(self, null)
end
private class CCompilerOptionsPhase
super Phase
- fun compiler_annotation_name: String do return "c_compiler_option"
- fun linker_annotation_name: String do return "c_linker_option"
- fun cpp_compiler_annotation_name: String do return "cpp_compiler_option"
+ fun compiler_annotation_name: String do return "cflags"
+ fun linker_annotation_name: String do return "ldflags"
+ fun cpp_compiler_annotation_name: String do return "cppflags"
redef fun process_annotated_node(nmoduledecl, nat)
do
fun process_c_compiler_annotation(mmodule: MModule, opt: String)
do
- mmodule.c_compiler_options = "{mmodule.c_compiler_options} {opt}"
+ mmodule.cflags = "{mmodule.cflags} {opt}"
end
fun process_c_linker_annotation(mmodule: MModule, opt: String)
do
- mmodule.c_linker_options = "{mmodule.c_linker_options} {opt}"
+ mmodule.ldflags = "{mmodule.ldflags} {opt}"
end
fun process_cpp_compiler_annotation(mmodule: MModule, opt: String)
do
- mmodule.cpp_compiler_options = "{mmodule.cpp_compiler_options} {opt}"
+ mmodule.cppflags = "{mmodule.cppflags} {opt}"
end
end
redef class MModule
private var cpp_file: nullable CPPCompilationUnit = null
- var cpp_compiler_options = "" is writable
+ var cppflags = "" is writable
end
class CPPLanguage
mmodule.ffi_files.add(file)
# add linked option to support C++
- mmodule.c_linker_options = "{mmodule.c_linker_options} -lstdc++"
+ mmodule.ldflags = "{mmodule.ldflags} -lstdc++"
end
redef fun compile_callback(callback, mmodule, mainmodule, ecc)
var mmodule: MModule
redef fun makefile_rule_name do return "{filename.basename("")}.o"
- redef fun makefile_rule_content do return "$(CXX) $(CFLAGS) {mmodule.cpp_compiler_options} -c {filename.basename("")} -o {filename.basename("")}.o"
+ redef fun makefile_rule_content do return "$(CXX) $(CFLAGS) {mmodule.cppflags} -c {filename.basename("")} -o {filename.basename("")}.o"
redef fun compiles_to_o_file do return true
end
ffi_ccu.write_as_impl(self, compdir)
for filename in ffi_ccu.files do
- var f = new ExternCFile(filename, c_compiler_options)
+ var f = new ExternCFile(filename, cflags)
f.pkgconfigs.add_all pkgconfigs
ffi_files.add(f)
end
# 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/ -I $(JAVA_HOME)/include/linux/"
- c_linker_options = "{c_linker_options} -L $(JNI_LIB_PATH) -ljvm"
+ cflags = "{cflags} -I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/"
+ ldflags = "{ldflags} -L $(JNI_LIB_PATH) -ljvm"
end
# Name of the generated Java class where to store all implementation methods of this module
files.add compdir/c_file
- mmodule.c_linker_options = "{mmodule.c_linker_options} -lobjc"
+ mmodule.ldflags = "{mmodule.ldflags} -lobjc"
return new ExternObjCFile(compdir/c_file, mmodule)
end
no_warning
pkgconfig
-c_compiler_option
-c_linker_option
+cflags
+ldflags
platform
"""