├── .gitignore ├── Dockerfile ├── Makefile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore all dotfiles except git dotfiles 2 | .* 3 | !.git* 4 | 5 | # File extensions 6 | *.xz 7 | *.bz2 8 | *.gz 9 | *.log 10 | 11 | # Build target folders 12 | /local 13 | /plugin-build 14 | /osxcross 15 | /crosstool-ng-* 16 | /Rack-SDK-* 17 | /MacOSX*.sdk.tar.* 18 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | ENV LANG=C.UTF-8 3 | 4 | ARG JOBS 5 | ARG MACOS_SDK_VERSION 6 | 7 | # Install make and sudo to bootstrap 8 | ENV DEBIAN_FRONTEND=noninteractive 9 | RUN apt-get update && apt-get install -y --no-install-recommends \ 10 | make \ 11 | sudo \ 12 | ca-certificates \ 13 | git \ 14 | build-essential \ 15 | autoconf \ 16 | automake \ 17 | bison \ 18 | flex \ 19 | gawk \ 20 | libtool-bin \ 21 | libncurses5-dev \ 22 | unzip \ 23 | zip \ 24 | jq \ 25 | libgl-dev \ 26 | libglu-dev \ 27 | git \ 28 | wget \ 29 | curl \ 30 | cmake \ 31 | nasm \ 32 | xz-utils \ 33 | file \ 34 | python3 \ 35 | libxml2-dev \ 36 | libssl-dev \ 37 | texinfo \ 38 | help2man \ 39 | libz-dev \ 40 | rsync \ 41 | xxd \ 42 | perl \ 43 | coreutils \ 44 | zstd \ 45 | markdown \ 46 | libarchive-tools \ 47 | gettext \ 48 | libgmp-dev \ 49 | libmpfr-dev 50 | RUN echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers 51 | 52 | # Create unprivileged user to build toolchains and plugins 53 | RUN useradd --non-unique --create-home --uid 1000 --gid 1000 --shell /bin/bash build 54 | RUN usermod -aG sudo build 55 | 56 | # Switch user from root 57 | USER build 58 | 59 | # Create toolchain directory 60 | RUN mkdir -p /home/build/rack-plugin-toolchain 61 | WORKDIR /home/build/rack-plugin-toolchain 62 | 63 | COPY Makefile /home/build/rack-plugin-toolchain/ 64 | 65 | # Clean up files to free up space 66 | USER root 67 | RUN rm -rf /var/lib/apt/lists/* 68 | 69 | USER build 70 | COPY MacOSX${MACOS_SDK_VERSION}.sdk.tar.* /home/build/rack-plugin-toolchain/ 71 | 72 | # Build toolchains 73 | RUN JOBS=$JOBS make toolchain-mac 74 | RUN JOBS=$JOBS make toolchain-win 75 | RUN JOBS=$JOBS make toolchain-lin 76 | 77 | RUN JOBS=$JOBS make cppcheck 78 | 79 | RUN JOBS=$JOBS make rack-sdk-all 80 | 81 | RUN rm MacOSX12.3.sdk.tar.* 82 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Installation path for executables 2 | LOCAL_DIR := $(PWD)/local 3 | # Local programs should have higher path priority than system-installed programs 4 | export PATH := $(LOCAL_DIR)/bin:$(PATH) 5 | 6 | # Allow specifying the number of jobs for toolchain build for systems that need it. 7 | # Due to different build systems used in the toolchain build, just `make -j` won't work here. 8 | # Note: Plugin build uses `$(MAKE)` to inherit `-j` argument from command line. 9 | ifdef JOBS 10 | export JOBS := $(JOBS) 11 | # Define number of jobs for crosstool-ng (uses different argument format) 12 | export JOBS_CT_NG := .$(JOBS) 13 | else 14 | # If `JOBS` is not specified, default to max number of jobs. 15 | export JOBS := 16 | export JOBS_CT_NG := 17 | endif 18 | 19 | WGET := wget -c 20 | UNTAR := tar -x -f 21 | UNZIP := unzip 22 | SHA256 := sha256check() { echo "$$2 $$1" | sha256sum -c; }; sha256check 23 | 24 | RACK_SDK_VERSION := 2.6.4 25 | DOCKER_IMAGE_VERSION := 18 26 | 27 | MACOS_SDK_VERSION := 12.3 28 | DARWIN_VERSION := 21.4 29 | 30 | all: toolchain-all rack-sdk-all 31 | 32 | 33 | # Toolchain build 34 | 35 | 36 | toolchain-all: toolchain-lin toolchain-win toolchain-mac cppcheck 37 | 38 | 39 | crosstool-ng := $(LOCAL_DIR)/bin/ct-ng 40 | $(crosstool-ng): 41 | git clone "https://github.com/crosstool-ng/crosstool-ng.git" crosstool-ng 42 | cd crosstool-ng && git checkout b49e4c689c4dc8e9c8da5b8f56d7ddf59e485d3b 43 | cd crosstool-ng && ./bootstrap 44 | cd crosstool-ng && ./configure --prefix="$(LOCAL_DIR)" 45 | cd crosstool-ng && make -j $(JOBS) 46 | cd crosstool-ng && make install 47 | rm -rf crosstool-ng 48 | 49 | 50 | toolchain-lin := $(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu 51 | toolchain-lin: $(toolchain-lin) 52 | $(toolchain-lin): $(crosstool-ng) 53 | $(WGET) "https://ftp.gnu.org/gnu/texinfo/texinfo-7.2.tar.gz" 54 | $(SHA256) texinfo-7.2.tar.gz e86de7dfef6b352aa1bf647de3a6213d1567c70129eccbf8977706d9c91919c8 55 | $(UNTAR) texinfo-7.2.tar.gz 56 | rm texinfo-7.2.tar.gz 57 | cd texinfo-7.2 && ./configure --prefix="$(LOCAL_DIR)" 58 | cd texinfo-7.2 && make -j $(JOBS) 59 | cd texinfo-7.2 && make install -j $(JOBS) 60 | rm -rf texinfo-7.2 61 | 62 | ct-ng x86_64-ubuntu16.04-linux-gnu 63 | CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG) 64 | rm -rf .build .config build.log 65 | # HACK Copy GL and related include dirs to toolchain sysroot 66 | chmod +w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include 67 | cp -r /usr/include/GL $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/ 68 | cp -r /usr/include/KHR $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/ 69 | cp -r /usr/include/X11 $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/ 70 | chmod -w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include 71 | 72 | 73 | toolchain-win := $(LOCAL_DIR)/x86_64-w64-mingw32 74 | toolchain-win: $(toolchain-win) 75 | $(toolchain-win): $(crosstool-ng) 76 | ct-ng x86_64-w64-mingw32 77 | # I don't know how to set crosstool-ng variables from the command line 78 | sed -i 's/CT_MINGW_W64_VERSION=.*/CT_MINGW_W64_VERSION="v10.0.0"/' .config 79 | CT_PREFIX="$(LOCAL_DIR)" ct-ng build$(JOBS_CT_NG) 80 | rm -rf .build .config build.log 81 | 82 | 83 | OSXCROSS_CLANG_VERSION := 20.1.1 84 | OSXCROSS_BINUTILS_VERSION := 2.37 85 | 86 | toolchain-mac := $(LOCAL_DIR)/osxcross 87 | toolchain-mac: $(toolchain-mac) 88 | $(toolchain-mac): export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH) 89 | $(toolchain-mac): 90 | # Obtain osxcross sources. 91 | git clone "https://github.com/tpoechtrager/osxcross.git" osxcross 92 | cd osxcross && git checkout 4372d5560307c649af5dbbfa20b39199c9ef48be 93 | 94 | # Build a custom clang compiler using the system's gcc compiler. 95 | # This enables us to have custom compiler environment needed for cross-compilation. 96 | cd osxcross && UNATTENDED=1 INSTALLPREFIX="$(LOCAL_DIR)" GITPROJECT=llvm CLANG_VERSION=$(OSXCROSS_CLANG_VERSION) OCDEBUG=1 ENABLE_CLANG_INSTALL=1 JOBS=$(JOBS) ./build_clang.sh 97 | 98 | ## Build osxcross. 99 | cp MacOSX$(MACOS_SDK_VERSION).sdk.tar.* osxcross/tarballs/ 100 | cd osxcross && PATH="$(LOCAL_DIR)/bin:$(PATH)" UNATTENDED=1 TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build.sh 101 | 102 | ## Build compiler-rt. 103 | cd osxcross && ENABLE_COMPILER_RT_INSTALL=1 JOBS=$(JOBS) ./build_compiler_rt.sh 104 | 105 | ## Build MacOS binutils and build LLVM gold. 106 | cd osxcross && BINUTILS_VERSION=$(OSXCROSS_BINUTILS_VERSION) TARGET_DIR="$(LOCAL_DIR)/osxcross" JOBS=$(JOBS) ./build_binutils.sh 107 | cd osxcross/build/clang-$(OSXCROSS_CLANG_VERSION)/build_stage2 && cmake . -DLLVM_BINUTILS_INCDIR=$(PWD)/osxcross/build/binutils-$(OSXCROSS_BINUTILS_VERSION)/include && make install -j $(JOBS) 108 | 109 | # Fix library paths (for Arch Linux and Ubuntu arm64). 110 | export PLATFORM_ID=$$($(LOCAL_DIR)/bin/clang -dumpmachine) ; \ 111 | echo "Platform ID: $$PLATFORM_ID" ; \ 112 | if [ ! -z "$$PLATFORM_ID" ] && [ -e "$(LOCAL_DIR)/lib/$$PLATFORM_ID/" ]; then \ 113 | echo "Copying lib files..." ; \ 114 | cp -Pv $(LOCAL_DIR)/lib/$$PLATFORM_ID/* $(LOCAL_DIR)/lib/ ; \ 115 | echo "done" ; \ 116 | fi 117 | 118 | ## Download rcodesign binary to ad-hoc sign arm64 plugin builds in a cross-compilation environment. 119 | $(WGET) "https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.22.0/apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz" 120 | $(UNTAR) apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz 121 | rm apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz 122 | cp ./apple-codesign-0.22.0-x86_64-unknown-linux-musl/rcodesign $(LOCAL_DIR)/osxcross/bin/ 123 | rm -r apple-codesign-0.22.0-x86_64-unknown-linux-musl 124 | 125 | rm -rf osxcross 126 | 127 | 128 | CPPCHECK_VERSION := 2.16.0 129 | cppcheck := $(LOCAL_DIR)/cppcheck/bin/cppcheck 130 | cppcheck: $(cppcheck) 131 | $(cppcheck): 132 | $(WGET) "https://github.com/danmar/cppcheck/archive/refs/tags/$(CPPCHECK_VERSION).tar.gz" 133 | $(UNTAR) $(CPPCHECK_VERSION).tar.gz 134 | cd cppcheck-$(CPPCHECK_VERSION) && mkdir build 135 | cd cppcheck-$(CPPCHECK_VERSION)/build \ 136 | && cmake .. \ 137 | -DUSE_MATCHCOMPILER=On \ 138 | -DUSE_THREADS=On \ 139 | -DCMAKE_INSTALL_PREFIX=$(LOCAL_DIR)/cppcheck \ 140 | && cmake --build . -j \ 141 | && cmake --install . 142 | rm $(CPPCHECK_VERSION).tar.gz 143 | rm -rf cppcheck-$(CPPCHECK_VERSION) 144 | 145 | 146 | toolchain-clean: 147 | rm -rf local osxcross .build build.log .config 148 | 149 | 150 | # Rack SDK 151 | 152 | 153 | rack-sdk-all: rack-sdk-mac-x64 rack-sdk-mac-arm64 rack-sdk-win-x64 rack-sdk-lin-x64 154 | 155 | 156 | rack-sdk-mac-x64 := Rack-SDK-mac-x64 157 | rack-sdk-mac-x64: $(rack-sdk-mac-x64) 158 | $(rack-sdk-mac-x64): 159 | $(WGET) "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip" 160 | $(UNZIP) Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip 161 | mv Rack-SDK Rack-SDK-mac-x64 162 | rm Rack-SDK-$(RACK_SDK_VERSION)-mac-x64.zip 163 | RACK_DIR_MAC_X64 := $(PWD)/$(rack-sdk-mac-x64) 164 | 165 | 166 | rack-sdk-mac-arm64 := Rack-SDK-mac-arm64 167 | rack-sdk-mac-arm64: $(rack-sdk-mac-arm64) 168 | $(rack-sdk-mac-arm64): 169 | $(WGET) "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip" 170 | $(UNZIP) Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip 171 | mv Rack-SDK Rack-SDK-mac-arm64 172 | rm Rack-SDK-$(RACK_SDK_VERSION)-mac-arm64.zip 173 | RACK_DIR_MAC_ARM64 := $(PWD)/$(rack-sdk-mac-arm64) 174 | 175 | 176 | rack-sdk-win-x64 := Rack-SDK-win-x64 177 | rack-sdk-win-x64: $(rack-sdk-win-x64) 178 | $(rack-sdk-win-x64): 179 | $(WGET) "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip" 180 | $(UNZIP) Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip 181 | mv Rack-SDK Rack-SDK-win-x64 182 | rm Rack-SDK-$(RACK_SDK_VERSION)-win-x64.zip 183 | RACK_DIR_WIN_X64 := $(PWD)/$(rack-sdk-win-x64) 184 | 185 | 186 | rack-sdk-lin-x64 := Rack-SDK-lin-x64 187 | rack-sdk-lin-x64: $(rack-sdk-lin-x64) 188 | $(rack-sdk-lin-x64): 189 | $(WGET) "https://vcvrack.com/downloads/Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip" 190 | $(UNZIP) Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip 191 | mv Rack-SDK Rack-SDK-lin-x64 192 | rm Rack-SDK-$(RACK_SDK_VERSION)-lin-x64.zip 193 | RACK_DIR_LIN_X64 := $(PWD)/$(rack-sdk-lin-x64) 194 | 195 | 196 | rack-sdk-clean: 197 | rm -rf $(rack-sdk-mac-x64) $(rack-sdk-mac-arm64) $(rack-sdk-win-x64) $(rack-sdk-lin-x64) 198 | 199 | 200 | # Plugin build 201 | 202 | 203 | PLUGIN_BUILD_DIR := plugin-build 204 | PLUGIN_DIR ?= 205 | 206 | 207 | plugin-build: 208 | $(MAKE) plugin-build-mac-x64 209 | $(MAKE) plugin-build-mac-arm64 210 | $(MAKE) plugin-build-win-x64 211 | $(MAKE) plugin-build-lin-x64 212 | 213 | 214 | plugin-build-mac: 215 | $(MAKE) plugin-build-mac-x64 216 | $(MAKE) plugin-build-mac-arm64 217 | 218 | 219 | plugin-build-win: 220 | $(MAKE) plugin-build-win-x64 221 | 222 | 223 | plugin-build-lin: 224 | $(MAKE) plugin-build-lin-x64 225 | 226 | 227 | plugin-build-mac-x64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH) 228 | plugin-build-mac-x64: export CC := x86_64-apple-darwin$(DARWIN_VERSION)-clang 229 | plugin-build-mac-x64: export CXX := x86_64-apple-darwin$(DARWIN_VERSION)-clang++-libc++ 230 | plugin-build-mac-x64: export STRIP := x86_64-apple-darwin$(DARWIN_VERSION)-strip 231 | plugin-build-mac-x64: export INSTALL_NAME_TOOL := x86_64-apple-darwin$(DARWIN_VERSION)-install_name_tool 232 | plugin-build-mac-x64: export OTOOL := x86_64-apple-darwin$(DARWIN_VERSION)-otool 233 | plugin-build-mac-x64: export CODESIGN := rcodesign sign 234 | 235 | 236 | plugin-build-mac-arm64: export PATH := $(LOCAL_DIR)/osxcross/bin:$(PATH) 237 | plugin-build-mac-arm64: export CC := arm64-apple-darwin$(DARWIN_VERSION)-clang 238 | plugin-build-mac-arm64: export CXX := arm64-apple-darwin$(DARWIN_VERSION)-clang++-libc++ 239 | plugin-build-mac-arm64: export STRIP := arm64-apple-darwin$(DARWIN_VERSION)-strip 240 | plugin-build-mac-arm64: export INSTALL_NAME_TOOL := arm64-apple-darwin$(DARWIN_VERSION)-install_name_tool 241 | plugin-build-mac-arm64: export OTOOL := arm64-apple-darwin$(DARWIN_VERSION)-otool 242 | plugin-build-mac-arm64: export CODESIGN := rcodesign sign 243 | 244 | 245 | plugin-build-win-x64: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH) 246 | plugin-build-win-x64: export CC := x86_64-w64-mingw32-gcc 247 | plugin-build-win-x64: export CXX := x86_64-w64-mingw32-g++ 248 | plugin-build-win-x64: export STRIP := x86_64-w64-mingw32-strip 249 | plugin-build-win-x64: export OBJCOPY := x86_64-w64-mingw32-objcopy 250 | 251 | 252 | plugin-build-lin-x64: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH) 253 | plugin-build-lin-x64: export CC := x86_64-ubuntu16.04-linux-gnu-gcc 254 | plugin-build-lin-x64: export CXX := x86_64-ubuntu16.04-linux-gnu-g++ 255 | plugin-build-lin-x64: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip 256 | plugin-build-lin-x64: export OBJCOPY := x86_64-ubuntu16.04-linux-gnu-objcopy 257 | 258 | 259 | plugin-build-mac-x64: export RACK_DIR := $(RACK_DIR_MAC_X64) 260 | plugin-build-mac-arm64: export RACK_DIR := $(RACK_DIR_MAC_ARM64) 261 | plugin-build-win-x64: export RACK_DIR := $(RACK_DIR_WIN_X64) 262 | plugin-build-lin-x64: export RACK_DIR := $(RACK_DIR_LIN_X64) 263 | 264 | 265 | plugin-build-mac-x64 plugin-build-mac-arm64 plugin-build-win-x64 plugin-build-lin-x64: 266 | cd $(PLUGIN_DIR) && $(MAKE) clean 267 | cd $(PLUGIN_DIR) && $(MAKE) cleandep 268 | cd $(PLUGIN_DIR) && $(MAKE) dep 269 | cd $(PLUGIN_DIR) && $(MAKE) dist 270 | mkdir -p $(PLUGIN_BUILD_DIR) 271 | cp $(PLUGIN_DIR)/dist/*.vcvplugin $(PLUGIN_BUILD_DIR)/ 272 | cd $(PLUGIN_DIR) && $(MAKE) clean 273 | 274 | 275 | plugin-build-clean: 276 | rm -rf $(PLUGIN_BUILD_DIR) 277 | 278 | 279 | # Static Analysis 280 | 281 | static-analysis-cppcheck: export PATH := $(LOCAL_DIR)/cppcheck/bin:$(PATH) 282 | static-analysis-cppcheck: cppcheck 283 | cd $(PLUGIN_DIR) && cppcheck src/ -isrc/dep --std=c++11 -j $(shell nproc) --error-exitcode=1 284 | 285 | 286 | plugin-analyze: static-analysis-cppcheck 287 | 288 | 289 | # Docker helpers 290 | 291 | 292 | dep-ubuntu: 293 | sudo apt-get install --no-install-recommends \ 294 | ca-certificates \ 295 | git \ 296 | build-essential \ 297 | autoconf \ 298 | automake \ 299 | bison \ 300 | flex \ 301 | gawk \ 302 | libtool-bin \ 303 | libncurses5-dev \ 304 | unzip \ 305 | zip \ 306 | jq \ 307 | libgl-dev \ 308 | libglu-dev \ 309 | git \ 310 | wget \ 311 | curl \ 312 | cmake \ 313 | nasm \ 314 | xz-utils \ 315 | file \ 316 | python3 \ 317 | libxml2-dev \ 318 | libssl-dev \ 319 | texinfo \ 320 | help2man \ 321 | libz-dev \ 322 | rsync \ 323 | xxd \ 324 | perl \ 325 | coreutils \ 326 | zstd \ 327 | markdown \ 328 | libarchive-tools \ 329 | gettext \ 330 | libgmp-dev \ 331 | libmpfr-dev 332 | 333 | 334 | dep-arch-linux: 335 | sudo pacman -S --needed \ 336 | gcc \ 337 | git \ 338 | cmake \ 339 | patch \ 340 | python3 \ 341 | automake \ 342 | help2man \ 343 | texinfo \ 344 | libtool \ 345 | jq \ 346 | rsync \ 347 | autoconf \ 348 | flex \ 349 | bison \ 350 | which \ 351 | unzip \ 352 | wget \ 353 | glu \ 354 | libx11 \ 355 | mesa 356 | 357 | 358 | 359 | docker-build: rack-sdk-all 360 | docker build --build-arg JOBS=$(JOBS) --build-arg MACOS_SDK_VERSION=$(MACOS_SDK_VERSION) --no-cache --tag rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) . --progress=plain 2>&1 | tee docker-build.log 361 | 362 | 363 | DOCKER_RUN := docker run --rm --interactive --tty \ 364 | --volume=$(PLUGIN_DIR):/home/build/plugin-src \ 365 | --volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/rack-plugin-toolchain/$(PLUGIN_BUILD_DIR) \ 366 | --volume=$(PWD)/Rack-SDK-mac-x64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-x64 \ 367 | --volume=$(PWD)/Rack-SDK-mac-arm64:/home/build/rack-plugin-toolchain/Rack-SDK-mac-arm64 \ 368 | --volume=$(PWD)/Rack-SDK-win-x64:/home/build/rack-plugin-toolchain/Rack-SDK-win-x64 \ 369 | --volume=$(PWD)/Rack-SDK-lin-x64:/home/build/rack-plugin-toolchain/Rack-SDK-lin-x64 \ 370 | --env PLUGIN_DIR=/home/build/plugin-src \ 371 | rack-plugin-toolchain:$(DOCKER_IMAGE_VERSION) \ 372 | /bin/bash 373 | 374 | docker-run: 375 | $(DOCKER_RUN) 376 | 377 | docker-plugin-build: 378 | mkdir -p $(PLUGIN_BUILD_DIR) 379 | $(DOCKER_RUN) -c "$(MAKE) plugin-build $(MFLAGS)" 380 | 381 | docker-plugin-build-mac-x64: 382 | mkdir -p $(PLUGIN_BUILD_DIR) 383 | $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-x64 $(MFLAGS)" 384 | 385 | docker-plugin-build-mac-arm64: 386 | mkdir -p $(PLUGIN_BUILD_DIR) 387 | $(DOCKER_RUN) -c "$(MAKE) plugin-build-mac-arm64 $(MFLAGS)" 388 | 389 | docker-plugin-build-win-x64: 390 | mkdir -p $(PLUGIN_BUILD_DIR) 391 | $(DOCKER_RUN) -c "$(MAKE) plugin-build-win-x64 $(MFLAGS)" 392 | 393 | docker-plugin-build-lin-x64: 394 | mkdir -p $(PLUGIN_BUILD_DIR) 395 | $(DOCKER_RUN) -c "$(MAKE) plugin-build-lin-x64 $(MFLAGS)" 396 | 397 | docker-plugin-analyze: 398 | $(DOCKER_RUN) -c "$(MAKE) plugin-analyze $(MFLAGS)" 399 | 400 | 401 | .NOTPARALLEL: 402 | .PHONY: all plugin-build plugin-analyze 403 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VCV Rack Plugin Toolchain 2 | 3 | **Cross-compile** VCV Rack plugins for all supported platforms with a single command on any GNU/Linux-based distribution. 4 | 5 | **Analyze** plugin source code using open source static analysis tools (for example: cppcheck). 6 | 7 | ## Supported platforms and architectures 8 | 9 | The following platforms and architectures are supported by the VCV Rack Plugin Toolchain: 10 | 11 | | Platform | Architecture | 12 | |:---------:|:------------:| 13 | | GNU/Linux | x64 | 14 | | Windows | x64 | 15 | | macOS | x64, arm64 | 16 | 17 | All supported platforms and architectures will be built by **cross-compilation in a GNU/Linux-based environment**. 18 | 19 | Cross-platform support for using the toolchain on non-GNU/Linux platforms is provided via Docker (see below). 20 | 21 | ## Obtain the macOS SDK 12.3 22 | 23 | You must use a Mac computer for this step. 24 | You must generate this exact SDK version to build the Rack plugin toolchain. 25 | 26 | Download [Xcode 14.0.1](https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_14.0.1/Xcode_14.0.1.xip) and extract the .xip. 27 | 28 | Extract the macOS SDK with [osxcross](https://github.com/tpoechtrager/osxcross). 29 | ```bash 30 | git clone https://github.com/tpoechtrager/osxcross.git 31 | cd osxcross/tools 32 | XCODEDIR=~/Downloads/Xcode.app ./gen_sdk_package.sh 33 | ``` 34 | This generates `MacOSX12.3.sdk.tar.xz` in the `osxcross/tools` folder. 35 | 36 | ## Building 37 | 38 | Clone this repository in a **path without spaces**, or the Makefile will break. 39 | Obtain `MacOSX12.3.sdk.tar.xz` above and place it in the root of this repository. 40 | 41 | There are two ways to build the toolchains: 42 | - Locally on GNU/Linux: Uses your system's compilers to build the toolchains. 43 | - In a Docker container: This method uses a Ubuntu base image and installs all dependencies necessary to build the toolchains. 44 | 45 | **NOTE:** The official VCV Rack plugin build system is based on Arch Linux. 46 | 47 | ### Local toolchain build 48 | 49 | *Requires a GNU/Linux host.* 50 | 51 | Install toolchain build dependencies. 52 | On Arch Linux, 53 | ```bash 54 | sudo pacman -Syu 55 | make dep-arch-linux 56 | ``` 57 | or on Ubuntu, 58 | ```bash 59 | sudo apt-get update 60 | make dep-ubuntu 61 | ``` 62 | 63 | Build toolchains for all three platforms. 64 | ```bash 65 | make toolchain-all 66 | ``` 67 | Each toolchain will take around an hour to build and will require network access, about 8 GB free RAM, and about 15 GB free disk space. 68 | The final disk space after building is about 3.7 GB. 69 | 70 | Get Rack SDKs. 71 | ```bash 72 | make rack-sdk-all 73 | ``` 74 | The Rack SDK version is defined in the Makefile. 75 | 76 | Build your plugin. 77 | ```bash 78 | make -j$(nproc) plugin-build PLUGIN_DIR=... 79 | ``` 80 | 81 | Built plugin packages are placed in the `plugin-build/` directory. 82 | 83 | Analyze your plugin source code. 84 | 85 | ```bash 86 | make -j$(nproc) plugin-analyze PLUGIN_DIR=... 87 | ``` 88 | 89 | ### Docker toolchain build 90 | 91 | *Works on any operating system with [Docker](https://www.docker.com/) installed.* 92 | 93 | **IMPORTANT:** Do **not** invoke the Docker-based toolchain with `sudo`! There is no need to do so and it will not work correctly. 94 | 95 | Instead, follow the instructions to let non-root users manage Docker containers: https://docs.docker.com/engine/install/linux-postinstall/ 96 | 97 | Build the Docker container with toolchains for all platforms. 98 | ```bash 99 | make docker-build 100 | ``` 101 | 102 | *Optional*: Pass number of jobs to use to for the tool chain build with the `JOBS` environment variable. 103 | ```bash 104 | JOBS=$(nproc) make docker-build 105 | ``` 106 | (Just passing `-j$(nproc)` directly will not work due to the different build systems used in the toolchain build process.) 107 | 108 | Build your plugin. 109 | 110 | 111 | ```bash 112 | make -j$(nproc) docker-plugin-build PLUGIN_DIR=... 113 | ``` 114 | 115 | Built plugin packages are placed in the `plugin-build/` directory. 116 | 117 | Analyze plugin source code. 118 | 119 | ```bash 120 | make -j$(nproc) docker-plugin-analyze PLUGIN_DIR=... 121 | ``` 122 | 123 | #### Notes for building and using the Docker-based toolchain on macOS 124 | 125 | - Ensure that Docker Desktop has sufficient amount of resources (RAM, disk space) allocated to build the toolchain! 126 | - You may have to add `MAKE=make` to the build command:: 127 | 128 | ```bash 129 | MAKE=make make -j$(nproc) docker-plugin-build PLUGIN_DIR=... 130 | ``` 131 | 132 | ### Rack SDK management 133 | 134 | The latest Rack SDKs for all supported platforms are downloaded during the toolchain build. 135 | 136 | The SDKs can be updated to the latest version (defined in the `Makefile`) as follows: 137 | 138 | ```bash 139 | make rack-sdk-clean 140 | make rack-sdk-all 141 | ``` 142 | 143 | This is especially convenient for the Docker-based toolchain, because it does not require to rebuild the entire toolchain to update to the latest SDK. 144 | 145 | ## Acknowledgments 146 | 147 | Thanks to @cschol for help with crosstool-ng, Ubuntu, Docker, and testing. 148 | --------------------------------------------------------------------------------