|
| 1 | +# ADCAM Docker Build Test Environment |
| 2 | + |
| 3 | +This Docker container provides a clean environment to test building the [ADCAM repository](https://github.com/analogdevicesinc/ADCAM) before making a PR, ensuring no dependencies are missing. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +Build with default settings (main branches): |
| 8 | +```bash |
| 9 | +./build.sh -l /path/to/libs |
| 10 | +``` |
| 11 | + |
| 12 | +Build with specific branches: |
| 13 | +```bash |
| 14 | +./build.sh -l /path/to/libs <adcam-branch> <libaditof-branch> |
| 15 | +``` |
| 16 | + |
| 17 | +Build using local workspace code: |
| 18 | +```bash |
| 19 | +./build.sh --local -l /path/to/libs |
| 20 | +``` |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +```bash |
| 25 | +./build.sh [OPTIONS] [ADCAM_BRANCH] [LIBADITOF_BRANCH] |
| 26 | +``` |
| 27 | + |
| 28 | +### Options |
| 29 | + |
| 30 | +- `-h, --help` - Show help message |
| 31 | +- `-l, --libs PATH` - Path to libs folder to copy into container **(required)** |
| 32 | +- `-j, --jobs N` - Number of parallel build jobs (default: 6) |
| 33 | +- `-t, --tag NAME` - Docker image tag name (default: adcam-build-test) |
| 34 | +- `--no-cache` - Build without using Docker cache |
| 35 | +- `--local` - Use local workspace code instead of cloning from GitHub |
| 36 | + |
| 37 | +### Examples |
| 38 | + |
| 39 | +```bash |
| 40 | +# Use main for both repos (default) |
| 41 | +./build.sh -l /path/to/libs |
| 42 | + |
| 43 | +# Use specific branches |
| 44 | +./build.sh -l /path/to/libs feature-branch main |
| 45 | + |
| 46 | +# Build with 4 parallel jobs |
| 47 | +./build.sh -j 4 -l /path/to/libs main main |
| 48 | + |
| 49 | +# Force clean build without cache |
| 50 | +./build.sh --no-cache -l /path/to/libs main main |
| 51 | + |
| 52 | +# Custom image tag |
| 53 | +./build.sh -t my-test-build -l /path/to/libs main main |
| 54 | + |
| 55 | +# Use local workspace code (test uncommitted changes) |
| 56 | +./build.sh --local -l /path/to/libs |
| 57 | + |
| 58 | +# Use local code with clean build |
| 59 | +./build.sh --local --no-cache -l /path/to/libs |
| 60 | +``` |
| 61 | + |
| 62 | +### Manual Docker Build |
| 63 | + |
| 64 | +**Standard Mode:** |
| 65 | +```bash |
| 66 | +# First copy libs to the Docker context |
| 67 | +cp -r /path/to/libs ./libs |
| 68 | + |
| 69 | +# Then build |
| 70 | +sudo docker build \ |
| 71 | + --progress=plain \ |
| 72 | + --build-arg ADCAM_BRANCH=main \ |
| 73 | + --build-arg LIBADITOF_BRANCH=main \ |
| 74 | + --build-arg BUILD_JOBS=6 \ |
| 75 | + -t adcam-build-test . |
| 76 | +``` |
| 77 | + |
| 78 | +**Local Mode:** |
| 79 | +```bash |
| 80 | +# First copy libs and local code to the Docker context |
| 81 | +cp -r /path/to/libs ./libs |
| 82 | +rsync -a --exclude='build' --exclude='libaditof/build' --exclude='scripts' --exclude='.git' ../../ ./local_code/ |
| 83 | + |
| 84 | +# Then build using Dockerfile.local |
| 85 | +sudo docker build \ |
| 86 | + --progress=plain \ |
| 87 | + --build-arg BUILD_JOBS=6 \ |
| 88 | + -f Dockerfile.local \ |
| 89 | + -t adcam-build-test . |
| 90 | +``` |
| 91 | + |
| 92 | +## What's Included |
| 93 | + |
| 94 | +- Ubuntu 22.04 base image |
| 95 | +- All required build dependencies: |
| 96 | + - CMake |
| 97 | + - g++ |
| 98 | + - Python 3.10 with dev libraries |
| 99 | + - OpenCV (with contrib modules) |
| 100 | + - OpenGL and GLFW3 |
| 101 | + - X11 libraries (Xinerama, Xcursor, Xi, Xrandr) |
| 102 | + - Doxygen and Graphviz (for documentation) |
| 103 | +- ADCAM code (cloned from GitHub or copied from local workspace) |
| 104 | +- Pre-built project (Release configuration) |
| 105 | + |
| 106 | +## Viewing Build Output |
| 107 | + |
| 108 | +The build script saves full output to `build_output.log`. Use the view-log helper script: |
| 109 | + |
| 110 | +```bash |
| 111 | +./view-log.sh # Follow last 50 lines in real-time |
| 112 | +./view-log.sh errors # Show all errors and warnings |
| 113 | +./view-log.sh grep cmake # Search for specific text |
| 114 | +./view-log.sh all # Browse entire log with less |
| 115 | +``` |
| 116 | + |
| 117 | +Or view directly: |
| 118 | +```bash |
| 119 | +tail -f build_output.log # Follow in real-time |
| 120 | +grep -i error build_output.log # Search for errors |
| 121 | +less build_output.log # Browse the full log |
| 122 | +``` |
| 123 | + |
| 124 | +## Build Process |
| 125 | + |
| 126 | +The Dockerfile performs the following steps: |
| 127 | + |
| 128 | +### Standard Mode (default) |
| 129 | +1. Copies local `libs` folder into the container (if present) |
| 130 | +2. Installs all dependencies from the ADCAM README |
| 131 | +3. Clones the ADCAM repository |
| 132 | +4. Checks out specified branches for ADCAM and libaditof |
| 133 | +5. Initializes git submodules (ToF-drivers and libaditof) |
| 134 | +6. Runs CMake configuration (Release mode) |
| 135 | +7. Builds the project with configurable parallel jobs and verbose output |
| 136 | + |
| 137 | +### Local Mode (--local flag) |
| 138 | +1. Copies local `libs` folder into the container |
| 139 | +2. Installs all dependencies from the ADCAM README |
| 140 | +3. Copies local workspace code (excluding `build/`, `libaditof/build/`, `scripts/`, and `.git/`) |
| 141 | +4. Runs CMake configuration (Release mode) |
| 142 | +5. Builds the project with configurable parallel jobs and verbose output |
| 143 | + |
| 144 | +All build output is visible during the Docker build process, allowing you to catch any issues early. |
| 145 | + |
| 146 | +## Customization |
| 147 | + |
| 148 | +**Testing specific branches:** |
| 149 | +Use the branch arguments when running `build.sh`: |
| 150 | +```bash |
| 151 | +./build.sh -l /path/to/libs <adcam-branch> <libaditof-branch> |
| 152 | +``` |
| 153 | + |
| 154 | +**Testing local uncommitted changes:** |
| 155 | +Use the `--local` flag: |
| 156 | +```bash |
| 157 | +./build.sh --local -l /path/to/libs |
| 158 | +``` |
| 159 | + |
| 160 | +**Inspecting the built container:** |
| 161 | +```bash |
| 162 | +docker run --rm -it adcam-build-test bash |
| 163 | +``` |
| 164 | + |
| 165 | +## Cleanup |
| 166 | + |
| 167 | +Since this is a build testing environment, you should clean up Docker artifacts after testing: |
| 168 | + |
| 169 | +```bash |
| 170 | +./cleanup.sh |
| 171 | +``` |
| 172 | + |
| 173 | +This will: |
| 174 | +- Remove the adcam-build-test image |
| 175 | +- Remove any custom tagged images |
| 176 | +- Clean up dangling images and build cache |
| 177 | +- Remove temporary folders (`libs/`, `local_code/`) |
| 178 | +- Remove build log file (`build_output.log`) |
| 179 | +- Reclaim disk space |
| 180 | + |
| 181 | +Manual cleanup: |
| 182 | +```bash |
| 183 | +sudo docker image rm adcam-build-test |
| 184 | +sudo docker system prune -f |
| 185 | +``` |
| 186 | + |
| 187 | +## Notes |
| 188 | + |
| 189 | +- The build uses `-j 6` for parallel compilation (6 jobs) |
| 190 | +- Build type is set to `Release` |
| 191 | +- The container is based on Ubuntu 22.04, matching the JetPack 6.2.1 environment |
0 commit comments