diff options
author | Simon Lipp <simon.lipp@scilab.org> | 2008-06-26 09:49:12 +0000 |
---|---|---|
committer | Simon Lipp <simon.lipp@scilab.org> | 2008-06-26 09:49:12 +0000 |
commit | 201af78f7786015b796e0828be86efdafe83734c (patch) | |
tree | c8254953179dccd203051126ae60045c2108977f /atoms_cc/buildtoolbox.pl | |
parent | 42d29476367da2d2de20137cdcc7bba37cd674ef (diff) | |
download | scilab-201af78f7786015b796e0828be86efdafe83734c.zip scilab-201af78f7786015b796e0828be86efdafe83734c.tar.gz |
atoms_cc/buildtoolbox.pl: check_tree done
Diffstat (limited to 'atoms_cc/buildtoolbox.pl')
-rwxr-xr-x | atoms_cc/buildtoolbox.pl | 95 |
1 files changed, 92 insertions, 3 deletions
diff --git a/atoms_cc/buildtoolbox.pl b/atoms_cc/buildtoolbox.pl index 827e726..80ef477 100755 --- a/atoms_cc/buildtoolbox.pl +++ b/atoms_cc/buildtoolbox.pl | |||
@@ -147,13 +147,19 @@ sub read_description { | |||
147 | # (required files are present, files are at their right place, and so on...) | 147 | # (required files are present, files are at their right place, and so on...) |
148 | sub check_tree { | 148 | sub check_tree { |
149 | my %tree = @_; | 149 | my %tree = @_; |
150 | my %newtree; | ||
150 | 151 | ||
151 | # Check that all files are under a root which has the same name as the toolbox | 152 | # Check that all files are under a root which has the same name as the toolbox |
153 | # Delete this root to simplify other tests | ||
152 | foreach (keys %tree) { | 154 | foreach (keys %tree) { |
153 | if(!m#^\Q$TOOLBOXNAME\E/#) { | 155 | if(s#^\Q$TOOLBOXNAME\E(/|$)##) { |
156 | $newtree{$_} = 1 if $_; | ||
157 | } | ||
158 | else { | ||
154 | die "Incorrect archive: \"$_\" is not a child of \"$TOOLBOXNAME\""; | 159 | die "Incorrect archive: \"$_\" is not a child of \"$TOOLBOXNAME\""; |
155 | } | 160 | } |
156 | } | 161 | } |
162 | %tree = %newtree; | ||
157 | 163 | ||
158 | # Check that basic files are here | 164 | # Check that basic files are here |
159 | my @required = qw(DESCRIPTION DESCRIPTION-FUNCTIONS readme.txt license.txt | 165 | my @required = qw(DESCRIPTION DESCRIPTION-FUNCTIONS readme.txt license.txt |
@@ -162,12 +168,95 @@ sub check_tree { | |||
162 | push(@required, "etc/$TOOLBOXNAME.end"); | 168 | push(@required, "etc/$TOOLBOXNAME.end"); |
163 | 169 | ||
164 | foreach (@required) { | 170 | foreach (@required) { |
165 | if(!defined($tree{"$TOOLBOXNAME/$_"})) { | 171 | if(!defined($tree{$_})) { |
166 | die "Incorrect archive: required file \"$_\" not present"; | 172 | die "Incorrect archive: required file \"$_\" not present"; |
167 | } | 173 | } |
168 | } | 174 | } |
169 | 175 | ||
170 | # | 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) { | ||
181 | 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". | ||
187 | " (\"$_\" found)"; | ||
188 | } | ||
189 | } | ||
190 | |||
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 | ||
196 | foreach (grep { $_ =~ /\.f$/} keys %tree) { | ||
197 | if(!m#^src/fortran/#) { | ||
198 | die "Incorrect archive: \"$_\" is a fortran source and hence has to be in ". | ||
199 | "src/fortran"; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | # All c files must be in src/c or sci_gateway/{c,fortran} | ||
204 | foreach (grep { $_ =~ /\.[ch]$/} keys %tree) { | ||
205 | if(!m#^(src/c|sci_gateway/(c|fortran))/#) { | ||
206 | die "Incorrect archive: \"$_\" is a C source and hence has to be in ". | ||
207 | "src/c, sci_gateway/c or sci_gateway/fortran"; | ||
208 | } | ||
209 | } | ||
210 | |||
211 | # if src/c contains at least a .c file, src/c/buildsrc_c.sce must exists | ||
212 | my $has_c_source = grep { $_ =~ m#^src/c/.+\.[ch]$# } keys %tree; | ||
213 | my $has_c_src_builder = defined($tree{"src/c/buildsrc_c.sce"}); | ||
214 | if($has_c_source && !$has_c_src_builder) { | ||
215 | die "Incorrect archives: C source found in src/c/ but no buildsrc_c.sce ". | ||
216 | "script found"; | ||
217 | } | ||
218 | |||
219 | # if src/fortran contains at least a .f file, src/fortran/buildsrc_fortran.sce must exists | ||
220 | my $has_f_source = grep { $_ =~ m#^src/fortran/.+\.f$# } keys %tree; | ||
221 | my $has_f_src_builder = defined($tree{"src/fortran/buildsrc_fortran.sce"}); | ||
222 | if($has_f_source && !$has_f_src_builder) { | ||
223 | die "Incorrect archives: Fortran source found in src/fortran/ ". | ||
224 | "but no buildsrc_fortran.sce script found"; | ||
225 | } | ||
226 | |||
227 | # if src/*/buildsrc_*.sce exists, src/buildsrc.sce must exists | ||
228 | my $has_src_builder = defined($tree{"src/buildsrc.sce"}); | ||
229 | if(($has_f_source || $has_c_source) && !$has_src_builder) { | ||
230 | die "Incorrect archive: sources file found but no buildsrc.sce script found"; | ||
231 | } | ||
232 | |||
233 | # if sci_gateway/fortran contains at least a .c file, | ||
234 | # sci_gateway/fortran/buildgateway_fortran.sce must exists. | ||
235 | my $has_f_gateway = grep { m#^sci_gateway/fortran/.+\.[ch]$# } keys %tree; | ||
236 | my $has_f_gateway_builder = defined($tree{"sci_gateway/fortran/buildgateway_fortran.sce"}); | ||
237 | if($has_f_gateway && !$has_f_gateway_builder) { | ||
238 | die "Incorrect archive: Fortran gateway found but can't find any builder for it"; | ||
239 | } | ||
240 | |||
241 | # if sci_gateway/c contains at least a .c file, sci_gateway/c/buildgateway_c.sce must exists | ||
242 | my $has_c_gateway = grep { m#^sci_gateway/c/.+\.[ch]$# } keys %tree; | ||
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 | } | ||
171 | } | 260 | } |
172 | 261 | ||
173 | # Init global vars, check arguments | 262 | # Init global vars, check arguments |