src: implements abstract methods of ExternCFile
authorJean Privat <jean@pryen.org>
Wed, 2 Apr 2014 13:33:18 +0000 (09:33 -0400)
committerJean Privat <jean@pryen.org>
Wed, 2 Apr 2014 13:51:06 +0000 (09:51 -0400)
`makefile_rule_name` and `makefile_rule_content` are let undefined
because unused.
The next commit will use them.

Also, document them.

Signed-off-by: Jean Privat <jean@pryen.org>

src/c_tools.nit

index a44d7e5..be9e649 100644 (file)
@@ -104,7 +104,12 @@ class ExternFile
        # The filename of the file
        var filename: String
 
+       # The name of the target in the Makefile
+       # Usually the produced .o file
        fun makefile_rule_name: 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
 end
 
@@ -124,5 +129,17 @@ class ExternCFile
 
        redef fun hash do return filename.hash
        redef fun ==(o) do return o isa ExternCFile and filename == o.filename
+
+       redef fun makefile_rule_name do
+               var basename = filename.basename(".c")
+               var res = "{basename}.extern.o"
+               return res
+       end
+
+       redef fun makefile_rule_content do
+               var ff = filename.basename("")
+               var o = makefile_rule_name
+               return "$(CC) $(CFLAGS) -D NONITCNI {self.cflags} -c -o {o} {ff}"
+       end
 end