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 <github@kheafield.com>2012-07-02 20:56:14 +0400
committerKenneth Heafield <github@kheafield.com>2012-07-02 20:56:14 +0400
commitbe2b2224fb3828e000b0bb04f90c6cc505e4d7d4 (patch)
treeee67769b0a4a9a40d3cfd3bad44445bd5fbfe5bb /jam-files/sanity.jam
parentc7e02eb67743b31f4cfab752c60fe96f8e2ae630 (diff)
Extract hack to force recompilation if arguments change
Diffstat (limited to 'jam-files/sanity.jam')
-rw-r--r--jam-files/sanity.jam55
1 files changed, 54 insertions, 1 deletions
diff --git a/jam-files/sanity.jam b/jam-files/sanity.jam
index 8c9715ac0..1080f9f3d 100644
--- a/jam-files/sanity.jam
+++ b/jam-files/sanity.jam
@@ -3,6 +3,7 @@ import option ;
import os ;
import path ;
import project ;
+import build-system ;
#Shell with trailing line removed http://lists.boost.org/boost-build/2007/08/17051.php
rule trim-nl ( str extras * ) {
@@ -186,7 +187,59 @@ rule install-headers ( name : list * : source-root ? ) {
}
rule build-projects ( projects * ) {
- for p in $(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) ;
+}
+
+
+#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) ;
+}
+
+#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) ;
+ }
+ }
+}