From 9f57bbaecd8e62663a758b47ec04464ade63471b Mon Sep 17 00:00:00 2001 From: Robert Bendun Date: Sun, 15 Jan 2023 00:37:11 +0100 Subject: [PATCH] Dockerfile builds Windows and Linux releases --- CHANGELOG.md | 3 ++- Dockerfile | 41 +++++++++++++++++++++++++++++++++++++---- Makefile | 6 ++++++ README.md | 2 ++ build_instructions.md | 4 ++-- config.mk | 2 +- 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9f4dc..44385bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Introduced start synchronization with builtins: `peers` and `start` - Connection with MIDI ports via parameters dropped in favour of function using context system: `port` - Listing ports via REPL command: `:ports` instead of commandline parameter +- Building release with `make musique.zip` using Docker ### Changed @@ -23,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed -- Release builder, since it's separate part of the project +- Release script builder ### Fixed diff --git a/Dockerfile b/Dockerfile index 92706bd..bf437d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,41 @@ -FROM ubuntu:20.04 - +FROM ubuntu:20.04 AS linux ARG TZ=Europe/Warsaw RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -RUN apt update && apt upgrade -y && apt install -y build-essential software-properties-common zip unzip +RUN apt update && apt install -y make software-properties-common zip unzip git RUN add-apt-repository ppa:ubuntu-toolchain-r/test RUN apt install -y gcc-11 g++-11 libasound2-dev +RUN mkdir -p /src/ +WORKDIR /src/ +COPY config.mk Makefile /src/ +COPY .git /src/.git/ +COPY musique /src/musique/ +COPY lib /src/lib/ +COPY scripts /src/scripts/ +RUN make clean && make CC=gcc-11 CXX=g++-11 + + +FROM ubuntu:22.04 AS windows +RUN apt update && apt install -y git make gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 +RUN mkdir -p /src/ +WORKDIR /src/ +COPY config.mk Makefile /src/ +COPY .git /src/.git/ +COPY musique /src/musique/ +COPY lib /src/lib/ +COPY scripts /src/scripts/ +RUN make clean && make os=windows CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix + + +FROM ubuntu:22.04 AS release +RUN apt update && apt install -y zip pandoc python3 python-is-python3 pandoc +COPY CHANGELOG.md LICENSE /musique/ +COPY examples /musique/examples/ +COPY --from=windows /src/bin/musique.exe /musique/musique-windows.exe +COPY --from=linux /src/bin/musique /musique/musique-linux + +COPY doc /doc/ +COPY scripts /scripts/ +RUN python /scripts/language-cmp-cheatsheet.py /doc/musique-vs-languages-cheatsheet.template \ + && bash -c 'cp /{doc,musique}/musique-vs-languages-cheatsheet.html' +RUN pandoc -o /musique/wprowadzenie.html /doc/wprowadzenie.md -s --toc +RUN zip -r musique.zip /musique/ diff --git a/Makefile b/Makefile index 01f7286..6e3d9fa 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,12 @@ doc/wprowadzenie.html: doc/wprowadzenie.md doc/functions.html: musique/interpreter/builtin_functions.cc scripts/document-builtin.py scripts/document-builtin.py -o $@ $< +musique.zip: doc/* $(Sources) scripts/* + docker build -t musique-builder . + docker create --name musique musique-builder + docker cp musique:/musique.zip musique.zip + docker rm -f musique + .PHONY: clean doc doc-open all test unit-tests release install $(shell mkdir -p $(subst musique/,bin/$(os)/,$(shell find musique/* -type d))) diff --git a/README.md b/README.md index fbf86cf..11cb968 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Musique interpreter +Reference implementation of Musique programming language. + ## Building Reference [`build_instructions.md`](./build_instructions.md). diff --git a/build_instructions.md b/build_instructions.md index a2e7fe1..f5351f4 100644 --- a/build_instructions.md +++ b/build_instructions.md @@ -2,7 +2,7 @@ ## Linux -Consult README.md. +Use your local C++ compiler (supporting C++20) and ALSA dev libraries or included Dockerfile. ## MacOS @@ -23,5 +23,5 @@ Windows support is provided via cross compilation. Mingw GCC C++ compiler is req $ make os=windows ``` -will create `bin/musique.exe` that can be used on x86_64 Windows operating systems. +will create `bin/musique.exe` that can be used on x86_64 Windows operating systems or use included Dockerfile diff --git a/config.mk b/config.mk index cc0f24f..c26d027 100644 --- a/config.mk +++ b/config.mk @@ -6,7 +6,7 @@ PATCH := 1 COMMIT := gc$(shell git rev-parse --short HEAD 2>/dev/null) ifeq ($(COMMIT),gc) - COMMIT = "gcunknown" + COMMIT = gcunknown endif VERSION := $(MAJOR).$(MINOR).$(PATCH)-dev+$(COMMIT)