2013-07-20 14:56:59 -07:00
|
|
|
'use strict';
|
|
|
|
module.exports = function (grunt) {
|
2015-04-20 08:10:23 +02:00
|
|
|
var os = require('os');
|
2013-09-13 13:52:13 -07:00
|
|
|
var config = {
|
2013-07-20 14:56:59 -07:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2013-11-14 21:29:41 -07:00
|
|
|
baseDir: '.',
|
2015-03-29 12:57:28 +02:00
|
|
|
srcDir: 'public',
|
2015-09-10 11:26:40 +02:00
|
|
|
genDir: 'public_gen',
|
2013-09-13 13:52:13 -07:00
|
|
|
destDir: 'dist',
|
|
|
|
tempDir: 'tmp',
|
2015-04-20 08:10:23 +02:00
|
|
|
platform: process.platform.replace('win32', 'windows'),
|
2018-10-25 16:55:27 +02:00
|
|
|
enterprise: false,
|
2019-10-24 14:34:14 +02:00
|
|
|
libc: null,
|
2013-09-13 13:52:13 -07:00
|
|
|
};
|
|
|
|
|
2018-05-08 09:42:20 +02:00
|
|
|
if (grunt.option('platform')) {
|
|
|
|
config.platform = grunt.option('platform');
|
|
|
|
}
|
|
|
|
|
2018-10-25 16:55:27 +02:00
|
|
|
if (grunt.option('enterprise')) {
|
|
|
|
config.enterprise = true;
|
|
|
|
}
|
|
|
|
|
2016-10-17 15:09:35 +02:00
|
|
|
if (grunt.option('arch')) {
|
2016-10-17 15:19:00 +02:00
|
|
|
config.arch = grunt.option('arch');
|
2016-10-17 15:09:35 +02:00
|
|
|
} else {
|
2016-10-17 15:19:00 +02:00
|
|
|
config.arch = os.arch();
|
2016-10-17 15:09:35 +02:00
|
|
|
|
|
|
|
if (process.platform.match(/^win/)) {
|
|
|
|
config.arch = process.env.hasOwnProperty('ProgramFiles(x86)') ? 'x64' : 'x86';
|
|
|
|
}
|
2015-04-21 08:56:32 +02:00
|
|
|
}
|
|
|
|
|
2019-10-24 14:34:14 +02:00
|
|
|
if (grunt.option('libc')) {
|
|
|
|
config.libc = grunt.option('libc');
|
|
|
|
}
|
|
|
|
|
2015-03-04 07:09:59 +01:00
|
|
|
config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
|
2017-10-22 07:03:26 +02:00
|
|
|
|
2016-03-30 12:02:44 -07:00
|
|
|
console.log('Version', config.pkg.version);
|
2015-03-04 07:09:59 +01:00
|
|
|
|
2013-11-14 16:07:14 -07:00
|
|
|
// load plugins
|
|
|
|
require('load-grunt-tasks')(grunt);
|
2013-09-19 10:17:42 -07:00
|
|
|
|
2013-11-14 16:07:14 -07:00
|
|
|
// load task definitions
|
2017-10-01 20:02:25 +02:00
|
|
|
grunt.loadTasks('./scripts/grunt');
|
2013-10-17 15:33:43 -07:00
|
|
|
|
2013-11-14 20:30:28 -07:00
|
|
|
// Utility function to load plugin settings into config
|
2019-10-24 14:34:14 +02:00
|
|
|
function loadConfig(config, path) {
|
2013-11-14 16:07:14 -07:00
|
|
|
require('glob').sync('*', {cwd: path}).forEach(function(option) {
|
2013-11-14 20:30:28 -07:00
|
|
|
var key = option.replace(/\.js$/,'');
|
|
|
|
// If key already exists, extend it. It is your responsibility to avoid naming collisions
|
|
|
|
config[key] = config[key] || {};
|
2013-11-15 09:44:06 -07:00
|
|
|
grunt.util._.extend(config[key], require(path + option)(config,grunt));
|
2013-09-19 10:17:42 -07:00
|
|
|
});
|
2013-11-14 20:30:28 -07:00
|
|
|
// technically not required
|
|
|
|
return config;
|
2013-11-14 16:07:14 -07:00
|
|
|
}
|
2013-09-19 13:45:09 -07:00
|
|
|
|
2013-11-14 16:07:14 -07:00
|
|
|
// Merge that object with what with whatever we have here
|
2017-10-01 20:02:25 +02:00
|
|
|
loadConfig(config,'./scripts/grunt/options/');
|
2013-09-19 10:17:42 -07:00
|
|
|
// pass the config to grunt
|
|
|
|
grunt.initConfig(config);
|
2014-08-11 16:37:31 +02:00
|
|
|
};
|