Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cli/src/builders/bob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class BobProject {
let list: DirectoryTargets = {};

for (let target of targets.getTargets()) {
if (target.relativePath) {
const dirname = path.dirname(target.relativePath);
if (target.source) {
const dirname = path.dirname(target.source.relativePath);
if (list[dirname] === undefined) list[dirname] = [];

list[dirname].push(target);
Expand Down Expand Up @@ -85,7 +85,7 @@ class RulesFile {

const existingLine = this.parsed.find(r => r.target === objName && r.isUserWritten !== true);

const lineContent = `${path.relative(this.subdir, target.relativePath)} ${target.headers ? target.headers.join(` `) + ` ` : ``}${target.deps.filter(d => d.reference !== true).map(d => `${d.systemName}.${d.type}`).join(` `)}`.trimEnd();
const lineContent = `${path.relative(this.subdir, target.source.relativePath)} ${target.headers ? target.headers.join(` `) + ` ` : ``}${target.deps.filter(d => d.reference !== true).map(d => `${d.systemName}.${d.type}`).join(` `)}`.trimEnd();

if (existingLine) {
existingLine.ogLine = `${objName}: ${lineContent}`;
Expand Down
10 changes: 5 additions & 5 deletions cli/src/builders/imd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export class ImpactMarkdown {
if (this.relativePaths.length > 0) {
lines.push(`## Impact Analysis`, ``);

const possibleObjects = this.relativePaths.map(r => this.targets.getResolvedObject(path.join(this.cwd, r))).filter(x => x && x.relativePath);
const possibleObjects = this.relativePaths.map(r => this.targets.getResolvedObject(path.join(this.cwd, r))).filter(x => x && x.source);

lines.push(
`Touched objects: `, ``,
...possibleObjects.map(ileObject => `* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\`: \`${ileObject.relativePath}\``),
...possibleObjects.map(ileObject => `* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\`: \`${ileObject.source.relativePath}\``),
``,
`---`,
``
Expand Down Expand Up @@ -141,7 +141,7 @@ export class ImpactMarkdown {
function lookupObject(ileObject: ILEObject) {
let resultLines: string[] = [];

resultLines.push(`${''.padEnd(currentTree.length, `\t`)}* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\` (${ileObject.relativePath ? `\`${ileObject.relativePath}\`` : `no source`})`);
resultLines.push(`${''.padEnd(currentTree.length, `\t`)}* ${TypeEmoji[ileObject.type] || `❔`} \`${ileObject.systemName}.${ileObject.type}\` (${ileObject.source ? `\`${ileObject.source.relativePath}\`` : `no source`})`);

currentTree.push(ileObject);

Expand Down Expand Up @@ -180,15 +180,15 @@ export class ImpactMarkdown {

this.targets.getResolvedObjects().forEach(ileObject => {

let logs = this.targets.logger.getLogsFor(ileObject.relativePath) || [];
let logs = this.targets.logger.getLogsFor(ileObject.source?.relativePath) || [];
let parents = this.targets.getTargets().filter(t => t.deps.some(d => d.systemName === ileObject.systemName && d.type === ileObject.type));
let children = this.targets.getTarget(ileObject)?.deps || [];

lines.push(`| ` + [
TypeEmoji[ileObject.type] || `❔`,
ileObject.systemName,
ileObject.type,
`\`${ileObject.relativePath}\``,
`\`${ileObject.source?.relativePath}\``,
ImpactMarkdown.createLogExpand(logs),
ImpactMarkdown.createObjectExpand(parents),
ImpactMarkdown.createObjectExpand(children)
Expand Down
20 changes: 10 additions & 10 deletions cli/src/builders/make/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export class MakeProject {
public getObjectAttributes(compileData: CompileData, ileObject: ILEObject): CommandParameters {
let customAttributes = this.settings.objectAttributes[`${ileObject.systemName}.${ileObject.type}`] || {};

if (ileObject.relativePath) {
if (ileObject.source) {
// We need to take in the current folders .ibmi.json file for any specific values
const folder = path.dirname(ileObject.relativePath);
const folder = ileObject.source && ileObject.source.relativePath ? path.dirname(ileObject.source.relativePath) : undefined;
const folderSettings = this.folderSettings[folder];
if (folderSettings) {
// If there is a tgtccsid, we only want to apply it to commands
Expand Down Expand Up @@ -174,8 +174,8 @@ export class MakeProject {

for (const ileObject of objects) {
if (ileObject.reference) continue;
if (ileObject.relativePath) {
const sourcePath = path.join(this.cwd, ileObject.relativePath);
if (ileObject.source) {
const sourcePath = path.join(this.cwd, ileObject.source.relativePath);
const exists = existsSync(sourcePath); // Is this even needed? We already have relativePath??

if (exists) {
Expand All @@ -187,13 +187,13 @@ export class MakeProject {
const customAttributes = this.settings.objectAttributes[`${ileObject.systemName}.${ileObject.type}`];

lines.push(
`$(PREPATH)/${ileObject.systemName}.${data.becomes}: ${asPosix(ileObject.relativePath)}`,
`$(PREPATH)/${ileObject.systemName}.${data.becomes}: ${asPosix(ileObject.source.relativePath)}`,
...(commands.map(l => `\t-system -q "${toCl(l, customAttributes)}"`)),
``,
);

} catch (e) {
console.log(`Failed to parse '${ileObject.relativePath}'`);
console.log(`Failed to parse '${ileObject.source.relativePath}'`);
process.exit();
}
}
Expand Down Expand Up @@ -245,13 +245,13 @@ export class MakeProject {
static generateSpecificTarget(data: CompileData, ileObject: ILEObjectTarget, customAttributes?: CommandParameters): string[] {
let lines: string[] = [];

const parentName = ileObject.relativePath ? path.dirname(ileObject.relativePath) : undefined;
const parentName = ileObject.source?.relativePath ? path.dirname(ileObject.source.relativePath) : undefined;
const qsysTempName: string | undefined = (parentName && parentName.length > 10 ? parentName.substring(0, 10) : parentName);

const resolve = (command: string) => {
command = command.replace(new RegExp(`\\*CURLIB`, `g`), `$(BIN_LIB)`);
command = command.replace(new RegExp(`\\$\\*`, `g`), ileObject.systemName);
command = command.replace(new RegExp(`\\$<`, `g`), asPosix(ileObject.relativePath));
command = command.replace(new RegExp(`\\$<`, `g`), asPosix(ileObject.source.relativePath));
command = command.replace(new RegExp(`\\$\\(SRCPF\\)`, `g`), qsysTempName);

if (ileObject.deps && ileObject.deps.length > 0) {
Expand Down Expand Up @@ -287,12 +287,12 @@ export class MakeProject {
const resolvedCommand = resolve(toCl(data.command, data.parameters));

lines.push(
`$(PREPATH)/${objectKey}: ${asPosix(ileObject.relativePath)}`,
`$(PREPATH)/${objectKey}: ${asPosix(ileObject.source.relativePath)}`,
...(qsysTempName && data.member ?
[
// TODO: consider CCSID when creating the source file
`\t-system -qi "CRTSRCPF FILE($(BIN_LIB)/${qsysTempName}) RCDLEN(112) CCSID(${sourceFileCcsid})"`,
`\tsystem "CPYFRMSTMF FROMSTMF('${asPosix(ileObject.relativePath)}') TOMBR('$(PREPATH)/${qsysTempName}.FILE/${ileObject.systemName}.MBR') MBROPT(*REPLACE)"`
`\tsystem "CPYFRMSTMF FROMSTMF('${asPosix(ileObject.source.relativePath)}') TOMBR('$(PREPATH)/${qsysTempName}.FILE/${ileObject.systemName}.MBR') MBROPT(*REPLACE)"`
] : []),
...(data.preCommands ? data.preCommands.map(cmd => `\t${resolve(cmd)}`) : []),
...(data.command ?
Expand Down
2 changes: 1 addition & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async function listDeps(cwd: string, targets: Targets, query: string) {
let currentTree: ILEObject[] = [];

function lookupObject(ileObject: ILEObject) {
console.log(`${''.padEnd(currentTree.length, `\t`)}${ileObject.systemName}.${ileObject.type} (${ileObject.relativePath || `no source`})`);
console.log(`${''.padEnd(currentTree.length, `\t`)}${ileObject.systemName}.${ileObject.type} (${ileObject.source ? ileObject.source.relativePath : `no source`})`);

currentTree.push(ileObject);

Expand Down
Loading