made cmake explode :D

This commit is contained in:
Aaro Koivukangas
2026-01-14 20:18:49 +02:00
parent ac646f2c1d
commit 37ab234b9f
5 changed files with 31 additions and 8 deletions
+1
View File
@@ -3,3 +3,4 @@ __pycache__
/.mypy_cache /.mypy_cache
.test-gadget/ .test-gadget/
build build
.cache
+5
View File
@@ -3,6 +3,10 @@ FROM alpine:3.23 AS builder
RUN apk update RUN apk update
RUN apk add --no-cache build-base git RUN apk add --no-cache build-base git
RUN apk add --no-cache cmake cmake-doc cmake-extras pkgconf RUN apk add --no-cache cmake cmake-doc cmake-extras pkgconf
RUN apk add --no-cache clang
ENV CC=/usr/bin/clang
ENV CXX=/usr/bin/clang
WORKDIR /usr/src/compiler WORKDIR /usr/src/compiler
@@ -10,6 +14,7 @@ COPY compiler .
RUN rm -rf build RUN rm -rf build
RUN mkdir build/ && cd build && cmake .. && make -j8 RUN mkdir build/ && cd build && cmake .. && make -j8
+1 -1
View File
@@ -15,4 +15,4 @@ add_executable(compilers_compiler src/main.cpp)
target_include_directories(compilers_compiler PRIVATE include) target_include_directories(compilers_compiler PRIVATE include)
target_include_directories(compilers_compiler_lib PRIVATE include) target_include_directories(compilers_compiler_lib PRIVATE include)
target_link_libraries(compilers_compiler compilers_compiler_lib -static) target_link_libraries(compilers_compiler compilers_compiler_lib -static-libgcc -static-libstdc++)
+7 -5
View File
@@ -1,11 +1,13 @@
#include <fstream>
#include <iostream> #include <iostream>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc >= 2) { if (argc < 3) {
std::cout << argv[1] << std::endl; std::cout << "Incorrect arg count :(" << std::endl;
} else { return 1;
std::cout << "No args :(" << std::endl;
} }
std::cout << argv[1] << argv[2] << std::endl;
std::cout << "Hello world!" << std::endl; std::cout << "Hello world!" << std::endl;
return 0;
std::ofstream result_file(argv[2]);
} }
+17 -2
View File
@@ -13,10 +13,25 @@ def call_compiler(source_code: str) -> bytes:
# Raise an exception on compilation error. # Raise an exception on compilation error.
# *** TODO *** # *** TODO ***
print("Compiling:", "./compilers_compiler", source_code) print("Compiling:", "./compilers_compiler", source_code)
response = subprocess.run(["./compilers_compiler", source_code], check=True, capture_output=True).stdout import uuid
# Give the compiler a file to write the result to
filename = "compile-result-" + str(uuid.uuid4())
response = subprocess.run(["./compilers_compiler", source_code, filename], check=True, capture_output=True).stdout
print(response) print(response)
return response try:
# Read the updated file and fetch compiler result
with open(filename,"rb") as file_content:
content = file_content.read()
print(content)
except FileNotFoundError as e:
print("File not found", filename, e)
content = b""
return content
def main() -> int: def main() -> int: