Browse Source

Refactor Dockerfile. Move it into its own folder.

pull/2/head
Andrew Belt 2 years ago
parent
commit
8477266a05
3 changed files with 58 additions and 39 deletions
  1. +44
    -30
      Makefile
  2. +3
    -3
      README.md
  3. +11
    -6
      docker/Dockerfile

+ 44
- 30
Makefile View File

@@ -26,27 +26,27 @@ $(crosstool-ng):
rm -rf crosstool-ng-1.24.0


toolchain-linux := $(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu
toolchain-linux: $(toolchain-linux)
$(toolchain-linux): $(crosstool-ng)
toolchain-lin := $(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu
toolchain-lin: $(toolchain-lin)
$(toolchain-lin): $(crosstool-ng)
ct-ng x86_64-ubuntu16.04-linux-gnu
CT_PREFIX="$(LOCAL_DIR)" ct-ng build
rm -rf .build .config
rm -rf .build .config build.log
# HACK Copy GL include dir to toolchain sysroot
chmod +w $(toolchain-linux)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
cp -r /usr/include/GL $(toolchain-linux)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
chmod -w $(toolchain-linux)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
chmod +w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include
cp -r /usr/include/GL $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include/
chmod -w $(toolchain-lin)/x86_64-ubuntu16.04-linux-gnu/sysroot/usr/include


toolchain-windows := $(LOCAL_DIR)/x86_64-w64-mingw32
toolchain-windows: $(toolchain-windows)
$(toolchain-windows): $(crosstool-ng)
toolchain-win := $(LOCAL_DIR)/x86_64-w64-mingw32
toolchain-win: $(toolchain-win)
$(toolchain-win): $(crosstool-ng)
ct-ng x86_64-w64-mingw32
CT_PREFIX="$(LOCAL_DIR)" ct-ng build
rm -rf .build .config
rm -rf .build .config build.log


toolchain-mac := osxcross
toolchain-mac := $(LOCAL_DIR)/osxcross
toolchain-mac: $(toolchain-mac)
$(toolchain-mac):
git clone "https://github.com/tpoechtrager/osxcross.git" $@
@@ -71,7 +71,7 @@ $(rack-sdk):
RACK_DIR := $(PWD)/$(rack-sdk)


toolchain-all: toolchain-linux toolchain-windows toolchain-mac rack-sdk
toolchain-all: toolchain-lin toolchain-win toolchain-mac rack-sdk


toolchain-clean:
@@ -90,10 +90,10 @@ plugin-build-mac: export CXX := x86_64-apple-darwin17-clang++-libc++
plugin-build-mac: export STRIP := x86_64-apple-darwin17-strip


plugin-build-windows: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
plugin-build-windows: export CC := x86_64-w64-mingw32-gcc
plugin-build-windows: export CXX := x86_64-w64-mingw32-g++
plugin-build-windows: export STRIP := x86_64-w64-mingw32-strip
plugin-build-win: export PATH := $(LOCAL_DIR)/x86_64-w64-mingw32/bin:$(PATH)
plugin-build-win: export CC := x86_64-w64-mingw32-gcc
plugin-build-win: export CXX := x86_64-w64-mingw32-g++
plugin-build-win: export STRIP := x86_64-w64-mingw32-strip


plugin-build-linux: export PATH:=$(LOCAL_DIR)/x86_64-ubuntu16.04-linux-gnu/bin:$(PATH)
@@ -102,13 +102,13 @@ plugin-build-linux: export CXX := x86_64-ubuntu16.04-linux-gnu-g++
plugin-build-linux: export STRIP := x86_64-ubuntu16.04-linux-gnu-strip


plugin-build-mac plugin-build-windows plugin-build-linux: export RACK_DIR := $(RACK_DIR)
plugin-build-mac plugin-build-win plugin-build-linux: export RACK_DIR := $(RACK_DIR)
# Since the compiler we're using could have a newer version than the minimum supported libstdc++ version, link it statically.
# Rack v2 includes this flag in plugin.mk, so remove it after it releases.
plugin-build-mac plugin-build-windows plugin-build-linux: export LDFLAGS := -static-libstdc++
plugin-build-mac plugin-build-win plugin-build-linux: export LDFLAGS := -static-libstdc++


plugin-build-mac plugin-build-windows plugin-build-linux:
plugin-build-mac plugin-build-win plugin-build-linux:
cd $(PLUGIN_DIR) && $(MAKE) clean
cd $(PLUGIN_DIR) && $(MAKE) cleandep
cd $(PLUGIN_DIR) && $(MAKE) dep
@@ -120,7 +120,7 @@ plugin-build-mac plugin-build-windows plugin-build-linux:

plugin-build:
$(MAKE) plugin-build-mac
$(MAKE) plugin-build-windows
$(MAKE) plugin-build-win
$(MAKE) plugin-build-linux


@@ -164,7 +164,6 @@ dep-ubuntu:
clang \
libz-dev \
rsync
rm -rf /var/lib/apt/lists/*


dep-arch-linux:
@@ -175,16 +174,31 @@ dep-arch-linux:


docker-build:
docker build -t rack-plugin-toolchain:1 .
docker build --tag rack-plugin-toolchain:1 docker


DOCKER_RUN := docker run --rm --interactive --tty \
--volume=$(PLUGIN_DIR):/home/build/plugin-src \
--volume=$(PWD)/$(PLUGIN_BUILD_DIR):/home/build/$(PLUGIN_BUILD_DIR) \
--env PLUGIN_DIR=/home/build/plugin-src \
rack-plugin-toolchain:1 \
/bin/bash

docker-run:
$(DOCKER_RUN)

docker-plugin-build-mac:
mkdir -p $(PLUGIN_BUILD_DIR)
$(DOCKER_RUN) -c "$(MAKE) plugin-build-mac"

docker-plugin-build-win:
mkdir -p $(PLUGIN_BUILD_DIR)
docker run --rm -it \
-v $(PLUGIN_DIR):/home/build/plugin-src \
-v $(PWD)/$(PLUGIN_BUILD_DIR):/home/build/$(PLUGIN_BUILD_DIR) \
-e PLUGIN_DIR=plugin-src \
rack-plugin-toolchain:1 \
/bin/bash \
-c "$(MAKE) plugin-build $(MFLAGS)"
$(DOCKER_RUN) -c "$(MAKE) plugin-build-win"

docker-plugin-build-lin:
mkdir -p $(PLUGIN_BUILD_DIR)
$(DOCKER_RUN) -c "$(MAKE) plugin-build-lin"

docker-plugin-build:
mkdir -p $(PLUGIN_BUILD_DIR)
$(DOCKER_RUN) -c "$(MAKE) plugin-build"

+ 3
- 3
README.md View File

@@ -6,7 +6,7 @@ Build Rack plugins for Mac, Windows, and Linux with a single command on any Linu
**IMPORTANT:** Clone this repository in a path without spaces, or the Makefile will break.

Obtain `MacOSX10.13.sdk.tar.bz2` using the method at https://github.com/tpoechtrager/osxcross#packaging-the-sdk, and place it in the root of this repository.
This must be done on a computer with macOS 10.13.
This must be done on a computer with Macintosh 10.13.

Place `MacOSX10.13.sdk.tar.bz2` in root directory of this repository.

@@ -21,7 +21,7 @@ The final disk space after building is about 1.6 GB.

Execute plugin build.
```
make plugin-build -j 8 PLUGIN_DIR=...
make plugin-build -j8 PLUGIN_DIR=...
```

Build artifacts will be located in `plugin-build` directory.
@@ -35,7 +35,7 @@ make docker-build

Execute plugin build in Docker container.
```
make docker-run -j 8 PLUGIN_DIR=...
make docker-plugin-build -j8 PLUGIN_DIR=...
```

Build artifacts will be located in `plugin-build` directory.


Dockerfile → docker/Dockerfile View File

@@ -8,17 +8,22 @@ RUN useradd --create-home --uid 1000 --gid 1000 --shell /bin/bash build
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends make

WORKDIR /home/build
USER build
RUN mkdir -p /home/build/rack-plugin-toolchain
WORKDIR /home/build/rack-plugin-toolchain

COPY Makefile /home/build/Makefile
COPY Makefile /home/build/rack-plugin-toolchain/

# Install dependencies for building toolchains and plugins
USER root
RUN make dep-ubuntu
RUN rm -rf /var/lib/apt/lists/*

USER build
COPY MacOSX10.13.sdk.tar.xz /home/build/MacOSX10.13.sdk.tar.xz
COPY MacOSX10.13.sdk.tar.* /home/build/rack-plugin-toolchain/

RUN make toolchain-all
RUN make toolchain-mac
RUN make toolchain-win
RUN make toolchain-lin

RUN rm /home/build/MacOSX10.13.sdk.tar.xz
RUN rm /home/build/build.log
RUN rm MacOSX10.13.sdk.tar.*

Loading…
Cancel
Save