Skip to content

Commit 5aa4a91

Browse files
committed
Granular makefile options
Signed-off-by: worksofliam <[email protected]>
1 parent 0cff644 commit 5aa4a91

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

cli/src/builders/make/index.ts

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ interface Step {
2424
* parents: this property controls the all target. It will include all the parents of partial build objects.
2525
* partial: if this property is true, the makefile will only include targets for the partial build objects (and optionally their parents)
2626
*/
27-
type PartialOptions = { partial?: boolean, parents?: boolean, parentsChildren?: boolean };
27+
type PartialOptions = {
28+
parents?: boolean,
29+
withChildren?: boolean,
30+
parentsChildren?: boolean
31+
};
2832

2933
interface PartialTargets {
30-
partial: ILEObject[];
31-
children?: ILEObject[];
34+
targets: ILEObject[];
35+
children: ILEObject[];
3236
}
3337

3438
export class MakeProject {
35-
private partialOptions: PartialOptions = { partial: false, parents: false, parentsChildren: false };
39+
private partialOptions: PartialOptions|undefined
3640
private settings: iProject = new iProject();
3741
private projectActions: ProjectActions;
3842
private actionsEnabled: boolean = false;
@@ -235,36 +239,37 @@ export class MakeProject {
235239
return;
236240
}
237241

238-
// Gets children of the partial build objects.
239-
let allChildren: ILEObject[]|undefined = this.partialOptions.partial ? this.targets.getRequiredObjects(partialBuild) : undefined;
240-
let allParents: ILEObject[]|undefined;
242+
let children: ILEObject[] = [];
241243

242244
// we also want to build their parents too. We update `partialBuild`
243245
// to include all the parents of the specific objects.
244-
if (this.partialOptions.parents) {
245-
allParents = [];
246-
const impacts = partialBuild.map(o => this.targets.getImpactFor(o));
247-
248-
const addImpact = (impactedObj: ImpactedObject) => {
249-
if (!allParents.some(o => o.systemName === impactedObj.ileObject.systemName && o.type === impactedObj.ileObject.type)) {
250-
allParents.push(impactedObj.ileObject);
251-
}
246+
247+
const allParents: ILEObject[] = [];
248+
const impacts = partialBuild.map(o => this.targets.getImpactFor(o));
252249

253-
impactedObj.children.forEach(child => addImpact(child));
250+
const addImpact = (impactedObj: ImpactedObject) => {
251+
if (!allParents.some(o => o.systemName === impactedObj.ileObject.systemName && o.type === impactedObj.ileObject.type)) {
252+
allParents.push(impactedObj.ileObject);
254253
}
255254

256-
impacts.forEach(impact => addImpact(impact));
257-
258-
partialBuild = allParents;
255+
impactedObj.children.forEach(child => addImpact(child));
259256
}
260257

258+
impacts.forEach(impact => addImpact(impact));
259+
261260
if (this.partialOptions.parentsChildren) {
262-
allChildren = this.targets.getRequiredObjects(partialBuild);
261+
children = this.targets.getRequiredChildren(allParents);
262+
} else if (this.partialOptions.withChildren) {
263+
children = this.targets.getRequiredChildren(partialBuild);
264+
}
265+
266+
if (this.partialOptions.parents) {
267+
partialBuild = allParents;
263268
}
264269

265270
return {
266-
partial: partialBuild,
267-
children: allChildren
271+
targets: partialBuild,
272+
children: children
268273
}
269274
}
270275

@@ -275,7 +280,7 @@ export class MakeProject {
275280
const buildObjects = this.getPartialTargets(partialBuild);
276281

277282
if (buildObjects) {
278-
partialBuild = buildObjects.partial;
283+
partialBuild = buildObjects.targets;
279284
}
280285

281286
// If we are in partial mode, we only want to generate targets for the specific objects
@@ -292,9 +297,19 @@ export class MakeProject {
292297
)
293298
}
294299

295-
if (buildObjects && buildObjects.children) {
300+
let allTargetObjects: ILEObject[]|undefined = undefined;
301+
if (this.partialOptions && buildObjects) {
302+
allTargetObjects = [];
303+
if (this.partialOptions.parentsChildren) {
304+
allTargetObjects = partialBuild.concat(buildObjects.children || []).filter((t, i, self) => self.indexOf(t) === i);
305+
} else if (this.partialOptions.withChildren) {
306+
allTargetObjects = buildObjects.children.filter((t, i, self) => self.indexOf(t) === i);
307+
}
308+
}
309+
310+
if (allTargetObjects) {
296311
// If we don't want the children to get built, we only generate the targets for the specific objects
297-
for (const obj of buildObjects.children) {
312+
for (const obj of allTargetObjects) {
298313
if (obj.reference) continue; // Skip references
299314

300315
const target = this.targets.getTarget(obj);
@@ -328,13 +343,13 @@ export class MakeProject {
328343
return lines;
329344
}
330345

331-
public generateGenericRules(partialBuild?: ILEObject[]): string[] {
346+
public generateGenericRules(buildFor?: ILEObject[]): string[] {
332347
let lines = [];
333348

334-
const buildObjects = this.getPartialTargets(partialBuild);
349+
const buildObjects = this.getPartialTargets(buildFor);
335350

336351
if (buildObjects) {
337-
partialBuild = buildObjects.partial;
352+
buildFor = buildObjects.children.concat(buildObjects.targets);
338353
}
339354

340355
for (const entry of Object.entries(this.settings.compiles)) {
@@ -380,7 +395,7 @@ export class MakeProject {
380395
for (const ileObject of objects) {
381396
if (ileObject.reference) continue;
382397

383-
if (buildObjects && buildObjects.children && !buildObjects.children.some(o => o.systemName === ileObject.systemName && o.type === ileObject.type)) {
398+
if (buildFor && !buildFor.some(o => o.systemName === ileObject.systemName && o.type === ileObject.type)) {
384399
continue; // Skip this object
385400
}
386401

cli/src/targets/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ export class Targets {
762762
/**
763763
* Returns a list of all the required objects to build this target
764764
*/
765-
public getRequiredObjects(bases: (ILEObject|ILEObjectTarget)[]) {
765+
public getRequiredChildren(bases: (ILEObject|ILEObjectTarget)[]) {
766766
let deps: ILEObject[] = [];
767767

768768
const addDep = (dep: ILEObject|ILEObjectTarget) => {

0 commit comments

Comments
 (0)