我似乎无法让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.

因此,似乎musg的gprbuild太过时了,导致无法构建GNATCOLL。有什么办法可以为musl-c获取gprbuild的最新版本?如果没有,还有其他方法可以安装GNATCOLL吗?

最佳答案

问题是gprbuild中的./bootstrap.sh不会安装所有内容,而只是创建了最少的gprbuild安装。此外,它不会构建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。

08-28 15:36