@@ -629,6 +629,13 @@ let configurationMakeArgs: string[] = [];
629629export function getConfigurationMakeArgs ( ) : string [ ] { return configurationMakeArgs ; }
630630export 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+
632639let configurationProblemMatchers : string [ ] = [ ] ;
633640export function getConfigurationProblemMatchers ( ) : string [ ] { return configurationProblemMatchers ; }
634641export 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