From 93df3fee9ced7633ab08c59c1d72a9ac9bc9e302 Mon Sep 17 00:00:00 2001 From: Le Bao Hiep Date: Tue, 5 Sep 2023 10:32:15 +0700 Subject: [PATCH] Move downloading testlib and precompiling headers to dedicated script Also precompile headers for multiple C++ versions --- .docker/download_testlib_and_precompile | 28 +++++++++++++++++++++++++ .docker/tier1/Dockerfile | 8 +------ .docker/tier2/Dockerfile | 8 +------ .docker/tier3/Dockerfile | 8 +------ .docker/tiervnoj/Dockerfile | 8 +------ 5 files changed, 32 insertions(+), 28 deletions(-) create mode 100755 .docker/download_testlib_and_precompile diff --git a/.docker/download_testlib_and_precompile b/.docker/download_testlib_and_precompile new file mode 100755 index 000000000..67c0443bf --- /dev/null +++ b/.docker/download_testlib_and_precompile @@ -0,0 +1,28 @@ +#!/bin/bash + +FLAGS="-Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s" + +# Download and precompile testlib.h +curl -L https://raw.githubusercontent.com/VNOI-Admin/testlib/master/testlib.h -o /usr/include/testlib.h +sed -i '/^#include /a#include ' /usr/include/testlib.h +g++ -std=c++17 $FLAGS /usr/include/testlib.h + +# Download and precompile testlib_themis_cms.h +curl -L https://raw.githubusercontent.com/skyvn97/testlib/customized-testlib/testlib_themis_cms.h -o /usr/include/testlib_themis_cms.h +sed -i '/^#include /a#include ' /usr/include/testlib_themis_cms.h +mkdir -p /usr/include/testlib_themis_cms.h.gch +g++ -std=c++17 $FLAGS -DTHEMIS /usr/include/testlib_themis_cms.h -o /usr/include/testlib_themis_cms.h.gch/themis +g++ -std=c++17 $FLAGS -DCMS /usr/include/testlib_themis_cms.h -o /usr/include/testlib_themis_cms.h.gch/cms + +# Precompile bits/stdc++.h +IFS=$'\n' files=( $(find /usr/include/ -name stdc++.h) ); +for item in "${files[@]}"; { + GCH_DIR="$item".gch + mkdir -p $GCH_DIR + g++ -std=c++03 $FLAGS -o $GCH_DIR/cpp03 $item + g++ -std=c++11 $FLAGS -o $GCH_DIR/cpp11 $item + g++ -std=c++14 $FLAGS -o $GCH_DIR/cpp14 $item + g++ -std=c++17 $FLAGS -o $GCH_DIR/cpp17 $item + g++ -std=c++20 $FLAGS -o $GCH_DIR/cpp20 $item + g++ -std=c++14 -pipe -O2 -s -static -DTHEMIS -o $GCH_DIR/cppthemis $item +} diff --git a/.docker/tier1/Dockerfile b/.docker/tier1/Dockerfile index 49a643779..e3b3f4cee 100644 --- a/.docker/tier1/Dockerfile +++ b/.docker/tier1/Dockerfile @@ -22,12 +22,6 @@ RUN mkdir /judge /problems && cd /judge && \ HOME=~judge . ~judge/.profile && \ runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \ echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml && \ - curl -L https://raw.githubusercontent.com/VNOI-Admin/testlib/master/testlib.h -o /usr/include/testlib.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s /usr/include/testlib.h && \ - curl -L https://raw.githubusercontent.com/skyvn97/testlib/customized-testlib/testlib_themis_cms.h -o /usr/include/testlib_themis_cms.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib_themis_cms.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -DTHEMIS -O2 -fmax-errors=5 -march=native -s /usr/include/testlib_themis_cms.h && \ - find /usr/include/ -name stdc++.h -exec g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s {} \; + /judge/.docker/download_testlib_and_precompile ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"] diff --git a/.docker/tier2/Dockerfile b/.docker/tier2/Dockerfile index 7d19c09bb..10731f6e3 100644 --- a/.docker/tier2/Dockerfile +++ b/.docker/tier2/Dockerfile @@ -22,12 +22,6 @@ RUN mkdir /judge /problems && cd /judge && \ HOME=~judge . ~judge/.profile && \ runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \ echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml && \ - curl -L https://raw.githubusercontent.com/VNOI-Admin/testlib/master/testlib.h -o /usr/include/testlib.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s /usr/include/testlib.h && \ - curl -L https://raw.githubusercontent.com/skyvn97/testlib/customized-testlib/testlib_themis_cms.h -o /usr/include/testlib_themis_cms.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib_themis_cms.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -DTHEMIS -O2 -fmax-errors=5 -march=native -s /usr/include/testlib_themis_cms.h && \ - find /usr/include/ -name stdc++.h -exec g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s {} \; + /judge/.docker/download_testlib_and_precompile ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"] diff --git a/.docker/tier3/Dockerfile b/.docker/tier3/Dockerfile index 62ad189fb..97563ee1b 100644 --- a/.docker/tier3/Dockerfile +++ b/.docker/tier3/Dockerfile @@ -22,12 +22,6 @@ RUN mkdir /judge /problems && cd /judge && \ HOME=~judge . ~judge/.profile && \ runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \ echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml && \ - curl -L https://raw.githubusercontent.com/VNOI-Admin/testlib/master/testlib.h -o /usr/include/testlib.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s /usr/include/testlib.h && \ - curl -L https://raw.githubusercontent.com/skyvn97/testlib/customized-testlib/testlib_themis_cms.h -o /usr/include/testlib_themis_cms.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib_themis_cms.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -DTHEMIS -O2 -fmax-errors=5 -march=native -s /usr/include/testlib_themis_cms.h && \ - find /usr/include/ -name stdc++.h -exec g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s {} \; + /judge/.docker/download_testlib_and_precompile ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"] diff --git a/.docker/tiervnoj/Dockerfile b/.docker/tiervnoj/Dockerfile index e2c002116..3de463ce4 100644 --- a/.docker/tiervnoj/Dockerfile +++ b/.docker/tiervnoj/Dockerfile @@ -47,12 +47,6 @@ RUN mkdir /judge /problems && cd /judge && \ HOME=~judge . ~judge/.profile && \ runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \ echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml && \ - curl -L https://raw.githubusercontent.com/VNOI-Admin/testlib/master/testlib.h -o /usr/include/testlib.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s /usr/include/testlib.h && \ - curl -L https://raw.githubusercontent.com/skyvn97/testlib/customized-testlib/testlib_themis_cms.h -o /usr/include/testlib_themis_cms.h && \ - sed -i '/^#include /a#include ' /usr/include/testlib_themis_cms.h && \ - g++ -std=c++17 -Wall -DONLINE_JUDGE -DTHEMIS -O2 -fmax-errors=5 -march=native -s /usr/include/testlib_themis_cms.h && \ - find /usr/include/ -name stdc++.h -exec g++ -std=c++17 -Wall -DONLINE_JUDGE -O2 -fmax-errors=5 -march=native -s {} \; + /judge/.docker/download_testlib_and_precompile ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"]