Skip to content

Commit 5a47164

Browse files
authored
Report not found stuff in Makefile Tools UI (#432)
* Report not found stuff in Makefile Tools UI * Fix some spacing and refactor some Makefile Tools UI tree nodes updates
1 parent c570369 commit 5a47164

5 files changed

Lines changed: 273 additions & 80 deletions

File tree

package.json

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@
177177
"dark": "res/dark/edit.svg"
178178
}
179179
},
180+
{
181+
"command": "workbench.action.openWorkspaceSettings",
182+
"title": "%workbench.action.openWorkspaceSettings.title%",
183+
"icon": {
184+
"light": "res/light/edit.svg",
185+
"dark": "res/dark/edit.svg"
186+
}
187+
},
180188
{
181189
"command": "makefile.outline.configure",
182190
"title": "%makefile-tools.command.makefile.configure.title%",
@@ -537,7 +545,6 @@
537545
"makefile__viewContainer": [
538546
{
539547
"id": "makefile.outline",
540-
"when": "makefile:fullFeatureSet",
541548
"name": "%makefile-tools.configuration.views.makefile.outline.description%"
542549
}
543550
]
@@ -615,6 +622,10 @@
615622
{
616623
"command": "makefile.outline.setLaunchConfiguration",
617624
"when": "makefile:localDebugFeature"
625+
},
626+
{
627+
"command": "workbench.action.openWorkspaceSettings",
628+
"when": "always"
618629
}
619630
],
620631
"view/title": [
@@ -635,22 +646,22 @@
635646
},
636647
{
637648
"command": "makefile.outline.buildTarget",
638-
"when": "view == makefile.outline",
649+
"when": "makefile:fullFeatureSet && view == makefile.outline",
639650
"group": "navigation@1"
640651
},
641652
{
642653
"command": "makefile.outline.buildCleanTarget",
643-
"when": "view == makefile.outline",
654+
"when": "makefile:fullFeatureSet && view == makefile.outline",
644655
"group": "1_makefileOutline@4"
645656
},
646657
{
647658
"command": "makefile.outline.launchDebug",
648-
"when": "view == makefile.outline && makefile:localDebugFeature",
659+
"when": "makefile:fullFeatureSet && view == makefile.outline && makefile:localDebugFeature",
649660
"group": "navigation@2"
650661
},
651662
{
652663
"command": "makefile.outline.launchRun",
653-
"when": "view == makefile.outline && makefile:localRunFeature",
664+
"when": "makefile:fullFeatureSet && view == makefile.outline && makefile:localRunFeature",
654665
"group": "navigation@3"
655666
}
656667
],
@@ -667,38 +678,53 @@
667678
},
668679
{
669680
"command": "makefile.outline.setBuildConfiguration",
670-
"when": "view == makefile.outline && viewItem =~ /nodeType=configuration/",
681+
"when": "makefile:fullFeatureSet && view == makefile.outline && viewItem =~ /nodeType=configuration/",
671682
"group": "inline@1"
672683
},
673684
{
674685
"command": "makefile.outline.buildTarget",
675-
"when": "view == makefile.outline && viewItem =~ /nodeType=buildTarget/",
686+
"when": "makefile:fullFeatureSet && view == makefile.outline && viewItem =~ /nodeType=buildTarget/",
676687
"group": "1_stateActions@1"
677688
},
678689
{
679690
"command": "makefile.outline.buildCleanTarget",
680-
"when": "view == makefile.outline && viewItem =~ /nodeType=buildTarget/",
691+
"when": "makefile:fullFeatureSet && view == makefile.outline && viewItem =~ /nodeType=buildTarget/",
681692
"group": "1_stateActions@2"
682693
},
683694
{
684695
"command": "makefile.outline.setBuildTarget",
685-
"when": "view == makefile.outline && viewItem =~ /nodeType=buildTarget/",
696+
"when": "makefile:fullFeatureSet && view == makefile.outline && viewItem =~ /nodeType=buildTarget/",
686697
"group": "inline@1"
687698
},
688699
{
689700
"command": "makefile.outline.launchDebug",
690-
"when": "view == makefile.outline && viewItem =~ /nodeType=launchTarget/",
701+
"when": "makefile:fullFeatureSet && view == makefile.outline && viewItem =~ /nodeType=launchTarget/",
691702
"group": "1_stateActions@1"
692703
},
693704
{
694705
"command": "makefile.outline.launchRun",
695-
"when": "view == makefile.outline && viewItem =~ /nodeType=launchTarget/",
706+
"when": "makefile:fullFeatureSet && view == makefile.outline && viewItem =~ /nodeType=launchTarget/",
696707
"group": "1_stateActions@2"
697708
},
698709
{
699710
"command": "makefile.outline.setLaunchConfiguration",
700-
"when": "view == makefile.outline && viewItem =~ /nodeType=launchTarget/",
711+
"when": "makefile:fullFeatureSet && view == makefile.outline && viewItem =~ /nodeType=launchTarget/",
701712
"group": "inline@1"
713+
},
714+
{
715+
"command": "workbench.action.openWorkspaceSettings",
716+
"when": "view == makefile.outline && viewItem =~ /nodeType=makefilePathInfo/",
717+
"group": "inline@1"
718+
},
719+
{
720+
"command": "workbench.action.openWorkspaceSettings",
721+
"when": "view == makefile.outline && viewItem =~ /nodeType=makePathInfo/",
722+
"group": "inline@1"
723+
},
724+
{
725+
"command": "workbench.action.openWorkspaceSettings",
726+
"when": "view == makefile.outline && viewItem =~ /nodeType=buildLogPathInfo/",
727+
"group": "inline@1"
702728
}
703729
]
704730
}

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"makefile-tools.command.makefile.setBuildConfiguration.title": "Makefile: Set the current build configuration",
99
"makefile-tools.command.makefile.setBuildTarget.title": "Makefile: Set the target to be built by make",
1010
"makefile-tools.command.makefile.setLaunchConfiguration.title": "Makefile: Set the make launch configuration",
11+
"workbench.action.openWorkspaceSettings.title": "Preferences: Open Workspace Settings",
1112
"makefile-tools.command.makefile.configure.title": "Makefile: Configure",
1213
"makefile-tools.command.makefile.cleanConfigure.title": "Makefile: Clean Configure",
1314
"makefile-tools.command.makefile.preConfigure.title": "Makefile: Pre-Configure",

src/configuration.ts

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,13 @@ let configurationMakeArgs: string[] = [];
629629
export function getConfigurationMakeArgs(): string[] { return configurationMakeArgs; }
630630
export function setConfigurationMakeArgs(args: string[]): void { configurationMakeArgs = args; }
631631

632+
// The following (makefile, problem matchers, build log), same as command&args above
633+
// are deduced via a set of rules of defaults and overrides that we calculate only when necessary
634+
// and access the last result otherwise.
635+
let configurationMakefile: string | undefined;
636+
export function getConfigurationMakefile(): string | undefined { return configurationMakefile; }
637+
export function setConfigurationMakefile(makefilePath: string | undefined): void { configurationMakefile = makefilePath; }
638+
632639
let configurationProblemMatchers: string[] = [];
633640
export function getConfigurationProblemMatchers(): string[] { return configurationProblemMatchers; }
634641
export function setConfigurationProblemMatchers(problemMatchers: string[]): void { configurationProblemMatchers = problemMatchers; }
@@ -686,27 +693,27 @@ export function getCommandForConfiguration(configuration: string | undefined): v
686693

687694
// Add the makefile path via the -f make switch.
688695
// makefile.configurations.makefilePath overwrites makefile.makefilePath.
689-
let makefileUsed: string | undefined = makefileConfiguration?.makefilePath ? util.resolvePathToRoot(makefileConfiguration?.makefilePath) : makefilePath;
690-
if (makefileUsed) {
696+
configurationMakefile = makefileConfiguration?.makefilePath ? util.resolvePathToRoot(makefileConfiguration?.makefilePath) : makefilePath;
697+
if (configurationMakefile) {
691698
// check if the makefile path is a directory. If so, try adding `Makefile` or `makefile`
692-
if (util.checkDirectoryExistsSync(makefileUsed)) {
693-
let makeFileTest = path.join(makefileUsed, "Makefile");
699+
if (util.checkDirectoryExistsSync(configurationMakefile)) {
700+
let makeFileTest = path.join(configurationMakefile, "Makefile");
694701
if (!util.checkFileExistsSync(makeFileTest)) {
695-
makeFileTest = path.join(makefileUsed, "makefile");
702+
makeFileTest = path.join(configurationMakefile, "makefile");
696703
}
697704

698-
// if we found the makefile in the directory, set the `makefileUsed` to the found file path.
705+
// if we found the makefile in the directory, set the `configurationMakefile` to the found file path.
699706
if (util.checkFileExistsSync(makeFileTest)) {
700-
makefileUsed = makeFileTest;
707+
configurationMakefile = makeFileTest;
701708
}
702709
}
703710

704711
configurationMakeArgs.push("-f");
705-
configurationMakeArgs.push(`${makefileUsed}`);
712+
configurationMakeArgs.push(`${configurationMakefile}`);
706713
// Need to rethink this (GitHub 59).
707714
// Some repos don't work when we automatically add -C, others don't work when we don't.
708715
// configurationMakeArgs.push("-C");
709-
// configurationMakeArgs.push(path.parse(makefileUsed).dir);
716+
// configurationMakeArgs.push(path.parse(configurationMakefile).dir);
710717
}
711718

712719
// Add the working directory path via the -C switch.
@@ -740,7 +747,23 @@ export function getCommandForConfiguration(configuration: string | undefined): v
740747
logger.message(`Deduced command '${configurationMakeCommand} ${configurationMakeArgs.join(" ")}' for configuration "${configuration}"`);
741748
}
742749

743-
// Validation and warnings about properly defining the makefile and make tool.
750+
// Check for makefile path on disk: we search first for any makefile specified via the makefilePath setting,
751+
// then via the makeDirectory setting and then in the root of the workspace. On linux/mac, it often is 'Makefile', so verify that we default to the right filename.
752+
if (!configurationMakefile) {
753+
if (makeDirectoryUsed) {
754+
configurationMakefile = util.resolvePathToRoot(path.join(makeDirectoryUsed, "Makefile"));
755+
if (!util.checkFileExistsSync(configurationMakefile)) {
756+
configurationMakefile = util.resolvePathToRoot(path.join(makeDirectoryUsed, "makefile"));
757+
}
758+
} else {
759+
configurationMakefile = util.resolvePathToRoot("./Makefile");
760+
if (!util.checkFileExistsSync(configurationMakefile)) {
761+
configurationMakefile = util.resolvePathToRoot("./makefile");
762+
}
763+
}
764+
}
765+
766+
// Validation and warnings about properly defining the makefile and make tool.
744767
// These are not needed if the current configuration reads from a build log instead of dry-run output.
745768
let buildLog: string | undefined = getConfigurationBuildLog();
746769
let buildLogContent: string | undefined = buildLog ? util.readFile(buildLog) : undefined;
@@ -752,22 +775,21 @@ export function getCommandForConfiguration(configuration: string | undefined): v
752775

753776
// If configuration command has a path (absolute or relative), check if it exists on disk and error if not.
754777
// If no path is given to the make tool, search all paths in the environment and error if make is not on the path.
755-
const makeNotFoundStr: string = localize("make.not.found", "{0} not found.", "Make");
756778
if (configurationCommandPath !== "") {
757-
if (!util.checkFileExistsSync(configurationMakeCommand)) {
758-
vscode.window.showErrorMessage(makeNotFoundStr);
759-
logger.message("Make was not found on disk at the location provided via makefile.makePath or makefile.configurations[].makePath.");
760-
761-
// How often location settings don't work (maybe because not yet expanding variables)?
762-
const telemetryProperties: telemetry.Properties = {
763-
reason: "not found at path given in settings"
764-
};
765-
telemetry.logEvent("makeNotFound", telemetryProperties);
779+
if (!util.checkFileExistsSync(configurationMakeCommand)) {
780+
logger.message("Make was not found on disk at the location provided via makefile.makePath or makefile.configurations[].makePath.");
781+
782+
// How often location settings don't work (maybe because not yet expanding variables)?
783+
const telemetryProperties: telemetry.Properties = {
784+
reason: "not found at path given in settings"
785+
};
786+
telemetry.logEvent("makeNotFound", telemetryProperties);
766787
}
767788
} else {
768-
if (!util.toolPathInEnv(path.parse(configurationMakeCommand).base)) {
769-
vscode.window.showErrorMessage(makeNotFoundStr);
770-
logger.message("Make was not given any path in settings and is also not found on the environment path.");
789+
const makeBaseName: string = path.parse(configurationMakeCommand).base;
790+
const makePathInEnv: string | undefined = util.toolPathInEnv(makeBaseName);
791+
if (!makePathInEnv) {
792+
logger.message("Make was not given any path in settings and is also not found on the environment path.");
771793

772794
// Do the users need an environment automatically set by the extension?
773795
// With a kits feature or expanding on the pre-configure script.
@@ -778,32 +800,19 @@ export function getCommandForConfiguration(configuration: string | undefined): v
778800
}
779801
}
780802

781-
// Check for makefile path on disk: we search first for any makefile specified via the makefilePath setting,
782-
// then via the makeDirectory setting and then in the root of the workspace. On linux/mac, it often is 'Makefile', so verify that we default to the right filename.
783-
if (!makefileUsed) {
784-
if (makeDirectoryUsed) {
785-
makefileUsed = util.resolvePathToRoot(path.join(makeDirectoryUsed, "Makefile"));
786-
if (!util.checkFileExistsSync(makefileUsed)) {
787-
makefileUsed = util.resolvePathToRoot(path.join(makeDirectoryUsed, "makefile"));
788-
}
789-
} else {
790-
makefileUsed = util.resolvePathToRoot("./Makefile");
791-
if (!util.checkFileExistsSync(makefileUsed)) {
792-
makefileUsed = util.resolvePathToRoot("./makefile");
793-
}
794-
}
795-
}
796-
797-
if (!util.checkFileExistsSync(makefileUsed)) {
803+
if (!util.checkFileExistsSync(configurationMakefile)) {
798804
logger.message("The makefile entry point was not found. " +
799805
"Make sure it exists at the location defined by makefile.makefilePath, makefile.configurations[].makefilePath, " +
800806
"makefile.makeDirectory, makefile.configurations[].makeDirectory" +
801807
"or in the root of the workspace.");
802808

809+
// we may need more advanced ability to process settings
810+
// insight into different project structures
803811
const telemetryProperties: telemetry.Properties = {
804-
reason: makefileUsed ?
805-
"not found at path given in settings" : // we may need more advanced ability to process settings
806-
"not found in workspace root" // insight into different project structures
812+
reason: makefileConfiguration?.makefilePath || makefilePath ?
813+
"not found at path given in settings" :
814+
(makeDirectoryUsed ? "not found in -C provided make directory" :
815+
"not found in workspace root")
807816
};
808817

809818
telemetry.logEvent("makefileNotFound", telemetryProperties);
@@ -1051,9 +1060,12 @@ export async function initFromStateAndSettings(): Promise<void> {
10511060

10521061
analyzeConfigureParams();
10531062

1054-
await extension._projectOutlineProvider.update(extension.getState().buildConfiguration || "unset",
1055-
extension.getState().buildTarget || "unset",
1056-
extension.getState().launchConfiguration || "unset");
1063+
await extension._projectOutlineProvider.update(extension.getState().buildConfiguration,
1064+
extension.getState().buildTarget,
1065+
extension.getState().launchConfiguration,
1066+
getConfigurationMakefile(),
1067+
getConfigurationMakeCommand(),
1068+
getConfigurationBuildLog());
10571069

10581070
// Verify the dirty state of the IntelliSense config provider and update accordingly.
10591071
// The makefile.configureOnEdit setting can be set to false when this behavior is inconvenient.
@@ -1401,9 +1413,10 @@ export async function initFromStateAndSettings(): Promise<void> {
14011413
}
14021414

14031415
// Final updates in some constructs that depend on more than one of the above settings.
1404-
if (extension.getState().configureDirty) {
1405-
analyzeConfigureParams();
1406-
}
1416+
analyzeConfigureParams();
1417+
await extension._projectOutlineProvider.updateMakePathInfo(getConfigurationMakeCommand());
1418+
await extension._projectOutlineProvider.updateMakefilePathInfo(getConfigurationMakefile());
1419+
await extension._projectOutlineProvider.updateBuildLogPathInfo(getConfigurationBuildLog());
14071420

14081421
// Report all the settings changes detected by now.
14091422
// TODO: to avoid unnecessary telemetry processing, evaluate whether the changes done

0 commit comments

Comments
 (0)