Browse Source

Merge pull request #512 from mkroehnert/compiler

Amberc enhancements
Nicolas Petton 11 years ago
parent
commit
04e9d9197f
2 changed files with 18 additions and 14 deletions
  1. 2 3
      Gruntfile.js
  2. 16 11
      grunt/tasks/grunt-amberc.js

+ 2 - 3
Gruntfile.js

@@ -28,7 +28,7 @@ module.exports = function(grunt) {
     },
 
     amberc: {
-      _config: {
+      options: {
         amber_dir: process.cwd(),
         closure_jar: ''
       },
@@ -59,8 +59,7 @@ module.exports = function(grunt) {
       amber_canvas: {
         output_dir : 'js',
         src: ['st/Canvas.st', 'st/SUnit.st'],
-        deploy: true,
-        verbose: true
+        deploy: true
       },
       amber_IDE: {
         output_dir : 'js',

+ 16 - 11
grunt/tasks/grunt-amberc.js

@@ -9,7 +9,8 @@ module.exports = function(grunt) {
      amberc: {
        _config: {
          amber_dir: process.cwd(),     // REQUIRED
-         closure_jar: ''               // optional
+         closure_jar: '',              // optional
+         verbose: true                 // optional
        },
        helloWorld: {
          src: ['projects/HelloWorld/st/HelloWorld.st'], // REQUIRED
@@ -21,25 +22,31 @@ module.exports = function(grunt) {
          main_file: 'myMain.js',               // optional
          deploy: true,                         // optional
          output_suffix: 'mySuffix',            // optional
-         library_suffix: '-0.9',               // optional
-         verbose: true                         // optional
+         library_suffix: '-0.9'               // optional
        },
      },
 
    */
   grunt.registerMultiTask('amberc', 'Compile Smalltalk files with the amberc compiler', function() {
     // mark required properties
-    this.requiresConfig('amberc._config.amber_dir');
+    this.requiresConfig('amberc.options.amber_dir');
     this.requiresConfig(['amberc', this.target, 'src']);
 
+    var options = this.options({
+      amber_dir: undefined,
+      closure_jar: '',
+      verbose: false
+    });
+    this.data.verbose = options.verbose;
+
     // mark task as async task
     var done = this.async();
 
     // create and initialize amberc
-    var compiler = new amberc.Compiler(grunt.config('amberc._config.amber_dir'), grunt.config('amberc._config.closure_jar'));
+    var compiler = new amberc.Compiler(grunt.config('amberc.options.amber_dir'), grunt.config('amberc.options.closure_jar'));
 
     // generate the amberc configuration out of the given target properties
-    var configuration = generateCompilerConfiguration(this.data, grunt.config('amberc._config.amber_dir'));
+    var configuration = generateCompilerConfiguration(this.data, grunt.config('amberc.options.amber_dir'));
 
     // run the compiler
     // change back to the old working directory and call the async callback once finished
@@ -68,7 +75,7 @@ module.exports = function(grunt) {
       configuration.main = mainClass;
     }
     var mainFile = data.main_file;
-    if (undefined !== initFile) {
+    if (undefined !== mainFile) {
       configuration.mainfile = mainFile;
     }
     if (true === data.deploy) {
@@ -103,11 +110,9 @@ module.exports = function(grunt) {
       configuration.program = outputName;
     }
     if (undefined !== data.output_dir) {
-    	configuration.output_dir = data.output_dir;
-    }
-    if (true === data.verbose) {
-    	configuration.verbose = true;
+      configuration.output_dir = data.output_dir;
     }
+    configuration.verbose = data.verbose;
     return configuration;
   }
 };