Last active
December 9, 2018 09:06
-
-
Save twlz0ne/9faf00346a2acf10044c54f9ba0b9805 to your computer and use it in GitHub Desktop.
Debian 9 Docker image with Clang 6 installed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cd /ccls | |
rm -rf release | |
cmake -H. -Brelease \ | |
-DCMAKE_CXX_COMPILER=clang++-6.0 \ | |
-DCMAKE_PREFIX_PATH=/usr/lib/llvm-6.0 \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ | |
-DSYSTEM_CLANG=On \ | |
-DUSE_SHARED_LLVM=on | |
# -DCURSES_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libncurses.so \ | |
# -DCURSES_INCLUDE_PATH:PATH=/usr/include \ | |
# -DZLIB_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libz.so \ | |
# -DZLIB_INCLUDE_DIR:PATH=/usr/include \ | |
cmake --build release --target install | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function usage { | |
cat<<EOF | |
Usage: $0 [option] | |
Options: | |
-r|--refetch Refetch source code | |
EOF | |
} | |
function fetch { | |
git clone --depth 1 https://github.com/MaskRay/ccls | |
pushd ccls | |
git submodule update --init | |
popd | |
} | |
ostype=debian | |
tag=clang6-$ostype | |
if [ $# -gt 0 ]; then | |
case $1 in | |
-r|--refetch) rm -rf ccls; fetch;; | |
*) echo "Unknown option '$1'"; usage; exit 1;; | |
esac | |
fi | |
if [[ ! -d ccls ]]; then | |
fetch | |
fi | |
docker build --rm -t $tag -f Dockerfile . | |
docker run \ | |
-v $PWD/ccls:/ccls \ | |
--name ccls \ | |
--rm -it $tag:latest bash -c '/build-ccls.sh cd /ccls; exec "${SHELL:-sh}"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM launcher.gcr.io/google/debian9:latest | |
RUN apt-get update && apt-get install -y gnupg wget software-properties-common | |
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - | |
RUN apt-add-repository "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-6.0 main" | |
RUN apt-get update && apt-get install -y clang-6.0 | |
RUN apt-get -y install libclang-common-6.0-dev libclang-6.0-dev libclang1-6.0 libllvm6.0 llvm-6.0-dev | |
## ISSUE: | |
# CMake Error at /usr/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message): | |
# Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) | |
# Call Stack (most recent call first): | |
# /usr/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) | |
# /usr/share/cmake-3.7/Modules/FindCurses.cmake:196 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) | |
# cmake/FindClang.cmake:120 (find_package) | |
# CMakeLists.txt:108 (find_package) | |
RUN apt-get install -y libncurses5-dev | |
## ISSUE: | |
# CMake Error at /usr/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message): | |
# Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) | |
# Call Stack (most recent call first): | |
# /usr/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) | |
# /usr/share/cmake-3.7/Modules/FindZLIB.cmake:114 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) | |
# cmake/FindClang.cmake:121 (find_package) | |
# CMakeLists.txt:108 (find_package) | |
RUN apt-get install -y zlibc zlib1g zlib1g-dev | |
## ISSUE: | |
# CMake Error in CMakeLists.txt: | |
# Target "ccls" requires the language dialect "CXX17" , but CMake does not | |
# know the compile flags to use to enable it. | |
# | |
## Solution 1: Install cmake from source | |
# RUN apt-get install -y build-essential | |
# RUN wget http://www.cmake.org/files/v3.8/cmake-3.8.2.tar.gz && \ | |
# tar xf cmake-3.8.2.tar.gz && \ | |
# cd cmake-3.8.2 && \ | |
# ./configure && \ | |
# make && make install | |
# | |
## Solution 2: Install cmake official binary | |
RUN apt-get install -y make | |
RUN export version=3.8 && \ | |
export build=2 && \ | |
mkdir ~/temp && \ | |
cd ~/temp && \ | |
wget https://cmake.org/files/v$version/cmake-$version.$build-Linux-x86_64.sh && \ | |
mkdir /opt/cmake && \ | |
sh cmake-$version.$build-Linux-x86_64.sh --prefix=/opt/cmake --skip-license && \ | |
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake | |
## ISSUE: | |
# /usr/bin/clang++-6.0 -DDEFAULT_RESOURCE_DIRECTORY=\"/usr/lib/llvm-6.0/lib/clang/6.0.1\" -DLOGURU_FILENAME_WIDTH=18 -DLOGURU_THREADNAME_WIDTH=13 -DLOGURU_WITH_STREAMS=1 -I/ccls/src -I/ccls/third_party -I/ccls/third_party/rapidjson/include -I/ccls/third_party/loguru -I/ccls/third_party/doctest -isystem /usr/lib/llvm-6.0/include -O3 -DNDEBUG -fno-rtti -Wall -Wno-sign-compare -pthread -std=c++1z -o CMakeFiles/ccls.dir/src/cache_manager.cc.o -c /ccls/src/cache_manager.cc | |
# In file included from /ccls/src/cache_manager.cc:1: | |
# /ccls/src/cache_manager.h:3:10: fatal error: 'optional' file not found | |
# #include <optional> | |
# ^~~~~~~~~~ | |
# 1 error generated. | |
# CMakeFiles/ccls.dir/build.make:89: recipe for target 'CMakeFiles/ccls.dir/src/cache_manager.cc.o' failed | |
# make[2]: *** [CMakeFiles/ccls.dir/src/cache_manager.cc.o] Error 1 | |
# make[2]: Leaving directory '/ccls/release' | |
# CMakeFiles/Makefile2:70: recipe for target 'CMakeFiles/ccls.dir/all' failed | |
# make[1]: *** [CMakeFiles/ccls.dir/all] Error 2 | |
# make[1]: Leaving directory '/ccls/release' | |
# Makefile:132: recipe for target 'all' failed | |
# make: *** [all] Error 2 | |
RUN apt-add-repository "deb http://httpredir.debian.org/debian unstable main" | |
RUN apt-get update && apt-get -t unstable install -y libstdc++-7-dev | |
ADD ./build-ccls.sh /build-ccls.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Build ccls in docker container: