app.nit: exit and print an error if not bound to a platform
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 7 May 2017 22:34:37 +0000 (18:34 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 8 May 2017 16:08:34 +0000 (12:08 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/android/platform.nit
lib/app/app_base.nit
lib/gamnit/gamnit.nit
lib/linux/linux.nit

index f305144..3a2e105 100644 (file)
@@ -19,6 +19,9 @@ module platform is platform "android"
 
 import java
 import app
+intrude import app::app_base # For test_bound_platform
 import aware
 
 redef fun bound_platform do return "Android"
+
+redef fun test_bound_platform do end
index e3e870a..5c2a902 100644 (file)
@@ -122,5 +122,16 @@ fun app: App do return once new App
 # However, this value can be used in log files and communications with servers.
 fun bound_platform: String do return "none"
 
+# Test if the application was bound to a platform, if not crash
+private fun test_bound_platform
+do
+       print_error "Apps must be bound to a platform at compilation using `-m linux` or `-m android`"
+       exit 1
+end
+
+if "NIT_TESTING".environ == "true" then exit 0
+
+test_bound_platform
+
 app.setup
 app.run
index 41bfb37..0d39f1e 100644 (file)
@@ -78,11 +78,3 @@ redef class App
        # right after this method returns. They should not be preserved.
        fun accept_event(event: InputEvent): Bool do return false
 end
-
-redef class Sys
-       redef fun run
-       do
-               if "NIT_TESTING".environ == "true" then exit 0
-               super
-       end
-end
index 32a5ad4..3f08b98 100644 (file)
@@ -18,6 +18,7 @@
 module linux
 
 import app
+intrude import app::app_base # For test_bound_platform
 
 redef class App
        # Path to the expected location of the asset folder of this program
@@ -62,3 +63,5 @@ redef class TextAsset
 end
 
 redef fun bound_platform do return "GNU/Linux"
+
+redef fun test_bound_platform do end