nitg/pnacl: automate option no_main
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 12 May 2014 14:16:08 +0000 (10:16 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 20 May 2014 18:16:31 +0000 (14:16 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/abstract_compiler.nit
src/platform.nit
src/pnacl_platform.nit

index a19af3e..831311d 100644 (file)
@@ -540,9 +540,9 @@ abstract class AbstractCompiler
                var v = self.new_visitor
                v.add_decl("#include <signal.h>")
                var ost = modelbuilder.toolcontext.opt_stacktrace.value
+               var platform = mainmodule.target_platform
 
                if ost == null then
-                       var platform = mainmodule.target_platform
                        if platform != null and not platform.supports_libunwind then
                                ost = "none"
                        else
@@ -551,6 +551,8 @@ abstract class AbstractCompiler
                        modelbuilder.toolcontext.opt_stacktrace.value = ost
                end
 
+               if platform != null and platform.no_main then modelbuilder.toolcontext.opt_no_main.value = true
+
                if ost == "nitstack" or ost == "libunwind" then
                        v.add_decl("#define UNW_LOCAL_ONLY")
                        v.add_decl("#include <libunwind.h>")
index ccb506d..17257f5 100644 (file)
@@ -112,4 +112,7 @@ end
 # Services will be added to this class in other modules.
 abstract class Platform
        fun supports_libunwind: Bool do return true
+
+       # Does this platform declare its own main function? If so, we won't generate one in Nit.
+       fun no_main: Bool do return false
 end
index e05c5c6..9add122 100644 (file)
@@ -31,6 +31,10 @@ end
 class PnaclPlatform
        super Platform
 
+       redef fun supports_libunwind do return false
+
+       redef fun no_main do return true
+
        redef fun toolchain(toolcontext) do return new PnaclToolchain(toolcontext)
 end