Skip to content

Commit 5b5a455

Browse files
authored
Merge pull request #131 from IBM/fix/makefile_rules_override
Fix `Rules.mk` blanking out dependencies, fix incorrect `actions.json` usage
2 parents affb52d + a6bc11e commit 5b5a455

File tree

10 files changed

+1185
-1205
lines changed

10 files changed

+1185
-1205
lines changed

cli/src/builders/make/customRules.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ export function readAllRules(targets: Targets, project: MakeProject) {
6767
const currentTarget = targets.getTarget({systemName: targetName, type: targetType});
6868

6969
if (currentTarget) {
70-
// We set this to empty since we're overriding them
71-
currentTarget.deps = [];
70+
// We actually don't want to clear out existing deps found by SO
71+
// Instead, let's combine them with the deps found in rules.mk
72+
// currentTarget.deps = [];
7273

7374
const parts = value.split(` `).map(p => p.trim()).filter(p => p.length > 0);
7475

@@ -80,17 +81,19 @@ export function readAllRules(targets: Targets, project: MakeProject) {
8081
const objType = partSplit[1] as ObjectType;
8182

8283
if (objName && objType) {
83-
const obj = targets.searchForObject({systemName: objName, type: objType});
84-
85-
if (obj) {
86-
currentTarget.deps.push(obj);
87-
} else {
88-
warningOut(`make: Failed to find '${part}' in '${relative}'`);
84+
if (!currentTarget.deps.some(d => d.systemName === objName && d.type === objType)) {
85+
const obj = targets.searchForObject({systemName: objName, type: objType});
86+
87+
if (obj) {
88+
currentTarget.deps.push(obj);
89+
} else {
90+
warningOut(`make: Failed to find '${part}' in '${relative}'`);
91+
}
8992
}
9093
}
9194
}
9295
}
93-
}
96+
}
9497

9598
}
9699
}

cli/src/builders/make/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class MakeProject {
2424
private noChildren: boolean = false;
2525
private settings: iProject = new iProject();
2626
private projectActions: ProjectActions;
27+
private actionsEnabled: boolean = false;
2728

2829
private folderSettings: {[folder: string]: FolderOptions} = {};
2930

@@ -35,8 +36,14 @@ export class MakeProject {
3536
this.noChildren = noChildren;
3637
}
3738

39+
public useActions() {
40+
this.actionsEnabled = true;
41+
}
42+
3843
async setupSettings() {
39-
await this.projectActions.loadAllActions();
44+
if (this.actionsEnabled) {
45+
await this.projectActions.loadAllActions();
46+
}
4047

4148
// First, let's setup the project settings
4249
try {

cli/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export let cliSettings = {
55
cliMode: false,
66
infoMessages: false,
77
buildFile: "none" as BuildFiles,
8+
withActions: false,
89
fixIncludes: false,
910
autoRename: false,
1011
fileList: false,

cli/src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ async function main() {
5858
i++;
5959
break;
6060

61+
case `-wa`:
62+
cliSettings.withActions = true;
63+
break;
64+
6165
case '-nc':
6266
case '--no-children':
6367
cliSettings.makeFileNoChildren = true;
@@ -95,6 +99,9 @@ async function main() {
9599
console.log(`\t-bf make|bob|imd|json\tCreate build files of a specific format`);
96100
console.log(`\t\t\t\tExample: -bf make`);
97101
console.log(``);
102+
console.log(`\t-wa\t\tWhen using '-bf make', use commands`);
103+
console.log(`\t\t\tthat are found in the 'actions.json' files.`);
104+
console.log(``);
98105
console.log(`\t-bl <name>\tSet the BRANCHLIB environment variable based on `);
99106
console.log(`\t\t\ta user provided branch name, and will write it out.`);
100107
console.log(`\t\t\tExample: -bl feature/123-cool-idea`);
@@ -213,6 +220,12 @@ async function main() {
213220
break;
214221
case `make`:
215222
const makeProj = new MakeProject(cwd, targets, fs);
223+
224+
// Enables the use of actions.json for commands
225+
if (cliSettings.withActions) {
226+
makeProj.useActions();
227+
}
228+
216229
await makeProj.setupSettings();
217230

218231
makeProj.setNoChildrenInBuild(cliSettings.makeFileNoChildren);

cli/src/targets.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,11 @@ export class Targets {
927927
const simpleName = trimQuotes(def.object.name, `"`);
928928
// TODO: do we need to look for SRVPGM (function) or PGM (procedure) here?
929929
const resolvedObject = this.searchForAnyObject({ name: simpleName, types: [`FILE`, `SRVPGM`, `PGM`] });
930-
if (resolvedObject) newTarget.deps.push(resolvedObject);
930+
if (resolvedObject) {
931+
if (!newTarget.deps.find(d => d.systemName === resolvedObject.systemName && d.type === resolvedObject.type)) {
932+
newTarget.deps.push(resolvedObject);
933+
}
934+
}
931935
else if (!isSqlFunction(def.object.name)) {
932936
this.logger.fileLog(newTarget.relativePath, {
933937
message: `No object found for reference '${def.object.name}'`,

cli/test/cs_srvpgm.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe(`pseudo tests`, () => {
7878

7979
test('makefile', async () => {
8080
const makefile = new MakeProject(targets.getCwd(), targets, fs);
81+
makefile.useActions();
8182
await makefile.setupSettings();
8283

8384
const contents = makefile.getMakefile().join(`\n`);
@@ -87,8 +88,7 @@ describe(`pseudo tests`, () => {
8788

8889
expect(contents).not.toContain(`EMPDET.SRVPGM`); // Ensure no service program is created
8990
expect(contents).toContain(`EMPDET.MODULE`);
90-
91-
console.log(contents);
91+
expect(contents).toContain(`CRTSQLRPGI OBJ($(BIN_LIB)/EMPDET) SRCSTMF('qrpglesrc/empdet.sqlrpgle') COMMIT(*NONE) DBGVIEW(*SOURCE) COMPILEOPT('TGTCCSID(*JOB)') RPGPPOPT(*LVL2) OPTION(*EVENTF) OBJTYPE(*MODULE)`);
9292

9393
// As picked up from the actions.json
9494
expect(contents).toContain(`system "CRTBNDRPG NAME(mypgm) THEPARM('qrpglesrc/mypgm.pgm.rpgle')" > .logs/mypgm.splf`);

vs/client/package-lock.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)