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
|
/.mypy_cache
|
||||||
.test-gadget/
|
.test-gadget/
|
||||||
build
|
build
|
||||||
|
.cache
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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++)
|
||||||
|
|||||||
@@ -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]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user