smallshen
04/24/2024, 1:18 AMandrey.dernov
04/25/2024, 8:57 AMsmallshen
06/19/2024, 9:04 PMtype
type can be:
• c/lib
• c/app
• cpp/lib
• cpp/app
This is similar to jvm/app
or jvm/lib
, where a cpp
type product may include C source files.
platforms
In C/C++ projects, platforms are often represented as macro preprocessors (e.g., #ifdef WINDOWS_64
). We can pass the platform as a macro to the compiler and generate compilation_database.json
. Alternatively, and preferably, we can pass different source sets to the compiler instead of using macros directly(but should still be provided).
variants
Although not currently implemented in Amper, variants are a valuable feature. For C/C++, different build configurations (e.g., debug, release) can be implemented using variants, allowing different source sets to be passed to the compiler.
dependencies
• Include Another Amper C/C++ Module: Include the path when passing to the compiler and use #include <lib_name>
in the code.
• Include a Module from Repository: While C/C++ lacks a standard repository, the concept remains the same: include the path for the compiler and use #include <libname>
.
settings
C/C++ projects can have specific settings categories, such as compiler settings. Common options such as custom includes, optimization levels, and libc options. Amper can provide commonly used compiler options for these settings.
Toolchain Integration
CMake is widely used. However Amper's configuration file can be easily evaluated, adding special support for Amper should be straightforward. Alternatively, generating compilation_database.json
is another viable option.
Source Files Layout
• Common Layout:
◦ include
◦ src
• Platform-Specific Layout:
◦ include@platform
◦ src@platform
This approach, similar to Amper, is preferred over macros (though macros should also be supported).
Build Output
Common C/C++ library output includes headers and static or dynamic libraries for different platforms. We should preprocess include header files from different include@platform
directories into a single file, ensuring other tools can use the output library properly.
For applications, the process is straightforward.