Makefile Visual Studio Code



Suggest: 1) CFLAGS:= -Wall -Wextra -Wconversion -pedantic -std=C11` (and place -c and $(CFLAGS) in the compile rule) and to avoid problems with #include files, generate a rule that creates the dependency files and include them at the bottom of the makefile. And modify the compile rule to include the dependency file that is related to the file being compiled. – user3629249 Jun 8 '20 at 20:17. Follow these steps to configure makefile projects so that IntelliSense works as expected: Open the Property Pages dialog box. For details, see Set C compiler and build properties in Visual Studio. Expand the Configuration Properties node. Select the NMake property page, and then modify properties.

Makefile Command Runner empowers the Makefile capabilities built into Visual Studio Code — Run any command from the sidebar, run and watch tests by right clicking either on a file or folder.

Settings Options

This extension contributes the following variables to the settings:

  • makefilePath: use this setting to set the file path of your Makefile, for example bin/local
  • unitTestCommand: use this setting to set the unit test command, for exmample unit-test-all
  • integrationTestCommand: use this setting to set the integration test command, for exmample integration-test
  • unitTestWatchCommand: use this setting to set the unit test watch command, for exmample unit-test-all-watch
  • integrationTestWatchCommand: use this setting to set the integration test watch command, for exmample integration-test-all-watch
  • filePathEnv: use this setting to set the file path environment variable used to pass down to node scripts the file path, for example FILE_PATH

Features

Commands view

A view to visualize and explore Makefile commands

Explorer menu

Adds 'Run test' and 'Run and watch test' in the explorer menu

  • Use right click to open the menu

How to use

  1. Locate your makefile path and name. Example for a makefile located in bin/make and named Makefile.main

  2. Open settings and update Makefile path and Makefile name

  3. Check the remaining settings and make sure you update them correctly according to your project

Open

Source Code can be found at github.

Visual Studio Code (VSCode) is a source-code editor developed by Microsoft for Windows, Linux and macOS.[7] It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.

GCC and make

Makefile visual studio code

Makefile In Visual Studio

We are going to use gcc, make and a makefile.

Preparation

In Windows you need to install msys2. Ensure that the PATH environment variable is updated and contains the msys2 paths, as noted in the mentioned post.

In CentOS Linux now, if you don’t have gcc, you’ll find plenty of information on internet on how to install it. To just ensure you already have gcc and make installed type the following in a terminal.

Gcc

VSCode *.json setting files

Generate Makefile Visual Studio Code

VSCode keeps *.json setting files in the .vscode folder.

Here is the launch.json file.

Visual Studio Code Makefile Support

Here is the tasks.json file.

Code

And here is the c_cpp_properties.json file.

Makefile

The makefile is used in compiling and cleaning the project.

You may call the makefile directly using the VSCode terminal, provided that you are in the root directory of the project.

Vscode Makefile Gcc

Makefile

Visual Studio Code Makefile Project

Good luck.