Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 7fa3c0a

Browse files
committed
Makefile to also generate targets for impacted objects when targetting specific objects
1 parent 14aceef commit 7fa3c0a

2 files changed

Lines changed: 66 additions & 2 deletions

File tree

cli/src/builders/make.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { existsSync, readFileSync } from 'fs';
22
import path from 'path';
3-
import { ILEObject, ILEObjectTarget, ObjectType, Targets } from '../targets';
3+
import { ILEObject, ILEObjectTarget, ImpactedObject, ObjectType, Targets } from '../targets';
44
import { asPosix } from '../utils';
55

66
interface CompileData {
@@ -209,6 +209,24 @@ export class MakeProject {
209209
public generateTargets(specificObjects?: ILEObject[]): string[] {
210210
let lines = [];
211211

212+
if (specificObjects) {
213+
const impacts = specificObjects.map(o => this.targets.getImpactFor(o));
214+
215+
let allAffected: ILEObject[] = [];
216+
217+
const addImpact = (impactedObj: ImpactedObject) => {
218+
if (!allAffected.some(o => o.name === impactedObj.ileObject.name && o.type === impactedObj.ileObject.type)) {
219+
allAffected.push(impactedObj.ileObject);
220+
}
221+
222+
impactedObj.children.forEach(child => addImpact(child));
223+
}
224+
225+
impacts.forEach(impact => addImpact(impact));
226+
227+
specificObjects = allAffected;
228+
}
229+
212230
const all = specificObjects || [
213231
...(this.targets.binderRequired() ? [this.targets.getBinderTarget()] : []),
214232
...this.targets.getParentObjects(`PGM`),

cli/test/project.test.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => {
248248
].join());
249249
});
250250

251-
test(`Checking makefile rule generation`, async () => {
251+
test(`Checking makefile rule generation`, () => {
252252
const project = new MakeProject(cwd, targets);
253253

254254
const headerContent = project.generateGenericRules();
@@ -259,6 +259,52 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => {
259259
expect(headerContent.find(l => l === `$(PREPATH)/DEPARTMENT.FILE: qddssrc/department.table`)).toBeDefined();
260260
});
261261

262+
test(`Makefile targets for all`, () => {
263+
const project = new MakeProject(cwd, targets);
264+
265+
// Generate targets on it's own will have BNDDIR, PGM, etc
266+
const headerContent = project.generateTargets();
267+
268+
const allTarget = headerContent.find(l => l.startsWith(`all:`));
269+
expect(allTarget).toBeDefined();
270+
271+
expect(allTarget).toContain(`all: .logs .evfevent library`);
272+
// The order cannot be guaranteed, so we just check for the presence of the targets
273+
expect(allTarget).toContain(`$(PREPATH)/$(APP_BNDDIR).BNDDIR`);
274+
expect(allTarget).toContain(`$(PREPATH)/MYPGM.PGM`);
275+
expect(allTarget).toContain(`$(PREPATH)/DEPTS.PGM`);
276+
expect(allTarget).toContain(`$(PREPATH)/EMPLOYEES.PGM`);
277+
});
278+
279+
test(`Makefile targets for specific object (DEPTS display file)`, () => {
280+
const project = new MakeProject(cwd, targets);
281+
282+
const deptsFile = targets.getDep({name: `DEPTS`, type: `FILE`});
283+
284+
// Generate targets on it's own will have BNDDIR, PGM, etc
285+
const headerContent = project.generateTargets([deptsFile]);
286+
287+
const allTarget = headerContent.find(l => l.startsWith(`all:`));
288+
expect(allTarget).toBeDefined();
289+
290+
expect(allTarget).toBe(`all: .logs .evfevent library $(PREPATH)/DEPTS.FILE $(PREPATH)/DEPTS.PGM`);
291+
});
292+
293+
test(`Makefile targets for specific object (EMPLOYEE table)`, () => {
294+
const project = new MakeProject(cwd, targets);
295+
296+
const deptsFile = targets.getDep({name: `EMPLOYEE`, type: `FILE`});
297+
298+
// Generate targets on it's own will have BNDDIR, PGM, etc
299+
const headerContent = project.generateTargets([deptsFile]);
300+
301+
const allTarget = headerContent.find(l => l.startsWith(`all:`));
302+
expect(allTarget).toBeDefined();
303+
304+
expect(allTarget).toBe(`all: .logs .evfevent library $(PREPATH)/EMPLOYEE.FILE $(PREPATH)/EMPLOYEES.PGM $(PREPATH)/DEPTS.PGM`);
305+
});
306+
307+
262308
test(`Impact of EMPLOYEES`, () => {
263309
const empPgm = targets.getDep({name: `EMPLOYEES`, type: `PGM`});
264310
expect(empPgm.relativePath).toBe(path.join(`qrpglesrc`, `employees.pgm.sqlrpgle`));

0 commit comments

Comments
 (0)