{"id":469,"date":"2021-02-18T22:44:32","date_gmt":"2021-02-18T22:44:32","guid":{"rendered":"https:\/\/tbekk.com\/devstream\/?p=469"},"modified":"2021-02-18T22:54:50","modified_gmt":"2021-02-18T22:54:50","slug":"visual-studio-code-now-supports-makefile","status":"publish","type":"post","link":"https:\/\/tbekk.com\/devstream\/2021\/02\/18\/visual-studio-code-now-supports-makefile\/","title":{"rendered":"Visual Studio Code now supports Makefile"},"content":{"rendered":"\n<p>VS Code annouces the support of Makefiles (as a preview version). Here&#8217;s the link to the blog bost.<\/p>\n\n\n\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/now-announcing-makefile-support-in-visual-studio-code\/\"><em><strong>Now announcing: Makefile support in Visual Studio Code!<\/strong><\/em><\/a><\/p>\n\n\n\n<p>From the blog post:<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-cf25a2ac-6d92-4183-a280-d1c20bcb5b3f\"><li><em>Published at:<\/em> <em><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/now-announcing-makefile-support-in-visual-studio-code\/\">https:\/\/devblogs.microsoft.com\/python\/iot-exploration-with-vs-code-python-and-the-device-simulator-express\/<\/a><\/em><\/li><li><em>Author:<\/em> <a href=\"https:\/\/devblogs.microsoft.com\/python\/author\/luabudmicrosoft-com\/\"><em><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/author\/jureidmicrosoft-com\/\">Julia Reid<\/a><\/em><\/a><\/li><li><em>Publication date:<\/em> <em>2021, February 17th<\/em><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>We are excited to announce a brand-new extension for building and debugging Makefile projects in Visual Studio Code:\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.makefile-tools\" target=\"_blank\">Makefile Tools (preview)<\/a>! The extension is in pilot stages, but we\u2019ve curated a\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/blob\/main\/docs\/repositories.md\" target=\"_blank\">list of over 70 popular opensource Makefile projects<\/a>\u00a0that work with Makefile Tools. Give it a try and let us know what you think!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-the-extension\">Installing the extension<\/h2>\n\n\n\n<p>First, install the&nbsp;<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.makefile-tools\" target=\"_blank\" rel=\"noreferrer noopener\">Makefile Tools extension<\/a>&nbsp;from the VS Code Marketplace.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-tools-marketplace.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-tools-marketplace.png\" alt=\"Image of Makefile Tools extension in VS Code Marketplace\" class=\"wp-image-27626\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"activating-the-extension\">Activating the extension<\/h2>\n\n\n\n<p>Once the extension is installed, it will activate when it finds a Makefile in your&nbsp;project\u2019s root folder. If your project\u2019s Makefile is not in the root folder, you can use the&nbsp;<strong>Makefile Path<\/strong>&nbsp;setting to instruct the extension where to find it. Update&nbsp;<strong>Makefile Path<\/strong>&nbsp;by going to&nbsp;<strong>File<\/strong>&nbsp;&gt;&nbsp;<strong>Preferences<\/strong>&nbsp;&gt;&nbsp;<strong>Settings<\/strong>&nbsp;and then selecting&nbsp;<strong>makefile<\/strong>&nbsp;under&nbsp;<strong>Extensions.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile.makefilepath.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile.makefilepath.png\" alt=\"Image showing the Makefile Tools extension's Makefile Path property in VS Code settings\" class=\"wp-image-27611\"\/><\/a><\/figure>\n\n\n\n<p>After updating&nbsp;<strong>Makefile Path<\/strong>, type \u201cmakefile\u201d into the Command Palette and run a Makefile Tools command to activate the extension.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuring-your-project\">Configuring your project<\/h2>\n\n\n\n<p>By default, the extension will attempt to use a&nbsp;make&nbsp;program that resides within your $PATH to configure the project. If your make.exe is not in your $PATH, update the&nbsp;<strong>Make Path&nbsp;<\/strong>setting by going to&nbsp;<strong>File<\/strong>&nbsp;&gt;&nbsp;<strong>Preferences<\/strong>&nbsp;&gt;&nbsp;<strong>Settings<\/strong>&nbsp;and then selecting&nbsp;<strong>makefile<\/strong>&nbsp;under&nbsp;<strong>Extensions.&nbsp;<\/strong>The<strong>&nbsp;Make Path<\/strong>&nbsp;setting tells the extension where to find your make executable.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile.makepath.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile.makepath.png\" alt=\"Image showing the Makefile Tools extension's Make Path property in VS Code settings\" class=\"wp-image-27612\"\/><\/a><\/figure>\n\n\n\n<p>Once your make path is properly set, accept the prompt to allow Makefile Tools to configure IntelliSense.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-allow-intellisense.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-allow-intellisense.png\" alt=\"Image showing pop-up notification for allowing the Makefile Tools extension to configure IntelliSense\" class=\"wp-image-27623\"\/><\/a><\/figure>\n\n\n\n<p>If you don\u2019t see that notification, or you accidentally dismissed it, you can grant Makefile Tools permission to configure IntelliSense by running&nbsp;\u201c<strong>C\/C++: Change Configuration Provider\u201d<\/strong>&nbsp;from the Command Palette and selecting&nbsp;<strong>Makefile Tools<\/strong>.<\/p>\n\n\n\n<p>Now you\u2019re ready to configure your project! If you normally run&nbsp;make from the command line without passing it any additional arguments, you shouldn\u2019t need to do anything else at this point.<\/p>\n\n\n\n<p>If you regularly pass additional arguments to&nbsp;make, use the&nbsp;Makefile Tools\u2019&nbsp;<strong>Configurations<\/strong>&nbsp;setting (<strong>makefile.configurations<\/strong>&nbsp;in settings.json) to specify those arguments. Makefile.configurations is an array of configuration objects, each with a&nbsp;<strong>name<\/strong>&nbsp;and&nbsp;<strong>makeArgs<\/strong>&nbsp;property that holds the arguments to pass to make. To help you out, we\u2019ve&nbsp;<a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/blob\/main\/docs\/repositories.md\" target=\"_blank\" rel=\"noreferrer noopener\">documented the correct configurations<\/a>&nbsp;for over 70 popular open-source repositories. For example, to create a configuration for&nbsp;<a href=\"https:\/\/github.com\/littlekernel\/lk\" target=\"_blank\" rel=\"noreferrer noopener\">littlekernel<\/a>, where you need to pass \u201cPROJECT=armemu-test\u201d to make, your settings.json would look something like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\"makefile.configurations\": [\n    {\n        \"name\": \"littlekernel\",\n        \"makeArgs\": [\"PROJECT=armemu-test\"]\n    }\n]<\/pre>\n\n\n\n<p>To choose the configuration for a project, select the Makefile Tools icon in the left explorer menu.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-explorer-icon.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-explorer-icon.png\" alt=\"Image showing the Makefile Tools icon in the explorer menu on the left\" class=\"wp-image-27619\"\/><\/a><\/figure>\n\n\n\n<p>Hover over&nbsp;<strong>Configuration<\/strong>&nbsp;and select the pencil icon to choose a configuration for your project.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-choose-configuration.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-choose-configuration.png\" alt=\"Image showing the &quot;edit Configuration&quot; button that appears on hover in the Makefile Tools UI pane\" class=\"wp-image-27615\"\/><\/a><\/figure>\n\n\n\n<p>If you didn\u2019t define any configurations in<strong>&nbsp;makefile.configurations<\/strong>, the extension will automatically select a default one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"building-targets\">Building targets<\/h2>\n\n\n\n<p>After configuring your project, you\u2019re ready to build. Choose a Build target by selecting the pencil icon that appears on hover.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-choose-build-target.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-choose-build-target.png\" alt=\"Image showing the &quot;edit Build target&quot; button that appears on hover in the Makefile Tools UI pane\" class=\"wp-image-27614\"\/><\/a><\/figure>\n\n\n\n<p>Then choose from the list of targets found in your project\u2019s Makefile.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-list-build-targets.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-list-build-targets.png\" alt=\"Image showing a list of build targets found in the project's Makefile, returned by the Makefile Tools extension\" class=\"wp-image-27620\"\/><\/a><\/figure>\n\n\n\n<p>After setting the Build target, click the Build icon.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-build-target.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-build-target.png\" alt=\"Image showing the Build button in the top right corner of the Makefile Tools UI pane\" class=\"wp-image-27613\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"debugging-and-running-targets\">Debugging and running targets<\/h2>\n\n\n\n<p>To run\/debug your program, use the pencil icon to select a Launch target. A configuration for the selected target will be added to the&nbsp;<strong>makefile.launchConfigurations&nbsp;<\/strong>setting. If you need to pass additional arguments to your targets\u2014things like MIMode, miDebuggerPath, stopAtEntry\u2014 add the&nbsp;<strong>binaryArgs<\/strong>&nbsp;property to the target\u2019s configuration in&nbsp;<strong>makefile.launchConfigurations<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-choose-launch-target.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-choose-launch-target.png\" alt=\"Image showing the &quot;edit Launch target&quot; button that appears on hover in the Makefile Tools UI pane\" class=\"wp-image-27616\"\/><\/a><\/figure>\n\n\n\n<p>Once the Launch target is set, select the Debug icon to start a debugging session.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-debug-target.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-debug-target.png\" alt=\"Image showing the Debug target button in the top right corner of the Makefile Tools UI pane\" class=\"wp-image-27618\"\/><\/a><\/figure>\n\n\n\n<p>To run the program without debugging, select the Run in Terminal button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-run-in-terminal.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-run-in-terminal.png\" alt=\"Image showing the Run in Terminal button in top right corner of the Makefile Tools UI pane\" class=\"wp-image-27621\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"makefile-tools-commands\">Makefile Tools commands<\/h2>\n\n\n\n<p>You can find all the Makefile Tools commands by opening the Command Palette and typing \u201cmakefile\u201d. For your convenience, there are commands for building clean and building ALL that you can run without changing the Build target.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-commands.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2021\/02\/makefile-commands.png\" alt=\"Image showing the Makefile Tools extensions commands in the Command Palette, all beginning with &quot;makefile:&quot;\" class=\"wp-image-27617\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"makefile-tools-settings\">Makefile Tools settings<\/h2>\n\n\n\n<p>To find all Makefile Tools settings, go to&nbsp;<strong>File<\/strong>&nbsp;&gt;&nbsp;<strong>Preferences<\/strong>&nbsp;&gt;&nbsp;<strong>Settings<\/strong>&nbsp;and then select&nbsp;<strong>makefile<\/strong>&nbsp;under&nbsp;<strong>Extensions.<\/strong>&nbsp;The settings you\u2019ll probably use the most are:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>configurations (tells the extension which arguments to pass to make when configuring your project)<\/li><li>defaultLaunchConfiguration (global debugger settings)<\/li><li>launchConfigurations (debugger settings for specific launch targets)<\/li><li>makePath (path to your make executable)<\/li><li>makefilePath (path to project\u2019s Makefile)<\/li><li>buildLog (alternative to dry-run)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"known-limitations\">Known limitations<\/h2>\n\n\n\n<p>This is a preview release of Makefile Tools, and although we\u2019ve tested it with over 70 repositories, you may need to do some fiddling to configure your project for the first time. Please feel free to submit a PR to&nbsp;<a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/blob\/main\/docs\/repositories.md\" target=\"_blank\" rel=\"noreferrer noopener\">this document<\/a>, adding your repository and its correct configuration settings, to help anyone who might be trying to build the same project.<\/p>\n\n\n\n<p>Check out our&nbsp;<a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/blob\/main\/docs\/troubleshooting.md\" target=\"_blank\" rel=\"noreferrer noopener\">troubleshooting guide<\/a>&nbsp;for a list of known limitations and work-arounds.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-do-you-think\">What do you think?<\/h2>\n\n\n\n<p>Download the&nbsp;<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode.makefile-tools\" target=\"_blank\" rel=\"noreferrer noopener\">Makefile Tools extension<\/a>&nbsp;for Visual Studio Code&nbsp;today, give it a try, and let us know what you think. If you run into any issues, or have any suggestions, please report them in the&nbsp;<a href=\"https:\/\/github.com\/microsoft\/vscode-makefile-tools\/issues\" target=\"_blank\" rel=\"noreferrer noopener\">Issues section of our GitHub repository<\/a>.<\/p>\n\n\n\n<p>We can be reached via the comments below or in email at&nbsp;<a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>. You can also find our team on Twitter at&nbsp;<a href=\"https:\/\/twitter.com\/visualc\" target=\"_blank\" rel=\"noreferrer noopener\">@<\/a><a href=\"https:\/\/twitter.com\/visualc\" target=\"_blank\" rel=\"noreferrer noopener\">VisualC<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VS Code annouces the support of Makefiles (as a preview version). Here&#8217;s the link to the blog bost. Now announcing: Makefile support in Visual Studio Code! From the blog post:&#8230; <a class=\"read-more-link\" href=\"https:\/\/tbekk.com\/devstream\/2021\/02\/18\/visual-studio-code-now-supports-makefile\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[78,105],"class_list":["post-469","post","type-post","status-publish","format-standard","hentry","category-development","category-news","tag-makefile","tag-vs-code"],"_links":{"self":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/comments?post=469"}],"version-history":[{"count":3,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/469\/revisions"}],"predecessor-version":[{"id":477,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/469\/revisions\/477"}],"wp:attachment":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/media?parent=469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/categories?post=469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/tags?post=469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}