|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a CMake-based build system for creating a statically linked version of CRIU (Checkpoint/Restore In Userspace) along with all its dependencies. The project builds CRIU v4.1 with all necessary libraries statically compiled to produce a self-contained binary and libcriu.o object file. |
| 8 | + |
| 9 | +## Build Commands |
| 10 | + |
| 11 | +### Configure the build |
| 12 | +```bash |
| 13 | +cmake --preset static-release |
| 14 | +``` |
| 15 | + |
| 16 | +### Build the project |
| 17 | +```bash |
| 18 | +cmake --build --preset static-release |
| 19 | +``` |
| 20 | + |
| 21 | +### Install or package |
| 22 | +```bash |
| 23 | +# Install directly |
| 24 | +sudo cmake --install build |
| 25 | + |
| 26 | +# Create package |
| 27 | +cpack --config build/CPackConfig.cmake --verbose -B dist -G STGZ |
| 28 | +``` |
| 29 | + |
| 30 | +### Alternative presets |
| 31 | +- `static-debug` - Debug build with debug symbols |
| 32 | +- `static-release` - Release build (default, optimized) |
| 33 | + |
| 34 | +## Architecture |
| 35 | + |
| 36 | +### Build System Structure |
| 37 | + |
| 38 | +The project uses a sophisticated CMake build system that: |
| 39 | + |
| 40 | +1. **External Dependencies**: Downloads and builds all CRIU dependencies from source as static libraries: |
| 41 | + - Protocol Buffers (protobuf & protobuf-c) |
| 42 | + - Network libraries (libnet, libnl, libmnl, libnftnl, libnftables) |
| 43 | + - System libraries (libcap, libaio, zlib, util-linux uuid, libintl) |
| 44 | + |
| 45 | +2. **Dependency Management**: Each dependency is managed via individual CMake files in `dependencies/` directory, using the `register_dependency()` macro from `macros/dependencies.cmake` |
| 46 | + |
| 47 | +3. **CRIU Integration**: The main CRIU build is handled as an ExternalProject that: |
| 48 | + - Downloads CRIU source code |
| 49 | + - Applies patches from `patch/` directory for static building |
| 50 | + - Compiles with all dependencies statically linked |
| 51 | + - Includes CUDA plugin compilation |
| 52 | + |
| 53 | +### Key Components |
| 54 | + |
| 55 | +- **CMakeLists.txt**: Main build configuration, sets up all dependencies and CRIU build |
| 56 | +- **CMakePresets.json**: Defines build presets for different configurations |
| 57 | +- **dependencies/*.cmake**: Individual dependency build configurations |
| 58 | +- **macros/dependencies.cmake**: Macro for registering dependencies with license tracking |
| 59 | +- **patch/**: Contains patches applied to CRIU for static building support |
| 60 | +- **jreleaser.yml**: Release configuration for GitHub releases |
| 61 | + |
| 62 | +### Build Process Flow |
| 63 | + |
| 64 | +1. Configure phase downloads and builds all static dependencies in order |
| 65 | +2. CRIU source is downloaded and patched for static plugin support |
| 66 | +3. CRIU is built with custom CFLAGS/LDFLAGS pointing to static dependencies |
| 67 | +4. Final artifacts are installed: `criu` binary, `libcriu.o` object file, headers, and CUDA plugin |
| 68 | + |
| 69 | +### Static Plugin Architecture |
| 70 | + |
| 71 | +The build enables static plugins (STATIC_PLUGINS=y) and specifically compiles the CUDA plugin statically into the main binary rather than as a shared library, controlled by patches in `patch/criu-static-plugin.patch`. |
| 72 | + |
| 73 | +### License Management |
| 74 | + |
| 75 | +The build system automatically tracks all dependency licenses and consolidates them into `THIRD-PARTY-LICENSES.txt` for distribution compliance. |
0 commit comments