diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 0000000000..fe7cb24847 --- /dev/null +++ b/BUILD.md @@ -0,0 +1,215 @@ +# Building OrcaSlicer with ZAA on macOS + +A step-by-step guide to building OrcaSlicer from source on macOS. No prior experience with building software required. + +## What You'll Need + +- A Mac running macOS 11.3 (Big Sur) or later +- About 15 GB of free disk space +- An internet connection +- About 1-2 hours for the first build (mostly waiting) + +## Step 1: Open Terminal + +Press **Cmd + Space**, type **Terminal**, and press Enter. A window with a command prompt will appear. All commands below are typed into this window. + +## Step 2: Install Xcode Command Line Tools + +This installs the compiler and basic development tools. + +```bash +xcode-select --install +``` + +A dialog will pop up. Click **Install** and wait for it to finish (a few minutes). + +To verify it worked: + +```bash +xcode-select -p +``` + +You should see something like `/Library/Developer/CommandLineTools` or `/Applications/Xcode.app/Contents/Developer`. + +## Step 3: Install Homebrew + +[Homebrew](https://brew.sh) is a package manager that makes it easy to install developer tools on macOS. + +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +Follow the prompts. When it finishes, it will tell you to run one or two commands to add Homebrew to your PATH. **Run those commands** — they look something like: + +```bash +echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile +eval "$(/opt/homebrew/bin/brew shellenv)" +``` + +To verify: + +```bash +brew --version +``` + +## Step 4: Install CMake + +CMake is the build system OrcaSlicer uses. + +```bash +brew install cmake +``` + +To verify: + +```bash +cmake --version +``` + +You need version 3.13 or later (anything recent from Homebrew will work). + +## Step 5: Install Git (if needed) + +Git usually comes with the Xcode Command Line Tools. Check: + +```bash +git --version +``` + +If it's not found: + +```bash +brew install git +``` + +## Step 6: Clone the Repository + +Choose where you want the source code. For example, in your home directory: + +```bash +cd ~ +git clone https://github.com/mnott/OrcaSlicer.git +cd OrcaSlicer +``` + +If you want the ZAA feature branch: + +```bash +git checkout feature/zaa-contouring +``` + +## Step 7: Build + +The `build.sh` script handles everything. For a first-time build: + +```bash +chmod +x build.sh +./build.sh --full +``` + +This does three things: +1. **Builds dependencies** (Boost, wxWidgets, OpenSSL, etc.) — takes 30-60 minutes the first time +2. **Configures CMake** — sets up the build system +3. **Builds OrcaSlicer** — compiles the application + +Go get a coffee. The dependency step only needs to run once. + +### After the first build + +For subsequent builds (after making code changes), just run: + +```bash +./build.sh +``` + +This does an incremental build — only recompiles what changed. Usually takes 1-5 minutes. + +### Other build options + +```bash +./build.sh --help # Show all options +./build.sh --clean # Clean rebuild (if something is broken) +./build.sh --deps # Rebuild dependencies only +./build.sh --configure # Reconfigure CMake only +``` + +## Step 8: Run OrcaSlicer + +After a successful build, the script prints the app location. You can run it with: + +```bash +open build/arm64/src/RelWithDebInfo/OrcaSlicer.app +``` + +Or find `OrcaSlicer.app` in Finder and double-click it. + +## Troubleshooting + +### "CMake not found" + +Make sure Homebrew is in your PATH (see Step 3), then `brew install cmake`. + +### "No rule to make target" or CMake generator errors + +Your build directory may have been configured with a different generator. Clean and reconfigure: + +```bash +./build.sh --clean --full +``` + +### Build fails during dependencies + +Some deps need a lot of memory. Close other applications and try again. If a specific dependency fails, check if you have the latest Xcode Command Line Tools: + +```bash +softwareupdate --list +``` + +### wxWidgets "hardcoded path" errors + +wxWidgets bakes the installation path into its config files. If you move the source directory after building deps, you need to rebuild them: + +```bash +./build.sh --deps +./build.sh --clean +``` + +### "Permission denied" on build.sh + +```bash +chmod +x build.sh +``` + +### Apple Silicon (M1/M2/M3/M4) vs Intel + +The build script auto-detects your architecture. If you need to specify it explicitly: + +```bash +./build.sh --full --arch arm64 # Apple Silicon +./build.sh --full --arch x86_64 # Intel +``` + +## Project Structure + +``` +OrcaSlicer/ +├── src/ +│ ├── libslic3r/ # Core slicing engine +│ │ ├── ContourZ.cpp # ZAA raycasting algorithm +│ │ └── ... +│ └── slic3r/GUI/ # User interface +├── deps/ # External dependencies +├── build/ # Build output (created by build.sh) +│ └── arm64/ +│ └── src/RelWithDebInfo/ +│ └── OrcaSlicer.app +├── docs/ +│ └── ZAA.md # ZAA feature documentation +├── build.sh # Build script (this guide uses it) +├── BUILD.md # This file +└── build_release_macos.sh # Official release build script +``` + +## ZAA (Z Anti-Aliasing) + +See [docs/ZAA.md](docs/ZAA.md) for details on the Z Anti-Aliasing feature. In short: enable **Z contouring** in Print Settings > Quality to get smoother curved surfaces. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000..42332937b3 --- /dev/null +++ b/build.sh @@ -0,0 +1,207 @@ +#!/usr/bin/env bash +# OrcaSlicer Build Script (macOS) +# Handles the full build lifecycle: deps, configure, build +# +# Usage: +# ./build.sh # Incremental build (after initial setup) +# ./build.sh --full # Full build from scratch (deps + configure + build) +# ./build.sh --deps # Build dependencies only +# ./build.sh --configure # Run CMake configure only +# ./build.sh --clean # Remove build dir and rebuild +# ./build.sh --help # Show all options + +set -e +set -o pipefail + +# ── Configuration ────────────────────────────────────────────── + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ARCH="${ARCH:-$(uname -m)}" +BUILD_CONFIG="${BUILD_CONFIG:-RelWithDebInfo}" +OSX_DEPLOYMENT_TARGET="${OSX_DEPLOYMENT_TARGET:-11.3}" +NCPU=$(sysctl -n hw.ncpu 2>/dev/null || echo 4) + +BUILD_DIR="${SCRIPT_DIR}/build/${ARCH}" +DEPS_DIR="${SCRIPT_DIR}/deps" +DEPS_BUILD_DIR="${DEPS_DIR}/build/${ARCH}" +DEPS_INSTALL_DIR="${DEPS_BUILD_DIR}/OrcaSlicer_dep" + +# CMake 4.x compatibility +CMAKE_VERSION=$(cmake --version 2>/dev/null | head -1 | sed 's/[^0-9]*\([0-9]*\).*/\1/') +CMAKE_COMPAT="" +if [ "${CMAKE_VERSION:-3}" -ge 4 ] 2>/dev/null; then + CMAKE_COMPAT="-DCMAKE_POLICY_VERSION_MINIMUM=3.5" +fi + +# ── Colors ───────────────────────────────────────────────────── + +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +BLUE='\033[0;34m' +BOLD='\033[1m' +NC='\033[0m' + +info() { echo -e "${BLUE}▸${NC} $*"; } +ok() { echo -e "${GREEN}✓${NC} $*"; } +warn() { echo -e "${YELLOW}⚠${NC} $*"; } +err() { echo -e "${RED}✗${NC} $*"; } + +# ── Parse Arguments ──────────────────────────────────────────── + +DO_DEPS=false +DO_CONFIGURE=false +DO_BUILD=true +DO_CLEAN=false +DO_FULL=false + +while [[ $# -gt 0 ]]; do + case $1 in + --full) DO_FULL=true; shift ;; + --deps) DO_DEPS=true; DO_BUILD=false; shift ;; + --configure) DO_CONFIGURE=true; DO_BUILD=false; shift ;; + --clean) DO_CLEAN=true; shift ;; + --arch) ARCH="$2"; shift 2 ;; + --config) BUILD_CONFIG="$2"; shift 2 ;; + --help|-h) + echo "OrcaSlicer Build Script (macOS)" + echo "" + echo "Usage: $0 [OPTIONS]" + echo "" + echo "Build modes:" + echo " (no flags) Incremental build (fastest, use after initial setup)" + echo " --full Full build from scratch: deps → configure → build" + echo " --deps Build dependencies only (takes 30-60 min first time)" + echo " --configure Run CMake configure only" + echo " --clean Remove build directory, then rebuild" + echo "" + echo "Options:" + echo " --arch ARCH Architecture: arm64, x86_64 (default: $(uname -m))" + echo " --config CFG Build config: Release, RelWithDebInfo, Debug" + echo " (default: RelWithDebInfo)" + echo "" + echo "Examples:" + echo " $0 --full # First-time build (do this first!)" + echo " $0 # Quick rebuild after code changes" + echo " $0 --clean # Clean rebuild if something is broken" + echo "" + echo "Prerequisites: Xcode Command Line Tools, CMake 3.13+" + echo " xcode-select --install" + echo " brew install cmake" + exit 0 + ;; + *) + err "Unknown option: $1 (use --help)" + exit 1 + ;; + esac +done + +# --full implies all steps +if [ "$DO_FULL" = true ]; then + DO_DEPS=true + DO_CONFIGURE=true + DO_BUILD=true +fi + +# ── Preflight Checks ────────────────────────────────────────── + +echo "" +echo -e "${BOLD}OrcaSlicer Build${NC}" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo " Architecture: ${ARCH}" +echo " Config: ${BUILD_CONFIG}" +echo " CPU cores: ${NCPU}" +echo " CMake: $(cmake --version 2>/dev/null | head -1 || echo 'NOT FOUND')" +[ -n "$CMAKE_COMPAT" ] && echo " CMake compat: 4.x → policy 3.5" +echo "" + +# Check prerequisites +if ! command -v cmake &>/dev/null; then + err "CMake not found. Install it with: brew install cmake" + exit 1 +fi + +if ! command -v git &>/dev/null; then + err "Git not found. Install Xcode Command Line Tools: xcode-select --install" + exit 1 +fi + +if ! xcode-select -p &>/dev/null; then + err "Xcode Command Line Tools not found. Install: xcode-select --install" + exit 1 +fi + +# ── Clean ────────────────────────────────────────────────────── + +if [ "$DO_CLEAN" = true ]; then + warn "Removing build directory: ${BUILD_DIR}" + rm -rf "${BUILD_DIR}" + ok "Clean complete" + echo "" +fi + +# ── Build Dependencies ───────────────────────────────────────── + +if [ "$DO_DEPS" = true ]; then + info "Building dependencies (this takes a while the first time)..." + mkdir -p "${DEPS_INSTALL_DIR}" + cd "${DEPS_BUILD_DIR}" + + cmake "${DEPS_DIR}" \ + -G "Unix Makefiles" \ + -DCMAKE_BUILD_TYPE="${BUILD_CONFIG}" \ + -DCMAKE_OSX_ARCHITECTURES:STRING="${ARCH}" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="${OSX_DEPLOYMENT_TARGET}" \ + ${CMAKE_COMPAT} + + cmake --build . --config "${BUILD_CONFIG}" --target deps -j"${NCPU}" + + ok "Dependencies built" + echo "" +fi + +# ── Configure ────────────────────────────────────────────────── + +if [ "$DO_CONFIGURE" = true ] || { [ "$DO_BUILD" = true ] && [ ! -f "${BUILD_DIR}/Makefile" ] && [ ! -f "${BUILD_DIR}/build.ninja" ]; }; then + info "Configuring CMake..." + mkdir -p "${BUILD_DIR}" + cd "${BUILD_DIR}" + + cmake "${SCRIPT_DIR}" \ + -G "Unix Makefiles" \ + -DCMAKE_BUILD_TYPE="${BUILD_CONFIG}" \ + -DCMAKE_OSX_ARCHITECTURES="${ARCH}" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="${OSX_DEPLOYMENT_TARGET}" \ + ${CMAKE_COMPAT} + + ok "CMake configured" + echo "" +fi + +# ── Build ────────────────────────────────────────────────────── + +if [ "$DO_BUILD" = true ]; then + if [ ! -d "${BUILD_DIR}" ]; then + err "Build directory not found: ${BUILD_DIR}" + err "Run '$0 --full' for a first-time build" + exit 1 + fi + + info "Building OrcaSlicer..." + cd "${SCRIPT_DIR}" + + cmake --build "${BUILD_DIR}" \ + --config "${BUILD_CONFIG}" \ + --target OrcaSlicer \ + -j"${NCPU}" + + echo "" + echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + ok "Build complete!" + echo "" + echo " App: ${BUILD_DIR}/src/${BUILD_CONFIG}/OrcaSlicer.app" + echo "" + echo " Run: open \"${BUILD_DIR}/src/${BUILD_CONFIG}/OrcaSlicer.app\"" + echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" +fi