Refactor folder (#10475)

Move many third-party components' source codes from the src folder to a new folder called deps_src. The goal is to make the code structure clearer and easier to navigate.
This commit is contained in:
SoftFever 2025-08-22 20:02:26 +08:00 committed by GitHub
parent 3808f7eb28
commit 883607e1d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2083 changed files with 1163 additions and 19503 deletions

View file

@ -24,6 +24,7 @@ install_*
build_*/
!build_linux.sh
SVG
Dockerfile
DockerBuild.sh
DockerRun.sh
scripts/Dockerfile
scripts/DockerBuild.sh
scripts/DockerRun.sh
scripts/.dockerignore

View file

@ -13,7 +13,7 @@ on:
- 'localization/**'
- 'resources/**'
- ".github/workflows/build_*.yml"
- 'flatpak/**'
- 'scripts/flatpak/**'
pull_request:
branches:
@ -28,7 +28,7 @@ on:
- 'build_linux.sh'
- 'build_release_vs2022.bat'
- 'build_release_macos.sh'
- 'flatpak/**'
- 'scripts/flatpak/**'
workflow_dispatch: # allows for manual dispatch
inputs:
@ -103,7 +103,7 @@ jobs:
- uses: flathub-infra/flatpak-github-actions/flatpak-builder@master
with:
bundle: OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak
manifest-path: flatpak/io.github.softfever.OrcaSlicer.yml
manifest-path: scripts/flatpak/io.github.softfever.OrcaSlicer.yml
cache: true
arch: ${{ matrix.variant.arch }}
upload-artifact: false

View file

@ -24,7 +24,7 @@ jobs:
- name: Update translation catalog
run: |
./run_gettext.sh --full
./scripts/run_gettext.sh --full
git add localization/i18n/*
- name: Commit translation catalog updates

1
.gitignore vendored
View file

@ -35,3 +35,4 @@ src/OrcaSlicer-doc/
**/.flatpak-builder/
resources/profiles/user/default
*.code-workspace
deps_src/build/

132
Build.PL
View file

@ -1,132 +0,0 @@
#!/usr/bin/perl
print "This script is currently used for installing Perl dependenices for running\n";
print "the libslic3r unit / integration tests through Perl prove.\n";
print "If you don't plan to run the unit / integration tests, you don't need to\n";
print "install these dependencies to build and run OrcaSlicer.\n";
use strict;
use warnings;
use Config;
use File::Spec;
my %prereqs = qw(
Devel::CheckLib 0
ExtUtils::MakeMaker 6.80
ExtUtils::ParseXS 3.22
ExtUtils::XSpp 0
ExtUtils::XSpp::Cmd 0
ExtUtils::CppGuess 0
ExtUtils::Typemaps 0
ExtUtils::Typemaps::Basic 0
File::Basename 0
File::Spec 0
Getopt::Long 0
Module::Build::WithXSpp 0.14
Moo 1.003001
POSIX 0
Scalar::Util 0
Test::More 0
IO::Scalar 0
Time::HiRes 0
);
my %recommends = qw(
Class::XSAccessor 0
Test::Harness 0
);
my $sudo = grep { $_ eq '--sudo' } @ARGV;
my $nolocal = grep { $_ eq '--nolocal' } @ARGV;
my @missing_prereqs = ();
if ($ENV{SLIC3R_NO_AUTO}) {
foreach my $module (sort keys %prereqs) {
my $version = $prereqs{$module};
next if eval "use $module $version; 1";
push @missing_prereqs, $module if exists $prereqs{$module};
print "Missing prerequisite $module $version\n";
}
foreach my $module (sort keys %recommends) {
my $version = $recommends{$module};
next if eval "use $module $version; 1";
print "Missing optional $module $version\n";
}
} else {
my @try = (
$ENV{CPANM} // (),
File::Spec->catfile($Config{sitebin}, 'cpanm'),
File::Spec->catfile($Config{installscript}, 'cpanm'),
);
my $cpanm;
foreach my $path (@try) {
if (-e $path) { # don't use -x because it fails on Windows
$cpanm = $path;
last;
}
}
if (!$cpanm) {
if ($^O =~ /^(?:darwin|linux)$/ && system(qw(which cpanm)) == 0) {
$cpanm = 'cpanm';
}
}
die <<'EOF'
cpanm was not found. Please install it before running this script.
There are several ways to install cpanm, try one of these:
apt-get install cpanminus
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
cpan App::cpanminus
If it is installed in a non-standard location you can do:
CPANM=/path/to/cpanm perl Build.PL
EOF
if !$cpanm;
my @cpanm_args = ();
push @cpanm_args, "--sudo" if $sudo;
# install local::lib without --local-lib otherwise it's not usable afterwards
if (!eval "use local::lib qw(local-lib); 1") {
my $res = system $cpanm, @cpanm_args, 'local::lib';
warn "Warning: local::lib is required. You might need to run the `cpanm --sudo local::lib` command in order to install it.\n"
if $res != 0;
}
push @cpanm_args, ('--local-lib', 'local-lib') if ! $nolocal;
# make sure our cpanm is updated (old ones don't support the ~ syntax)
system $cpanm, @cpanm_args, 'App::cpanminus';
my %modules = (%prereqs, %recommends);
foreach my $module (sort keys %modules) {
my $version = $modules{$module};
my @cmd = ($cpanm, @cpanm_args);
# temporary workaround for upstream bug in test
push @cmd, '--notest'
if $module =~ /^(?:OpenGL|Test::Harness)$/;
push @cmd, "$module~$version";
my $res = system @cmd;
if ($res != 0) {
if (exists $prereqs{$module}) {
push @missing_prereqs, $module;
} else {
printf "Don't worry, this module is optional.\n";
}
}
}
}
print "\n";
print "In the next step, you need to build the OrcaSlicer C++ library.\n";
print "1) Create a build directory and change to it\n";
print "2) run cmake .. -DCMAKE_BUILD_TYPE=Release\n";
print "3) run make\n";
print "4) to execute the automatic tests, run ctest --verbose\n";
__END__

241
CLAUDE.md
View file

@ -8,6 +8,23 @@ OrcaSlicer is an open-source 3D slicer application forked from Bambu Studio, bui
## Build Commands
### Building on Windows
```bash
# Build everything
build_release_vs2022.bat
# Build with debug symbols
build_release_vs2022.bat debug
# Build only dependencies
build_release_vs2022.bat deps
# Build only slicer (after deps are built)
build_release_vs2022.bat slicer
```
### Building on macOS
```bash
# Build everything (dependencies and slicer)
@ -23,94 +40,208 @@ OrcaSlicer is an open-source 3D slicer application forked from Bambu Studio, bui
./build_release_macos.sh -x
# Build for specific architecture
./build_release_macos.sh -a arm64 # or x86_64
./build_release_macos.sh -a arm64 # or x86_64 or universal
# Build for specific macOS version target
./build_release_macos.sh -t 11.3
```
### Building on Linux
```bash
# Build everything
./build_linux.sh
# First time setup - install system dependencies
./build_linux.sh -u
# Check system resources first (build requires 10GB+ RAM and disk)
./build_linux.sh -r # skip resource checks
# Build dependencies and slicer
./build_linux.sh -dsi
# Build everything (alternative)
./build_linux.sh -dsi
# Individual options:
./build_linux.sh -d # dependencies only
./build_linux.sh -s # slicer only
./build_linux.sh -i # build AppImage
# Performance and debug options:
./build_linux.sh -j N # limit to N cores
./build_linux.sh -1 # single core build
./build_linux.sh -b # debug build
./build_linux.sh -c # clean build
./build_linux.sh -r # skip RAM/disk checks
./build_linux.sh -l # use Clang instead of GCC
```
### Build System
- Uses CMake with minimum version 3.13
- Uses CMake with minimum version 3.13 (maximum 3.31.x on Windows)
- Primary build directory: `build/`
- Dependencies are built in `deps/build/`
- The build process is split into dependency building and main application building
- Windows builds use Visual Studio generators
- macOS builds use Xcode by default, Ninja with -x flag
- Linux builds use Ninja generator
### Testing
Tests are located in the `tests/` directory and can be run via CMake/CTest after building.
Tests are located in the `tests/` directory and use multiple testing frameworks. Test structure:
- `tests/libslic3r/` - Core library tests (Catch2 framework)
- `tests/libnest2d/` - 2D nesting algorithm tests
- `tests/fff_print/` - FFF printing tests
- `tests/sla_print/` - SLA printing tests
- `tests/t/` - Legacy Perl-based unit tests (.t files)
- `tests/lib/` - Perl test library modules
- `tests/xs/` - XS (C/Perl interface) related tests
- `tests/sandboxes/` - Experimental/sandbox test code
Run tests after building:
```bash
cd build && ctest
```
Legacy Perl tests can be run individually:
```bash
cd tests/t
perl support.t # example test file
```
## Architecture
### Core Libraries
- **libslic3r/**: Core slicing engine and algorithms
- Contains the main slicing logic, geometry processing, G-code generation
- Platform-independent slicing functionality
- **libslic3r/**: Core slicing engine and algorithms (platform-independent)
- Main slicing logic, geometry processing, G-code generation
- Key classes: Print, PrintObject, Layer, GCode, Config
- Modular design with specialized subdirectories:
- `GCode/` - G-code generation, cooling, pressure equalization, thumbnails
- `Fill/` - Infill pattern implementations (gyroid, honeycomb, lightning, etc.)
- `Support/` - Tree supports and traditional support generation
- `Geometry/` - Advanced geometry operations, Voronoi diagrams, medial axis
- `Format/` - File I/O for 3MF, AMF, STL, OBJ, STEP formats
- `SLA/` - SLA-specific print processing and support generation
- `Arachne/` - Advanced wall generation using skeletal trapezoidation
- **src/slic3r/**: Main application framework
- GUI application entry points and main loops
- Integration between libslic3r and the GUI
- **src/slic3r/**: Main application framework and GUI
- GUI application built with wxWidgets
- Integration between libslic3r core and user interface
- Located in `src/slic3r/GUI/` (not shown in this directory but exists)
### GUI Components
- Built with wxWidgets framework
- Located primarily in `src/slic3r/GUI/`
- Main application class: `GUI_App`
- Uses OpenGL for 3D visualization
### Key Algorithmic Components
- **Arachne Wall Generation**: Variable-width perimeter generation using skeletal trapezoidation
- **Tree Supports**: Organic support generation algorithm
- **Lightning Infill**: Sparse infill optimization for internal structures
- **Adaptive Slicing**: Variable layer height based on geometry
- **Multi-material**: Multi-extruder and soluble support processing
- **G-code Post-processing**: Cooling, fan control, pressure advance, conflict checking
### Key Modules
- **3MF Format Support**: `src/libslic3r/Format/3mf.cpp` - 3MF file format reading/writing
- **G-code Processing**: `src/libslic3r/GCode/` - G-code generation and processing
- **Geometry**: `src/libslic3r/Geometry.cpp` - 2D/3D geometry operations
- **Print Configuration**: `src/libslic3r/PrintConfig.cpp` - Print settings and presets
- **Model Handling**: `src/libslic3r/Model.cpp` - 3D model representation and manipulation
### File Format Support
- **3MF/BBS_3MF**: Native format with extensions for multi-material and metadata
- **STL**: Standard tessellation language for 3D models
- **AMF**: Additive Manufacturing Format with color/material support
- **OBJ**: Wavefront OBJ with material definitions
- **STEP**: CAD format support for precise geometry
- **G-code**: Output format with extensive post-processing capabilities
### External Dependencies
- **Clipper**: 2D polygon clipping operations
- **libigl**: Geometry processing library
- **OpenVDB**: Voxel data structures (optional)
- **TBB**: Threading Building Blocks for parallelization
- **wxWidgets**: Cross-platform GUI toolkit
- **OpenGL**: 3D graphics rendering
- **Clipper2**: Advanced 2D polygon clipping and offsetting
- **libigl**: Computational geometry library for mesh operations
- **TBB**: Intel Threading Building Blocks for parallelization
- **wxWidgets**: Cross-platform GUI framework
- **OpenGL**: 3D graphics rendering and visualization
- **CGAL**: Computational Geometry Algorithms Library (selective use)
- **OpenVDB**: Volumetric data structures for advanced operations
- **Eigen**: Linear algebra library for mathematical operations
## File Organization
### Configuration and Profiles
- `resources/profiles/`: Printer and material profiles organized by manufacturer
- `resources/printers/`: Printer-specific configurations and G-code templates
### Resources and Configuration
- `resources/profiles/` - Printer and material profiles organized by manufacturer
- `resources/printers/` - Printer-specific configurations and G-code templates
- `resources/images/` - UI icons, logos, calibration images
- `resources/calib/` - Calibration test patterns and data
- `resources/handy_models/` - Built-in test models (benchy, calibration cubes)
### Internationalization
- `localization/i18n/`: Translation files
- `resources/i18n/`: Runtime language resources
### Internationalization and Localization
- `localization/i18n/` - Source translation files (.pot, .po)
- `resources/i18n/` - Runtime language resources
- Translation managed via `scripts/run_gettext.sh` / `scripts/run_gettext.bat`
### Platform-Specific Code
- Platform abstractions in `src/libslic3r/Platform.cpp`
- macOS-specific utilities in `src/libslic3r/MacUtils.mm`
- `src/libslic3r/Platform.cpp` - Platform abstractions and utilities
- `src/libslic3r/MacUtils.mm` - macOS-specific utilities (Objective-C++)
- Windows-specific build scripts and configurations
- Linux distribution support scripts in `scripts/linux.d/`
### Build and Development Tools
- `cmake/modules/` - Custom CMake find modules and utilities
- `scripts/` - Python utilities for profile generation and validation
- `tools/` - Windows build tools (gettext utilities)
- `deps/` - External dependency build configurations
## Development Workflow
### Code Style
- C++17 standard
- Use existing patterns found in libslic3r for consistency
- Follow existing naming conventions (PascalCase for classes, snake_case for functions)
### Code Style and Standards
- **C++17 standard** with selective C++20 features
- **Naming conventions**: PascalCase for classes, snake_case for functions/variables
- **Header guards**: Use `#pragma once`
- **Memory management**: Prefer smart pointers, RAII patterns
- **Thread safety**: Use TBB for parallelization, be mindful of shared state
### Common Tasks
- **Adding new print settings**: Extend `PrintConfig.cpp` and related GUI components
- **Modifying slicing algorithms**: Work in `libslic3r/` core modules
- **GUI changes**: Modify components in `src/slic3r/GUI/`
- **Adding printer support**: Add profiles in `resources/profiles/`
### Common Development Tasks
### Dependencies Management
Dependencies are managed through CMake and built separately from the main application. The `deps/` directory contains dependency build configurations.
#### Adding New Print Settings
1. Define setting in `PrintConfig.cpp` with proper bounds and defaults
2. Add UI controls in appropriate GUI components
3. Update serialization in config save/load
4. Add tooltips and help text for user guidance
5. Test with different printer profiles
## Important Notes
#### Modifying Slicing Algorithms
1. Core algorithms live in `libslic3r/` subdirectories
2. Performance-critical code should be profiled and optimized
3. Consider multi-threading implications (TBB integration)
4. Validate changes don't break existing profiles
5. Add regression tests where appropriate
- The codebase is large and complex - use search tools to navigate effectively
- Many algorithms are performance-critical - consider computational complexity
- The project maintains backward compatibility with various file formats
- Cross-platform compatibility is important (Windows, macOS, Linux)
- The GUI uses a custom theming system supporting light/dark modes
#### GUI Development
1. GUI code resides in `src/slic3r/GUI/` (not visible in current tree)
2. Use existing wxWidgets patterns and custom controls
3. Support both light and dark themes
4. Consider DPI scaling on high-resolution displays
5. Maintain cross-platform compatibility
#### Adding Printer Support
1. Create JSON profile in `resources/profiles/[manufacturer].json`
2. Add printer-specific start/end G-code templates
3. Configure build volume, capabilities, and material compatibility
4. Test thoroughly with actual hardware when possible
5. Follow existing profile structure and naming conventions
### Dependencies and Build System
- **CMake-based** with separate dependency building phase
- **Dependencies** built once in `deps/build/`, then linked to main application
- **Cross-platform** considerations important for all changes
- **Resource files** embedded at build time, platform-specific handling
### Performance Considerations
- **Slicing algorithms** are CPU-intensive, profile before optimizing
- **Memory usage** can be substantial with complex models
- **Multi-threading** extensively used via TBB
- **File I/O** optimized for large 3MF files with embedded textures
- **Real-time preview** requires efficient mesh processing
## Important Development Notes
### Codebase Navigation
- Use search tools extensively - codebase has 500k+ lines
- Key entry points: `src/OrcaSlicer.cpp` for application startup
- Core slicing: `libslic3r/Print.cpp` orchestrates the slicing pipeline
- Configuration: `PrintConfig.cpp` defines all print/printer/material settings
### Compatibility and Stability
- **Backward compatibility** maintained for project files and profiles
- **Cross-platform** support essential (Windows/macOS/Linux)
- **File format** changes require careful version handling
- **Profile migrations** needed when settings change significantly
### Quality and Testing
- **Regression testing** important due to algorithm complexity
- **Performance benchmarks** help catch performance regressions
- **Memory leak** detection important for long-running GUI application
- **Cross-platform** testing required before releases

View file

@ -412,7 +412,7 @@ message(STATUS "LIBDIR_BIN: ${LIBDIR_BIN}")
# For the bundled boost libraries (boost::nowide)
include_directories(SYSTEM ${LIBDIR})
# For generated header files
include_directories(SYSTEM ${LIBDIR_BIN}/platform)
include_directories(SYSTEM ${LIBDIR_BIN}/dev-utils/platform)
# For ligigl
include_directories(SYSTEM ${LIBDIR}/libigl)
@ -796,6 +796,7 @@ endfunction()
# libslic3r, OrcaSlicer GUI and the OrcaSlicer executable.
add_subdirectory(deps_src)
add_subdirectory(src)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT OrcaSlicer_app_gui)
@ -818,7 +819,7 @@ endif()
if (NOT WIN32 AND NOT APPLE)
set(SLIC3R_APP_CMD "orca-slicer")
configure_file(${LIBDIR}/platform/unix/build_appimage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_appimage.sh USE_SOURCE_PERMISSIONS @ONLY)
configure_file(${LIBDIR}/dev-utils/platform/unix/build_appimage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_appimage.sh USE_SOURCE_PERMISSIONS @ONLY)
endif()
option(BUILD_BBS_TEST_TOOLS "Build bbs test tools" OFF)
@ -839,7 +840,7 @@ elseif (SLIC3R_FHS)
install(DIRECTORY ${SLIC3R_RESOURCES_DIR}/ DESTINATION ${SLIC3R_FHS_RESOURCES}
PATTERN "*/udev" EXCLUDE
)
install(FILES src/platform/unix/OrcaSlicer.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
install(FILES src/dev-utils/platform/unix/OrcaSlicer.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
foreach(SIZE 32 128 192)
install(FILES ${SLIC3R_RESOURCES_DIR}/images/OrcaSlicer_${SIZE}px.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}x${SIZE}/apps RENAME OrcaSlicer.png
@ -848,12 +849,12 @@ elseif (SLIC3R_FHS)
elseif (CMAKE_MACOSX_BUNDLE)
# install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/OrcaSlicer.app/Contents/resources")
else ()
install(FILES src/platform/unix/OrcaSlicer.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/resources/applications)
install(FILES src/dev-utils/platform/unix/OrcaSlicer.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/resources/applications)
install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources")
endif ()
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE.txt DESTINATION ".")
configure_file(${LIBDIR}/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp)
configure_file(${LIBDIR}/dev-utils/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/dev-utils/platform/unix/fhs.hpp)
set (CPACK_PACKAGE_NAME "OrcaSlicer")
set (CPACK_PACKAGE_VENDOR "SoftFever")

341
build_flatpak.sh Executable file
View file

@ -0,0 +1,341 @@
#!/bin/bash
# OrcaSlicer Flatpak Build Script
# This script builds and packages OrcaSlicer as a Flatpak package locally
# Based on the GitHub Actions workflow in .github/workflows/build_all.yml
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Default values
ARCH=$(uname -m)
BUILD_DIR="build_flatpak"
CLEANUP=false
INSTALL_RUNTIME=false
JOBS=$(nproc)
FORCE_CLEAN=false
ENABLE_CCACHE=false
CACHE_DIR=".flatpak-builder"
# Help function
show_help() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Build OrcaSlicer as a Flatpak package"
echo ""
echo "Options:"
echo " -a, --arch ARCH Target architecture (x86_64, aarch64) [default: $ARCH]"
echo " -d, --build-dir DIR Build directory [default: $BUILD_DIR]"
echo " -j, --jobs JOBS Number of parallel build jobs for flatpak-builder and modules [default: $JOBS]"
echo " -c, --cleanup Clean build directory before building"
echo " -f, --force-clean Force clean build (disables caching)"
echo " --ccache Enable ccache for faster rebuilds (requires ccache in SDK)"
echo " --cache-dir DIR Flatpak builder cache directory [default: $CACHE_DIR]"
echo " -i, --install-runtime Install required Flatpak runtime and SDK"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Build for current architecture with caching enabled"
echo " $0 -f # Force clean build (no caching)"
echo " $0 --ccache -j 8 # Use ccache and 8 parallel jobs for faster builds"
echo " $0 -a x86_64 -c # Build for x86_64 and cleanup first"
echo " $0 -i -j 16 --ccache # Install runtime, build with 16 jobs and ccache"
}
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-a|--arch)
ARCH="$2"
shift 2
;;
-d|--build-dir)
BUILD_DIR="$2"
shift 2
;;
-j|--jobs)
JOBS="$2"
shift 2
;;
-c|--cleanup)
CLEANUP=true
shift
;;
-f|--force-clean)
FORCE_CLEAN=true
shift
;;
--ccache)
ENABLE_CCACHE=true
shift
;;
--cache-dir)
CACHE_DIR="$2"
shift 2
;;
-i|--install-runtime)
INSTALL_RUNTIME=true
shift
;;
-h|--help)
show_help
exit 0
;;
*)
echo -e "${RED}Error: Unknown option $1${NC}"
show_help
exit 1
;;
esac
done
# Validate architecture
if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" ]]; then
echo -e "${RED}Error: Unsupported architecture '$ARCH'. Supported: x86_64, aarch64${NC}"
exit 1
fi
# Validate jobs parameter
if ! [[ "$JOBS" =~ ^[1-9][0-9]*$ ]]; then
echo -e "${RED}Error: Jobs must be a positive integer, got '$JOBS'${NC}"
exit 1
fi
echo -e "${BLUE}OrcaSlicer Flatpak Build Script${NC}"
echo -e "${BLUE}================================${NC}"
echo -e "Architecture: ${GREEN}$ARCH${NC}"
echo -e "Build directory: ${GREEN}$BUILD_DIR${NC}"
echo -e "Cache directory: ${GREEN}$CACHE_DIR${NC}"
echo -e "Parallel jobs: ${GREEN}$JOBS${NC}"
if [[ "$FORCE_CLEAN" == true ]]; then
echo -e "Cache mode: ${RED}DISABLED (force clean)${NC}"
else
echo -e "Cache mode: ${GREEN}ENABLED${NC}"
fi
if [[ "$ENABLE_CCACHE" == true ]]; then
echo -e "Ccache: ${GREEN}ENABLED${NC}"
else
echo -e "Ccache: ${YELLOW}DISABLED${NC}"
fi
echo ""
# Check available disk space (flatpak builds need several GB)
AVAILABLE_SPACE=$(df . | awk 'NR==2 {print $4}')
REQUIRED_SPACE=$((5 * 1024 * 1024)) # 5GB in KB
if [[ $AVAILABLE_SPACE -lt $REQUIRED_SPACE ]]; then
echo -e "${YELLOW}Warning: Low disk space detected.${NC}"
echo -e "Available: $(( AVAILABLE_SPACE / 1024 / 1024 ))GB, Recommended: 5GB+"
echo -e "Continue anyway? (y/N)"
read -r response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
echo "Build cancelled by user"
exit 1
fi
fi
# Check if flatpak is installed
if ! command -v flatpak &> /dev/null; then
echo -e "${RED}Error: Flatpak is not installed. Please install it first.${NC}"
echo "On Ubuntu/Debian: sudo apt install flatpak"
echo "On Fedora: sudo dnf install flatpak"
echo "On Arch: sudo pacman -S flatpak"
exit 1
fi
# Check if flatpak-builder is installed
if ! command -v flatpak-builder &> /dev/null; then
echo -e "${RED}Error: flatpak-builder is not installed. Please install it first.${NC}"
echo "On Ubuntu/Debian: sudo apt install flatpak-builder"
echo "On Fedora: sudo dnf install flatpak-builder"
echo "On Arch: sudo pacman -S flatpak-builder"
exit 1
fi
# Check additional build dependencies
echo -e "${YELLOW}Checking build dependencies...${NC}"
MISSING_DEPS=()
if ! command -v cmake &> /dev/null; then
MISSING_DEPS+=("cmake")
fi
if ! command -v ninja &> /dev/null && ! command -v make &> /dev/null; then
MISSING_DEPS+=("ninja or make")
fi
if ! command -v pkg-config &> /dev/null; then
MISSING_DEPS+=("pkg-config")
fi
if [ ${#MISSING_DEPS[@]} -ne 0 ]; then
echo -e "${RED}Error: Missing required build dependencies: ${MISSING_DEPS[*]}${NC}"
echo "On Ubuntu/Debian: sudo apt install cmake ninja-build pkg-config"
echo "On Fedora: sudo dnf install cmake ninja-build pkgconfig"
exit 1
fi
echo -e "${GREEN}All required dependencies found${NC}"
# Install runtime and SDK if requested
if [[ "$INSTALL_RUNTIME" == true ]]; then
echo -e "${YELLOW}Installing GNOME runtime and SDK...${NC}"
flatpak install --user -y flathub org.gnome.Platform//47
flatpak install --user -y flathub org.gnome.Sdk//47
fi
# Check if required runtime is available
if ! flatpak info --user org.gnome.Platform//47 &> /dev/null; then
echo -e "${RED}Error: GNOME Platform 47 runtime is not installed.${NC}"
echo "Run with -i flag to install it automatically, or install manually:"
echo "flatpak install --user flathub org.gnome.Platform//47"
exit 1
fi
if ! flatpak info --user org.gnome.Sdk//47 &> /dev/null; then
echo -e "${RED}Error: GNOME SDK 47 is not installed.${NC}"
echo "Run with -i flag to install it automatically, or install manually:"
echo "flatpak install --user flathub org.gnome.Sdk//47"
exit 1
fi
# Get version information
echo -e "${YELLOW}Getting version information...${NC}"
if [[ -f "version.inc" ]]; then
VER_PURE=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2)
VER="V$VER_PURE"
DATE=$(date +'%Y%m%d')
echo -e "Version: ${GREEN}$VER${NC}"
echo -e "Date: ${GREEN}$DATE${NC}"
else
echo -e "${RED}Error: version.inc not found${NC}"
exit 1
fi
# Cleanup build directory if requested
if [[ "$CLEANUP" == true ]]; then
echo -e "${YELLOW}Cleaning up flatpak-specific build directories...${NC}"
rm -rf deps/build_flatpak build_flatpak
echo -e "${YELLOW}Cleaning up flatpak build directories...${NC}"
rm -rf "$BUILD_DIR"
# Only clean cache if force-clean is enabled
if [[ "$FORCE_CLEAN" == true ]]; then
echo -e "${YELLOW}Cleaning up flatpak build cache...${NC}"
rm -rf "$CACHE_DIR"
else
echo -e "${BLUE}Preserving build cache at: $CACHE_DIR${NC}"
fi
echo -e "${BLUE}Note: Host build directories (deps/build, build) are preserved${NC}"
fi
# Create build directory
mkdir -p "$BUILD_DIR"
rm -rf "$BUILD_DIR/build-dir"
# Check if flatpak manifest exists
if [[ ! -f "./scripts/flatpak/io.github.softfever.OrcaSlicer.yml" ]]; then
echo -e "${RED}Error: Flatpak manifest not found at scripts/flatpak/io.github.softfever.OrcaSlicer.yml${NC}"
exit 1
fi
# Build the Flatpak
echo -e "${YELLOW}Building Flatpak package...${NC}"
echo -e "This may take a while (30+ minutes depending on your system)..."
echo ""
BUNDLE_NAME="OrcaSlicer-Linux-flatpak_${VER}_${ARCH}.flatpak"
# Remove any existing bundle
rm -f "$BUNDLE_NAME"
# Create necessary directories inside repo
mkdir -p "$BUILD_DIR/cache" "$BUILD_DIR/flatpak-builder"
# Set environment variables to match GitHub Actions
export FLATPAK_BUILDER_N_JOBS=$JOBS
echo -e "${BLUE}Running flatpak-builder...${NC}"
echo -e "Using $JOBS parallel jobs for flatpak-builder and $FLATPAK_BUILDER_N_JOBS for module builds"
# Check flatpak-builder version to determine available options
FLATPAK_BUILDER_VERSION=$(flatpak-builder --version 2>/dev/null | head -1 | awk '{print $2}' || echo "unknown")
echo -e "flatpak-builder version: $FLATPAK_BUILDER_VERSION"
# Build command with caching support
BUILDER_ARGS=(
--arch="$ARCH"
--user
--install-deps-from=flathub
--repo="$BUILD_DIR/repo"
--verbose
--state-dir="$CACHE_DIR"
--jobs="$JOBS"
)
# Add force-clean only if explicitly requested (disables caching)
if [[ "$FORCE_CLEAN" == true ]]; then
BUILDER_ARGS+=(--force-clean)
echo -e "${YELLOW}Using --force-clean (caching disabled)${NC}"
else
echo -e "${GREEN}Using build cache for faster rebuilds${NC}"
fi
# Add ccache if enabled
if [[ "$ENABLE_CCACHE" == true ]]; then
BUILDER_ARGS+=(--ccache)
echo -e "${GREEN}Using ccache for compiler caching${NC}"
fi
if ! flatpak-builder \
"${BUILDER_ARGS[@]}" \
"$BUILD_DIR/build-dir" \
scripts/flatpak/io.github.softfever.OrcaSlicer.yml; then
echo -e "${RED}Error: flatpak-builder failed${NC}"
echo -e "${YELLOW}Check the build log above for details${NC}"
exit 1
fi
# Create bundle
echo -e "${YELLOW}Creating Flatpak bundle...${NC}"
if ! flatpak build-bundle \
"$BUILD_DIR/repo" \
"$BUNDLE_NAME" \
io.github.softfever.OrcaSlicer \
--arch="$ARCH"; then
echo -e "${RED}Error: Failed to create Flatpak bundle${NC}"
exit 1
fi
# Success message
echo ""
echo -e "${GREEN}✓ Flatpak build completed successfully!${NC}"
echo -e "Bundle created: ${GREEN}$BUNDLE_NAME${NC}"
echo -e "Size: ${GREEN}$(du -h "$BUNDLE_NAME" | cut -f1)${NC}"
if [[ "$FORCE_CLEAN" != true ]]; then
echo -e "Build cache: ${GREEN}$CACHE_DIR${NC} (preserved for faster future builds)"
fi
echo ""
echo -e "${BLUE}To install the Flatpak:${NC}"
echo -e "flatpak install --user $BUNDLE_NAME"
echo ""
echo -e "${BLUE}To run OrcaSlicer:${NC}"
echo -e "flatpak run io.github.softfever.OrcaSlicer"
echo ""
echo -e "${BLUE}To uninstall:${NC}"
echo -e "flatpak uninstall --user io.github.softfever.OrcaSlicer"
echo ""
if [[ "$FORCE_CLEAN" != true ]]; then
echo -e "${BLUE}Cache Management:${NC}"
echo -e "• Subsequent builds will be faster thanks to caching"
echo -e "• To force a clean build: $0 -f"
echo -e "• To clean cache manually: rm -rf $CACHE_DIR"
fi

View file

@ -115,13 +115,13 @@ elif [[ "${DISTRIBUTION_LIKE}" == *"arch"* ]] ; then
DISTRIBUTION="arch"
fi
if [ ! -f ./linux.d/${DISTRIBUTION} ] ; then
echo "Your distribution \"${DISTRIBUTION}\" is not supported by system-dependency scripts in ./linux.d/"
if [ ! -f ./scripts/linux.d/${DISTRIBUTION} ] ; then
echo "Your distribution \"${DISTRIBUTION}\" is not supported by system-dependency scripts in ./scripts/linux.d/"
echo "Please resolve dependencies manually and contribute a script for your distribution to upstream."
exit 1
else
echo "resolving system dependencies for distribution \"${DISTRIBUTION}\" ..."
source ./linux.d/${DISTRIBUTION}
source ./scripts/linux.d/${DISTRIBUTION}
fi
echo "FOUND_GTK3=${FOUND_GTK3}"
@ -189,7 +189,7 @@ if [[ -n "${BUILD_ORCA}" ]] ; then
BUILD_ARGS="${BUILD_ARGS} -DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=0"
fi
CMAKE_CMD="cmake -S . -B build ${CMAKE_C_CXX_COMPILER_CLANG} -G Ninja \
CMAKE_CMD="cmake -S . -B build ${CMAKE_C_CXX_COMPILER_CLANG} -G Ninja Multi-Config \
-DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} \
-DCMAKE_PREFIX_PATH="${SCRIPT_PATH}/deps/build/destdir/usr/local" \
-DSLIC3R_STATIC=1 \
@ -203,7 +203,7 @@ ${BUILD_ARGS}"
cmake --build build --target OrcaSlicer
echo "Building OrcaSlicer_profile_validator .."
cmake --build build --target OrcaSlicer_profile_validator
./run_gettext.sh
./scripts/run_gettext.sh
echo "done"
fi

View file

@ -45,6 +45,6 @@ echo cmake .. -G "Visual Studio 16 2019" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 -DCMAK
cmake .. -G "Visual Studio 16 2019" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./OrcaSlicer" -DCMAKE_BUILD_TYPE=%build_type% -DWIN10SDK_PATH="C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0"
cmake --build . --config %build_type% --target ALL_BUILD -- -m
cd ..
call run_gettext.bat
call scripts/run_gettext.bat
cd %build_dir%
cmake --build . --target install --config %build_type%

View file

@ -189,7 +189,7 @@ function build_slicer() {
echo "Verify localization with gettext..."
(
cd "$PROJECT_DIR"
./run_gettext.sh
./scripts/run_gettext.sh
)
echo "Fix macOS app package..."

View file

@ -62,6 +62,6 @@ cmake .. -G "Visual Studio 17 2022" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 -DORCA_TOOL
cmake --build . --config %build_type% --target ALL_BUILD -- -m
@echo off
cd ..
call run_gettext.bat
call scripts/run_gettext.bat
cd %build_dir%
cmake --build . --target install --config %build_type%

View file

@ -123,7 +123,7 @@ if (OPENVDB_FIND_MODULE_PATH)
endif ()
# ###########################################################################
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.13)
# Monitoring <PackageName>_ROOT variables
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)

View file

@ -18,7 +18,7 @@ else ()
endif ()
# Note: The flatpak build builds wxwidgets separately due to CI size constraints.
# ANY CHANGES MADE IN HERE MUST ALSO BE REFLECTED IN `flatpak/io.github.SoftFever.OrcaSlicer.yml`.
# ANY CHANGES MADE IN HERE MUST ALSO BE REFLECTED IN `scripts/flatpak/io.github.SoftFever.OrcaSlicer.yml`.
# ** THIS INCLUDES BUILD ARGS. **
# ...if you can find a way around this size limitation, be my guest.

35
deps_src/CMakeLists.txt Normal file
View file

@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.13)
project(deps_src)
# Include all dependency subdirectories
# Header-only libraries (INTERFACE)
add_subdirectory(agg)
add_subdirectory(ankerl)
add_subdirectory(fast_float)
add_subdirectory(nanosvg)
add_subdirectory(nlohmann)
add_subdirectory(spline) # Header-only spline library
add_subdirectory(stb_dxt) # Header-only STB DXT compression library
# Static libraries
add_subdirectory(Shiny)
add_subdirectory(admesh)
add_subdirectory(clipper)
add_subdirectory(expat)
add_subdirectory(glu-libtess)
add_subdirectory(hidapi)
add_subdirectory(hints) # Hints library with utility executable
add_subdirectory(imgui)
add_subdirectory(imguizmo)
add_subdirectory(libigl)
add_subdirectory(libnest2d)
add_subdirectory(mcut)
add_subdirectory(miniz)
add_subdirectory(minilzo)
add_subdirectory(qhull)
add_subdirectory(qoi)
add_subdirectory(semver) # Semver static library
# Eigen header-only library
add_subdirectory(eigen)

View file

@ -0,0 +1,119 @@
# CMake Interfaces for deps_src Libraries
This document describes how to use the CMake interface libraries created for the subdirectories in `deps_src/`.
## Available Libraries
### 1. **semver** (Static Library)
- **Type**: Static library
- **Target**: `semver` or `semver::semver`
- **Headers**: `semver.h`
- **Usage**:
```cmake
target_link_libraries(your_target PRIVATE semver)
# or
target_link_libraries(your_target PRIVATE semver::semver)
```
### 2. **hints** (Interface Library)
- **Type**: Interface library (header-only)
- **Target**: `hints`
- **Utility**: `hintsToPot` executable
- **Usage**:
```cmake
target_link_libraries(your_target PRIVATE hints)
```
### 3. **spline** (Interface Library)
- **Type**: Interface library (header-only)
- **Target**: `spline` or `spline::spline`
- **Headers**: `spline.h`
- **Usage**:
```cmake
target_link_libraries(your_target PRIVATE spline)
# or
target_link_libraries(your_target PRIVATE spline::spline)
```
### 4. **stb_dxt** (Interface Library)
- **Type**: Interface library (header-only)
- **Target**: `stb_dxt` or `stb_dxt::stb_dxt`
- **Headers**: `stb_dxt.h`
- **Usage**:
```cmake
target_link_libraries(your_target PRIVATE stb_dxt)
# or
target_link_libraries(your_target PRIVATE stb_dxt::stb_dxt)
```
## How to Use in Your Project
### From within the OrcaSlicer src/ directory:
1. **In your CMakeLists.txt**, simply link the library:
```cmake
add_executable(my_app main.cpp)
target_link_libraries(my_app
PRIVATE
semver::semver # For version parsing
spline::spline # For spline interpolation
stb_dxt::stb_dxt # For DXT texture compression
hints # For hints functionality
)
```
2. **In your C++ code**, include the headers:
```cpp
// For semver
#include <semver.h>
// For spline
#include <spline.h>
// For stb_dxt
#include <stb_dxt.h>
// Use the libraries as documented in their respective headers
```
## Benefits of This Approach
1. **Modern CMake**: Uses target-based CMake with proper INTERFACE/PUBLIC/PRIVATE visibility
2. **Proper Include Paths**: Automatically sets up include directories
3. **Namespace Aliases**: Provides namespaced aliases (e.g., `spline::spline`) for clarity
4. **Position Independent Code**: Static libraries are built with `-fPIC` for compatibility
5. **Install Support**: Libraries can be installed and used by external projects
6. **Build/Install Interface**: Separates build-time and install-time include paths
## Example Integration
Here's a complete example of using these libraries in a new component:
```cmake
# In src/mycomponent/CMakeLists.txt
add_library(mycomponent STATIC
mycomponent.cpp
mycomponent.h
)
target_link_libraries(mycomponent
PUBLIC
semver::semver # Version handling is part of public API
PRIVATE
spline::spline # Used internally for interpolation
stb_dxt::stb_dxt # Used internally for texture compression
)
target_include_directories(mycomponent
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
```
## Notes
- All header-only libraries use the INTERFACE library type, which means they don't produce any binaries
- The `semver` library produces a static library that will be linked into your target
- The `hints` project also produces a `hintsToPot` executable utility
- All libraries require at least C++11 (some require C++17)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.13)
project(Shiny)
add_library(Shiny STATIC
@ -23,3 +23,7 @@ add_library(Shiny STATIC
ShinyZone.c
ShinyZone.h
)
target_include_directories(Shiny PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

View file

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.13)
project(admesh)
add_library(admesh STATIC
connect.cpp
normals.cpp
shared.cpp
stl.h
stl_io.cpp
stlinit.cpp
util.cpp
)
target_include_directories(admesh PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
)
target_link_libraries(admesh
PRIVATE boost_headeronly
PUBLIC eigen
)

View file

@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.13)
project(agg)
add_library(agg INTERFACE)
target_include_directories(agg INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_sources(agg INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/agg_array.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_basics.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_bezier_arc.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_clip_liang_barsky.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_color_gray.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_color_rgba.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_config.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_conv_transform.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_gamma_functions.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_gamma_lut.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_math.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_path_storage.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_pixfmt_base.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_pixfmt_gray.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_pixfmt_rgb.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_rasterizer_cells_aa.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_rasterizer_scanline_aa.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_rasterizer_scanline_aa_nogamma.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_rasterizer_sl_clip.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_renderer_base.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_renderer_scanline.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_rendering_buffer.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_scanline_p.h
${CMAKE_CURRENT_SOURCE_DIR}/agg_trans_affine.h
)

View file

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.13)
project(ankerl)
add_library(ankerl INTERFACE)
target_include_directories(ankerl INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_sources(ankerl INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/unordered_dense.h
)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.13)
project(clipper)
add_library(clipper STATIC
@ -9,4 +9,11 @@ add_library(clipper STATIC
clipper_z.hpp
)
target_link_libraries(clipper TBB::tbb TBB::tbbmalloc)
target_include_directories(clipper PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(clipper
PUBLIC eigen
PRIVATE TBB::tbb TBB::tbbmalloc
)

View file

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.13)
project(eigen)
add_library(eigen INTERFACE)
target_include_directories(eigen INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
# Eigen is header-only, so we only need to specify the include directory
# The headers are in the Eigen/ subdirectory structure

Some files were not shown because too many files have changed in this diff Show more