nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/doc: introduce option --no-render in HTML phase.
[nit.git]
/
src
/
c_tools.nit
diff --git
a/src/c_tools.nit
b/src/c_tools.nit
index
9abb685
..
9a03c5a
100644
(file)
--- a/
src/c_tools.nit
+++ b/
src/c_tools.nit
@@
-47,33
+47,37
@@
class CCompilationUnit
# files to compile TODO check is appropriate
var files = new Array[String]
# files to compile TODO check is appropriate
var files = new Array[String]
- fun add_local_function( efc : CFunction )
+ # Add a `static` `c_function` to be strictly local to this unit
+ fun add_local_function(c_function: CFunction)
do
do
- body_decl.add( "{efc.signature};\n" )
- body_impl.add( "\n" )
- body_impl.add( efc.to_writer )
+ body_decl.add "static {c_function.signature};\n"
+ body_impl.add "\n"
+ body_impl.add c_function.to_writer
end
end
- fun add_exported_function( efc : CFunction )
+ # Add a public `c_function` accessible from outside this compilation unit
+ fun add_exported_function(c_function: CFunction)
do
do
- header_decl.add( "{efc.signature};\n" )
- body_impl.add( "\n" )
- body_impl.add( efc.to_writer )
+ body_decl.add "{c_function.signature};\n"
+ body_impl.add "\n"
+ body_impl.add c_function.to_writer
end
end
- fun compile_header_core( stream : OStream )
+ # Write the core of the header to `stream`
+ fun compile_header_core(stream: Writer)
do
do
- header_c_base.write_to( stream )
- header_custom.write_to( stream )
- header_c_types.write_to( stream )
- header_decl.write_to( stream )
+ header_c_base.write_to stream
+ header_custom.write_to stream
+ header_c_types.write_to stream
+ header_decl.write_to stream
end
end
- fun compile_body_core( stream : OStream )
+ # Write the core of the body to `stream`
+ fun compile_body_core(stream: Writer)
do
do
- body_decl.write_to( stream )
- body_custom.write_to( stream )
- body_impl.write_to( stream )
+ body_decl.write_to stream
+ body_custom.write_to stream
+ body_impl.write_to stream
end
end
end
end
@@
-111,20
+115,21
@@
class ExternFile
# The content of the rule in the make
# Usually the one-line shell command after the tabulation
fun makefile_rule_content: String is abstract
# 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
+
+ # Additional libraries needed for the compilation
+ # Will be used with pkg-config
+ var pkgconfigs = new Array[String]
end
# An extern C file to compile
class ExternCFile
super ExternFile
end
# An extern C file to compile
class ExternCFile
super ExternFile
- init (filename, cflags: String)
- do
- super filename
-
- self.cflags = cflags
- end
-
- # Additionnal specific CC compiler -c flags
+ # Custom options for the C compiler (CFLAGS)
var cflags: String
redef fun hash do return filename.hash
var cflags: String
redef fun hash do return filename.hash
@@
-137,9
+142,15
@@
class ExternCFile
end
redef fun makefile_rule_content do
end
redef fun makefile_rule_content do
- var ff = filename.basename("")
+ var ff = filename.basename
var o = makefile_rule_name
var o = makefile_rule_name
- return "$(CC) $(CFLAGS) {self.cflags} -c -o {o} {ff}"
+ var pkg = ""
+ if not pkgconfigs.is_empty then
+ pkg = "`pkg-config --cflags {pkgconfigs.join(" ")}`"
+ end
+ return "$(CC) $(CFLAGS) -Wall -Wno-unused-function {self.cflags} {pkg} -c -o {o} {ff}"
end
end
+
+ redef fun compiles_to_o_file do return true
end
end