Skip to content

Commit 26be0e0

Browse files
committed
Create iProject class
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
1 parent cf508ab commit 26be0e0

File tree

6 files changed

+300
-298
lines changed

6 files changed

+300
-298
lines changed

cli/src/builders/environment.ts

+250-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,254 @@
11
import { str } from "crc-32/crc32c";
2+
import { ObjectType } from "../targets";
3+
4+
// Always try and store parmId as lowercase
5+
export type CommandParameters = { [parmId: string]: string };
6+
7+
export type CompileAttribute = { [ext: string]: CompileData };
8+
9+
export interface CompileData {
10+
/** indicates what type of object will be built from this source */
11+
becomes: ObjectType;
12+
/** will copy the source to a temp member first */
13+
member?: boolean,
14+
/** `preCommands` do not respect the library list and is run before 'command' */
15+
preCommands?: string[]
16+
/** `command` does respect the library list */
17+
command?: string;
18+
19+
parameters?: CommandParameters;
20+
/** Used if the commands are built up from source. Usually means `command` and `commands` is blank */
21+
commandSource?: boolean;
22+
/** `postCommands` do not respect the library list and is run after 'command' */
23+
postCommands?: string[];
24+
25+
/** if the object can be built without source, flag this true so it builds generic rules */
26+
sourceOptional?: boolean;
27+
/** if the non-source object now requires source. Use make generic name like `qbndsrc/%.bnd` */
28+
targetSource?: string;
29+
};
230

331
export function getBranchLibraryName(currentBranch: string) {
4-
return `VS${(str(currentBranch, 0)>>>0).toString(16).toUpperCase()}`;
32+
return `VS${(str(currentBranch, 0) >>> 0).toString(16).toUpperCase()}`;
33+
}
34+
35+
export function getDefaultCompiles(): CompileAttribute {
36+
const binderSourceCompile: CompileData = {
37+
becomes: `SRVPGM`,
38+
preCommands: [
39+
`-system -q "CRTBNDDIR BNDDIR($(BIN_LIB)/$(APP_BNDDIR))"`,
40+
// `-system -q "RMVBNDDIRE BNDDIR($(BIN_LIB)/$(APP_BNDDIR)) OBJ(($(BIN_LIB)/$*))"`,
41+
// `-system "DLTOBJ OBJ($(BIN_LIB)/$*) OBJTYPE(*SRVPGM)"`
42+
],
43+
command: `CRTSRVPGM`,
44+
parameters: {
45+
srvpgm: `$(BIN_LIB)/$*`,
46+
module: `*MODULES`,
47+
srcstmf: `'$<'`,
48+
bnddir: `$(BNDDIR)`,
49+
replace: `*YES`
50+
},
51+
postCommands: [
52+
`-system -q "ADDBNDDIRE BNDDIR($(BIN_LIB)/$(APP_BNDDIR)) OBJ((*LIBL/$* *SRVPGM *IMMED))"`
53+
]
54+
};
55+
56+
return {
57+
"pgm": {
58+
becomes: `PGM`,
59+
command: `CRTPGM`,
60+
parameters: {
61+
pgm: `$(BIN_LIB)/$*`,
62+
entmod: `$*`,
63+
module: `*MODULES`,
64+
tgtrls: `*CURRENT`,
65+
bnddir: `$(BNDDIR)`,
66+
actgrp: `*NEW`
67+
}
68+
},
69+
"pgm.rpgle": {
70+
becomes: `PGM`,
71+
command: `CRTBNDRPG`,
72+
parameters: {
73+
pgm: `$(BIN_LIB)/$*`,
74+
srcstmf: `'$<'`,
75+
option: `*EVENTF`,
76+
dbgview: `*SOURCE`,
77+
tgtrls: `*CURRENT`,
78+
tgtccsid: `*JOB`,
79+
bnddir: `$(BNDDIR)`,
80+
dftactgrp: `*NO`
81+
}
82+
},
83+
"pgm.sqlrpgle": {
84+
becomes: "PGM",
85+
command: `CRTSQLRPGI`,
86+
parameters: {
87+
obj: `$(BIN_LIB)/$*`,
88+
srcstmf: `'$<'`,
89+
commit: `*NONE`,
90+
dbgview: `*SOURCE`,
91+
option: `*EVENTF`,
92+
rpgppopt: `*LVL2`,
93+
compileopt: `TGTCCSID(*JOB) BNDDIR($(BNDDIR)) DFTACTGRP(*no)`
94+
}
95+
},
96+
"rpgle": {
97+
becomes: `MODULE`,
98+
command: `CRTRPGMOD`,
99+
parameters: {
100+
module: `$(BIN_LIB)/$*`,
101+
srcstmf: `'$<'`,
102+
option: `*EVENTF`,
103+
dbgview: `*SOURCE`,
104+
tgtrls: `*CURRENT`,
105+
tgtccsid: `*JOB`
106+
}
107+
},
108+
"sqlrpgle": {
109+
becomes: "MODULE",
110+
command: `CRTSQLRPGI`,
111+
parameters: {
112+
obj: `$(BIN_LIB)/$*`,
113+
srcstmf: `'$<'`,
114+
commit: `*NONE`,
115+
dbgview: `*SOURCE`,
116+
compileopt: `'TGTCCSID(*JOB)'`,
117+
rpgppopt: `*LVL2`,
118+
option: `*EVENTF`,
119+
objtype: `*MODULE`
120+
}
121+
},
122+
"pgm.clle": {
123+
becomes: `PGM`,
124+
command: `CRTBNDCL`,
125+
parameters: {
126+
pgm: `$(BIN_LIB)/$*`,
127+
srcstmf: `'$<'`,
128+
option: `*EVENTF`,
129+
dbgview: `*SOURCE`,
130+
tgtrls: `*CURRENT`,
131+
dftactgrp: `*NO`
132+
}
133+
},
134+
dspf: {
135+
becomes: "FILE",
136+
member: true,
137+
command: "CRTDSPF",
138+
parameters: {
139+
file: `$(BIN_LIB)/$*`,
140+
srcfile: `$(BIN_LIB)/$(SRCPF)`,
141+
srcmbr: `$*`,
142+
option: `*EVENTF`
143+
}
144+
},
145+
prtf: {
146+
becomes: "FILE",
147+
member: true,
148+
command: "CRTPRTF",
149+
parameters: {
150+
file: `$(BIN_LIB)/$*`,
151+
srcfile: `$(BIN_LIB)/$(SRCPF)`,
152+
srcmbr: `$*`,
153+
option: `*EVENTF`
154+
}
155+
},
156+
cmd: {
157+
becomes: "CMD",
158+
member: true,
159+
command: "CRTCMD",
160+
parameters: {
161+
cmd: `$(BIN_LIB)/$*`,
162+
pgm: `$(BIN_LIB)/$*`,
163+
srcfile: `$(BIN_LIB)/$(SRCPF)`,
164+
option: `*EVENTF`
165+
}
166+
},
167+
sql: {
168+
becomes: `FILE`,
169+
command: `RUNSQLSTM`,
170+
parameters: {
171+
srcstmf: `'$<'`,
172+
commit: `*NONE`
173+
}
174+
},
175+
sqludf: {
176+
becomes: `SRVPGM`,
177+
command: `RUNSQLSTM`,
178+
parameters: {
179+
srcstmf: `'$<'`,
180+
commit: `*NONE`
181+
}
182+
},
183+
table: {
184+
becomes: `FILE`,
185+
command: `RUNSQLSTM`,
186+
parameters: {
187+
srcstmf: `'$<'`,
188+
commit: `*NONE`
189+
}
190+
},
191+
binder: binderSourceCompile,
192+
bnd: binderSourceCompile,
193+
srvpgm: {
194+
becomes: `SRVPGM`,
195+
preCommands: [
196+
`-system -q "CRTBNDDIR BNDDIR($(BIN_LIB)/$(APP_BNDDIR))"`,
197+
`-system -q "RMVBNDDIRE BNDDIR($(BIN_LIB)/$(APP_BNDDIR)) OBJ(($(BIN_LIB)/$*))"`,
198+
`-system "DLTOBJ OBJ($(BIN_LIB)/$*) OBJTYPE(*SRVPGM)"`
199+
],
200+
command: `CRTSRVPGM`,
201+
parameters: {
202+
srvpgm: `$(BIN_LIB)/$*`,
203+
module: `*MODULES`,
204+
srcstmf: `'$<'`,
205+
bnddir: `$(BNDDIR)`
206+
},
207+
postCommands: [
208+
`-system -q "ADDBNDDIRE BNDDIR($(BIN_LIB)/$(APP_BNDDIR)) OBJ((*LIBL/$* *SRVPGM *IMMED))"`
209+
]
210+
},
211+
bnddir: {
212+
sourceOptional: true,
213+
becomes: `BNDDIR`,
214+
preCommands: [
215+
`-system -q "CRTBNDDIR BNDDIR($(BIN_LIB)/$*)"`,
216+
`-system -q "ADDBNDDIRE BNDDIR($(BIN_LIB)/$*) OBJ($(patsubst %.SRVPGM,(*LIBL/% *SRVPGM *IMMED),$(notdir $^)))"`
217+
]
218+
},
219+
dtaara: {
220+
becomes: `DTAARA`,
221+
commandSource: true
222+
},
223+
mnucmd: {
224+
becomes: `MENU`,
225+
member: true,
226+
command: `CRTMNU`,
227+
parameters: {
228+
menu: `$(BIN_LIB)/$*`,
229+
type: `*DSPF`,
230+
dspf: `$(BIN_LIB)/$*`
231+
}
232+
},
233+
pf: {
234+
becomes: `FILE`,
235+
member: true,
236+
command: `CRTPF`,
237+
parameters: {
238+
file: `$(BIN_LIB)/$*`,
239+
srcfile: `$(BIN_LIB)/$(SRCPF)`,
240+
option: `*EVENTF`
241+
}
242+
},
243+
lf: {
244+
becomes: `FILE`,
245+
member: true,
246+
command: `CRTLF`,
247+
parameters: {
248+
file: `$(BIN_LIB)/$*`,
249+
srcfile: `$(BIN_LIB)/$(SRCPF)`,
250+
option: `*EVENTF`
251+
}
252+
}
253+
};
5254
}

cli/src/builders/iProject.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { CompileData, CommandParameters, CompileAttribute, getDefaultCompiles } from "./environment";
2+
3+
export class iProject {
4+
includePaths?: string[] = [];
5+
compiles?: CompileAttribute = getDefaultCompiles();
6+
objectAttributes?: {
7+
[object: string]: CommandParameters
8+
} = {};
9+
binders?: string[] = [];
10+
11+
constructor() {
12+
13+
}
14+
15+
applySettings(input: Partial<iProject>) {
16+
if (input.includePaths && input.includePaths.length > 0) {
17+
this.includePaths = input.includePaths;
18+
}
19+
20+
if (input.binders && input.binders.length > 0) {
21+
this.binders = input.binders;
22+
}
23+
24+
if (input.compiles) {
25+
for (const [ext, data] of Object.entries(input.compiles)) {
26+
// We don't want to fully overwrite the default settings,
27+
// perhaps the user is only changing the `dir`?
28+
this.compiles[ext] = {
29+
...(this.compiles[ext] || {}),
30+
...data
31+
};
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)