Updated README and travis.yml

This commit is contained in:
Colin Eberhardt
2015-08-12 08:45:41 +01:00
parent 6714c36824
commit fec329f800
4 changed files with 20 additions and 72 deletions

View File

@@ -2,9 +2,12 @@ language: node_js
node_js:
- "0.12"
sudo: false
before_install:
- npm install grunt-cli -g
before_script:
- sudo apt-get update -q
- sudo apt-get install gcc
addons:
apt:
packages:
- gcc

View File

@@ -97,20 +97,29 @@ module.exports = function(grunt) {
}
});
// 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']);

View File

@@ -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

View File

@@ -82,9 +82,10 @@ Development
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`
- 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.
While developing you can just run the lint / Chrome-based tests a follows:
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
```