diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-09-26 22:14:26 +0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-09-26 22:14:26 +0400 |
commit | bc866f37ff13251e9c8cf8548669f788449d9238 (patch) | |
tree | 0eb6545172c4e1fbb09b42c4efd9b86bd6290a66 | |
parent | bf81bdeda58eed12d971c001add9a031219a9efb (diff) |
New approach to forcing recompiles
Fixes annoying problem that unsuccessful build iterations would keep rebuilding Factory.o and CompactPT
-rw-r--r-- | jam-files/sanity.jam | 47 | ||||
-rw-r--r-- | moses/src/CompactPT/Jamfile | 12 | ||||
-rw-r--r-- | moses/src/LM/Jamfile | 40 |
3 files changed, 38 insertions, 61 deletions
diff --git a/jam-files/sanity.jam b/jam-files/sanity.jam index a2616f6bf..6beec3f94 100644 --- a/jam-files/sanity.jam +++ b/jam-files/sanity.jam @@ -235,42 +235,21 @@ rule add-post-hook ( names * ) { post-hooks += $(names) ; } - -#Backend for writing content to files after build completes. -post-files = ; -post-contents = ; -rule save-post-build ( ok ? ) { - if $(ok) { - while $(post-files) { - local ignored = @($(post-files[1]):E=$(post-contents[1])) ; - post-files = $(post-files[2-]) ; - post-contents = $(post-contents[2-]) ; - } - } -} -add-post-hook save-post-build ; - -#Queue content to be written to file when build completes successfully. -rule add-post-write ( name content ) { - post-files += $(name) ; - post-contents += $(content) ; +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, force the targets to rebuild then overwrite the file. -rule always-if-changed ( file current : targets * ) { - local previous = inconsistent ; - if [ path.exists $(file) ] { - previous = [ _shell "cat $(file)" ] ; - } - if $(current) != $(previous) { - #Write inconsistent while the build is running - if [ path.exists $(file) ] { - local ignored = @($(file):E=inconsistent) ; - } - add-post-write $(file) $(current) ; - for local i in $(targets) { - always $(i) ; - } +#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) ; } } diff --git a/moses/src/CompactPT/Jamfile b/moses/src/CompactPT/Jamfile index cf7fe2552..c4c5db96f 100644 --- a/moses/src/CompactPT/Jamfile +++ b/moses/src/CompactPT/Jamfile @@ -1,10 +1,10 @@ -local current = ; +local current = "" ; local includes = ; local with-cmph = [ option.get "with-cmph" ] ; if $(with-cmph) { lib cmph : : <search>$(with-cmph)/lib ; includes += <include>$(with-cmph)/include ; - current += "--with-cmph=$(with-cmph)" ; + current = "--with-cmph=$(with-cmph)" ; } else { alias cmph ; @@ -12,9 +12,7 @@ else { alias sources : [ glob *.cpp ] ; -lib CompactPT : sources ..//moses_internal cmph : $(includes) ; - path-constant PT-LOG : bin/pt.log ; -current = $(current:J=" ") ; -current ?= "" ; -always-if-changed $(PT-LOG) $(current) : sources ; +update-if-changed $(PT-LOG) $(current) ; + +lib CompactPT : sources ..//moses_internal cmph : $(includes) <dependency>$(PT-LOG) ; diff --git a/moses/src/LM/Jamfile b/moses/src/LM/Jamfile index c9d3ac76a..60f73303d 100644 --- a/moses/src/LM/Jamfile +++ b/moses/src/LM/Jamfile @@ -7,6 +7,25 @@ import option path ; +#This is a kludge to force rebuilding if different --with options are passed. +#Could have used features like <srilm>on but getting these to apply only to +#linking was ugly and it still didn't trigger an install (since the install +#path doesn't encode features). It stores a file lm.log with the previous +#options and forces a rebuild if the current options differ. +local current = ; +for local i in srilm irstlm randlm { + local optval = [ option.get "with-$(i)" ] ; + if $(optval) { + current += "--with-$(i)=$(optval)" ; + } +} +current = $(current:J=" ") ; +current ?= "" ; + +path-constant LM-LOG : bin/lm.log ; +update-if-changed $(LM-LOG) $(current) ; + + local dependencies = ; #IRSTLM @@ -69,28 +88,9 @@ if $(with-ldhtlm) { obj ORLM.o : ORLM.cpp ..//headers ../DynSAInclude//dynsa : : : <include>../DynSAInclude ; #The factory needs the macros LM_IRST etc to know which ones to use. -obj Factory.o : Factory.cpp ..//headers $(dependencies) : <include>../DynSAInclude ; +obj Factory.o : Factory.cpp ..//headers $(dependencies) : <include>../DynSAInclude <dependency>$(LM-LOG) ; #Top-level LM library. If you've added a file that doesn't depend on external #libraries, put it here. lib LM : Base.cpp Factory.o Implementation.cpp Joint.cpp Ken.cpp MultiFactor.cpp Remote.cpp SingleFactor.cpp ORLM.o ../../../lm//kenlm ..//headers $(dependencies) ; - -#Everything below is a kludge to force rebuilding if different --with options -#are passed. Could have used features like <srilm>on but getting these to -#apply only to linking was ugly and it still didn't trigger an install (since -#the install path doesn't encode features). It stores a file lm.log with the -#previous options and forces a rebuild if the current options differ. -path-constant LM-LOG : bin/lm.log ; - -local current = ; -for local i in srilm irstlm randlm { - local optval = [ option.get "with-$(i)" ] ; - if $(optval) { - current += "--with-$(i)=$(optval)" ; - } -} -current = $(current:J=" ") ; -current ?= "" ; - -always-if-changed $(LM-LOG) $(current) : Factory.o LM ; |