contrib/jwrapper: saving the model must be asked by an option
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 4 Aug 2015 18:40:41 +0000 (14:40 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 5 Aug 2015 01:41:51 +0000 (21:41 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/jwrapper/src/code_generator.nit
contrib/jwrapper/src/jwrapper.nit

index 02a3cb5..e716a2e 100644 (file)
@@ -146,6 +146,8 @@ class CodeGenerator
        # Serialize `model` to a file next to `file_name`
        fun write_model_to_file
        do
+               if not sys.opt_save_model.value then return
+
                # Write the model to file next to the Nit module
                var model_path = file_name.strip_extension + ".jwrapper.bin"
                var model_stream = model_path.to_path.open_wo
@@ -435,6 +437,9 @@ redef class Sys
 
        # Option to _not_ generate properties (static or from classes)
        var opt_no_properties = new OptionBool("Do not wrap properties, only classes and basic services", "-n", "--no-properties")
+
+       # Should the model be serialized to a file?
+       var opt_save_model = new OptionBool("Save the model next to the generated Nit module", "-s", "--save-model")
 end
 
 redef class String
index 847f121..bf25f1e 100644 (file)
@@ -44,7 +44,7 @@ var opt_output = new OptionString("Output file", "-o")
 var opt_regex = new OptionString("Regex pattern to filter classes in Jar archives", "-r")
 var opt_help = new OptionBool("Show this help message", "-h", "--help")
 
-opts.add_option(opt_output, opt_unknown, opt_extern_class_prefix, opt_libs, opt_regex, opt_cast_objects, opt_arrays, opt_load_models, opt_no_properties, opt_verbose, opt_help)
+opts.add_option(opt_output, opt_unknown, opt_extern_class_prefix, opt_libs, opt_regex, opt_cast_objects, opt_arrays, opt_save_model, opt_load_models, opt_no_properties, opt_verbose, opt_help)
 opts.parse args
 
 if opts.errors.not_empty or opts.rest.is_empty or opt_help.value then