From 0768600a709992a532fcf92e3870d6e68b93f8f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 11 Apr 2014 11:29:18 -0700 Subject: [PATCH] clean up build system and reuse previously built libraries in other targets --- .travis.yml | 16 ++++++- Makefile | 98 +++++++++++++--------------------------- bin/._.DS_Store | Bin 0 -> 4096 bytes bin/build-shaders.js | 13 +++--- bin/build-style.js | 7 +-- bin/lazy-update.js | 12 +++++ test/rotation_range.cpp | 2 + test/test.gyp | 10 ++++ 8 files changed, 79 insertions(+), 79 deletions(-) create mode 100644 bin/._.DS_Store create mode 100644 bin/lazy-update.js diff --git a/.travis.yml b/.travis.yml index d1460572e..c785dee9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,21 @@ before_install: - sudo add-apt-repository --yes ppa:boost-latest/ppa - sudo apt-get update -qq - sudo apt-get -y install gcc-4.8 g++-4.8 -- sudo apt-get -y install pkg-config nodejs +- sudo apt-get -y install pkg-config nodejs cmake - sudo apt-get -y install libboost1.55-dev libpng-dev libcurl4-openssl-dev -- sudo apt-get -y install libglu1-mesa-dev +- sudo apt-get -y install libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev + +install: +- export CURRENT_DIR=$(pwd) +- git clone https://github.com/glfw/glfw.git +- cd glfw +- git checkout -qf 3.0.4 +- mkdir build +- cd build +- cmake ../ -DCMAKE_C_COMPILER_ENV_VAR=gcc-4.8 -DGLFW_BUILD_EXAMPLES=off -DGLFW_BUILD_TESTS=off -DGLFW_BUILD_DOCS=off +- make +- sudo make install +- cd ${CURRENT_DIR} before_script: - export CXX="g++-4.8" diff --git a/Makefile b/Makefile index f98311b7f..3b264e853 100644 --- a/Makefile +++ b/Makefile @@ -6,81 +6,45 @@ V ?= 1 all: llmr -llmr: config.gypi src llmr.gyp - deps/run_gyp llmr.gyp -Goutput_dir=./out/ --depth=. --generator-output=./out -f make - make -j8 -C out BUILDTYPE=Release V=$(V) llmr-x86 - -gtest: config.gypi src llmr.gyp - deps/run_gyp llmr.gyp -Goutput_dir=./out/ --depth=. --generator-output=./build/gtest -f make - make -C build/gtest gtest V=$(V) - -# build OS X app with pure make -app: config.gypi src macosx/llmr-app.gyp - deps/run_gyp macosx/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./build/macosx-make -f make - make -C build/macosx-make V=$(V) - open build/macosx-make/out/Release/llmr.app - -linux: config.gypi src linux/llmr-app.gyp - deps/run_gyp linux/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./build/linux-make -f make - make -C build/linux-make V=$(V) - ./build/linux-make/out/Release/llmr.app +# Builds the regular library +llmr: config.gypi llmr.gyp + deps/run_gyp llmr.gyp --depth=. -Goutput_dir=.. --generator-output=./build/llmr -f make + make -C build/llmr V=$(V) llmr-x86 -# build OS X app with Xcode -lproj: config.gypi src linux/llmr-app.gyp - deps/run_gyp linux/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode - open ./linux/llmr-app.xcodeproj +##### Test cases ############################################################### -# build just xcode project for libllmr -xcode: config.gypi llmr.gyp - deps/run_gyp llmr.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode +# Runs the test cases +test: config.gypi test/test.gyp + deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build/test -f make + make -C build/test V=$(V) test -# build OS X app with Xcode -xproj: config.gypi src macosx/llmr-app.gyp - deps/run_gyp macosx/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode - open ./macosx/llmr-app.xcodeproj - -# build OS X app with xcodebuild -xapp: config.gypi src macosx/llmr-app.gyp - deps/run_gyp macosx/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode - xcodebuild -project ./macosx/llmr-app.xcodeproj - open macosx/build/Release/llmr.app - -# build iOS app with Xcode -iproj: config.gypi src ios/llmr-app.gyp - deps/run_gyp ios/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode - open ./ios/llmr-app.xcodeproj - -# build iOS app with xcodebuild -iapp: config.gypi src ios/llmr-app.gyp - deps/run_gyp ios/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode - xcodebuild -project ./ios/llmr-app.xcodeproj - # launch app with ios-sim? - -isim: config.gypi src ios/llmr-app.gyp - deps/run_gyp ios/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode - xcodebuild -project ./ios/llmr-app.xcodeproj -arch i386 -sdk iphonesimulator - # does not work - #"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator" -SimulateApplication ios/build/Release-iphonesimulator/llmr.app/llmr - -test: config.gypi src test/test.gyp - deps/run_gyp test/test.gyp -Goutput_dir=. --depth=. --generator-output=./build/test -f make - make -C build/test V=$(V) - @for FILE in build/test/Release/test_*; do \ +run-tests: test + @for FILE in build/Release/test_*; do \ $${FILE}; \ done + +##### Makefile builds ########################################################## + + +# Builds the linux app with make. This is also used by Travis CI +linux: config.gypi linux/llmr-app.gyp + deps/run_gyp linux/llmr-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make + make -C build/linux V=$(V) linuxapp + +# Executes the linux binary +run-linux: linux + build/Release/llmr + + + +##### Maintenace operations #################################################### + clean: - -rm -rf out - -rm -rf build - -rm -rf macosx/build - -rm -rf ios/build + -rm -rf build/Release distclean: - -rm -f config.gypi - -rm -f config.mk - -rm -rf llmr.xcodeproj - -rm -rf macosx/llmr-app.xcodeproj - -rm -rf ios/llmr-app.xcodeproj + -rm -rf build -.PHONY: test linux +.PHONY: llmr test linux diff --git a/bin/._.DS_Store b/bin/._.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d32b4e9491b9f52460da6d921fb96426e0b60063 GIT binary patch literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIk*Y|peR=07!nf1 zz`#}q(ZNuGRne&6Xb6mkz-S1JhQMeDjE2By2#kinXb6mkz-S1JhQMeDP&ot`f#!iQ z7|4ZWWELwFr55Lx7A2=Dq~#Z7D`e)Cq~?`m=I15m4jn|NjF3_aq$} literal 0 HcmV?d00001 diff --git a/bin/build-shaders.js b/bin/build-shaders.js index 60d510907..7201a0019 100755 --- a/bin/build-shaders.js +++ b/bin/build-shaders.js @@ -3,10 +3,11 @@ var fs = require('fs'); var path = require('path'); +var lazy_update = require('./lazy-update'); try { var glsl = require('glsl-optimizer'); } catch(err) {} -module.exports = function(shader_type, root) { +module.exports = function(shader_type) { var name; var shaders = {}; @@ -101,7 +102,6 @@ module.exports = function(shader_type, root) { header += '}\n'; header += '\n'; header += '#endif\n'; - fs.writeFileSync('include/llmr/shader/shaders.hpp', header); var code = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n'; @@ -113,10 +113,9 @@ module.exports = function(shader_type, root) { code += lines.join(',\n'); code += '\n};\n'; - fs.writeFileSync(path.join(root, 'src/shader/shaders_' + shader_type + '.cpp'), code); - + lazy_update('include/llmr/shader/shaders.hpp', header); + lazy_update('src/shader/shaders_' + shader_type + '.cpp', code); }; -var root = path.resolve(process.argv[2] || '.'); -module.exports('gl', root); -module.exports('gles2', root); +module.exports('gl'); +module.exports('gles2'); diff --git a/bin/build-style.js b/bin/build-style.js index 970ccacda..380c13434 100755 --- a/bin/build-style.js +++ b/bin/build-style.js @@ -1,7 +1,7 @@ #!/usr/bin/env node 'use strict'; -var fs = require('fs'); +var lazy_update = require('./lazy-update'); var name = 'style'; var data = JSON.stringify(require('./style')); @@ -22,7 +22,8 @@ header += '}\n'; header += '}\n'; header += '\n'; header += '#endif\n'; -fs.writeFileSync('include/llmr/style/resources.hpp', header); + +lazy_update('include/llmr/style/resources.hpp', header); var code = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n'; code += '#include \n'; @@ -32,5 +33,5 @@ code += '\n'; code += 'const unsigned char resources::' + name + '[] = R"JSON(' + data + ')JSON";\n'; code += 'const unsigned long resources::' + name + '_size = sizeof(resources::' + name + ');\n'; -fs.writeFileSync('src/style/resources.cpp', code); +lazy_update('src/style/resources.cpp', code); diff --git a/bin/lazy-update.js b/bin/lazy-update.js new file mode 100644 index 000000000..0f3ea81ac --- /dev/null +++ b/bin/lazy-update.js @@ -0,0 +1,12 @@ +var fs = require('fs'); + +module.exports = function(file, content) { + try { + var existing = fs.readFileSync(file, 'utf8'); + if (existing != content) { + fs.writeFileSync(file, content); + } + } catch(err) { + fs.writeFileSync(file, content); + } +}; diff --git a/test/rotation_range.cpp b/test/rotation_range.cpp index 70126f978..41b23f1f8 100644 --- a/test/rotation_range.cpp +++ b/test/rotation_range.cpp @@ -1,6 +1,8 @@ #include #include "gtest/gtest.h" +#include + #include using namespace llmr; diff --git a/test/test.gyp b/test/test.gyp index b601af08c..a9c55ed9a 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -8,6 +8,9 @@ "target_name": "rotation_range", "product_name": "test_rotation_range", "type": "executable", + "libraries": [ + "-lpthread", + ], "sources": [ "./main.cpp", "./rotation_range.cpp", @@ -17,5 +20,12 @@ "../llmr.gyp:llmr-x86" ] }, + { + "target_name": "test", + "type": "none", + "dependencies": [ + "rotation_range" + ], + } ] }