Skip to content

Commit 7bcfe28

Browse files
committed
[minor] Use Docker to compile C file
1 parent befe5c9 commit 7bcfe28

File tree

3 files changed

+60
-19
lines changed

3 files changed

+60
-19
lines changed

src/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Available at https://hub.docker.com/r/mlocati/powershell-phpmanager-src
2+
3+
FROM ubuntu:18.04
4+
5+
LABEL maintainer="[email protected]"
6+
7+
ARG DEBIAN_FRONTEND=noninteractive
8+
9+
RUN \
10+
apt-get update -q \
11+
&& apt-get upgrade -y \
12+
&& apt-get install -y -q --no-install-recommends \
13+
autoconf \
14+
automake \
15+
autopoint \
16+
bison \
17+
bzip2 \
18+
flex \
19+
g++ \
20+
g++-multilib \
21+
gettext \
22+
git \
23+
gperf \
24+
intltool \
25+
libc6-dev-i386 \
26+
libltdl-dev \
27+
libssl-dev \
28+
libtool-bin \
29+
lzip \
30+
make \
31+
openssl \
32+
p7zip-full \
33+
patch \
34+
perl \
35+
pkg-config \
36+
python \
37+
ruby \
38+
sed \
39+
unzip \
40+
wget \
41+
xz-utils \
42+
&& git clone --depth 1 https://github.com/mxe/mxe.git /opt/mxe \
43+
&& cd /opt/mxe \
44+
&& make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' cc \
45+
&& apt-get clean \
46+
&& rm -rf /var/lib/apt/lists/* \
47+
&& rm -rf /opt/mxe/.log \
48+
&& rm -rf /opt/mxe/pkg
49+
50+
ENV PATH="/opt/mxe/usr/bin:${PATH}"

src/compile

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
#!/bin/sh
22

33
set -o errexit
4-
if ! test -f /usr/lib/mxe/usr/bin/i686-w64-mingw32.static-gcc -a -f /usr/lib/mxe/usr/bin/x86_64-w64-mingw32.static-gcc
5-
then
6-
if ! test -f /etc/apt/sources.list.d/mxeapt.list
7-
then
8-
echo 'Configuring MXE'
9-
sudo sh -c "echo 'deb http://pkg.mxe.cc/repos/apt/debian wheezy main' >> /etc/apt/sources.list.d/mxeapt.list"
10-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D43A795B73B16ABE9643FE1AFD8FFF16DB45C6AB
11-
fi
12-
echo 'Installing MXE'
13-
sudo apt-get update
14-
sudo apt-get install --yes mxe-i686-w64-mingw32.static-gcc mxe-x86-64-w64-mingw32.static-gcc
15-
fi
16-
echo 'Compiling with MXE'
17-
make
4+
5+
docker --version || (
6+
echo Please install Docker. >&2
7+
exit 1
8+
)
9+
10+
docker run --rm --volume "$(CDPATH= cd -- "$(dirname -- "$0")" && cd .. && pwd)":/app --workdir /app/src mlocati/powershell-phpmanager-src:latest make

src/compile.bat

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
@echo off
22
setlocal
3-
bash.exe --version >NUL 2>NUL
3+
docker.exe --version >NUL 2>NUL
44
if errorlevel 1 (
5-
echo Please enable Windows Subsystem for Linux. >&2
5+
echo Please install Docker for Windows. >&2
66
exit /b 1
77
)
88

9-
cd /D "%~dp0"
10-
11-
bash -c "sh ./compile"
9+
docker run --rm --volume "%~dp0..":/app --workdir /app/src mlocati/powershell-phpmanager-src:latest make

0 commit comments

Comments
 (0)