-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from codecrafters-io/CC-1222-cpp-upgrade
CC-1222: update cpp version, and add vcpkg support for dependency resolution
- Loading branch information
Showing
20 changed files
with
140 additions
and
24 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
project(grep-starter-cpp) | ||
set(CMAKE_CXX_STANDARD 20) # Enable the C++20 standard | ||
|
||
file(GLOB_RECURSE SOURCE_FILES src/*.cpp) | ||
set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard | ||
|
||
file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp) | ||
|
||
add_executable(server ${SOURCE_FILES}) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"default-registry": { | ||
"kind": "git", | ||
"baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", | ||
"repository": "https://github.com/microsoft/vcpkg" | ||
}, | ||
"registries": [ | ||
{ | ||
"kind": "artifact", | ||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", | ||
"name": "microsoft" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dependencies": [] | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM gcc:13.2.0-bookworm | ||
|
||
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="vcpkg.json,vcpkg-configuration.json" | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y zip=3.* && \ | ||
apt-get install --no-install-recommends -y g++=4:* && \ | ||
apt-get install --no-install-recommends -y build-essential=12.* && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# cmake 3.29.2 is required by vcpkg | ||
RUN wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-Linux-x86_64.tar.gz && \ | ||
tar -xzvf cmake-3.29.2-Linux-x86_64.tar.gz && \ | ||
mv cmake-3.29.2-linux-x86_64/ /cmake | ||
|
||
ENV CMAKE_BIN="/cmake/bin" | ||
ENV PATH="${CMAKE_BIN}:$PATH" | ||
|
||
RUN git clone https://github.com/microsoft/vcpkg.git && \ | ||
./vcpkg/bootstrap-vcpkg.sh -disableMetrics | ||
|
||
ENV VCPKG_ROOT="/vcpkg" | ||
ENV PATH="${VCPKG_ROOT}:$PATH" | ||
|
||
WORKDIR /app | ||
|
||
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses | ||
COPY --exclude=.git --exclude=README.md . /app | ||
|
||
RUN vcpkg install --no-print-usage | ||
RUN sed -i '1s/^/set(VCPKG_INSTALL_OPTIONS --no-print-usage)\n/' ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake | ||
|
||
RUN mkdir -p /app-cached/build | ||
RUN if [ -d "/app/build" ]; then mv /app/build /app-cached; fi | ||
RUN if [ -d "/app/vcpkg_installed" ]; then mv /app/vcpkg_installed /app-cached/build; fi | ||
|
||
RUN echo "cd \${CODECRAFTERS_SUBMISSION_DIR} && cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && cmake --build ./build && sed -i '/^cmake/ s/^/# /' ./your_grep.sh" > /codecrafters-precompile.sh | ||
RUN chmod +x /codecrafters-precompile.sh | ||
|
||
# Once the heavy steps are done, we can copy all files back | ||
COPY . /app |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
project(grep-starter-cpp) | ||
set(CMAKE_CXX_STANDARD 20) # Enable the C++20 standard | ||
|
||
file(GLOB_RECURSE SOURCE_FILES src/*.cpp) | ||
set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard | ||
|
||
file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp) | ||
|
||
add_executable(server ${SOURCE_FILES}) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"default-registry": { | ||
"kind": "git", | ||
"baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", | ||
"repository": "https://github.com/microsoft/vcpkg" | ||
}, | ||
"registries": [ | ||
{ | ||
"kind": "artifact", | ||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", | ||
"name": "microsoft" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dependencies": [] | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
project(grep-starter-cpp) | ||
set(CMAKE_CXX_STANDARD 20) # Enable the C++20 standard | ||
|
||
file(GLOB_RECURSE SOURCE_FILES src/*.cpp) | ||
set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard | ||
|
||
file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp) | ||
|
||
add_executable(server ${SOURCE_FILES}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"default-registry": { | ||
"kind": "git", | ||
"baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", | ||
"repository": "https://github.com/microsoft/vcpkg" | ||
}, | ||
"registries": [ | ||
{ | ||
"kind": "artifact", | ||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", | ||
"name": "microsoft" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dependencies": [] | ||
} |
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