|
| 1 | +# CortexIDE Builder - Linux Build Guide |
| 2 | + |
| 3 | +## Linux Build Prerequisites |
| 4 | + |
| 5 | +### System Dependencies |
| 6 | + |
| 7 | +Install the following packages on Ubuntu/Debian-based systems: |
| 8 | + |
| 9 | +```bash |
| 10 | +sudo apt-get update |
| 11 | +sudo apt-get install -y \ |
| 12 | + build-essential \ |
| 13 | + libkrb5-dev \ |
| 14 | + libnss3-dev \ |
| 15 | + libatk-bridge2.0-dev \ |
| 16 | + libdrm2 \ |
| 17 | + libxkbcommon-dev \ |
| 18 | + libxcomposite-dev \ |
| 19 | + libxdamage-dev \ |
| 20 | + libxrandr-dev \ |
| 21 | + libgbm-dev \ |
| 22 | + libxss1 \ |
| 23 | + libasound2-dev \ |
| 24 | + python3 \ |
| 25 | + python3-pip \ |
| 26 | + git \ |
| 27 | + curl \ |
| 28 | + wget |
| 29 | +``` |
| 30 | + |
| 31 | +For cross-compilation (ARM64, ARMHF, etc.), also install: |
| 32 | + |
| 33 | +```bash |
| 34 | +# For ARM64 |
| 35 | +sudo apt-get install -y \ |
| 36 | + gcc-aarch64-linux-gnu \ |
| 37 | + g++-aarch64-linux-gnu \ |
| 38 | + crossbuild-essential-arm64 |
| 39 | + |
| 40 | +# For ARMHF |
| 41 | +sudo apt-get install -y \ |
| 42 | + gcc-arm-linux-gnueabihf \ |
| 43 | + g++-arm-linux-gnueabihf \ |
| 44 | + crossbuild-essential-armhf |
| 45 | +``` |
| 46 | + |
| 47 | +### Node.js and Rust |
| 48 | + |
| 49 | +- **Node.js**: v22.15.1 (matches CI) |
| 50 | +- **Rust**: Latest stable (installed via rustup) |
| 51 | +- **Python**: 3.11+ |
| 52 | + |
| 53 | +Install Node.js: |
| 54 | +```bash |
| 55 | +# Using nvm (recommended) |
| 56 | +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash |
| 57 | +nvm install 22.15.1 |
| 58 | +nvm use 22.15.1 |
| 59 | + |
| 60 | +# Or download from nodejs.org |
| 61 | +``` |
| 62 | + |
| 63 | +Install Rust: |
| 64 | +```bash |
| 65 | +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 66 | +source $HOME/.cargo/env |
| 67 | +``` |
| 68 | + |
| 69 | +### Memory Requirements |
| 70 | + |
| 71 | +- **Minimum**: 16GB RAM |
| 72 | +- **Recommended**: 32GB RAM |
| 73 | +- Node.js will use up to 12GB during build (configured via `NODE_OPTIONS`) |
| 74 | + |
| 75 | +## Local Linux Build |
| 76 | + |
| 77 | +### Quick Start |
| 78 | + |
| 79 | +```bash |
| 80 | +# Set environment variables |
| 81 | +export APP_NAME="CortexIDE" |
| 82 | +export BINARY_NAME="cortexide" |
| 83 | +export VSCODE_QUALITY="stable" |
| 84 | +export CI_BUILD="no" # For local builds |
| 85 | +export SHOULD_BUILD="yes" |
| 86 | +export OS_NAME="linux" |
| 87 | +export VSCODE_ARCH="x64" # or "arm64", "armhf", etc. |
| 88 | + |
| 89 | +# Run the build |
| 90 | +./build.sh |
| 91 | + |
| 92 | +# Output will be in: ../VSCode-linux-${VSCODE_ARCH}/ |
| 93 | +# Binary: ../VSCode-linux-${VSCODE_ARCH}/bin/cortexide |
| 94 | +``` |
| 95 | + |
| 96 | +### Build Process |
| 97 | + |
| 98 | +The Linux build follows these steps: |
| 99 | + |
| 100 | +1. **Source Preparation**: Fetches CortexIDE source code |
| 101 | +2. **Dependency Installation**: Installs npm packages |
| 102 | +3. **TypeScript Compilation**: Compiles the codebase |
| 103 | +4. **React Build**: Builds CortexIDE's React components |
| 104 | +5. **Extension Compilation**: Compiles built-in extensions |
| 105 | +6. **Minification**: Bundles and minifies the application |
| 106 | +7. **Packaging**: Creates Linux binaries and packages |
| 107 | + |
| 108 | +### Architecture-Specific Builds |
| 109 | + |
| 110 | +#### x64 (Intel/AMD 64-bit) |
| 111 | +```bash |
| 112 | +export VSCODE_ARCH="x64" |
| 113 | +./build.sh |
| 114 | +``` |
| 115 | + |
| 116 | +#### ARM64 |
| 117 | +```bash |
| 118 | +export VSCODE_ARCH="arm64" |
| 119 | +# Ensure cross-compilation tools are installed |
| 120 | +./build.sh |
| 121 | +``` |
| 122 | + |
| 123 | +#### ARMHF (32-bit ARM) |
| 124 | +```bash |
| 125 | +export VSCODE_ARCH="armhf" |
| 126 | +# Ensure cross-compilation tools are installed |
| 127 | +./build.sh |
| 128 | +``` |
| 129 | + |
| 130 | +## CI Build Process |
| 131 | + |
| 132 | +The GitHub Actions workflow (`.github/workflows/stable-linux.yml`) uses a two-stage build: |
| 133 | + |
| 134 | +### Stage 1: Compile Job |
| 135 | +- Compiles TypeScript and React components once |
| 136 | +- Creates a tarball artifact (`vscode.tar.gz`) |
| 137 | +- Runs on `ubuntu-22.04` |
| 138 | + |
| 139 | +### Stage 2: Build Jobs (Matrix) |
| 140 | +- Downloads the compiled artifact |
| 141 | +- Packages for each architecture in parallel |
| 142 | +- Uses Docker containers for cross-compilation |
| 143 | +- Creates `.deb`, `.rpm`, `.tar.gz`, and optionally `.AppImage` packages |
| 144 | + |
| 145 | +### CI Environment Variables |
| 146 | + |
| 147 | +The workflow automatically sets: |
| 148 | +- `CI_BUILD=yes` |
| 149 | +- `OS_NAME=linux` |
| 150 | +- `VSCODE_PLATFORM=linux` |
| 151 | +- `VSCODE_ARCH` (per matrix job: x64, arm64, armhf, etc.) |
| 152 | +- `NODE_OPTIONS=--max-old-space-size=12288` |
| 153 | + |
| 154 | +## Building Packages |
| 155 | + |
| 156 | +After a successful build, create distribution packages: |
| 157 | + |
| 158 | +```bash |
| 159 | +# Set packaging options |
| 160 | +export SHOULD_BUILD_DEB="yes" # Create .deb package |
| 161 | +export SHOULD_BUILD_RPM="yes" # Create .rpm package |
| 162 | +export SHOULD_BUILD_TAR="yes" # Create .tar.gz archive |
| 163 | +export SHOULD_BUILD_APPIMAGE="yes" # Create AppImage (x64 only) |
| 164 | + |
| 165 | +# Run packaging |
| 166 | +./prepare_assets.sh |
| 167 | + |
| 168 | +# Outputs will be in: assets/ |
| 169 | +# - cortexide-${VERSION}-${ARCH}.deb |
| 170 | +# - cortexide-${VERSION}-${ARCH}.rpm |
| 171 | +# - cortexide-linux-${ARCH}-${VERSION}.tar.gz |
| 172 | +# - cortexide-${VERSION}-${ARCH}.AppImage (if enabled) |
| 173 | +``` |
| 174 | + |
| 175 | +## Troubleshooting |
| 176 | + |
| 177 | +### Build Fails with "utils.sh not found" |
| 178 | + |
| 179 | +**Issue**: Script can't find `utils.sh` |
| 180 | +**Solution**: Ensure you're running scripts from the builder root directory, or the scripts have been updated to use absolute paths (fixed in recent updates). |
| 181 | + |
| 182 | +### Build Fails with "CI_BUILD is no" |
| 183 | + |
| 184 | +**Issue**: Script exits because `CI_BUILD` is set to "no" |
| 185 | +**Solution**: For local builds, set `CI_BUILD="no"` and use `./build.sh` instead of `./build/linux/package_bin.sh`. The `package_bin.sh` script is CI-only. |
| 186 | + |
| 187 | +### Out of Memory Errors |
| 188 | + |
| 189 | +**Issue**: Node.js runs out of memory during build |
| 190 | +**Solution**: Increase memory limit: |
| 191 | +```bash |
| 192 | +export NODE_OPTIONS="--max-old-space-size=16384" # 16GB |
| 193 | +# Or for 32GB systems: |
| 194 | +export NODE_OPTIONS="--max-old-space-size=24576" # 24GB |
| 195 | +``` |
| 196 | + |
| 197 | +### Cross-Compilation Fails |
| 198 | + |
| 199 | +**Issue**: ARM builds fail with linker errors |
| 200 | +**Solution**: Ensure cross-compilation toolchain is installed: |
| 201 | +```bash |
| 202 | +# For ARM64 |
| 203 | +sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu |
| 204 | + |
| 205 | +# For ARMHF |
| 206 | +sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf |
| 207 | +``` |
| 208 | + |
| 209 | +### Electron Binary Download Fails |
| 210 | + |
| 211 | +**Issue**: Alternative architectures (riscv64, ppc64le, loong64) can't download Electron |
| 212 | +**Solution**: These architectures use custom Electron repositories. The build scripts automatically handle this via environment variables: |
| 213 | +- `VSCODE_ELECTRON_REPOSITORY`: Custom repository |
| 214 | +- `VSCODE_ELECTRON_TAG`: Specific Electron version |
| 215 | + |
| 216 | +### React Build Fails |
| 217 | + |
| 218 | +**Issue**: `npm run buildreact` fails |
| 219 | +**Solution**: Clean and rebuild: |
| 220 | +```bash |
| 221 | +cd vscode |
| 222 | +rm -rf src/vs/workbench/contrib/*/browser/react/out |
| 223 | +npm run buildreact |
| 224 | +``` |
| 225 | + |
| 226 | +## Build Scripts Reference |
| 227 | + |
| 228 | +### Main Scripts |
| 229 | + |
| 230 | +- **`build.sh`**: Main build script (for local builds) |
| 231 | +- **`build/linux/package_bin.sh`**: CI packaging script (requires `CI_BUILD=yes`) |
| 232 | +- **`build/linux/package_reh.sh`**: Remote Extension Host packaging |
| 233 | +- **`build/linux/deps.sh`**: Installs system dependencies |
| 234 | +- **`prepare_assets.sh`**: Creates distribution packages |
| 235 | + |
| 236 | +### Environment Variables |
| 237 | + |
| 238 | +| Variable | Description | Default | |
| 239 | +|----------|-------------|---------| |
| 240 | +| `APP_NAME` | Application name | `CortexIDE` | |
| 241 | +| `BINARY_NAME` | Binary executable name | `cortexide` | |
| 242 | +| `VSCODE_ARCH` | Target architecture | `x64` | |
| 243 | +| `VSCODE_QUALITY` | Build quality | `stable` | |
| 244 | +| `CI_BUILD` | CI mode flag | `no` (local) / `yes` (CI) | |
| 245 | +| `OS_NAME` | Operating system | `linux` | |
| 246 | +| `VSCODE_PLATFORM` | Platform identifier | `linux` | |
| 247 | +| `NODE_OPTIONS` | Node.js options | `--max-old-space-size=12288` | |
| 248 | + |
| 249 | +## Testing Your Build |
| 250 | + |
| 251 | +### Quick Test |
| 252 | +```bash |
| 253 | +# Run the built binary |
| 254 | +../VSCode-linux-${VSCODE_ARCH}/bin/cortexide --version |
| 255 | + |
| 256 | +# Or launch the full application |
| 257 | +../VSCode-linux-${VSCODE_ARCH}/bin/cortexide |
| 258 | +``` |
| 259 | + |
| 260 | +### Install and Test .deb Package |
| 261 | +```bash |
| 262 | +sudo dpkg -i assets/cortexide-${VERSION}-${ARCH}.deb |
| 263 | +sudo apt-get install -f # Fix dependencies if needed |
| 264 | +cortexide --version |
| 265 | +``` |
| 266 | + |
| 267 | +### Install and Test .rpm Package |
| 268 | +```bash |
| 269 | +sudo rpm -i assets/cortexide-${VERSION}-${ARCH}.rpm |
| 270 | +cortexide --version |
| 271 | +``` |
| 272 | + |
| 273 | +## Known Limitations |
| 274 | + |
| 275 | +- **AppImage**: Only supported for x64 architecture |
| 276 | +- **Alternative Architectures**: riscv64, ppc64le, loong64 require custom Electron builds |
| 277 | +- **Snap Package**: Currently disabled in CI (commented out in workflow) |
| 278 | +- **Local Builds**: Some alternative architectures may not work locally without proper cross-compilation setup |
| 279 | + |
| 280 | +## Next Steps |
| 281 | + |
| 282 | +1. **Test Local Build**: Follow "Quick Start" section |
| 283 | +2. **Test CI Build**: Push to GitHub and check Actions |
| 284 | +3. **Create Release**: Use `./release.sh` after successful build |
| 285 | +4. **Report Issues**: Check build logs and report any problems |
| 286 | + |
| 287 | +## Additional Resources |
| 288 | + |
| 289 | +- **General Build Instructions**: See `BUILD_INSTRUCTIONS.md` |
| 290 | +- **Migration Notes**: See `MIGRATION_SUMMARY.md` |
| 291 | +- **CI Workflows**: See `.github/workflows/stable-linux.yml` |
0 commit comments