microsoft / vscode-makefile-tools

MAKE integration in Visual Studio Code
Other
185 stars 55 forks source link

Makefile Includes break VS code build. #459

Closed zachgillette closed 1 year ago

zachgillette commented 1 year ago

Our makefile is split up into sub make files that are included in the main makefile. When attempting to build within the IDE, it reports that the other make files that are included cannot be found, and errors out. Making from the command line works fine, even the intellisense works (except for another issue that I will make a ticket for, .inc files).

andreeis commented 1 year ago

@zachgillette, let's see if there is a difference between the "make" command you use when you build in terminal and which succeeds and the "make" command the extension deduces and runs in the VSCode IDE.

Set the following in ".vscode/settings.json": "makefile.loggingLevel": "Debug", "makefile.extensionOutputFolder": "./MyOutput", "makefile.extensionLog": "extension.log"

Open the project again in VSCode, let it finish configure, then go to the left UI panel for the extension to mouse click on the build icon (or you can run the command "Makefile: Build current target" from the palette). Share with us "extension.log" file from under "./MyOutput" folder. "dryrun.log", from the same location, might also be useful since you say IntelliSense works fine (and which is a result of a successful "make" invocation).

And provide the exact command that you use and which succeeds in your non VSCode environment.

zachgillette commented 1 year ago

Keep in mind I'm running on a remote Amazon Linux server. The make program is in the /usr/bin/ folder, however that folder is not in the scope of the project (we have many program distributions for testing). My configuration for Make Path is simply "make," since it is included in the runtime path. In the terminal, simply typing "make" is how we make. If you want, I could ask my senior programmer if we use a specialized make file.

extension.log

andreeis commented 1 year ago

@zachgillette , It looks from the log that you selected by mistake the target make. "Reading current build target "make" from the workspace state." This selection happens from the "Build Target" edit pen --> quickPick selection list in the left side C/C++ Panel UI specific for the Makefile Tools extension. We automatically detect what are the targets defined in the makefile. Unless there are bugs, if you found a "make" entry it means there is a "make" target in your makefile. But since you say you run "make" with no arguments, you don't want to define any target. You have to unset it. Currently, the only way to unset that is run from the palette the command "Makefile: Reset workspace state (for troubleshooting)".

Also, in terminal, you run the simple command "make", no arguments, but from what folder? From the same folder that you open in VSCode as root workspace?

zachgillette commented 1 year ago

I get it to now execute this:

Running that in the terminal works fine, but through VSCode I get the attached.

Also, the Output tab reads: Error: the task 'makefile: Makefile Tools Build Task' neither specifies a command nor a dependsOn property. The task will be ignored. Its definition is: { "type": "shell", "id": "shell,make,-f,/u2/webs/zach/live4/dist/source/makefile,", "problemMatcher": [], "label": "makefile: Makefile Tools Build Task" } make.log

andreeis commented 1 year ago

@zachgillette , you can safely ignore the Tasks Output error. It actually doesn't break anything. It is a VSCode bug: https://github.com/microsoft/vscode/issues/176670.

Do you set "makefile.makefilePath" in your settings? Usually we add -f if you do. Please specify what is the folder you open in VSCode as workspace root. What is the folder when you run that command in the terminal. Do you run make -f? You mentioned you run make simple, no -f.

zachgillette commented 1 year ago

I run from the /source/ folder.

My current json settings: { "workbench.colorTheme": "Default Dark+", "perltidy.additionalArguments": [

],
"workbench.iconTheme": "material-icon-theme",
"remote.SSH.remotePlatform": {
    "aws5.strategysystems.com": "linux",
    "dvl1.strategysystems.com": "linux"
},
"files.associations": {
    "*.inc": "c"
},
"makefile.makefilePath": "source/makefile",
"C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools",
"C_Cpp.loggingLevel": "Debug",
"makefile.loggingLevel": "Debug",
"makefile.extensionOutputFolder": "./MyOutput",
"makefile.extensionLog": "extension.log",
"C_Cpp.files.exclude": {

    "**/.vscode": true,
    "**/.vs": true
},
"makefile.ignoreDirectoryCommands": false,

}

andreeis commented 1 year ago

So, please confirm: in the terminal outside VSCode, you go to "> cd source" and there you run "make" simple, correct?

Then, in VSCode, you open the folder "source" as workspace root or one level above it? To replicate as much as possible the terminal, let's open "source" as workspace root in VSCode and remove "makefile.makefilePath" setting. The extension will find the makefile automatically, because it will be in the root. Later we'll try to achieve the same with opening from a different level and using makefilePath setting again.

Also, the setting "makefile.ignoreDirectoryCommands" is meant to ignore commands like "cd", "pushd", "popd" which somnetimes are not logged completely and correctly by "make" itself and only messes up our calculations. That's why the default of that boolean setting is "true". If you make it false, make sure all those commands are properly logged in how "make" will output its activity. Also, many times we don't need to look at the commands because "make" will also report "entering" or "exiting" directory. So try that boolean setting true as well, maybe will help.

Let me know what happens now.

zachgillette commented 1 year ago

I cannot make source the root, as it relies on files in web/source as well. The make will never work without those files. This is how I originally opened the project and realized this.

The core file structure is files in {workspace}/source and {workspace}/web/source. structure

andreeis commented 1 year ago

@zachgillette, but in terminal, you do "make" simple (no -f switch) from "source" and there is no problem with the web/source outside, correct?

Ok, let's open in VSCode one level up as you did, define makefilePath as you did.... but also define "makefile.makeDirectory": "./source". Try that. And keep "makefile.ignoreDirectoryCommands": "true" for now, unless needed to be false.

zachgillette commented 1 year ago

That did the trick. It now runs successfully.

andreeis commented 1 year ago

@zachgillette , excellent, closing the ticket. Let me know about 460 then.