From 5d9e9c021ad554716671ccff1b975f04403acba1 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 12 Dec 2025 02:48:40 +0200 Subject: [PATCH] aoc2025: Prepare programming environment --- userspace/CMakeLists.txt | 1 + userspace/aoc2025/CMakeLists.txt | 25 ++++++++++ userspace/aoc2025/day-template/CMakeLists.txt | 9 ++++ userspace/aoc2025/day-template/main.cpp | 47 +++++++++++++++++++ userspace/aoc2025/full/CMakeLists.txt | 9 ++++ userspace/aoc2025/full/main.cpp | 22 +++++++++ userspace/aoc2025/init-day.sh | 15 ++++++ userspace/aoc2025/input/.gitignore | 1 + 8 files changed, 129 insertions(+) create mode 100644 userspace/aoc2025/CMakeLists.txt create mode 100644 userspace/aoc2025/day-template/CMakeLists.txt create mode 100644 userspace/aoc2025/day-template/main.cpp create mode 100644 userspace/aoc2025/full/CMakeLists.txt create mode 100644 userspace/aoc2025/full/main.cpp create mode 100755 userspace/aoc2025/init-day.sh create mode 100644 userspace/aoc2025/input/.gitignore diff --git a/userspace/CMakeLists.txt b/userspace/CMakeLists.txt index b788639b..e8d66ed1 100644 --- a/userspace/CMakeLists.txt +++ b/userspace/CMakeLists.txt @@ -2,6 +2,7 @@ add_custom_target(userspace) #add_subdirectory(aoc2023) #add_subdirectory(aoc2024) +#add_subdirectory(aoc2025) add_subdirectory(libraries) add_subdirectory(programs) add_subdirectory(tests) diff --git a/userspace/aoc2025/CMakeLists.txt b/userspace/aoc2025/CMakeLists.txt new file mode 100644 index 00000000..c0f723e0 --- /dev/null +++ b/userspace/aoc2025/CMakeLists.txt @@ -0,0 +1,25 @@ +set(AOC2025_PROJECTS + full +) + +set(BANAN_AOC2025_BIN ${CMAKE_INSTALL_BINDIR}/aoc2025) +set(BANAN_AOC2025_INPUT ${BANAN_SHARE}/aoc2025) + +set(CMAKE_INSTALL_BINDIR ${BANAN_AOC2025_BIN}) + +add_custom_target(aoc2025) + +file(GLOB_RECURSE input_files "input/*") +foreach(file ${input_files}) + install(FILES ${file} DESTINATION ${BANAN_AOC2025_INPUT}) +endforeach() + +foreach(AOC2025_PROJECT ${AOC2025_PROJECTS}) + add_subdirectory(${AOC2025_PROJECT}) + add_dependencies(aoc2025 aoc2025_${AOC2025_PROJECT}) + + target_link_options(aoc2025_${AOC2025_PROJECT} PRIVATE -nolibc) + target_compile_options(aoc2025_${AOC2025_PROJECT} PRIVATE -g -O2 -Wall -Wextra -Werror) +endforeach() + +add_dependencies(userspace aoc2025) diff --git a/userspace/aoc2025/day-template/CMakeLists.txt b/userspace/aoc2025/day-template/CMakeLists.txt new file mode 100644 index 00000000..2183775d --- /dev/null +++ b/userspace/aoc2025/day-template/CMakeLists.txt @@ -0,0 +1,9 @@ +set(SOURCES + main.cpp +) + +add_executable(aoc2025_day-template ${SOURCES}) +banan_include_headers(aoc2025_day-template ban) +banan_link_library(aoc2025_day-template libc) + +install(TARGETS aoc2025_day-template OPTIONAL) diff --git a/userspace/aoc2025/day-template/main.cpp b/userspace/aoc2025/day-template/main.cpp new file mode 100644 index 00000000..334bd355 --- /dev/null +++ b/userspace/aoc2025/day-template/main.cpp @@ -0,0 +1,47 @@ +#include +#include + +using i8 = int8_t; +using i16 = int16_t; +using i32 = int32_t; +using i64 = int64_t; + +using u8 = uint8_t; +using u16 = uint16_t; +using u32 = uint32_t; +using u64 = uint64_t; + +i64 part1(FILE* fp) +{ + (void)fp; + return -1; +} + +i64 part2(FILE* fp) +{ + (void)fp; + return -1; +} + +int main(int argc, char** argv) +{ + const char* file_path = "/usr/share/aoc2025/day-template_input.txt"; + + if (argc >= 2) + file_path = argv[1]; + + FILE* fp = fopen(file_path, "r"); + if (fp == nullptr) + { + perror("fopen"); + return 1; + } + + printf("part1: %" PRId64 "\n", part1(fp)); + + fseek(fp, 0, SEEK_SET); + + printf("part2: %" PRId64 "\n", part2(fp)); + + fclose(fp); +} diff --git a/userspace/aoc2025/full/CMakeLists.txt b/userspace/aoc2025/full/CMakeLists.txt new file mode 100644 index 00000000..e77395de --- /dev/null +++ b/userspace/aoc2025/full/CMakeLists.txt @@ -0,0 +1,9 @@ +set(SOURCES + main.cpp +) + +add_executable(aoc2025_full ${SOURCES}) +banan_include_headers(aoc2025_full ban) +banan_link_library(aoc2025_full libc) + +install(TARGETS aoc2025_full OPTIONAL) diff --git a/userspace/aoc2025/full/main.cpp b/userspace/aoc2025/full/main.cpp new file mode 100644 index 00000000..732dca70 --- /dev/null +++ b/userspace/aoc2025/full/main.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +int main() +{ + for (int i = 1; i <= 25; i++) + { + char command[128]; + sprintf(command, "/bin/aoc2025/aoc2025_day%d", i); + + struct stat st; + if (stat(command, &st) == -1) + continue; + + printf("day%d\n", i); + + system(command); + } + + return 0; +} diff --git a/userspace/aoc2025/init-day.sh b/userspace/aoc2025/init-day.sh new file mode 100755 index 00000000..fd6e3c99 --- /dev/null +++ b/userspace/aoc2025/init-day.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo Please specify day number >& 2 + exit 1 +fi + +if [[ ! -d day$1 ]]; then + cp -r day-template day$1 + sed -i "s/day-template/day$1/g" day$1/* +fi + +if [[ ! -f input/day$1_input.txt ]]; then + wget --no-cookies --header "Cookie: session=$AOC_SESSION" https://adventofcode.com/2025/day/$1/input -O input/day$1_input.txt +fi diff --git a/userspace/aoc2025/input/.gitignore b/userspace/aoc2025/input/.gitignore new file mode 100644 index 00000000..327bab29 --- /dev/null +++ b/userspace/aoc2025/input/.gitignore @@ -0,0 +1 @@ +day*_input.txt