Skip to content

Commit

Permalink
remote test
Browse files Browse the repository at this point in the history
  • Loading branch information
andy1li committed Oct 24, 2024
1 parent 8024401 commit d04b6d7
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 27 deletions.
3 changes: 2 additions & 1 deletion compiled_starters/c/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

set -e # Exit on failure

gcc -o /tmp/codecrafters-build-interpreter-c app/*.c
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
cmake --build ./build
2 changes: 1 addition & 1 deletion compiled_starters/c/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec /tmp/codecrafters-build-interpreter-c "$@"
exec ./build/redis "$@"
10 changes: 10 additions & 0 deletions compiled_starters/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.13)

project(redis-starter-c)

file(GLOB_RECURSE SOURCE_FILES app/*.c)

set(CMAKE_C_STANDARD 23) # Enable the C23 standard
set(THREADS_PREFER_PTHREAD_FLAG ON)

add_executable(redis ${SOURCE_FILES})
4 changes: 2 additions & 2 deletions compiled_starters/c/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the C version used to run your code
# on Codecrafters.
#
# Available versions: c-14.2
language_pack: c-14.2
# Available versions: c-23
language_pack: c-23
14 changes: 14 additions & 0 deletions compiled_starters/c/vcpkg-configuration.json
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"
}
]
}
6 changes: 6 additions & 0 deletions compiled_starters/c/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": [
"asio",
"pthreads"
]
}
5 changes: 3 additions & 2 deletions compiled_starters/c/your_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ set -e # Exit early if any commands fail
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
(
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
gcc -o /tmp/codecrafters-build-interpreter-c app/*.c
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
cmake --build ./build
)

# Copied from .codecrafters/run.sh
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec /tmp/codecrafters-build-interpreter-c "$@"
exec ./build/redis "$@"
13 changes: 0 additions & 13 deletions dockerfiles/c-14.2.Dockerfile

This file was deleted.

43 changes: 43 additions & 0 deletions dockerfiles/c-23.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# syntax=docker/dockerfile:1.7-labs
FROM gcc:14.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"

# Ensures the container is re-built if dependency files change
# ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="<placeholder-dependency-files>"

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

# Install language-specific dependencies
RUN .codecrafters/compile.sh
3 changes: 2 additions & 1 deletion solutions/c/01-ry8/code/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

set -e # Exit on failure

gcc -o /tmp/codecrafters-build-interpreter-c app/*.c
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
cmake --build ./build
2 changes: 1 addition & 1 deletion solutions/c/01-ry8/code/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec /tmp/codecrafters-build-interpreter-c "$@"
exec ./build/redis "$@"
10 changes: 10 additions & 0 deletions solutions/c/01-ry8/code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.13)

project(redis-starter-c)

file(GLOB_RECURSE SOURCE_FILES app/*.c)

set(CMAKE_C_STANDARD 23) # Enable the C23 standard
set(THREADS_PREFER_PTHREAD_FLAG ON)

add_executable(redis ${SOURCE_FILES})
4 changes: 2 additions & 2 deletions solutions/c/01-ry8/code/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the C version used to run your code
# on Codecrafters.
#
# Available versions: c-14.2
language_pack: c-14.2
# Available versions: c-23
language_pack: c-23
14 changes: 14 additions & 0 deletions solutions/c/01-ry8/code/vcpkg-configuration.json
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"
}
]
}
6 changes: 6 additions & 0 deletions solutions/c/01-ry8/code/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": [
"asio",
"pthreads"
]
}
5 changes: 3 additions & 2 deletions solutions/c/01-ry8/code/your_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ set -e # Exit early if any commands fail
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
(
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
gcc -o /tmp/codecrafters-build-interpreter-c app/*.c
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
cmake --build ./build
)

# Copied from .codecrafters/run.sh
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec /tmp/codecrafters-build-interpreter-c "$@"
exec ./build/redis "$@"
3 changes: 2 additions & 1 deletion starter_templates/c/code/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

set -e # Exit on failure

gcc -o /tmp/codecrafters-build-interpreter-c app/*.c
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
cmake --build ./build
2 changes: 1 addition & 1 deletion starter_templates/c/code/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec /tmp/codecrafters-build-interpreter-c "$@"
exec ./build/redis "$@"
10 changes: 10 additions & 0 deletions starter_templates/c/code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.13)

project(redis-starter-c)

file(GLOB_RECURSE SOURCE_FILES app/*.c)

set(CMAKE_C_STANDARD 23) # Enable the C23 standard
set(THREADS_PREFER_PTHREAD_FLAG ON)

add_executable(redis ${SOURCE_FILES})
14 changes: 14 additions & 0 deletions starter_templates/c/code/vcpkg-configuration.json
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"
}
]
}
6 changes: 6 additions & 0 deletions starter_templates/c/code/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": [
"asio",
"pthreads"
]
}

0 comments on commit d04b6d7

Please sign in to comment.