Conversation
'all' is a well-known name The default target must be explicitly named on the dry-run command line, because of [Remaking Makefiles](https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html) rule of GNU Make. In order to avoid remaking makefiles during a dry-run, the makefile must also be given as an explicit target. If the makefile were given as the only target, the dry-run would not mean 'dry-run the default target', but 'dry-run nothing'. Thus, if the makefile must be given as a target, the default target must be made explicit, and thus is must be defined. Also, previously 'all' was added to the make invokation for listing targets. This would prevent the .DEFAULT_GOAL to be correctly set as the Makefile declared, and instead be set to the value given on the command line. An explicit target is no longer given on the --print-data-base invocation, so the output .DEFAULT_GOAL will be the genuine default goal. This commit makes currentTarget always defined, with the default value 'all'; this is a reasonable, well-known default.
The top makefile in projects that use autotools and automake contains a rule to remake the makefile itself when the configuration changes (configure.ac). Even when dry-running, GNU make regenerates the makefile, in a bid to generate a 'correct' dry-run output. VScode needs to add --always-make in order to get a complete view of the dry-run. Without it, it would only get the commands needed for outdated targets. These two behaviours combined cause a naive 'make --dry-run --always-make' to continuously remake the Makefile. In order to avoid this infinite loop, make must be instructed as in the "Remaking Makefiles" man page, to avoid remaking the makefile. This is done by adding two options: --assume-old=Makefile, and Makefile (ie, target). Make requires the Makefile to be explicitly specified as target, otherwise it ignores the --assume-old=Makefile option. Furthermore, Makefiles generated by automake cause the top invocation to be a recursive sub-make invocation. On recursive makes, make itself calls submake without passing the --assume-old option, thus breaking the combo required for the sub-make to avoid remaking the makefile. As a result, automake Makefiles need one more workaround. The --assume-old option must be manually passed to sub-make via the AM_MAKEFLAGS, which is always appended to sub-make's command line. This commit implements the above incantation to enable automake Makefiles to be dry-run without an infinite loop. Additionally, the makefilePath, makeDirectory, updatedMakefilePath and updatedMakeDirectory variables are made to store the respective setting, rather then re-purposing them to store the corresponding resolved, absolute paths. makefilePath cannot be undefined because for dry-running the name of the makefile must always be supplied on the make commandline.
out-of-tree builds allow multiple configurations to be built simultaneously from one source tree. Each build configuration exists in a separate builddir, and the srcdir contains no configuration, object files or build artifacts. The builddir need not be a subdirectory of srcdir, and typically it is on another filesystem than the sources. In an autotools project which uses automake, the Makefiles are object files, ie they are generated specifically for a particular configuration, therefore they reside in the builddir. When building an autotools project out-of-tree, the workspace is the srcdir, and does not contain a Makefile. instead, the Makefile is in $makeDirectory which is the builddir. This commit cleans up the detection of makefile location that is done in the extension so that the correct makefile is found, even if it lives out-of-tree/out-of-workspace, has a name other than Makefile/makefile, an whether or not a file named Makefile also exists in the srcdir. The activationEvent is changed to "*" because when building out of tree, there are no makefiles in the workspace. "*" is the better activation because it means activate whenever the user enabled the extension; don't second guess. OTOH, the extension does nothing if a makefile is not found and not configured, so it's safe to have it activated on workspaces without makefiles, because of the cleaned-up detection/configuration of makefiles.
When building out of tree, whether the extension is in fullFeatureSet or not depends on which build configuration is chosen. The workspace does not have a Makefile, but one of the builddirs in a configuration does. Allow that configuration to be selected, unconditionally on the currently selected configuration.
Previously, one buildLog was used for all configurations, which is wrong, because the build is subject to configuration. When a (non-Default) configuration is active, its buildLog will be used. If not set, no buildLog will be used. The Default configuration buildLog will not be used for a specific configuration. When the apropriate buildLog (either Default or specific) is not set, the make --dry-run process will be followed to obtain a fresh build configuration.
A cached configuration makes sense only when associated with a
configuration, and the build target that was dry-run scanned.
The previous approach of a global configuration cache that lived in the
extensionOutputFolder with a hardcoded filename did not scale to
multiple configurations and targets.
Even though it could be configured to another directory, it was still
not scaleable.
This commit removes the user configuration for configurationCachePath,
and instead calculates the filename used for cache using the format
${makeDirectory}/.vscode/${targetName}.cache
The unfortunate name "makeDirectory" is semantically the configuration
directory, when it differs from the source directory. The configured
Makefile typically lives there.
Configurability of this item is now removed.
Saving the dryrun.log to the extension output directory doesn't extract
much value from it, especially as it is overriden per configuration.
This commit makes saving it to the disk optional (default = not saved),
configurable with a new makefile.keepDryRuns option, and moves the save
location to ${makeDirectory}/.vscode/${targetName}.dryrun.log
This location allows changes to the configuration to be easily tracked.
For example, it could be added to git for easy review of configuration
changes.
If the build directory is out of tree, you could create a git
repo specifically for tracking configurations of builds.
If the srcdir and builddir are the same (in-tree building), you could
use the source repo to also track builds; mixing source and diagnostic
files can be messy; a separate repo initialized in the .vscode directory
can help. Otherwise, worktrees or hard links can be useful to track the
dry-run output in a separate repo.
A new setting is added named makefile.keepConfigurationCache (default=false) which when enable causes the configuration cache to be saved to disk and loaded on reload.
This folder is no longer needed. dry-run and configurationCache are saved to a configuration-specific directory ($makeDirectory/.vscode) The extensionLog no longer defaults to this value, it must be specified explicitly.
50f5c8e to
e6bfc53
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move dryrun.log to builddir - optionally saved
Saving the dryrun.log to the extension output directory doesn't extract
much value from it, especially as it is overriden per configuration.
This commit makes saving it to the disk optional (default = not saved),
configurable with a new makefile.keepDryRuns option, and moves the save
location to ${makeDirectory}/.vscode/${targetName}.dryrun.log
This location allows changes to the configuration to be easily tracked.
For example, it could be added to git for easy review of configuration
changes.
If the build directory is out of tree, you could create a git
repo specifically for tracking configurations of builds.
If the srcdir and builddir are the same (in-tree building), you could
use the source repo to also track builds; mixing source and diagnostic
files can be messy; a separate repo initialized in the .vscode directory
can help. Otherwise, worktrees or hard links can be useful to track the
dry-run output in a separate repo.