From d364211d9088667ddb98136e0c9a29b913c31717 Mon Sep 17 00:00:00 2001 From: Ulrich Germann Date: Thu, 26 Mar 2015 12:21:55 +0000 Subject: More bjam fiddling. --- Jamroot | 51 ++++++++++++++++------------------------- contrib/server/Jamfile | 2 +- jam-files/check-environment.jam | 42 +++++++++++++++++++++++++++++++++ jam-files/sanity.jam | 8 +++++++ moses/Jamfile | 20 ++++++---------- 5 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 jam-files/check-environment.jam diff --git a/Jamroot b/Jamroot index 8d56d5bf0..59ef26ee6 100644 --- a/Jamroot +++ b/Jamroot @@ -72,47 +72,38 @@ #--clean to clean #--debug-build to build with Og. Only available with gcc 4.8+ +import os ; import option ; import modules ; import path ; path-constant TOP : . ; + include $(TOP)/jam-files/sanity.jam ; -include $(TOP)/jam-files/server.jam ; -# exit : 0 ; +home = [ os.environ "HOME" ] ; +if [ path.exists $(home)/moses-environment.jam ] +{ include $(home)/moses-environment.jam ; } +include $(TOP)/jam-files/check-environment.jam ; # get resource locations + # from environment variables +include $(TOP)/jam-files/xmlrpc-c.jam ; # xmlrpc-c stuff for the server +include $(TOP)/jam-files/curlpp.jam ; # curlpp stuff for bias lookup (MMT only) + -if [ build_server ] != no +max-order = [ option.get "max-kenlm-order" : 6 : 6 ] ; +if ! [ option.get "max-kenlm-order" ] { - xmlrpc-c-prefix = [ shell_or_die "$(xmlrpc-c-config-cmd) c++2 abyss-server --prefix" ] ; - echo "XMLRPC-C: BUILDING MOSES WITH XMLRPC_C LIBRARY VERSION $(xmlrpc-c-version) FROM $(xmlrpc-c-prefix)" ; - - xmlrpc-cxxflags = [ shell_or_die "$(xmlrpc-c-config-cmd) c++2 abyss-server --cflags" ] ; - requirements += HAVE_XMLRPC_C ; - requirements += $(xmlrpc-cxxflags) ; - - xmlrpc-linkflags = [ shell_or_die "$(xmlrpc-c-config-cmd) c++2 abyss-server --libs" ] ; - for local i in [ SPLIT_BY_CHARACTERS $(xmlrpc-linkflags) : " " ] - { - local libname = [ MATCH "-l(xmlrpc.*)" : $(i) ] ; - if $(libname) - { - external-lib $(libname) - : : static:static shared:shared ; - requirements += $(libname) ; - } - local pathname = [ MATCH "-L(.*)" : $(i) ] ; - if $(pathname) - { - requirements += $(pathname) ; - } - } + # some classes in Moses pull in header files from KenLM, so this needs to be + # defined here, not in moses/lm/Jamfile + option.set "max-kenlm-order" : 6 ; + requirements += KENLM_MAX_ORDER=$(max-order) ; } -# echo $(requirements) ; -# exit 0 ; +# exit "all done" : 0 ; + boost 104400 ; external-lib z ; lib dl : : static:static shared:shared ; +# lib dl : : static ; requirements += dl ; @@ -139,6 +130,7 @@ if [ option.get "filter-warnings" : : "yes" ] { requirements += -Wno-unused-but-set-variable ; requirements += -Wno-unused-result ; requirements += -Wno-unused-variable ; + requirements += -Wcomment ; } if [ option.get "debug-build" : : "yes" ] { @@ -307,6 +299,3 @@ if [ path.exists $(TOP)/dist ] && $(prefix) != dist { local temp = [ _shell "mkdir -p $(TOP)/bin" ] ; local temp = [ _shell "rm $(TOP)/bin/moses_chart" ] ; local temp = [ _shell "cd $(TOP)/bin && ln -s moses moses_chart" ] ; - - - diff --git a/contrib/server/Jamfile b/contrib/server/Jamfile index 06624514b..048e540b0 100644 --- a/contrib/server/Jamfile +++ b/contrib/server/Jamfile @@ -11,7 +11,7 @@ else { with-xmlrpc-c = [ option.get "with-xmlrpc-c" ] ; if $(with-xmlrpc-c) { - echo Bulding mosesserver. ; + echo While building mosesserver ... ; echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ; echo "!!! You are linking the XMLRPC-C library; Do NOT use v.1.25.29 !!!" ; echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ; diff --git a/jam-files/check-environment.jam b/jam-files/check-environment.jam new file mode 100644 index 000000000..32866683b --- /dev/null +++ b/jam-files/check-environment.jam @@ -0,0 +1,42 @@ +# get stuff from environment variables if not set on the command line +# unless blocked explicitly +for local what in cmph irstlm +{ + if ! [ option.get "with-$(what)" ] && ! [ option.get "no-$(what)" : : no ] + { + local where = [ os.environ "$(what:U)_ROOT" ] ; + if $(where) + { + echo "setting option with-$(what) from environment variable " + "$(what:U)_ROOT ." ; + option.set "with-$(what)" : $(where) ; + } + } + local where = [ option.get "with-$(what)" ] ; +} + +# if --with-moses-regtest is specified without a directory +local regtest = [ option.get "with-moses-regtest" : no : yes ] ; +if $(regtest) = yes +{ # regtests requested but no path given + echo "Regression tests requested but no path given." ; + local $(where) = [ os.environ "MOSES_REGTEST_ROOT" ] ; + if ! $(where) + { + local HOME = [ os.environ "HOME" ] ; + if [ path.exists $(HOME)/moses-regression-tests ] + { + echo "Using ~/moses-regression-tests as the default." ; + option.set "with-moses-regtest" : "~/moses-regression-tests" ; + } + } + else + { + if [ path.exists $(where) ] + { + echo "Using $(where) from environment variable MOSES_REGTEST_ROOT." + option.set "with-moses-regtest" : $(where) ; + } + } +} + diff --git a/jam-files/sanity.jam b/jam-files/sanity.jam index e991b7eb2..b16343c7b 100644 --- a/jam-files/sanity.jam +++ b/jam-files/sanity.jam @@ -22,6 +22,14 @@ rule shell_or_fail ( cmd ) { } } +rule shell_or_die ( cmd ) { + local ret = [ SHELL $(cmd) : exit-status ] ; + if $(ret[2]) != 0 { + exit $(cmd) failed : 1 ; + } + return [ trim-nl $(ret[1]) ] ; +} + cxxflags = [ os.environ "CXXFLAGS" ] ; cflags = [ os.environ "CFLAGS" ] ; ldflags = [ os.environ "LDFLAGS" ] ; diff --git a/moses/Jamfile b/moses/Jamfile index 822645505..c94750ec6 100644 --- a/moses/Jamfile +++ b/moses/Jamfile @@ -1,3 +1,4 @@ +# -*- jam -*- max-factors = [ option.get "max-factors" : 4 : 4 ] ; path-constant FACTOR-LOG : bin/factor.log ; update-if-changed $(FACTOR-LOG) $(max-factors) ; @@ -58,23 +59,16 @@ obj FF_Factory.o : FF/Factory.cpp LM//macros headers ../lm//kenlm mmlib :