[Cook] Dependency Chaining Question
Henderson, Michael D
michael.d.henderson at lmco.com
Thu Oct 25 06:17:21 EST 2012
I am having a problem building items that depend on items that are built with a generic rule.
log/%: sql/%.sql [%_preq] {
bin/loadTable [target] set silent;
}
I have SQL files that load tables. When each script runs, it creates a log file. The SQL uses a naming standard sql/TABLE_NAME.sql. The log is similar, log/TABLE_NAME.
I want to run a SQL script if:
1. The script has never run
(there is no log file)
2. The script has changed since the last run
(the SQL is new than the log)
3. Another SQL has updated a table that the script uses
(the log for the other SQL is newer than the log for this script)
I thought that I could I could use a simple rule:
log/%: sql/%.sql [%_preq] {
bin/loadTable [target] set silent;
}
I create variables TABLENAME_preq that list the tables that are prerequisites for the script.
CT2_E86_preq += log/CT2_Table__153
log/CT2_Table__154;
But it's not working. I set the "all" target to the top table in the hierarchy, CT2_Table__600. It uses data loaded by the CT2_Table_500. Cook seems to be finding the rule for the 600 table and the dependency on the 500, but it's complaining that it can't determine how to create the 500.
cook: the "log/CT2_Table__600" file could not be derived, no relevant recipes were found; derivations attempted were via log/CT2_Table__500
cook: the "log/CT2_Table__600" file does not exist, this is specified as a terminal error in the cookbook (reason)
cook: Howto.cook: 1: the "all" file was not derived due to errors deriving the "log/CT2_Table__600" file
If I explicitly list the rules:
log/CT2_Table__500 sql/ CT2_Table__500.sql [CT2_Table__500_preq] {
bin/loadTable [target] set silent;
}
log/CT2_Table__600 sql/ CT2_Table__600.sql [CT2_Table__600_preq] {
bin/loadTable [target] set silent;
}
Then 600 realizes that it needs to run 500 first, but 500 fails to use the generic rule to build its dependencies. I've done something similar when building C projects that have library dependencies. I'm sure that I'm overlooking something obvious, but I don't see what.
I'm using 2.32. It's installed by our admin group and it's difficult to get updates applied to the system. If I have to upgrade, I can.
$ cook -version
cook version 2.32.D001
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Peter Miller;
The cook program comes with ABSOLUTELY NO WARRANTY;
for details use the 'cook -VERSion License' command.
The cook program is free software, and you are welcome
to redistribute it under certain conditions; for
details use the 'cook -VERSion License' command.
Here's the Howto.cook file.
$ cat Howto.cook
all: log/CT2_Table__600;
tblList = CT2_AIRPORT_AA
CT2_AIRPORT_CBT
CT2_AIRPORT_EOD
CT2_APPTABLE
CT2_E86
CT2_EOD
CT2_nexus
CT2_Table__146
CT2_Table__147
CT2_Table__149
CT2_Table__152
CT2_Table__153
CT2_Table__154
CT2_Table__164
CT2_Table__165
CT2_Table__166
CT2_Table__167
CT2_Table__169
CT2_Table__171
CT2_Table__172
CT2_Table__173
CT2_Table__178
CT2_Table__179
CT2_Table__180
CT2_Table__181
CT2_Table__183
CT2_Table__184
CT2_Table__185
CT2_Table__188
CT2_Table__189
CT2_Table__191
CT2_Table__284
CT2_Table__500
CT2_Table__600
;
loop local tbl = [tblList] {
[tbl]_dep = sql/[tbl].sql;
[tbl]_preq = ;
}
CT2_E86_preq += log/CT2_Table__153
log/CT2_Table__154;
CT2_nexus_preq += log/CT2_AIRPORT_AA
log/CT2_AIRPORT_CBT
log/CT2_AIRPORT_EOD
log/CT2_E86
log/CT2_EOD
log/CT2_Table__146
log/CT2_Table__147
log/CT2_Table__149
log/CT2_Table__152
log/CT2_Table__164
log/CT2_Table__165
log/CT2_Table__166
log/CT2_Table__167
log/CT2_Table__169
log/CT2_Table__171
log/CT2_Table__172
log/CT2_Table__173
log/CT2_Table__178
log/CT2_Table__179
log/CT2_Table__180
log/CT2_Table__181
log/CT2_Table__183
log/CT2_Table__184
log/CT2_Table__185
log/CT2_Table__188
log/CT2_Table__189
log/CT2_Table__284;
CT2_Table__146_preq += log/CT2_APPTABLE;
CT2_Table__191_preq += log/CT2_AIRPORT_AA
log/CT2_AIRPORT_CBT
log/CT2_AIRPORT_EOD
log/CT2_E86
log/CT2_EOD
log/CT2_Table__146
log/CT2_Table__147
log/CT2_Table__149
log/CT2_Table__152
log/CT2_Table__164
log/CT2_Table__165
log/CT2_Table__166
log/CT2_Table__167
log/CT2_Table__169
log/CT2_Table__171
log/CT2_Table__172
log/CT2_Table__173
log/CT2_Table__178
log/CT2_Table__179
log/CT2_Table__180
log/CT2_Table__181
log/CT2_Table__183
log/CT2_Table__184
log/CT2_Table__185
log/CT2_Table__188
log/CT2_Table__189
log/CT2_Table__284;
CT2_Table__500_preq += log/CT2_nexus;
CT2_Table__600_preq += log/CT2_Table__500;
loop local tbl = [tblList] {
echo [tbl]_dep is [[tbl]_dep] set silent;
echo [tbl]_preq is [[tbl]_preq] set silent;
}
log/%: sql/%.sql [%_preq] {
bin/loadTable [target] set silent;
}
Here's the output:
$ cook -reason
cook: mtime(".how.to.cook") == ENOENT (reason)
cook: mtime(".how.to.cook") == ENOENT (reason)
cook: mtime(".howto.cook") == ENOENT (reason)
cook: mtime(".howto.cook") == ENOENT (reason)
cook: mtime("how.to.cook") == ENOENT (reason)
cook: mtime("How.to.cook") == ENOENT (reason)
cook: mtime("howto.cook") == ENOENT (reason)
cook: mtime("Howto.cook") == 2012/10/24.18:51:19 (reason)
/* Howto.list, ~/jobs, Wed Oct 24 18:51 2012 */
cook: Howto.cook: 1: explicit recipe instantiated (reason)
CT2_AIRPORT_AA_dep is sql/CT2_AIRPORT_AA.sql
CT2_AIRPORT_AA_preq is
CT2_AIRPORT_CBT_dep is sql/CT2_AIRPORT_CBT.sql
CT2_AIRPORT_CBT_preq is
CT2_AIRPORT_EOD_dep is sql/CT2_AIRPORT_EOD.sql
CT2_AIRPORT_EOD_preq is
CT2_APPTABLE_dep is sql/CT2_APPTABLE.sql
CT2_APPTABLE_preq is
CT2_E86_dep is sql/CT2_E86.sql
CT2_E86_preq is log/CT2_Table__153 log/CT2_Table__154
CT2_EOD_dep is sql/CT2_EOD.sql
CT2_EOD_preq is
CT2_nexus_dep is sql/CT2_nexus.sql
CT2_nexus_preq is log/CT2_AIRPORT_AA log/CT2_AIRPORT_CBT log/CT2_AIRPORT_EOD log/CT2_E86 log/CT2_EOD log/CT2_Table__146 log/CT2_Table__147 log/CT2_Table__149 log/CT2_Table__152 log/CT2_Table__164 log/CT2_Table__165 log/CT2_Table__166 log/CT2_Table__167 log/CT2_Table__169 log/CT2_Table__171 log/CT2_Table__172 log/CT2_Table__173 log/CT2_Table__178 log/CT2_Table__179 log/CT2_Table__180 log/CT2_Table__181 log/CT2_Table__183 log/CT2_Table__184 log/CT2_Table__185 log/CT2_Table__188 log/CT2_Table__189 log/CT2_Table__284
CT2_Table__146_dep is sql/CT2_Table__146.sql
CT2_Table__146_preq is log/CT2_APPTABLE
CT2_Table__147_dep is sql/CT2_Table__147.sql
CT2_Table__147_preq is
CT2_Table__149_dep is sql/CT2_Table__149.sql
CT2_Table__149_preq is
CT2_Table__152_dep is sql/CT2_Table__152.sql
CT2_Table__152_preq is
CT2_Table__153_dep is sql/CT2_Table__153.sql
CT2_Table__153_preq is
CT2_Table__154_dep is sql/CT2_Table__154.sql
CT2_Table__154_preq is
CT2_Table__164_dep is sql/CT2_Table__164.sql
CT2_Table__164_preq is
CT2_Table__165_dep is sql/CT2_Table__165.sql
CT2_Table__165_preq is
CT2_Table__166_dep is sql/CT2_Table__166.sql
CT2_Table__166_preq is
CT2_Table__167_dep is sql/CT2_Table__167.sql
CT2_Table__167_preq is
CT2_Table__169_dep is sql/CT2_Table__169.sql
CT2_Table__169_preq is
CT2_Table__171_dep is sql/CT2_Table__171.sql
CT2_Table__171_preq is
CT2_Table__172_dep is sql/CT2_Table__172.sql
CT2_Table__172_preq is
CT2_Table__173_dep is sql/CT2_Table__173.sql
CT2_Table__173_preq is
CT2_Table__178_dep is sql/CT2_Table__178.sql
CT2_Table__178_preq is
CT2_Table__179_dep is sql/CT2_Table__179.sql
CT2_Table__179_preq is
CT2_Table__180_dep is sql/CT2_Table__180.sql
CT2_Table__180_preq is
CT2_Table__181_dep is sql/CT2_Table__181.sql
CT2_Table__181_preq is
CT2_Table__183_dep is sql/CT2_Table__183.sql
CT2_Table__183_preq is
CT2_Table__184_dep is sql/CT2_Table__184.sql
CT2_Table__184_preq is
CT2_Table__185_dep is sql/CT2_Table__185.sql
CT2_Table__185_preq is
CT2_Table__188_dep is sql/CT2_Table__188.sql
CT2_Table__188_preq is
CT2_Table__189_dep is sql/CT2_Table__189.sql
CT2_Table__189_preq is
CT2_Table__191_dep is sql/CT2_Table__191.sql
CT2_Table__191_preq is log/CT2_AIRPORT_AA log/CT2_AIRPORT_CBT log/CT2_AIRPORT_EOD log/CT2_E86 log/CT2_EOD log/CT2_Table__146 log/CT2_Table__147 log/CT2_Table__149 log/CT2_Table__152 log/CT2_Table__164 log/CT2_Table__165 log/CT2_Table__166 log/CT2_Table__167 log/CT2_Table__169 log/CT2_Table__171 log/CT2_Table__172 log/CT2_Table__173 log/CT2_Table__178 log/CT2_Table__179 log/CT2_Table__180 log/CT2_Table__181 log/CT2_Table__183 log/CT2_Table__184 log/CT2_Table__185 log/CT2_Table__188 log/CT2_Table__189 log/CT2_Table__284
CT2_Table__284_dep is sql/CT2_Table__284.sql
CT2_Table__284_preq is
CT2_Table__500_dep is sql/CT2_Table__500.sql
CT2_Table__500_preq is log/CT2_nexus
CT2_Table__600_dep is sql/CT2_Table__600.sql
CT2_Table__600_preq is log/CT2_Table__500
cook: Howto.cook: 114: implicit recipe instantiated (reason)
cook: Howto.cook: 1: the "all" file requires the "log/CT2_Table__600" file (reason)
cook: Howto.cook: 114: the "log/CT2_Table__600" file may require the "sql/CT2_Table__600.sql" file (reason)
cook: mtime("sql/CT2_Table__600.sql") == 2012/10/13.23:40:40 (reason)
cook: the "sql/CT2_Table__600.sql" file exists, it appears to be a primary source file for the derivation (reason)
cook: Howto.cook: 114: the "log/CT2_Table__600" file may require the "log/CT2_Table__500" file (reason)
cook: mtime("log/CT2_Table__500") == ENOENT (reason)
cook: the "log/CT2_Table__500" file does not exist, the derivation will attempt to find an alternative (reason)
cook: Howto.cook: 114: the "log/CT2_Table__600" file is backtracking because this recipe did not apply (reason)
cook: mtime("log/CT2_Table__600") == ENOENT (reason)
cook: the "log/CT2_Table__600" file could not be derived, no relevant recipes were found; derivations attempted were via log/CT2_Table__500
cook: the "log/CT2_Table__600" file does not exist, this is specified as a terminal error in the cookbook (reason)
cook: Howto.cook: 1: the "all" file was not derived due to errors deriving the "log/CT2_Table__600" file
1 backtrack_bad_path
1 backtrack_by_ingredient
1 error_by_ingredient
2 implicit_not_applicable
1 inhibit_self_recursion
1 leaf_error
1 leaf_exists
1 leaf_backtrack
More information about the Cook-users
mailing list