1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- module.exports = function (grunt) {
- var amberc = require('..').amberc;
-
- grunt.registerMultiTask('amberc', 'Compile Smalltalk files with the amberc compiler', function () {
-
- var done = this.async();
- var options = this.options({
- amber_dir: undefined,
- configFile: null,
- paths: {},
- verbose: grunt.option('verbose') || false
- });
- this.data.verbose = options.verbose;
- this.data.configFile = options.configFile;
- this.data.paths = options.paths;
-
- this.requiresConfig('amberc.options.amber_dir');
-
- if (this.filesSrc.length === 0) {
- grunt.fail.fatal('No source files to compile or link.');
- }
-
- var compiler = new amberc.Compiler(grunt.config('amberc.options.amber_dir'));
-
- var configuration = generateCompilerConfiguration(this.data, this.filesSrc);
-
- var self = this;
- compiler.main(configuration, function (err) {
- done(err || true);
- });
- });
- function generateCompilerConfiguration(data, sourceFiles) {
- var configuration = amberc.createDefaultConfiguration();
- if (data.libraries != null) {
- configuration.load = data.libraries;
- }
- if (data.configFile != null) {
- configuration.configFile = data.configFile;
- }
- if (data.paths != null) {
- configuration.paths = data.paths;
- }
- if (sourceFiles != null) {
- configuration.stFiles = sourceFiles;
- }
- if (data.amd_namespace != null) {
- configuration.amdNamespace = data.amd_namespace;
- }
- if (data.output_dir != null) {
- configuration.outputDir = data.output_dir;
- }
- if (data.jsGlobals != null) {
- configuration.jsGlobals.push.apply(configuration.jsGlobals, data.jsGlobals);
- }
- if (data.verbose != null) {
- configuration.verbose = data.verbose;
- }
- return configuration;
- }
- };
|