Merge pull request #106 from ColinEberhardt/build-process-continues
Build complete and integrated with Travis
This commit is contained in:
19
.travis.yml
19
.travis.yml
@@ -1,8 +1,13 @@
|
|||||||
language: c
|
language: node_js
|
||||||
compiler:
|
node_js:
|
||||||
- clang
|
- "0.12"
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- npm install grunt-cli -g
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
- gcc
|
- gcc
|
||||||
before_script:
|
|
||||||
- sudo apt-get update -q
|
|
||||||
- sudo apt-get install nodejs
|
|
||||||
script: make
|
|
||||||
|
88
Gruntfile.js
88
Gruntfile.js
@@ -4,21 +4,33 @@ module.exports = function(grunt) {
|
|||||||
|
|
||||||
require('load-grunt-tasks')(grunt);
|
require('load-grunt-tasks')(grunt);
|
||||||
|
|
||||||
grunt.initConfig({
|
var config = {
|
||||||
|
libName: 'css-layout',
|
||||||
paths: {
|
|
||||||
distFolder: 'dist',
|
distFolder: 'dist',
|
||||||
srcFolder: 'src',
|
srcFolder: 'src',
|
||||||
testFolder: 'src/__tests__',
|
testFolder: 'src/__tests__',
|
||||||
},
|
cTestFiles: 'src/__tests__/Layout-test.c src/Layout.c src/Layout-test-utils.c',
|
||||||
|
cTestOutput: 'c_test',
|
||||||
|
javaLibFolder: 'src/java/lib',
|
||||||
|
javaSource: 'src/java/tests/com/facebook/csslayout/*.java',
|
||||||
|
javaTestFiles: 'org.junit.runner.JUnitCore com.facebook.csslayout.LayoutEngineTest com.facebook.csslayout.LayoutCachingTest com.facebook.csslayout.CSSNodeTest'
|
||||||
|
};
|
||||||
|
|
||||||
clean: ['<%= paths.distFolder %>'],
|
grunt.initConfig({
|
||||||
|
|
||||||
|
config: config,
|
||||||
|
|
||||||
|
clean: {
|
||||||
|
dist: ['<%= config.distFolder %>'],
|
||||||
|
cTest: ['<%= config.cTestOutput %>'],
|
||||||
|
javaTest: ['**/*.class']
|
||||||
|
},
|
||||||
|
|
||||||
eslint: {
|
eslint: {
|
||||||
options: {
|
options: {
|
||||||
configFile: '.eslintrc'
|
configFile: '.eslintrc'
|
||||||
},
|
},
|
||||||
target: ['<%= paths.srcFolder %>/Layout.js']
|
target: ['<%= config.srcFolder %>/Layout.js']
|
||||||
},
|
},
|
||||||
|
|
||||||
includereplace: {
|
includereplace: {
|
||||||
@@ -26,8 +38,8 @@ module.exports = function(grunt) {
|
|||||||
prefix: '// @@',
|
prefix: '// @@',
|
||||||
},
|
},
|
||||||
main: {
|
main: {
|
||||||
src: '<%= paths.srcFolder %>/css-layout.js',
|
src: '<%= config.srcFolder %>/<%= config.libName %>.js',
|
||||||
dest: '<%= paths.distFolder %>/css-layout.js'
|
dest: '<%= config.distFolder %>/<%= config.libName %>.js'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -38,7 +50,8 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
main: {
|
main: {
|
||||||
files: {
|
files: {
|
||||||
'<%= paths.distFolder %>/css-layout.min.js': ['<%= paths.distFolder %>/css-layout.js']
|
'<%= config.distFolder %>/<%= config.libName %>.min.js':
|
||||||
|
['<%= config.distFolder %>/<%= config.libName %>.js']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -47,20 +60,67 @@ module.exports = function(grunt) {
|
|||||||
main: {
|
main: {
|
||||||
options: {
|
options: {
|
||||||
files: [
|
files: [
|
||||||
'<%= paths.srcFolder %>/Layout.js',
|
'<%= config.srcFolder %>/Layout.js',
|
||||||
'<%= paths.srcFolder %>/Layout-test-utils.js',
|
'<%= config.srcFolder %>/Layout-test-utils.js',
|
||||||
'<%= paths.testFolder %>/Layout-test.js',
|
'<%= config.testFolder %>/Layout-test.js',
|
||||||
'<%= paths.testFolder %>/Layout-consts-test.js'
|
'<%= config.testFolder %>/Layout-consts-test.js'
|
||||||
],
|
],
|
||||||
browsers: ['Chrome'],
|
browsers: ['Chrome'],
|
||||||
frameworks: ['jasmine'],
|
frameworks: ['jasmine'],
|
||||||
singleRun: true
|
singleRun: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
execute: {
|
||||||
|
transpile: {
|
||||||
|
src: ['<%= config.srcFolder %>/transpile.js']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
shell: {
|
||||||
|
cCompile: {
|
||||||
|
command: 'gcc -std=c99 -Werror -Wno-padded <%= config.cTestFiles %> -lm -o "./<%= config.cTestOutput %>"'
|
||||||
|
},
|
||||||
|
cTestExecute: {
|
||||||
|
command: './<%= config.cTestOutput %>'
|
||||||
|
},
|
||||||
|
javaCompile: {
|
||||||
|
command: 'javac -cp <%= config.javaLibFolder %>/junit4.jar:<%= config.javaLibFolder %>/jsr305.jar:<%= config.javaLibFolder %>/infer-annotations-1.4.jar -sourcepath ./src/java/src:./src/java/tests <%= config.javaSource %>'
|
||||||
|
},
|
||||||
|
javaTestExecute: {
|
||||||
|
command: 'java -cp ./src/java/src:./src/java/tests:<%= config.javaLibFolder %>/junit4.jar:<%= config.javaLibFolder %>/infer-annotations-1.4.jar <%= config.javaTestFiles %>'
|
||||||
|
},
|
||||||
|
javaPackage: {
|
||||||
|
command: 'jar cf <%= config.distFolder %>/<%= config.libName %>.jar <%= config.javaSource %>'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('build', ['eslint', 'clean', 'karma' ,'includereplace', 'uglify']);
|
// Compiles and runs the Java tests
|
||||||
|
grunt.registerTask('test-java', ['shell:javaCompile', 'shell:javaTestExecute', 'clean:javaTest']);
|
||||||
|
|
||||||
|
// Compiles and runs the C tests
|
||||||
|
grunt.registerTask('test-c', ['shell:cCompile', 'shell:cTestExecute', 'clean:cTest']);
|
||||||
|
|
||||||
|
// Transpiles the JavaScript to C and Java, running tests
|
||||||
|
grunt.registerTask('transpile', ['execute:transpile', 'test-c', 'test-java']);
|
||||||
|
|
||||||
|
// Lints and tests the JavaScritp using Chrome
|
||||||
|
grunt.registerTask('test-javascript', ['eslint', 'karma']);
|
||||||
|
|
||||||
|
// Packages the JavaScript as a single UMD module and minifies
|
||||||
|
grunt.registerTask('package-javascript', ['includereplace', 'uglify']);
|
||||||
|
|
||||||
|
// Packages the Java as a JAR
|
||||||
|
grunt.registerTask('package-java', ['shell:javaPackage']);
|
||||||
|
|
||||||
|
// Default build, performs the full works!
|
||||||
|
grunt.registerTask('build', ['test-javascript', 'transpile', 'clean:dist', 'package-javascript', 'package-java']);
|
||||||
|
|
||||||
|
// 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('default', ['build']);
|
grunt.registerTask('default', ['build']);
|
||||||
};
|
};
|
||||||
|
65
Makefile
65
Makefile
@@ -1,65 +0,0 @@
|
|||||||
# Copyright (c) 2014, Facebook, Inc.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the BSD-style license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
|
|
||||||
FILES=src/__tests__/Layout-test.c src/Layout.c src/Layout-test-utils.c
|
|
||||||
JAVA_LIB_DIR=lib
|
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
C_TEST_EXE=./c_test.exe
|
|
||||||
ENVSEP=";"
|
|
||||||
WGET=wget --no-check-certificate
|
|
||||||
LLDB=gdb
|
|
||||||
else
|
|
||||||
C_TEST_EXE=./c_test
|
|
||||||
ENVSEP=":"
|
|
||||||
WGET=wget
|
|
||||||
LLDB=lldb
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: c c_test java java_test
|
|
||||||
|
|
||||||
c: transpile_all
|
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
c_test: c
|
|
||||||
@cl -nologo -Zi -Tpsrc/__tests__/Layout-test.c -Tpsrc/Layout.c -Tpsrc/Layout-test-utils.c -link -incremental:no -out:"$(C_TEST_EXE)" && "$(C_TEST_EXE)"
|
|
||||||
@rm "$(C_TEST_EXE)" ./*.obj ./*.pdb
|
|
||||||
|
|
||||||
else
|
|
||||||
c_test: c
|
|
||||||
@gcc -std=c99 -Werror -Wno-padded $(FILES) -lm -o "$(C_TEST_EXE)" && "$(C_TEST_EXE)"
|
|
||||||
@rm "$(C_TEST_EXE)"
|
|
||||||
|
|
||||||
debug:
|
|
||||||
@gcc -std=c99 -ggdb $(FILES) -lm -o $(C_TEST_EXE) && $(LLDB) $(C_TEST_EXE)
|
|
||||||
@rm $(C_TEST_EXE)
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(JAVA_LIB_DIR):
|
|
||||||
mkdir $(JAVA_LIB_DIR)
|
|
||||||
|
|
||||||
$(JAVA_LIB_DIR)/junit4.jar: | $(JAVA_LIB_DIR)
|
|
||||||
$(WGET) -O $(JAVA_LIB_DIR)/junit4.jar http://search.maven.org/remotecontent?filepath=junit/junit/4.10/junit-4.10.jar
|
|
||||||
|
|
||||||
$(JAVA_LIB_DIR)/jsr305.jar: | $(JAVA_LIB_DIR)
|
|
||||||
$(WGET) -O $(JAVA_LIB_DIR)/jsr305.jar http://search.maven.org/remotecontent?filepath=net/sourceforge/findbugs/jsr305/1.3.7/jsr305-1.3.7.jar
|
|
||||||
|
|
||||||
$(JAVA_LIB_DIR)/infer-annotations-1.4.jar: | $(JAVA_LIB_DIR)
|
|
||||||
$(WGET) -O $(JAVA_LIB_DIR)/infer-annotations-1.4.jar https://github.com/facebook/buck/raw/027ffe2b230c08cad7b340646c6f801bd6dabc78/third-party/java/infer-annotations/infer-annotations-1.4.jar
|
|
||||||
|
|
||||||
java: transpile_all src/java | $(JAVA_LIB_DIR)/junit4.jar $(JAVA_LIB_DIR)/jsr305.jar $(JAVA_LIB_DIR)/infer-annotations-1.4.jar
|
|
||||||
@javac -cp ./$(JAVA_LIB_DIR)/junit4.jar$(ENVSEP)./$(JAVA_LIB_DIR)/jsr305.jar$(ENVSEP)./$(JAVA_LIB_DIR)/infer-annotations-1.4.jar -sourcepath ./src/java/src$(ENVSEP)./src/java/tests src/java/tests/com/facebook/csslayout/*.java
|
|
||||||
|
|
||||||
java_test: java
|
|
||||||
@java -cp ./src/java/src$(ENVSEP)./src/java/tests$(ENVSEP)./$(JAVA_LIB_DIR)/junit4.jar$(ENVSEP)./$(JAVA_LIB_DIR)/infer-annotations-1.4.jar org.junit.runner.JUnitCore \
|
|
||||||
com.facebook.csslayout.LayoutEngineTest \
|
|
||||||
com.facebook.csslayout.LayoutCachingTest \
|
|
||||||
com.facebook.csslayout.CSSNodeTest
|
|
||||||
|
|
||||||
transpile_all: ./src/transpile.js
|
|
||||||
@node ./src/transpile.js
|
|
@@ -82,9 +82,10 @@ Development
|
|||||||
|
|
||||||
The core logic resides with `Layout.js`, which is transpiled into equivalent C and Java implementations.
|
The core logic resides with `Layout.js`, which is transpiled into equivalent C and Java implementations.
|
||||||
|
|
||||||
To run the tests
|
The JavaScript build process is managed via Grunt. The build performs linting, runs the tests against Chrome, transpiles and packages the code (JavaScript and Java) into the `dist` folder. For JavaScript, the build output uses the Universal Module Format (UMD) so that it can be used via AMD / RequireJS, CommonJS or included directly into an HTML page.
|
||||||
|
|
||||||
- For the JS tests: run `grunt karma`
|
While developing you can just run the lint / Chrome-based tests a follows:
|
||||||
- For the C and Java tests: run `make` in your terminal. It will also transpile the JS code. This build is also run via Travis CI.
|
|
||||||
|
|
||||||
The JavaScript build process is managed via Grunt. The build performs linting, runs the tests and produce a minified version of the code within a `dist` folder. The build output uses the Universal Module Format (UMD) so that it can be used via AMD / RequireJS, CommonJS or included directly into an HTML page.
|
```
|
||||||
|
grunt test-javascript
|
||||||
|
```
|
||||||
|
BIN
dist/css-layout.jar
vendored
Normal file
BIN
dist/css-layout.jar
vendored
Normal file
Binary file not shown.
@@ -3,6 +3,9 @@
|
|||||||
"version": "0.0.2",
|
"version": "0.0.2",
|
||||||
"description": "Reimplementation of CSS layout using pure JavaScript",
|
"description": "Reimplementation of CSS layout using pure JavaScript",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "grunt ci"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/facebook/css-layout.git"
|
"url": "https://github.com/facebook/css-layout.git"
|
||||||
@@ -20,8 +23,10 @@
|
|||||||
"grunt-contrib-copy": "^0.8.0",
|
"grunt-contrib-copy": "^0.8.0",
|
||||||
"grunt-contrib-uglify": "^0.9.1",
|
"grunt-contrib-uglify": "^0.9.1",
|
||||||
"grunt-eslint": "^17.1.0",
|
"grunt-eslint": "^17.1.0",
|
||||||
|
"grunt-execute": "^0.2.2",
|
||||||
"grunt-include-replace": "^3.1.0",
|
"grunt-include-replace": "^3.1.0",
|
||||||
"grunt-karma": "^0.12.0",
|
"grunt-karma": "^0.12.0",
|
||||||
|
"grunt-shell": "^1.1.2",
|
||||||
"jasmine-core": "^2.2.0",
|
"jasmine-core": "^2.2.0",
|
||||||
"karma": "^0.13.8",
|
"karma": "^0.13.8",
|
||||||
"karma-chrome-launcher": "^0.1.7",
|
"karma-chrome-launcher": "^0.1.7",
|
||||||
|
BIN
src/java/lib/infer-annotations-1.4.jar
Normal file
BIN
src/java/lib/infer-annotations-1.4.jar
Normal file
Binary file not shown.
BIN
src/java/lib/jsr305.jar
Normal file
BIN
src/java/lib/jsr305.jar
Normal file
Binary file not shown.
BIN
src/java/lib/junit4.jar
Normal file
BIN
src/java/lib/junit4.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user