xPack C/C++ Managed Build (beta)A VS Code extension to manage and build C/C++ projects with CMake, meson, etc, using the xPack tools. It is intended as a replacement for the managed build system available in Eclipse Embedded CDT. FeaturesManage typical multi-configuration projects (like Debug/Release), but also complex, multi-platform, multi-architecture, multi-toolchain projects, with an emphasis on modern C/C++ and embedded applications. OverviewThe xPack C/C++ Managed Build extension is an open source project hosted on GitHub and is part of the xPack Build Framework. It can be installed from the VisualStudio Marketplace as ilg-vscode.xpack and it pulls its own dependencies (like the C/C++). RequirementsVS Code 1.54 or later and a recent xpm, which is a portable Node.js command line application, available from npmjs.com.
For details please follow the instructions in the install page. Quick StartTL;DR: View → Command Palette... → xPack: Quick Start a Hello World project (C++, CMake) (but better read the Quick Start page). The simplest way to start with the VS Code xPack C/C++ Managed Build extension is to create a simple Hello World project. Open the Quick Start page in a browser and follow the steps. In addition to being a fully functional project, the result can also be a good starting point for more complex projects. How it worksThe xPack Build Framework is not necessarily specific to VS Code,
it is a set of portable CLI tools,
neutral to any build system,
which can basically
invoke any 3rd party tools, old and new, to perform the actual build;
it favours modern tools
(like CMake and meson) which can
generate a Future versions of the xPack Build Framework are planned to include an integrated build system generator, similar to that used in Eclipse CDT. DisclaimerThe xPack project does not introduce a new package format, but
inherits from the simplicity of npm; it adds a few more definitions
to Concepts (configurations & actions)Compared to typical CMake/meson projects, which in most cases use a single build folder, an xPack Managed Build project is by design defined as
each using a separate build folder, and
defined as sequences of commands (stored in JSON as arrays of string). To avoid redundant definitions between configurations, the actions can use generic templates, with substitutions performed by the LiquidJS template engine, based on user defined string properties. A typical example of a project with two build configurations, using CMake, may look like:
With a bit of
Note: this example does not require the presence of a compiler in the system, it includes a dependency to xPack GCC and a CMake toolchain description file using it, to prevent CMake picking any other unwanted compiler possibly present in the system. VS Code configurationsThe VS Code C/C++ extension keeps track of multiple configurations
in the IntelliSense correctly renders the content for the active configurations, shown in the status bar. IntelliSense enabled only for top foldersTL;DR: open separate projects/packages as separate workspace folders. Due to the specifics of the VS Code C/C++ extension, IntelliSense is available only if the package is in the root of the workspace folder. In other words, when opening a workspace folder which includes multiple packages, IntelliSense will not be enabled. The correct solution is to open all packages as workspace folders, either
separately or via a IntelliSense available only after the first buildIn order to correctly parse the project, for managed projects,
IntelliSense needs a file called Known Issues
Release NotesThe latest release is v0.4.17, which, according to semantic versioning rules, means it is still in initial development phase. The xPack extension is functional and can be used for beta-testing, but anything MAY change at any time and the public API SHOULD NOT be considered stable. More details about each release can be found in the releases pages. |