diff options
author | Eva Hasler <ehasler@saxnot.inf.ed.ac.uk> | 2012-10-03 21:53:55 +0400 |
---|---|---|
committer | Eva Hasler <ehasler@saxnot.inf.ed.ac.uk> | 2012-10-03 21:53:55 +0400 |
commit | e7e4dbd405e8d29a9a429c6b5eb366a2fe0ecf9a (patch) | |
tree | d6cc808944fab7112253c2be3e62652f45f0d076 /jam-files/sanity.jam | |
parent | ebbf0d028c8724767f49a29f1f052a938020dd5a (diff) | |
parent | 9931a1e0fd84fa0cd2a149fde0b67ccd54b4b65c (diff) |
merge remaining changes to mira, word pair features, phrase pair features
Diffstat (limited to 'jam-files/sanity.jam')
-rw-r--r-- | jam-files/sanity.jam | 131 |
1 files changed, 110 insertions, 21 deletions
diff --git a/jam-files/sanity.jam b/jam-files/sanity.jam index 7b93cf36f..6beec3f94 100644 --- a/jam-files/sanity.jam +++ b/jam-files/sanity.jam @@ -3,6 +3,8 @@ import option ; import os ; import path ; import project ; +import build-system ; +import version ; #Shell with trailing line removed http://lists.boost.org/boost-build/2007/08/17051.php rule trim-nl ( str extras * ) { @@ -13,8 +15,20 @@ rule _shell ( cmd : extras * ) { return [ trim-nl [ SHELL $(cmd) : $(extras) ] ] ; } +rule shell_or_fail ( cmd ) { + local ret = [ SHELL $(cmd) : exit-status ] ; + if $(ret[2]) != 0 { + exit $(cmd) failed : 1 ; + } +} + +cxxflags = [ os.environ "CXXFLAGS" ] ; +cflags = [ os.environ "CFLAGS" ] ; +ldflags = [ os.environ "LDFLAGS" ] ; + #Run g++ with empty main and these arguments to see if it passes. rule test_flags ( flags * ) { + flags = $(cxxflags) $(ldflags) $(flags) ; local cmd = "bash -c \"g++ "$(flags:J=" ")" -x c++ - <<<'int main() {}' -o /dev/null >/dev/null 2>/dev/null\"" ; local ret = [ SHELL $(cmd) : exit-status ] ; if --debug-configuration in [ modules.peek : ARGV ] { @@ -28,6 +42,14 @@ rule test_flags ( flags * ) { } } +rule test_header ( name ) { + return [ test_flags "-include $(name)" ] ; +} + +rule test_library ( name ) { + return [ test_flags "-l$(name)" ] ; +} + { local cleaning = [ option.get "clean" : : yes ] ; cleaning ?= [ option.get "clean-all" : no : yes ] ; @@ -37,13 +59,25 @@ rule test_flags ( flags * ) { constant CLEANING : $(cleaning) ; } +requirements = ; + +FORCE-STATIC = [ option.get "static" : : "yes" ] ; +if $(FORCE-STATIC) { + requirements += <runtime-link>static ; +} + #Determine if a library can be compiled statically. rule auto-shared ( name : additional * ) { additional ?= "" ; if [ test_flags $(additional)" -static -l"$(name) ] { return ; } else { - return "<link>shared" ; + if $(FORCE-STATIC) { + echo "Could not statically link against lib $(name). Your build will probably fail." ; + return ; + } else { + return "<link>shared" ; + } } } @@ -60,6 +94,7 @@ if $(with-macports) { } else { with-boost = [ option.get "with-boost" ] ; + with-boost ?= [ os.environ "BOOST_ROOT" ] ; if $(with-boost) { L-boost-search = -L$(with-boost)/lib" "-L$(with-boost)/lib64 ; boost-search = <search>$(with-boost)/lib <search>$(with-boost)/lib64 ; @@ -73,18 +108,16 @@ else { } } -#Are we linking static binaries against shared boost? -boost-auto-shared = [ auto-shared "boost_program_options" : $(L-boost-search) ] ; #Convenience rule for boost libraries. Defines library boost_$(name). -rule boost-lib ( name macro ) { +rule boost-lib ( name macro : deps * ) { #Link multi-threaded programs against the -mt version if available. Old #versions of boost do not have -mt tagged versions of all libraries. Sadly, #boost.jam does not handle this correctly. - if [ test_flags $(L-boost-search)" -lboost_"$(name)"-mt" ] { - lib inner_boost_$(name) : : <threading>single $(boost-search) <name>boost_$(name) ; - lib inner_boost_$(name) : : <threading>multi $(boost-search) <name>boost_$(name)-mt ; + if [ test_flags $(L-boost-search)" -lboost_"$(name)"-mt$(boost-lib-version)" ] { + lib inner_boost_$(name) : : <threading>single $(boost-search) <name>boost_$(name)$(boost-lib-version) : : <library>$(deps) ; + lib inner_boost_$(name) : : <threading>multi $(boost-search) <name>boost_$(name)-mt$(boost-lib-version) : : <library>$(deps) ; } else { - lib inner_boost_$(name) : : $(boost-search) <name>boost_$(name) ; + lib inner_boost_$(name) : : $(boost-search) <name>boost_$(name)$(boost-lib-version) : : <library>$(deps) ; } alias boost_$(name) : inner_boost_$(name) : $(boost-auto-shared) : : <link>shared:<define>BOOST_$(macro) $(boost-include) ; @@ -92,7 +125,7 @@ rule boost-lib ( name macro ) { #Argument is e.g. 103600 rule boost ( min-version ) { - local cmd = "bash -c \"g++ "$(I-boost-include)" -dM -x c++ -E /dev/null -include boost/version.hpp 2>/dev/null |grep '#define BOOST_VERSION '\"" ; + local cmd = "bash -c \"g++ "$(I-boost-include)" -dM -x c++ -E /dev/null -include boost/version.hpp 2>/dev/null |grep '#define BOOST_'\"" ; local boost-shell = [ SHELL "$(cmd)" : exit-status ] ; if $(boost-shell[2]) != 0 && $(CLEANING) = no { echo Failed to run "$(cmd)" ; @@ -102,11 +135,24 @@ rule boost ( min-version ) { if $(boost-version) < $(min-version) && $(CLEANING) = no { exit You have Boost $(boost-version). This package requires Boost at least $(min-version) (and preferably newer). : 1 ; } + # If matching version tags exist, use them. + boost-lib-version = [ MATCH "#define BOOST_LIB_VERSION \"([^\"]*)\"" : $(boost-shell[1]) ] ; + if [ test_flags $(L-boost-search)" -lboost_program_options-"$(boost-lib-version) ] { + boost-lib-version = "-"$(boost-lib-version) ; + } else { + boost-lib-version = "" ; + } + + #Are we linking static binaries against shared boost? + boost-auto-shared = [ auto-shared "boost_program_options"$(boost-lib-version) : $(L-boost-search) ] ; + #See tools/build/v2/contrib/boost.jam in a boost distribution for a table of macros to define. - boost-lib thread THREAD_DYN_DLL ; + boost-lib system SYSTEM_DYN_LINK ; + boost-lib thread THREAD_DYN_DLL : boost_system ; boost-lib program_options PROGRAM_OPTIONS_DYN_LINK ; boost-lib unit_test_framework TEST_DYN_LINK ; boost-lib iostreams IOSTREAMS_DYN_LINK ; + boost-lib filesystem FILE_SYSTEM_DYN_LINK : boost_system ; } #Link normally to a library, but sometimes static isn't installed so fall back to dynamic. @@ -132,15 +178,10 @@ rule external-lib ( name : search-path * ) { local ignored = @($(build-log):E=$(script)) ; } -requirements = ; -{ - local cxxflags = [ os.environ "CXXFLAGS" ] ; - local cflags = [ os.environ "CFLAGS" ] ; - local ldflags = [ os.environ "LDFLAGS" ] ; - - #Boost jam's static clang for Linux is buggy. - requirements += <cxxflags>$(cxxflags) <cflags>$(cflags) <linkflags>$(ldflags) <os>LINUX,<toolset>clang:<link>shared ; +#Boost jam's static clang for Linux is buggy. +requirements += <cxxflags>$(cxxflags) <cflags>$(cflags) <linkflags>$(ldflags) <os>LINUX,<toolset>clang:<link>shared ; +if ! [ option.get "without-libsegfault" : : "yes" ] && ! $(FORCE-STATIC) { #libSegFault prints a stack trace on segfault. Link against it if available. if [ test_flags "-lSegFault" ] { external-lib SegFault ; @@ -158,12 +199,14 @@ if [ option.get "git" : : "yes" ] { prefix = [ option.get "prefix" ] ; if $(prefix) { prefix = [ path.root $(prefix) [ path.pwd ] ] ; + prefix = $(prefix)$(GITTAG) ; } else { - prefix = $(TOP)/dist$(GITTAG) ; + prefix = $(TOP)$(GITTAG) ; } + +bindir = [ option.get "bindir" : $(prefix)/bin ] ; +libdir = [ option.get "libdir" : $(prefix)/lib ] ; rule install-bin-libs ( deps * ) { - local bindir = [ option.get "bindir" : $(prefix)/bin ] ; - local libdir = [ option.get "libdir" : $(prefix)/lib ] ; install prefix-bin : $(deps) : <location>$(bindir) <install-dependencies>on <install-type>EXE <link>shared:<dll-path>$(libdir) ; install prefix-lib : $(deps) : <location>$(libdir) <install-dependencies>on <install-type>LIB <link>shared:<dll-path>$(libdir) ; } @@ -172,3 +215,49 @@ rule install-headers ( name : list * : source-root ? ) { source-root ?= "." ; install $(name) : $(list) : <location>$(includedir) <install-source-root>$(source-root) ; } + +rule build-projects ( projects * ) { + for local p in $(projects) { + build-project $(p) ; + } +} + +#Only one post build hook is allowed. Allow multiple. +post-hooks = ; +rule post-build ( ok ? ) { + for local r in $(post-hooks) { + $(r) $(ok) ; + } +} +IMPORT $(__name__) : post-build : : $(__name__).post-build ; +build-system.set-post-build-hook $(__name__).post-build ; +rule add-post-hook ( names * ) { + post-hooks += $(names) ; +} + +import feature : feature ; +feature options-to-write : : free ; +import toolset : flags ; +flags write-options OPTIONS-TO-WRITE <options-to-write> ; +actions write-options { + echo "$(OPTIONS-TO-WRITE)" > $(<) ; +} + +#Compare contents of file with current. If they're different, write to the +#file. This file can then be used with <dependency>$(file) to force +#recompilation. +rule update-if-changed ( file current ) { + if ( ! [ path.exists $(file) ] ) || ( [ _shell "cat $(file)" ] != $(current) ) { + make $(file) : : $(__name__).write-options : <options-to-write>$(current) ; + always $(file) ; + } +} + +if [ option.get "sanity-test" : : "yes" ] { + local current_version = [ modules.peek : JAM_VERSION ] ; + if ( $(current_version[0]) < 2000 && [ version.check-jam-version 3 1 16 ] ) || [ version.check-jam-version 2011 0 0 ] { + EXIT "Sane" : 0 ; + } else { + EXIT "Bad" : 1 ; + } +} |