source: trunk/tools/create_def.CMD@ 201

Last change on this file since 201 was 164, checked in by gyoung, 19 months ago

Fix up all of the def file generation update version

  • Property svn:eol-style set to native
File size: 5.4 KB
Line 
1/* */
2/* Create DEF file for a MM helper program from a template */
3/* */
4/* (c) Chris Wohlgemuth 2005 */
5/* */
6
7call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
8call SysLoadFuncs
9
10DEBUG=1
11
12
13deffile=ARG(1)
14if ARG(1)="" then deffile="tst.def"
15/*Trim off the templateFile if any*/
16deffile=DELWORD(deffile,2)
17/* License file to be added to the DEF file */
18licenseFile=VALUE("CWMMLICENCE", ,"OS2ENVIRONMENT")
19
20/* Template file */
21templateFile=ARG(1)
22/*Trim end of args*/
23templateFile=DELWORD(templateFile,3)
24/*Template file is really ARG(2) but ARG(1) pulls in everything so we delete the first arg*/
25templateFile=DELWORD(templateFile,1,1)
26IF templateFile="" THEN
27 templateFile=DIRECTORY()||'\'||def.tpl
28
29/* Get the version of the classes */
30theVersion=VALUE("MMCLSVERSION", ,"OS2ENVIRONMENT")
31if theVersion="" THEN theVersion="0.0.0"
32
33/* The stem holding all the information we get from the template file */
34fileData.=''
35
36
37call getTemplateData templateFile
38/* Index */
39call assignTemplateVars
40
41IF DEBUG=1 THEN DO
42 DO a=1 to filedata.0
43 SAY fileData.a.sectionname":"
44 SAY fileData.a
45 END
46END
47
48/* Specify save defaults */
49IF fileData.buildmachine="" THEN
50 fileData.buildmachine="Default"
51fileData.buildmachine.desc="Build machine: "
52
53IF fileData.author="" THEN
54 fileData.author=" "
55fileData.author.desc="Author: "
56IF fileData.name='' THEN
57 fileData.name=""
58
59IF DEBUG=1 THEN DO
60 SAY ""
61 SAY "License file: "||licensefile
62 SAY "DEF-file: "||deffile
63 SAY "Version: "||theversion
64 SAY "Template file: "||templateFile
65 SAY "Template data: "
66 DO a=1 to fileData.0
67 SAY " "||fileData.a.desc||": "||fileData.a
68 END
69END
70
71'@type NUL > 'deffile
72
73/* Write header */
74call lineout deffile, ';'
75call lineout deffile, '; '||WORD(fileData.name,2)||": "fileData.description
76call lineout deffile, ';'
77
78/* Write copyright */
79call lineout deffile, ';'
80IF fileData.copyright><"" THEN
81 call lineout deffile, '; '||fileData.copyright||"-"WORD(DATE(),3)
82ELSE
83 call lineout deffile, '; '||fileData.author||" "WORD(DATE(),3)
84call lineout deffile, ';'
85/* Write creation date */
86call lineout deffile, ';'
87call lineout deffile, '; Created '||DATE()||" "||TIME()
88call lineout deffile, ';'
89
90/* Write license */
91DO WHILE LINES(licenseFile)
92 theLine=LINEIN(licenseFile)
93 IF LENGTH(theLine) >0 THEN DO
94 IF substr(theLine,1,1) >< ';' THEN
95 theLine=';'||theLine
96 END
97 ELSE
98 theLine=theLine||';'
99 call LINEOUT deffile, theLine
100END
101call stream licenseFile, "C", "close"
102
103/* Now write the NAME data */
104call lineout deffile, fileData.name
105
106/* Description with bldlevel info */
107timeData=OVERLAY(DATE("E")||" "||TIME("N"), " ")
108versionData=OVERLAY( LEFT(theVersion,3)," ")
109def="DESCRIPTION '$@#"||fileData.author||" "
110def=def||":"||theVersion||"#@##1## "||timeData
111def=def||" "||SUBSTR(fileData.buildmachine,1,11)||"::::"||WORD(TRANSLATE(theVersion," ", "."),3)
112def=def||"::@@"||fileData.description||" "||fileData.copyright||"-"WORD(DATE(),3)"'"
113call lineout deffile, def
114
115/* Additional info we may have */
116call lineout deffile, fileData.other
117
118call stream deffile, "C", "close"
119
120SAY "New DEF file created for V"||theVersion||"."
121exit
122
123/************************************************************/
124/* Assign the symbols specified by the sections list the position value
125 they have in the list of sections. By doing this the symbols may be used
126 as indexes in the filedata. stem*/
127assignTemplateVars: procedure expose (fileData.sections)
128 DO a=1 to WORDS(fileData.sections)
129 call VALUE WORD(fileData.sections,a),a
130 END
131return
132
133/************ Parse the template file ***********************/
134getTemplateData: procedure expose fileData.
135 theFile=arg(1)
136
137 fileData.=''
138 fileContents.=''
139
140 fileContents.0=0
141 /* Read in the file for easier processing */
142 DO WHILE LINES(theFile)
143 fileContents.0=fileContents.0+1
144 b=fileContents.0
145 fileContents.b=LINEIN(theFile)
146 END
147 call stream theFile, "C", "close"
148
149 DO b=1 to fileContents.0
150 theLine=fileContents.b
151 fileContents.current=b
152 section = Strip(Translate(word(theline,1)))
153 select
154 when (Left(section,1) = '#') | section = '' then
155 do
156 /* Jump comments and empty lines */
157 end;
158 WHEN LEFT(section,1)="[" THEN DO
159 call parseSection
160 b=fileContents.current
161 END
162 OTHERWISE
163 nop
164 END
165
166 END
167 fileData.0=WORDS(fileData.sections)
168 DROP fileContents.
169return
170
171parseSection: procedure expose fileData. fileContents.
172 b=fileContents.current
173 /* Add this section to the list of sections */
174 filedata.sections=filedata.sections||" "||SPACE(TRANSLATE(fileContents.b, " ", "[]"))
175 index=WORDS(fileData.sections)
176 fileData.index=""
177 fileData.index.sectionname=SPACE(TRANSLATE(fileContents.b, " ", "[]"))
178 /* Parse this section */
179 b=b+1
180 DO a=b to fileContents.0
181 theLine=fileContents.a
182 fileContents.current=a
183 section = Strip(Translate(word(theline,1)))
184 select
185 when (Left(section,1) = '#') | section = '' then
186 do
187 /* Jump comments and empty lines */
188 end;
189 WHEN LEFT(section,1)="[" THEN DO
190 /* New section jump back after correcting the index */
191 fileContents.current=fileContents.current-1
192 return
193 END
194 OTHERWISE
195 IF fileData.index <>"" THEN fileData.index=fileData.index||'0d'x||'0a'x
196 fileData.index=fileData.index||theLine
197 END
198
199 END
200
201return
202/***********************************************/
Note: See TracBrowser for help on using the repository browser.