mirror of
https://github.com/iritmaximus/compilers.git
synced 2026-10-12 19:13:35 +03:00
made cmake explode :D
This commit is contained in:
@@ -3,3 +3,4 @@ __pycache__
|
||||
/.mypy_cache
|
||||
.test-gadget/
|
||||
build
|
||||
.cache
|
||||
|
||||
@@ -3,6 +3,10 @@ FROM alpine:3.23 AS builder
|
||||
RUN apk update
|
||||
RUN apk add --no-cache build-base git
|
||||
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
|
||||
|
||||
@@ -10,6 +14,7 @@ COPY compiler .
|
||||
|
||||
RUN rm -rf build
|
||||
|
||||
|
||||
RUN mkdir build/ && cd build && cmake .. && make -j8
|
||||
|
||||
|
||||
|
||||
@@ -15,4 +15,4 @@ add_executable(compilers_compiler src/main.cpp)
|
||||
|
||||
target_include_directories(compilers_compiler 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++)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc >= 2) {
|
||||
std::cout << argv[1] << std::endl;
|
||||
} else {
|
||||
std::cout << "No args :(" << std::endl;
|
||||
if (argc < 3) {
|
||||
std::cout << "Incorrect arg count :(" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << argv[1] << argv[2] << std::endl;
|
||||
std::cout << "Hello world!" << std::endl;
|
||||
return 0;
|
||||
|
||||
std::ofstream result_file(argv[2]);
|
||||
}
|
||||
|
||||
@@ -13,10 +13,25 @@ def call_compiler(source_code: str) -> bytes:
|
||||
# Raise an exception on compilation error.
|
||||
# *** TODO ***
|
||||
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)
|
||||
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user