Skip to content

Commit acc6743

Browse files
authored
Merge pull request #113 from codecrafters-io/andy/upgrade
[HTTP] CC-1594: Move away from alpine based buildpacks to debian based ones for C
2 parents 805033a + 865fedb commit acc6743

File tree

31 files changed

+309
-23
lines changed

31 files changed

+309
-23
lines changed

compiled_starters/c/.codecrafters/compile.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88

99
set -e # Exit on failure
1010

11-
gcc -lcurl -lz -o /tmp/codecrafters-build-http-server-c app/*.c
11+
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
12+
cmake --build ./build

compiled_starters/c/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
exec /tmp/codecrafters-build-http-server-c "$@"
11+
exec $(dirname $0)/build/http-server "$@"

compiled_starters/c/.gitignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
39+
# Debug files
40+
*.dSYM/
41+
*.su
42+
*.idb
43+
*.pdb
44+
45+
# Kernel Module Compile Results
46+
*.mod*
47+
*.cmd
48+
.tmp_versions/
49+
modules.order
50+
Module.symvers
51+
Mkfile.old
52+
dkms.conf
53+
54+
build
55+
vcpkg_installed

compiled_starters/c/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(codecrafters-http-server)
4+
5+
file(GLOB_RECURSE SOURCE_FILES src/*.c src/*.h)
6+
7+
set(CMAKE_C_STANDARD 23) # Enable the C23 standard
8+
9+
add_executable(http-server ${SOURCE_FILES})

compiled_starters/c/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ and more.
1616

1717
# Passing the first stage
1818

19-
The entry point for your HTTP server implementation is in `app/server.c`. Study
19+
The entry point for your HTTP server implementation is in `src/main.c`. Study
2020
and uncomment the relevant code, and push your changes to pass the first stage:
2121

2222
```sh
@@ -30,8 +30,8 @@ Time to move on to the next stage!
3030

3131
Note: This section is for stages 2 and beyond.
3232

33-
1. Ensure you have `gcc` installed locally
33+
1. Ensure you have `cmake` installed locally
3434
1. Run `./your_program.sh` to run your program, which is implemented in
35-
`app/server.c`.
35+
`src/main.c`.
3636
1. Commit your changes and run `git push origin master` to submit your solution
3737
to CodeCrafters. Test output will be streamed to your terminal.

compiled_starters/c/codecrafters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ debug: false
77
# Use this to change the C version used to run your code
88
# on Codecrafters.
99
#
10-
# Available versions: c-9.2
11-
language_pack: c-9.2
10+
# Available versions: c-23
11+
language_pack: c-23
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"default-registry": {
3+
"kind": "git",
4+
"baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d",
5+
"repository": "https://github.com/microsoft/vcpkg"
6+
},
7+
"registries": [
8+
{
9+
"kind": "artifact",
10+
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
11+
"name": "microsoft"
12+
}
13+
]
14+
}

compiled_starters/c/vcpkg.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dependencies": []
3+
}

compiled_starters/c/your_program.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ set -e # Exit early if any commands fail
1414
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
1515
(
1616
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
17-
gcc -lcurl -lz -o /tmp/codecrafters-build-http-server-c app/*.c
17+
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
18+
cmake --build ./build
1819
)
1920

2021
# Copied from .codecrafters/run.sh
2122
#
2223
# - Edit this to change how your program runs locally
2324
# - Edit .codecrafters/run.sh to change how your program runs remotely
24-
exec /tmp/codecrafters-build-http-server-c "$@"
25+
exec $(dirname $0)/build/http-server "$@"

0 commit comments

Comments
 (0)