File tree Expand file tree Collapse file tree 9 files changed +27
-14
lines changed Expand file tree Collapse file tree 9 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13)
22
33project (shell-starter-cpp)
44
5- file (GLOB_RECURSE SOURCE_FILES src/*.cpp)
5+ file (GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp )
66
77set (CMAKE_CXX_STANDARD 23) # Enable the C++23 standard
88
Original file line number Diff line number Diff line change 11#include < iostream>
22
33int main () {
4+ // Flush after every std::cout / std:cerr
5+ std::cout << std::unitbuf;
6+ std::cerr << std::unitbuf;
7+
48 // You can use print statements as follows for debugging, they'll be visible when running tests.
59 std::cout << " Logs from your program will appear here!\n " ;
610
711 // Uncomment this block to pass the first stage
812 // std::cout << "$ ";
9- // std::cout.flush();
1013 //
1114 // std::string input;
1215 // std::getline(std::cin, input);
Original file line number Diff line number Diff line change @@ -18,15 +18,15 @@ ENV CMAKE_BIN="/cmake/bin"
1818ENV PATH="${CMAKE_BIN}:$PATH"
1919
2020RUN git clone https://github.com/microsoft/vcpkg.git && \
21- ./vcpkg/bootstrap-vcpkg.sh
21+ ./vcpkg/bootstrap-vcpkg.sh -disableMetrics
2222
2323ENV VCPKG_ROOT="/vcpkg"
2424ENV PATH="${VCPKG_ROOT}:$PATH"
2525
2626WORKDIR /app
2727
28- COPY vcpkg.json ./
29- COPY vcpkg-configuration.json ./
28+ # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
29+ COPY --exclude=.git --exclude=README.md . /app
3030
3131RUN vcpkg install --no-print-usage
3232RUN sed -i '1s/^/set(VCPKG_INSTALL_OPTIONS --no-print-usage)\n /' ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
@@ -36,4 +36,7 @@ RUN if [ -d "/app/build" ]; then mv /app/build /app-cached; fi
3636RUN if [ -d "/app/vcpkg_installed" ]; then mv /app/vcpkg_installed /app-cached/build; fi
3737
3838RUN 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_shell.sh" > /codecrafters-precompile.sh
39- RUN chmod +x /codecrafters-precompile.sh
39+ RUN chmod +x /codecrafters-precompile.sh
40+
41+ # Once the heavy steps are done, we can copy all files back
42+ COPY . /app
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13)
22
33project (shell-starter-cpp)
44
5- file (GLOB_RECURSE SOURCE_FILES src/*.cpp)
5+ file (GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp )
66
77set (CMAKE_CXX_STANDARD 23) # Enable the C++23 standard
88
Original file line number Diff line number Diff line change 11#include < iostream>
22
33int main () {
4+ // Flush after every std::cout / std:cerr
5+ std::cout << std::unitbuf;
6+ std::cerr << std::unitbuf;
7+
48 std::cout << " $ " ;
5- std::cout.flush ();
69
710 std::string input;
811 std::getline (std::cin, input);
Original file line number Diff line number Diff line change 1- @@ -1,13 +1,9 @@
1+ @@ -1,16 +1,12 @@
22 #include <iostream>
33
44 int main() {
5+ // Flush after every std::cout / std:cerr
6+ std::cout << std::unitbuf;
7+ std::cerr << std::unitbuf;
8+
59- // You can use print statements as follows for debugging, they'll be visible when running tests.
610- std::cout << "Logs from your program will appear here!\n";
711+ std::cout << "$ ";
8- + std::cout.flush();
912
1013- // Uncomment this block to pass the first stage
1114- // std::cout << "$ ";
12- - // std::cout.flush();
1315- //
1416- // std::string input;
1517- // std::getline(std::cin, input);
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ Study and uncomment the relevant code:
55``` cpp
66// Uncomment this block to pass the first stage
77std::cout << " $ " ;
8- std::cout.flush();
98
109std::string input;
1110std::getline (std::cin, input);
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13)
22
33project (shell-starter-cpp)
44
5- file (GLOB_RECURSE SOURCE_FILES src/*.cpp)
5+ file (GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp )
66
77set (CMAKE_CXX_STANDARD 23) # Enable the C++23 standard
88
Original file line number Diff line number Diff line change 11#include < iostream>
22
33int main () {
4+ // Flush after every std::cout / std:cerr
5+ std::cout << std::unitbuf;
6+ std::cerr << std::unitbuf;
7+
48 // You can use print statements as follows for debugging, they'll be visible when running tests.
59 std::cout << " Logs from your program will appear here!\n " ;
610
711 // Uncomment this block to pass the first stage
812 // std::cout << "$ ";
9- // std::cout.flush();
1013 //
1114 // std::string input;
1215 // std::getline(std::cin, input);
You can’t perform that action at this time.
0 commit comments