Skip to content

Build from source

Christos Georgiou edited this page Nov 25, 2026 · 4 revisions

Build from source

Advanced topic. This page is for developers.

Requirements

  • Rust (stable, 1.97 or later: the wasm loader uses wasmtime 51)
  • An OpenSCAD development snapshot with the Manifold backend. See Install.
  • Debian and Ubuntu: the GTK 3 development files and a Vulkan driver
  • A graphics driver with Vulkan (Linux and Windows), Metal (macOS) or DirectX 12 (Windows). CgeoCAD does not use OpenGL
sudo apt install libgtk-3-dev libxkbcommon-dev libvulkan1 mesa-vulkan-drivers

mesa-vulkan-drivers has lavapipe, a software Vulkan driver. cgeocad gpu-test and the screenshot scripts can use it (CGEOCAD_GPU_ADAPTER=llvmpipe).

  • Windows: the Visual Studio C++ build tools
  • macOS: the Xcode command line tools

Cargo features

Feature Default What it does
wasm on The wasm loader of plugins (wasmtime with its compiler). Without it, CgeoCAD loads only builtin plugins and plugins without code

cargo check --target aarch64-apple-darwin from Linux needs --no-default-features, because wasmtime compiles a C file that needs the macOS SDK. This check then does not cover integrations/plugin-wasm. The macOS build in CI builds it on macOS.

Build and run

cargo run --release -- examples/demo-box.scad

On Linux, the scripts build and package:

scripts/build.sh            # release build. It runs the test suite first when it is there
scripts/build.sh --debug    # debug build
scripts/smoke.sh            # smoke test of the built binary
scripts/package-deb.sh      # writes dist/cgeocad_<version>_<arch>.deb

The .deb installs the binary, a desktop entry, an icon, the .scad MIME type and the examples. It does not depend on OpenSCAD, because Debian has no OpenSCAD package with Manifold. The notice at the start of the app tells the user how to install a development snapshot.

Analytics key

A build reads the PostHog project key from POSTHOG_API_KEY at compile time. A debug build or a build with no key sends nothing and does not ask the privacy questions. CI uses the POSTHOG_API_KEY repository secret for tag builds only. scripts/build.sh also reads it from extras/website/.env for a release build.

Continuous integration

GitHub Actions (.github/workflows/build.yml) builds on a version tag, or when you start it by hand. The first job reads the annotated tag: without the line Suite-Result: pass, or when the line Code-Tree is not the tree of the commit, the build stops. scripts/release-check.sh makes this tag after the test suite passed.

System Steps
Linux clippy, release build, smoke test with OpenSCAD and gpu-test on lavapipe, a .deb and a .tar.gz
Windows release build, smoke test (version, params, gpu-test) and a .zip (scripts/package-windows.ps1)
macOS release build for both architectures, smoke test (version, params, gpu-test) and a universal .app in a .zip (scripts/package-macos.sh)

gpu-test gives "not tested" on a runner without a graphics adapter. A fault on Windows or macOS stops the package of that system, not the release. A tag v* (for example v0.2.0) also makes a GitHub release with all files attached. The release notes give the number of tests that passed. A push to main starts no build.

Tests

The code of CgeoCAD is open source under the MIT License. The test suite is private. It is the git submodule suite/, and a clone of the public repository has an empty folder there. The code builds and runs without it. Each release says how many tests passed. The owner tests pull requests.

  • cargo test --workspace runs no tests without the suite.
  • scripts/suite.sh runs the suite when you have access. Without access it prints "The test suite is private" and ends with exit code 2.
  • scripts/smoke.sh is public. It runs --version, and params, export, slice and parts-list of two examples, and cgeocad gpu-test. It does not compare values. --no-openscad runs only the commands that need no OpenSCAD.

Example models

Model What it shows
demo-box.scad Every Customizer widget type, text, hull
gear.scad Involute teeth from polygon math, many facets
knob.scad rotate_extrude, ribs, D-shaft bore, text
vase.scad linear_extrude with twist and scale, sloped walls, 450 layers
bracket.scad Holes, slots, a gusset, overhangs
honeycomb-tray.scad Many holes per layer, thin webs, include <lib/hex.scad>
multicolor-badge.scad SVG inlays, one part for each color in touching solids
desk-dock.scad The showcase of the Optimize tab: a part too large for the bed, horizontal holes, counterbores with holes above, blind holes, a thin foot, three same parts in a tilted rotation, % reference parts
reference-part.scad A % reference part that is not printed or exported
part-selector.scad A part selector list: each value builds on its own, and the parts get the labels as names
open-mesh.scad Open mesh: open-edge warning, STEP as an open shell

Source layout

The repository is a Cargo workspace. src/ is the app crate. The crates in libs/ do no I/O. The crates in integrations/ read files, run programs and use the network.

Path Content
src/main.rs CLI and window start
src/cli_gpu.rs cgeocad gpu-test
src/app.rs egui application: panels, camera, jobs
src/app/remote.rs MCP tools inside the window
src/app/select.rs Select a part in the 3D view, part menu, focus, color window of one part
src/app/tour.rs Welcome tour
src/app/start.rs Start page when no model is open, new model and its template
src/app/thumb.rs Model thumbnails: drawn when a model opens and closes, start page cache of thumbnails, titles and descriptions
src/app/optimize_tab.rs The Optimize tab: cards, plate view, pipeline runs in the background, plate export, MCP Optimize state
src/app/marks_job.rs The build job of the window: a model with marks shows its parts from the tree, the union build of the whole model follows
src/app/marks_ui.rs The Unit card, the Parts list and the Checks cards, the offer of the use line of the CgeoCAD library
src/marks.rs Models with marks: the parts of the 3D view from the facts, the parts of the print plate
src/cli_marks.rs cgeocad parts-list and cgeocad checks
src/cli_project.rs cgeocad project new / add / check, and parts-list, checks and export of a .cgeocad file
src/app/fix_info.rs The info window of each print fix: text and the pictures in assets/fixes/
src/mcp.rs MCP server, tool list, window listener
src/app/view3d.rs 3D view options for the parts: part colors, explode, Parts and Explode cards, part colors window
src/app/state.rs State of each model: right panel settings and last parameter values. cgeocad-store writes them to models.json
src/app/section.rs Section cut: planes on X, Y and Z in model or bed coordinates, the Section menu of the 3D view, MCP section state
src/render.rs The 3D view on sys-gpu: one mesh and one instance for each part with its own color, offset and transparency, the section cut with cut faces, the grid and the overlay of tubes and lines. render/screen.rs: the wgpu setup of the window, the own texture of the 3D view, the renderer of the thumbnails
src/assembly.rs Parts of the 3D view: shells, named parts, part palette, moved mesh for the photo
src/csg_split.rs Module split: parses the CSG tree, finds the module calls and renders each one
src/ui.rs Dark and light palettes and widgets
src/examples.rs Example models in the File menu
src/update.rs Update check of the window: the check every hour, the dismissed version
src/part_param.rs Builds each value of a part list
src/export.rs Writes the exports to files
src/settings.rs Settings of the app: the settings of cgeocad-store and the default print area, in one file
src/slicer.rs Preview slicer. Gives the toolpaths to the 3D view as an overlay
src/optimize/ Print preparation: pipeline.rs (print parts, plate, cache), plate.rs (same parts, overlap, layout), orient.rs, split.rs, fixes.rs with teardrop.rs, holes.rs, bridges.rs, brim.rs and ears.rs, check.rs, scad.rs (OpenSCAD runs on part meshes), headless.rs (CLI print options and report)
src/printer.rs Printer presets and the print area editor
src/pathtrace.rs Path tracer for photo renders (BVH, plastic material, studio light, section cut). A job runs on the GPU or on all CPU cores
src/pathtrace/gpu.rs GPU path tracer: the compute shader of sys-gpu (PathTracer) on a thread for each job, bands of rows, CPU fallback when the GPU stops
sys-gpu/ cgeocad-sys-gpu: the wgpu renderer (own texture, meshes and instances, lines as quads, section caps, overlay, shadow, picking) and the path tracer as a WGSL compute shader
libs/geom/ cgeocad-geom: indexed mesh, STL reader, checks, moves of a mesh, sections
libs/params/ cgeocad-params: Customizer parameter parser, part list, multicolor part list and colors, model definition <model>.yml (text, part names and colors, parameter sets, the OpenSCAD .json format of older models), apply a parameter set
libs/model-tree/ cgeocad-model-tree: reads the marks of the CgeoCAD library in the CSG tree: facts, shapes, copies, the rest, units, findings. The doc blocks of a SCAD library
libs/parts-list/ cgeocad-parts-list: the rows of the parts list, join, groups, totals, CSV, Markdown and JSON
libs/export/ cgeocad-export: STL, 3MF, multicolor 3MF and STEP writers, the face colors of a multicolor model
integrations/openscad/ cgeocad-openscad: finds and runs openscad, reads the STL, exports the CSG tree, builds .csg pieces and the parts of a multicolor model. The CgeoCAD library on the library path of each run (library.rs), the shape cache (shapes.rs)
app/session/ cgeocad-session: the use cases without egui that the window, the CLI and the MCP server share: the build from the tree, the parts list, the checks, the units, the library, and projects (project*.rs: objects, builds, undo, save, plugins, results over all objects, GLB and package)
scad/cgeocad/core.scad The CgeoCAD library. The binary embeds it
integrations/store/ cgeocad-store: the settings folder: settings file, models.json, recent models, thumbnails (thumbs/), last parameter sets. Reads and writes <model>.yml
integrations/http/ cgeocad-http: HTTP client, release list of GitHub, optional analytics and error reports (PostHog, telemetry.rs, telemetry/consent.rs, telemetry/report.rs)
suite/ The private test suite (git submodule, its own Cargo workspace). Empty in a public clone
examples/ Test models. The binary embeds the models that render.
scripts/ Build and packaging scripts
packaging/ Desktop entry, icon, MIME type for the .deb
assets/tour/ Tour screenshots, embedded in the binary
assets/examples/ Thumbnails of the examples (scripts/example-thumbs.sh), embedded in the binary
assets/guide/ Screenshots (scripts/guide-shots.sh) and before and after pictures of the guide Prepare a model for printing
docs/wiki/ The source of these wiki pages. scripts/publish-wiki.sh copies them to the GitHub wiki.
libs/plugin-sdk/, integrations/plugin-wasm/, integrations/plugin-store/ The plugin SDK, the wasm loader and the plugin store. See Plugin development

Stack: Rust 2024, eframe/egui 0.37 on wgpu 30 (Vulkan, Metal, DirectX 12; no OpenGL). The 3D view draws into its own texture, and egui shows it. glam for math, zip for 3MF, rfd for file dialogs.

Change these pages

Edit the files in docs/wiki/ and run scripts/publish-wiki.sh. Do not edit the pages on the wiki website, because the script replaces them.

Clone this wiki locally