feat(Gruntfile.js): Added package-c task which creates a unified single header css-layout.h for use in C code ;

This commit is contained in:
Pierre Renaux
2015-08-13 16:56:41 +08:00
parent 3e0a3697df
commit fee4d39367
4 changed files with 1354 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ module.exports = function(grunt) {
var isWindows = /^win/.test(process.platform);
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-contrib-concat');
// config
var config = {
@@ -102,6 +103,35 @@ module.exports = function(grunt) {
}
},
concat: {
options: {
separator: '\n',
// Replace all 'use strict' statements in the code with a single one at the top
banner: [
'/*',
' * #define CSS_LAYOUT_IMPLEMENTATION',
' * before you include this file in *one* C or C++ file to create the implementation.',
' */\n'
].join('\n'),
process: function(src, filepath) {
if (path.extname(filepath) === '.c') {
return [
'#ifdef CSS_LAYOUT_IMPLEMENTATION',
src,
'#endif // CSS_LAYOUT_IMPLEMENTATION'
].join('\n')
}
else {
return src;
}
},
},
dist: {
src: ['<%= config.srcFolder %>/Layout.h', '<%= config.srcFolder %>/Layout.c'],
dest: '<%= config.distFolder %>/css-layout.h',
},
},
shell: {
cCompile: {
command: cTestCompile
@@ -148,12 +178,15 @@ module.exports = function(grunt) {
// Packages the Java as a JAR
grunt.registerTask('package-java', ['shell:javaPackage']);
// Packages the C code as a single header
grunt.registerTask('package-c', ['concat']);
// Default build, performs the full works!
grunt.registerTask('build', ['test-javascript', 'transpile', 'clean:dist', 'package-javascript', 'package-java']);
grunt.registerTask('build', ['test-javascript', 'transpile', 'clean:dist', 'package-javascript', 'package-java', 'package-c']);
// The JavaScript unit tests require Chrome (they need a faithful flexbox implementation
// to test against), so under CI this step is skipped.
grunt.registerTask('ci', ['eslint', 'transpile', 'clean:dist', 'package-javascript', 'package-java']);
grunt.registerTask('ci', ['eslint', 'transpile', 'clean:dist', 'package-javascript', 'package-java', 'package-c']);
grunt.registerTask('default', ['build']);
};

1315
dist/css-layout.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -20,6 +20,7 @@
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-eslint": "^17.1.0",

View File

@@ -12,7 +12,10 @@
#include <stdlib.h>
#include <string.h>
// in concatenated header, don't include Layout.h it's already at the top
#ifndef CSS_LAYOUT_IMPLEMENTATION
#include "Layout.h"
#endif
#ifdef _MSC_VER
#include <float.h>