Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <kheafiel@cluster01.lti.ece.cmu.local>2012-05-07 20:58:34 +0400
committerKenneth Heafield <kheafiel@cluster01.lti.ece.cmu.local>2012-05-07 20:58:34 +0400
commit36f31a017bcb7550b434b52d36699db0581ce2a7 (patch)
tree1dc6457ddaaf3d00490aee4559013049efc7aac0 /jam-files
parent8f8b4693c3273d19a84f62fc22409e5adb334f37 (diff)
Refactor Jamroot to separate Moses high-level and common low-level.
Diffstat (limited to 'jam-files')
-rw-r--r--jam-files/sanity.jam152
-rwxr-xr-xjam-files/test.sh3
2 files changed, 152 insertions, 3 deletions
diff --git a/jam-files/sanity.jam b/jam-files/sanity.jam
new file mode 100644
index 000000000..e4784482e
--- /dev/null
+++ b/jam-files/sanity.jam
@@ -0,0 +1,152 @@
+import modules ;
+import option ;
+import os ;
+import path ;
+import project ;
+
+local prj = [ project.current ] ;
+mod = [ $(prj).project-module ] ;
+
+path-constant TOP : . ;
+
+#Shell with trailing line removed http://lists.boost.org/boost-build/2007/08/17051.php
+rule trim-nl ( str extras * ) {
+return [ MATCH "([^
+]*)" : $(str) ] $(extras) ;
+}
+rule _shell ( cmd : extras * ) {
+ return [ trim-nl [ SHELL $(cmd) : $(extras) ] ] ;
+}
+
+#Run g++ with empty main and these arguments to see if it passes.
+rule test_flags ( flags * ) {
+ local ret = [ SHELL "g++ "$(flags:J=" ")" -x c++ - <<<'int main() {}' -o /dev/null >/dev/null 2>/dev/null" : exit-status ] ;
+ if $(ret[2]) = 0 {
+ return true ;
+ } else {
+ return ;
+ }
+}
+
+{
+ local cleaning = [ option.get "clean" : : yes ] ;
+ cleaning ?= [ option.get "clean-all" : no : yes ] ;
+ if "clean" in [ modules.peek : ARGV ] {
+ cleaning = yes ;
+ }
+ constant CLEANING : $(cleaning) ;
+}
+
+#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" ;
+ }
+}
+
+with-boost = [ option.get "with-boost" ] ;
+if $(with-boost) {
+ L-boost-search = -L$(with-boost)/lib" "-L$(with-boost)/lib64 ;
+ boost-search = <search>$(with-boost)/lib <search>$(with-boost)/lib64 ;
+ I-boost-include = -I$(with-boost)/include ;
+ boost-include = <include>$(with-boost)/include ;
+} else {
+ L-boost-search = "" ;
+ boost-search = ;
+ I-boost-include = "" ;
+ boost-include = ;
+}
+
+#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 ) {
+ #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 ;
+ } else {
+ lib inner_boost_$(name) : : $(boost-search) <name>boost_$(name) ;
+ }
+
+ alias boost_$(name) : inner_boost_$(name) : $(boost-auto-shared) : : <link>shared:<define>BOOST_$(macro) $(boost-include) ;
+}
+
+#Argument is e.g. 103600
+rule boost ( min-version ) {
+ local boost-shell = [ SHELL "g++ "$(I-boost-include)" -dM -x c++ -E /dev/null -include boost/version.hpp 2>/dev/null |grep '#define BOOST_VERSION '" : exit-status ] ;
+ if $(boost-shell[2]) != 0 && $(CLEANING) = no {
+ exit Boost does not seem to be installed or g++ is confused. : 1 ;
+ }
+ boost-version = [ MATCH "#define BOOST_VERSION ([0-9]*)" : $(boost-shell[1]) ] ;
+ 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 ;
+ }
+ #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 program_options PROGRAM_OPTIONS_DYN_LINK ;
+ boost-lib unit_test_framework TEST_DYN_LINK ;
+}
+
+#Link normally to a library, but sometimes static isn't installed so fall back to dynamic.
+rule external-lib ( name : search-path * ) {
+ lib $(name) : : [ auto-shared $(name) : "-L"$(search-path) ] <search>$(search-path) ;
+}
+
+#Write the current command line to previous.sh. This does not do shell escaping.
+{
+ local build-log = $(TOP)/previous.sh ;
+ if ! [ path.exists $(build-log) ] {
+ SHELL "touch $(build-log) && chmod +x $(build-log)" ;
+ }
+ local script = [ modules.peek : ARGV ] ;
+ if $(script[1]) = "./jam-files/bjam" {
+ #The ./bjam shell script calls ./jam-files/bjam so that appears in argv but
+ #we want ./bjam to appear so the environment variables are set correctly.
+ script = "./bjam "$(script[2-]:J=" ") ;
+ } else {
+ script = $(script:J=" ") ;
+ }
+ script = "#!/bin/sh\n$(script)\n" ;
+ local ignored = @($(build-log):E=$(script)) ;
+}
+
+requirements = ;
+{
+ local cxxflags = [ os.environ "CXXFLAGS" ] ;
+ local cflags = [ os.environ "CFLAGS" ] ;
+ local ldflags = [ os.environ "LDFLAGS" ] ;
+
+ requirements += <cxxflags>$(cxxflags) <cflags>$(cflags) <linkflags>$(ldflags) <os>LINUX,<link>static,<toolset>clang:<linkflags>-static ;
+
+ #libSegFault prints a stack trace on segfault. Link against it if available.
+ if [ test_flags "-lSegfault" ] {
+ external-lib SegFault ;
+ requirements += <library>SegFault ;
+ }
+}
+
+if [ option.get "git" : : "yes" ] {
+ local revision = [ _shell "git rev-parse --verify HEAD |head -c 7" ] ;
+ GITTAG = "/"$(revision) ;
+} else {
+ GITTAG = "" ;
+}
+
+prefix = [ option.get "prefix" : $(TOP)/dist$(GITTAG) ] ;
+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) ;
+}
+rule install-headers ( name : list * : source-root ? ) {
+ local includedir = [ option.get "includedir" : $(prefix)/include ] ;
+ source-root ?= "." ;
+ install $(name) : $(list) : <location>$(includedir) <install-source-root>$(source-root) ;
+}
diff --git a/jam-files/test.sh b/jam-files/test.sh
deleted file mode 100755
index 4e06d9e2b..000000000
--- a/jam-files/test.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-g++ "$@" -x c++ - <<<'int main() {}' -o /dev/null >/dev/null 2>/dev/null
-echo -n $?