From 137472120272a557c24c761594311fcb2a394af5 Mon Sep 17 00:00:00 2001 From: huaijinwang Date: Wed, 7 Dec 2022 10:09:40 +0000 Subject: [PATCH] update Dockerfile, and force the env uses cmake and ninja in ./tools --- Dockerfile | 59 +++++++++++++++-------------------------------- build/envsetup.sh | 3 +++ 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1e5b20f81..0b250bd5a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,51 +1,30 @@ -FROM ubuntu:16.04 AS build-env +FROM ubuntu:18.04 AS build-env MAINTAINER https://www.openarkcompiler.cn # Setting up the build environment -RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list && \ - dpkg --add-architecture i386 && \ - apt-get -y update && \ - apt-get -y dist-upgrade && \ - apt-get -y install openjdk-8-jdk git-core build-essential zlib1g-dev libc6-dev-i386 g++-multilib gcc-multilib linux-libc-dev:i386 && \ - apt-get -y install gcc-5-aarch64-linux-gnu g++-5-aarch64-linux-gnu unzip tar curl && \ - apt-get -y install python3-paramiko python-paramiko python-requests && \ - mkdir -p /tools/ninja /tools/gn - -# 在国内请反注释下行, 因为容器也是个单独的系统,所以别用127.0.0.1 -#ENV http_proxy=http://192.168.3.81:1081 \ -# https_proxy=http://192.168.3.81:1081 - -RUN cd /tools && \ - curl -C - -LO http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz && \ - curl -LO https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip && \ - curl -LO http://tools.harmonyos.com/mirrors/gn/1523/linux/gn.1523.tar && \ - tar Jvxf /tools/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz -C /tools/ && \ - unzip /tools/ninja-linux.zip -d /tools/ninja/ && \ - tar xvf /tools/gn.1523.tar && \ - chmod a+x /tools/gn/gn && \ - rm /tools/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz /tools/ninja-linux.zip && \ - rm -rf /var/cache/apt/archives +RUN apt-get -y update +RUN apt-get -y install clang llvm lld libelf-dev libssl-dev python \ + qemu openjdk-8-jre-headless openjdk-8-jdk-headless git build-essential \ + zlib1g-dev libc6-dev-i386 gcc-7-aarch64-linux-gnu g++-7-aarch64-linux-gnu \ + lsb-core wget zip curl # copy source COPY . /OpenArkCompiler WORKDIR /OpenArkCompiler -# create symbolic link -RUN mkdir -p /OpenArkCompiler/tools /OpenArkCompiler/tools/gn && \ - ln -s /tools/ninja /OpenArkCompiler/tools/ninja_1.9.0 && \ - ln -s /tools/gn/gn /OpenArkCompiler/tools/gn/gn && \ - ln -s /tools/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04 /OpenArkCompiler/tools/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04 +# use the latest cmake +WORKDIR /OpenArkCompiler/tools +# change the version as you need +RUN wget https://github.com/Kitware/CMake/releases/download/v3.24.3/cmake-3.24.3-linux-x86_64.tar.gz && \ + tar -xf cmake-3.24.3-linux-x86_64.tar.gz && ln -s cmake-3.24.3-linux-x86_64 cmake +ENV PATH="/OpenArkCompiler/tools/cmake/bin:/$PATH" + +# build env +# this will take a long time. +WORKDIR /OpenArkCompiler +RUN ["/bin/bash", "-c", "source build/envsetup.sh arm release && make setup"] # compile -RUN ["/bin/bash", "-c", "source build/envsetup.sh && make && ls -al "] +ENV PATH="/OpenArkCompiler/tools/cmake/bin:/OpenArkCompiler/tools/ninja:/$PATH" +RUN ["/bin/bash", "-c", "source build/envsetup.sh arm release && make setup && make"] -# build final docker image -FROM ubuntu:16.04 -RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list && \ - apt-get -y update && \ - apt-get install -y openjdk-8-jdk curl vim && \ - rm -rf /var/cache/apt/archives -COPY --from=build-env /OpenArkCompiler/output /OpenArkCompiler -VOLUME /OpenArkCompiler -ENV PATH=/OpenArkCompiler/bin:$PATH -CMD maple -h diff --git a/build/envsetup.sh b/build/envsetup.sh index 0a363eac85..eba899daa0 100644 --- a/build/envsetup.sh +++ b/build/envsetup.sh @@ -26,6 +26,9 @@ if [ "$#" -lt 2 ]; then fi curdir=$(pwd) +# force to use local cmake and ninja +export PATH=${curdir}/tools/cmake/bin:${curdir}/tools/ninja:$PATH + export MAPLE_ROOT=${curdir} export SPEC=${MAPLE_ROOT}/testsuite/c_test/spec_test export LD_LIBRARY_PATH=${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib:${MAPLE_ROOT}/tools/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-18.04/lib:${LD_LIBRARY_PATH} -- Gitee