在 Alpine Linux Docker 容器中构建 GNATCOLL
Building GNATCOLL in an Alpine Linux Docker Container
我似乎无法让 GNATCOLL 在基于 Alpine Linux 的 Docker 容器中编译。
目前我的容器是:
FROM alpine:edge
# Add extra repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories; \
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories; \
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories;
RUN apk add --no-cache build-base coreutils curl-dev gcc-gnat git gmp-dev openssl
# Bootstrap GPRBuild
RUN git clone https://github.com/AdaCore/xmlada.git; \
git clone https://github.com/AdaCore/gprbuild.git; \
cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada; \
cd ..; \
rm -rf xmlada gprbuild
这工作正常,并为我提供了一个容器,其中包含一个基于 GNAT GPR 的 Ada 开发环境。当我尝试在此容器中安装 GNATCOLL 时出现问题。
运行 docker run -i -t <built_image>
发生以下情况:
/ # git clone https://github.com/AdaCore/gnatcoll-core.git
<Typical git clone output>
/ # cd gnatcoll-core/
/gnatcoll-core # make setup
/gnatcoll-core # make
gprbuild -p -m --target=x86_64-linux -j0 -XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static \
-XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD gnatcoll.gpr
Setup
[mkdir] object directory for project GnatColl
[mkdir] library directory for project GnatColl
gnatcoll.gpr:24:06: unknown project file: "gpr"
make: *** [Makefile:128: build-static] Error 4
根据 https://github.com/AdaCore/gnatcoll-core/issues/30 中的讨论,我检查了我的 gprbuild 版本:
/gnatcoll-core # gprbuild --version
GPRBUILD Pro 18.0w (19940713) (x86_64-alpine-linux-musl)
Copyright (C) 2004-2016, AdaCore
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
所以 musl 的 gprbuild 似乎已经过时了,导致无法构建 GNATCOLL。有没有办法为 musl-c 获取更新版本的 gprbuild?如果没有,还有其他方法可以安装 GNATCOLL 吗?
问题是 gprbuild 中的 ./bootstrap.sh
并没有安装所有东西,它只是创建了一个最低限度的 gprbuild 安装。此外,它不构建 gprlib,gprlib 是 gnatcoll 所必需的,也必须安装。
所需的步骤是:
# As before...
git clone https://github.com/AdaCore/xmlada.git
git clone https://github.com/AdaCore/gprbuild.git
cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada
# New: build and install xmlada
cd ../xmlada; ./configure && make && make install
# New: build and install gprbuild fully
cd ../gprbuild
export GPR_PROJECT_PATH=/usr/local/share/gpr
make prefix=/usr/local setup && make all && make install
# New: build and install gprlib
make libgpr.build && make libgpr.install
通过这些添加,我能够按照其项目中的指定构建 gnatcoll。
我似乎无法让 GNATCOLL 在基于 Alpine Linux 的 Docker 容器中编译。
目前我的容器是:
FROM alpine:edge
# Add extra repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories; \
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories; \
echo 'http://dl-cdn.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories;
RUN apk add --no-cache build-base coreutils curl-dev gcc-gnat git gmp-dev openssl
# Bootstrap GPRBuild
RUN git clone https://github.com/AdaCore/xmlada.git; \
git clone https://github.com/AdaCore/gprbuild.git; \
cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada; \
cd ..; \
rm -rf xmlada gprbuild
这工作正常,并为我提供了一个容器,其中包含一个基于 GNAT GPR 的 Ada 开发环境。当我尝试在此容器中安装 GNATCOLL 时出现问题。
运行 docker run -i -t <built_image>
发生以下情况:
/ # git clone https://github.com/AdaCore/gnatcoll-core.git
<Typical git clone output>
/ # cd gnatcoll-core/
/gnatcoll-core # make setup
/gnatcoll-core # make
gprbuild -p -m --target=x86_64-linux -j0 -XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static \
-XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD gnatcoll.gpr
Setup
[mkdir] object directory for project GnatColl
[mkdir] library directory for project GnatColl
gnatcoll.gpr:24:06: unknown project file: "gpr"
make: *** [Makefile:128: build-static] Error 4
根据 https://github.com/AdaCore/gnatcoll-core/issues/30 中的讨论,我检查了我的 gprbuild 版本:
/gnatcoll-core # gprbuild --version
GPRBUILD Pro 18.0w (19940713) (x86_64-alpine-linux-musl)
Copyright (C) 2004-2016, AdaCore
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
所以 musl 的 gprbuild 似乎已经过时了,导致无法构建 GNATCOLL。有没有办法为 musl-c 获取更新版本的 gprbuild?如果没有,还有其他方法可以安装 GNATCOLL 吗?
问题是 gprbuild 中的 ./bootstrap.sh
并没有安装所有东西,它只是创建了一个最低限度的 gprbuild 安装。此外,它不构建 gprlib,gprlib 是 gnatcoll 所必需的,也必须安装。
所需的步骤是:
# As before...
git clone https://github.com/AdaCore/xmlada.git
git clone https://github.com/AdaCore/gprbuild.git
cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada
# New: build and install xmlada
cd ../xmlada; ./configure && make && make install
# New: build and install gprbuild fully
cd ../gprbuild
export GPR_PROJECT_PATH=/usr/local/share/gpr
make prefix=/usr/local setup && make all && make install
# New: build and install gprlib
make libgpr.build && make libgpr.install
通过这些添加,我能够按照其项目中的指定构建 gnatcoll。