xPack C/C++ Managed BuildA Visual Studio Code extension for managing and building C/C++ projects with CMake, Meson, and other tools, utilising the xPack tools. This extension is intended as a replacement for the managed build system available in Eclipse Embedded CDT. Features related to the automatic generation of build configurations, similar to Eclipse managed builds, will be available in a future release and will be based on xcdl. FeaturesManage typical multi-configuration projects (such as Debug/Release), as well as complex, multi-platform, multi-architecture, and 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 forms part of the xPack Reproducible Build Framework. It can be installed from the Visual Studio Marketplace as ilg-vscode.xpack. All required dependencies (such as the C/C++ extension) are handled automatically. Prerequisites (Node.js/npm)Visual Studio Code 1.102 or later and a recent version of xpm, which is a portable Node.js command-line application, available from npmjs.com.
For further details, please follow the instructions on the installation page. Quick StartTL;DR: View → Command Palette... → xPack: Quick Start a Hello World project (C++, CMake) (however, it is recommended to read the Quick Start page). The simplest way to begin with the VS Code xPack C/C++ Managed Build extension is to create a basic Hello World project. Open the Quick Start page in your browser and follow the steps. In addition to being a fully functional project, the result can serve as an excellent starting point for more complex projects. How it WorksThe xPack Reproducible Build Framework is not specific to VS Code; it is a set of portable CLI tools,
agnostic to any build system,
which can invoke any third-party tools, both legacy and modern, to perform the actual build.
It favours modern tools
(such as CMake and Meson) which can
generate a Future versions of the xPack Reproducible 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 the simplicity of npm; it adds a few additional 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 strings). 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 on the system, as it includes a dependency on xPack GCC and a CMake toolchain description file using it, to prevent CMake from selecting any other unwanted compiler that may be present. VS Code ConfigurationsThe VS Code C/C++ extension manages multiple configurations
in the IntelliSense correctly renders the content for the active configuration, shown in the status bar. IntelliSense Enabled Only for Top-Level 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 requires a file called Ignore the Kits Selection PromptAlthough not required by the xPack extension, the CMake extension still prompts for a kit: Select Unspecified, as kits are not used by the xPack extension. This issue is currently under consideration by the CMake Tools project and is expected to be resolved in a future release. Known Issues
Project TemplatesCreating new projects is automated using project templates. Create a Hello World ProjectThe Quick Start a Hello World project command described above creates a C++ project built with CMake. The full set of options is available when executing the xPack: Create a Hello World project command, which is an interactive application requiring user input. The result is similar, but may use different build tools or languages (C vs C++). When this command is invoked, VS Code instantiates the separate project template available from: Create a Hello World QEMU Semihosted ProjectIn addition to native projects running on the host system, it is possible to create Arm Cortex-M, Arm Cortex-A (32/64-bit), and RISC-V (32/64-bit) bare-metal projects running on QEMU. When this command is invoked, VS Code instantiates the separate project template available from: Release NotesThe latest release is v1.0.1, which, according to semantic versioning rules, means it is in the production phase. The xPack extension is functional, but further improvements are to be expected in future releases. More details about each release can be found on the releases pages. LicenceThe original content is released under the MIT Licence, with all rights reserved to Liviu Ionescu. |