summaryrefslogtreecommitdiffstats
path: root/atoms_cc
diff options
context:
space:
mode:
authorSimon Lipp <simon.lipp@scilab.org>2008-06-26 11:37:11 +0000
committerSimon Lipp <simon.lipp@scilab.org>2008-06-26 11:37:11 +0000
commitc225f23613aa120c9c47369f47ff378a44ba7fc0 (patch)
treebfee4b45ff0fda31163aed94d30d4b8e15b35a31 /atoms_cc
parent8c0a6971aff81dbe08604d23e6120416b683f852 (diff)
downloadscilab-c225f23613aa120c9c47369f47ff378a44ba7fc0.zip
scilab-c225f23613aa120c9c47369f47ff378a44ba7fc0.tar.gz
atoms_cc/buildtoolbox.pl: make check_tree more maintainable (arguably easier to read)
Diffstat (limited to 'atoms_cc')
-rwxr-xr-xatoms_cc/buildtoolbox.pl93
1 files changed, 33 insertions, 60 deletions
diff --git a/atoms_cc/buildtoolbox.pl b/atoms_cc/buildtoolbox.pl
index 80ef477..770636d 100755
--- a/atoms_cc/buildtoolbox.pl
+++ b/atoms_cc/buildtoolbox.pl
@@ -174,24 +174,13 @@ sub check_tree {
174 } 174 }
175 175
176 # macros/ must contain only .sci and .sce files 176 # macros/ must contain only .sci and .sce files
177 # If it exists and is non-empty, it must contains buildmacros.sce
178 my $macros_empty = 1;
179 my $macros_has_builder = 0;
180 foreach (grep { $_ =~ m#^macros/# } keys %tree) { 177 foreach (grep { $_ =~ m#^macros/# } keys %tree) {
181 if(/\.sc[ie]$/) { 178 if(!/(\.sc[ie]|\/)$/) {
182 $macros_empty = 0;
183 $macros_has_builder = 1 if(m#/buildmacros\.sce$#);
184 }
185 elsif(!/\/$/) { # Don't be /too/ nazi: allow sub-directories :)
186 die "Incorrect archive: macros/ must contain only .sci and .sce files". 179 die "Incorrect archive: macros/ must contain only .sci and .sce files".
187 " (\"$_\" found)"; 180 " (\"$_\" found)";
188 } 181 }
189 } 182 }
190 183
191 if(!$macros_empty && !$macros_has_builder) {
192 die "Incorrect archive: macros/ not empty and no buildmacros.sce script found";
193 }
194
195 # All fortran files must be in src/fortran 184 # All fortran files must be in src/fortran
196 foreach (grep { $_ =~ /\.f$/} keys %tree) { 185 foreach (grep { $_ =~ /\.f$/} keys %tree) {
197 if(!m#^src/fortran/#) { 186 if(!m#^src/fortran/#) {
@@ -208,54 +197,38 @@ sub check_tree {
208 } 197 }
209 } 198 }
210 199
211 # if src/c contains at least a .c file, src/c/buildsrc_c.sce must exists 200 # Constraints: if $key exists, $constraints{$key} must exist
212 my $has_c_source = grep { $_ =~ m#^src/c/.+\.[ch]$# } keys %tree; 201 my %constraints = (
213 my $has_c_src_builder = defined($tree{"src/c/buildsrc_c.sce"}); 202 qr#help/.+\.xml$# => "help/buildhelp.sce",
214 if($has_c_source && !$has_c_src_builder) { 203 qr#macros/.+\.sc[ie]$# => "macros/buildmacros.sce");
215 die "Incorrect archives: C source found in src/c/ but no buildsrc_c.sce ". 204
216 "script found"; 205 # Build constraints for allowed languages
217 } 206 my %languages = (
218 207 "c" => qr/[ch]/,
219 # if src/fortran contains at least a .f file, src/fortran/buildsrc_fortran.sce must exists 208 "fortran" => qr/f/);
220 my $has_f_source = grep { $_ =~ m#^src/fortran/.+\.f$# } keys %tree; 209
221 my $has_f_src_builder = defined($tree{"src/fortran/buildsrc_fortran.sce"}); 210 foreach (keys %languages) {
222 if($has_f_source && !$has_f_src_builder) { 211 # if src/(lang) has source files, src/(lang)/buildsrc_(lang).sce must exist
223 die "Incorrect archives: Fortran source found in src/fortran/ ". 212 $constraints{qr#^src/$_/.+\.$languages{$_}$#} = "src/$_/buildsrc_$_.sce";
224 "but no buildsrc_fortran.sce script found"; 213
225 } 214 # if sci_gateway/(lang) has C sources, sci_gateway/(lang)/buildgateway_(lang).sce
226 215 # must exist
227 # if src/*/buildsrc_*.sce exists, src/buildsrc.sce must exists 216 $constraints{qr#^sci_gateway/$_/.+[ch]$#} = "sci_gateway/$_/buildgateway_$_.sce";
228 my $has_src_builder = defined($tree{"src/buildsrc.sce"}); 217
229 if(($has_f_source || $has_c_source) && !$has_src_builder) { 218 # if src/(lang)/buildsrc_(lang).sce exist, src/buildsrc.sce must exist
230 die "Incorrect archive: sources file found but no buildsrc.sce script found"; 219 $constraints{qr#^src/$_/buildsrc_$_.sce$#} = "src/buildsrc.sce";
231 } 220
232 221 # if sci_gateway/(lang)/buildgateway_(lang).sce exist, sci_gateway/buildgateway.sce must exist
233 # if sci_gateway/fortran contains at least a .c file, 222 $constraints{qr#^sci_gateway/$_/buildgateway_$_.sce$#} = "sci_gateway/buildgateway.sce";
234 # sci_gateway/fortran/buildgateway_fortran.sce must exists. 223 }
235 my $has_f_gateway = grep { m#^sci_gateway/fortran/.+\.[ch]$# } keys %tree; 224
236 my $has_f_gateway_builder = defined($tree{"sci_gateway/fortran/buildgateway_fortran.sce"}); 225 # Check constraints
237 if($has_f_gateway && !$has_f_gateway_builder) { 226 foreach my $constraint (keys %constraints) {
238 die "Incorrect archive: Fortran gateway found but can't find any builder for it"; 227 my $required = $constraints{$constraint};
239 } 228 my @found = grep { $_ =~ $constraint } keys %tree;
240 229 if(@found && !defined($tree{$required})) {
241 # if sci_gateway/c contains at least a .c file, sci_gateway/c/buildgateway_c.sce must exists 230 die "Invalid archive: \"$found[0]\" needs \"$required\", which isn't in the archive";
242 my $has_c_gateway = grep { m#^sci_gateway/c/.+\.[ch]$# } keys %tree; 231 }
243 my $has_c_gateway_builder = defined($tree{"sci_gateway/c/buildgateway_c.sce"});
244 if($has_c_gateway && !$has_c_gateway_builder) {
245 die "Incorrect archive: C gateway found but can't find any builder for it";
246 }
247
248 # if sci_gateway/*/buildgateway_*.sce exists, sci_gateway/buildgateway.sce must exists
249 my $has_gateway_builder = defined($tree{"sci_gateway/buildgateway.sce"});
250 if(($has_c_gateway || $has_f_gateway) && !$has_gateway_builder) {
251 die "Incorrect archive: gateway found no gateway builder (buildgateway.sce) found";
252 }
253
254 # if help/ contains .xml files, it must contains a buildhelp.sce file
255 my $has_help = grep { m#^help/.+\.xml$# } keys %tree;
256 my $has_help_builder = defined($tree{"help/buildhelp.sce"});
257 if($has_help && !$has_help_builder) {
258 die "Incorrect archive: help files found but no help builder (buildhelp.sce) found";
259 } 232 }
260} 233}
261 234