From f4144ac05a0e2f243414d5ebf6eef9510a5c1bc4 Mon Sep 17 00:00:00 2001 From: Dirk Baechle Date: Tue, 19 Jul 2011 19:09:01 +0000 Subject: - improved documentation for custom Decider functions (fix for #2711) --- doc/user/depends.in | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++- doc/user/depends.xml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 2 deletions(-) diff --git a/doc/user/depends.in b/doc/user/depends.in index 4428a63..88828fe 100644 --- a/doc/user/depends.in +++ b/doc/user/depends.in @@ -487,7 +487,7 @@ only its section of the input file. However, since the input file may contain a lot of data, we want to open the input file only if its timestamp has changed. - This could done with a custom + This could be done with a custom &Decider; function that might look something like this: @@ -591,6 +591,59 @@ + + + Another thing to look out for, is the fact that the three + attributes above may not be present at the time of the first run. + Without any prior build, no targets got created and no + .sconsign DB file exists yet. + So, it is recommended to always check whether the + prev_ni attribute in question is available. + + + + + + We finally present a small example for a + csig-based decider function. Note how the + signature information for the dependency file + has to get initialized via get_csig + during each function call (this is mandatory!). + + + + + env = Environment() + + def config_file_decider(dependency, target, prev_ni): + import os.path + + # We always have to init the .csig value... + dep_csig = dependency.get_csig() + # .csig may not exist, because no target was built yet... + if 'csig' not in dir(prev_ni): + return True + # Target file may not exist yet + if not os.path.exists(str(target.abspath)): + return True + if dep_csig != prev_ni.csig: + # Some change on source file => update installed one + return True + return False + + def update_file(): + f = open("test.txt","a") + f.write("some line\n") + f.close() + + update_file() + + # Activate our own decider function + env.Decider(config_file_decider) + + env.Install("install","test.txt") + +
diff --git a/doc/user/depends.xml b/doc/user/depends.xml index 2853975..a5e84d6 100644 --- a/doc/user/depends.xml +++ b/doc/user/depends.xml @@ -488,7 +488,7 @@ only its section of the input file. However, since the input file may contain a lot of data, we want to open the input file only if its timestamp has changed. - This could done with a custom + This could be done with a custom &Decider; function that might look something like this: @@ -587,6 +587,59 @@ + + + Another thing to look out for, is the fact that the three + attributes above may not be present at the time of the first run. + Without any prior build, no targets got created and no + .sconsign DB file exists yet. + So, it is recommended to always check whether the + prev_ni attribute in question is available. + + + + + + We finally present a small example for a + csig-based decider function. Note how the + signature information for the dependency file + has to get initialized via get_csig + during each function call (this is mandatory!). + + + + + env = Environment() + + def config_file_decider(dependency, target, prev_ni): + import os.path + + # We always have to init the .csig value... + dep_csig = dependency.get_csig() + # .csig may not exist, because no target was built yet... + if 'csig' not in dir(prev_ni): + return True + # Target file may not exist yet + if not os.path.exists(str(target.abspath)): + return True + if dep_csig != prev_ni.csig: + # Some change on source file => update installed one + return True + return False + + def update_file(): + f = open("test.txt","a") + f.write("some line\n") + f.close() + + update_file() + + # Activate our own decider function + env.Decider(config_file_decider) + + env.Install("install","test.txt") + +
-- cgit v0.12