cosmetix in Jambase: use single-quoted string where appropriate
[k8jam.git] / defaults / build / Jambase.build.genfile
blob8fa9420c6c172531733f7ebc53dd80be2e909133
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
14 # /GenFile target : image sources [: dependencies ] ;
16 # Runs the command "_image_ _target_ _sources_" to create _target_ from
17 # _sources_ and _image_ (where _image_ is an executable built by the @Main rule).
18 # 'source' starts with '-' or '/' is an option, don't include it in dependency graph.
19 # 'source' starts with '*' switches generator to GenFile2, which will not automatically
20 # add target to argument list.
21 # 'source' equals to $$ means '_target_' and switches to GenFile2.
22 # if 'image' starts with ':', this is standalone file, don't append any suffix to it.
24 rule GenFile {
25   ### Echo 'my GenFile!' ;
26   ### Echo ' <' $(<) ;
27   ### Echo ' >' $(>) ;
28   ### Echo ' exe:' $(>[1]) ;
29   local _exe = [ Match '^:(.+)$' : $(>[1]) ] ;
30   if ! $(_exe) { _exe = [ FAppendSuffix $(>[1]) : $(SUFEXE) ] ; } else { _exe = $(_exe[1]) ; }
31   local _t = [ FGristFiles $(<) ] ;
32   ### Echo $(_t) 'depends on' $(_exe) $(3) ;
33   Depends $(_t) : $(_exe) $(3) ;
34   local target_rule = GenFile1 ;
35   local sl = ;
36   for local s in $(>[2-]) {
37     if $(s) = "$$" {
38       # don't add "$$" to 'dependency list', add real target to arguments
39       sl += $(_t) ;
40       target_rule = GenFile2 ;
41     } else if ! ( $(s) ~= '^[-/]' ) {
42       local t = [ Match '^\*(.*)$' : $(s) ] ;
43       if $(t) {
44         t = $(t[1]) ;
45         if $(t) {
46           sl += $(t) ;
47           Depends $(_t) : $(t) ;
48         }
49         target_rule = GenFile2 ;
50       } else {
51         sl += $(s) ;
52         Depends $(_t) : $(s) ;
53       }
54     } else {
55       ### Echo 'option skipped:' $(s) ;
56       sl += $(s) ;
57       NoCare $(s) ;
58       NotFile $(s) ;
59     }
60   }
61   #Depends $(_t) : $(_exe) $(>[2-]) ;
62   ### Echo ' _t:' $(_t) ;
63   ### Echo ' sl:' $(sl) ;
64   $(target_rule) $(_t) : $(_exe) $(sl) ;
65   Clean clean : $(_t) ;
69 rule GenFile1 {
70   MakeLocate $(<) : $(LOCATE_SOURCE) ;
71   SEARCH on $(>) = $(SEARCH_SOURCE) ;
74 actions GenFile1 {
75   $(>[1]) $(<) $(>[2-])
79 rule GenFile2 {
80   MakeLocate $(<) : $(LOCATE_SOURCE) ;
81   SEARCH on $(>) = $(SEARCH_SOURCE) ;
84 actions GenFile2 {
85   $(>[1]) $(>[2-])
89 rule IncFile {
90   local _t = [ FGristFiles $(<) ] ;
91   Includes $(_t) : $(>) ;