From 1927818ab625e7fcef943d149a776f43adbcdfb7 Mon Sep 17 00:00:00 2001 From: Donald Filimon Date: Sun, 27 Jul 2025 17:06:10 -0400 Subject: [PATCH] Install Zig compiler and restore installer script --- .devcontainer/Dockerfile | 10 +++++++--- .devcontainer/devcontainer.json | 4 +--- CMakeLists.txt | 20 -------------------- README.md | 4 ++-- scripts/install_zig.sh | 32 ++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 7 ------- tests/CMakeLists.txt | 9 --------- 7 files changed, 42 insertions(+), 44 deletions(-) delete mode 100644 CMakeLists.txt create mode 100755 scripts/install_zig.sh delete mode 100644 src/CMakeLists.txt delete mode 100644 tests/CMakeLists.txt diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0bed702..5eac5ca 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,8 +1,12 @@ FROM ubuntu:24.04 RUN apt-get update && \ - apt-get install -y build-essential cmake clang clang-format clang-tidy git python3-pip \ - libssl-dev ninja-build && \ - pip3 install conan + apt-get install -y build-essential clang clang-format clang-tidy git python3-pip \ + libssl-dev ninja-build curl && \ + pip3 install conan && \ + curl -L https://ziglang.org/builds/zig-linux-x86_64-0.14.1.tar.xz \ + | tar -xJ && \ + mv zig-linux-x86_64-0.14.1 /opt/zig && \ + ln -s /opt/zig/zig /usr/local/bin/zig WORKDIR /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a44b61e..1a8292f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,12 +4,10 @@ "workspaceFolder": "/workspace", "extensions": [ "ms-vscode.cpptools", - "ms-vscode.cmake-tools", "llvm-vs-code-extensions.vscode-clangd" ], "settings": { - "C_Cpp.intelliSenseEngine": "Default", - "cmake.sourceDirectory": "${workspaceFolder}" + "C_Cpp.intelliSenseEngine": "Default" }, "forwardPorts": [3000] } diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index efa4dd7..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 3.23) -project(OuroLang LANGUAGES CXX) - -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -enable_testing() - -add_subdirectory(src) -add_subdirectory(tests) - -file(GLOB_RECURSE FORMAT_SOURCES - ${CMAKE_SOURCE_DIR}/src/*.cc - ${CMAKE_SOURCE_DIR}/include/*.h - ${CMAKE_SOURCE_DIR}/tests/*.cc) - -add_custom_target(format - COMMAND clang-format -i ${FORMAT_SOURCES} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMENT "Format all source files") diff --git a/README.md b/README.md index c2a3691..34c5b1a 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ Then run the REPL: ./ouro_lang ``` -A Zig build script is also included (`build.zig`) for environments with the Zig compiler installed. It now compiles the C portions of the project using the C23 standard and links against LLVM in addition to `libc`. The script mirrors the basic CMake configuration and exposes tasks for running the module example and its unit tests. +A Zig build script is also included (`build.zig`) for environments with the Zig compiler installed. It compiles the C portions of the project using the C23 standard and links against LLVM in addition to `libc`. The script mirrors the old CMake setup and exposes tasks for running the module example and its unit tests. If Zig is missing locally, run `scripts/install_zig.sh` to download version `0.14.1`. ## Repository Structure -The project now includes a CMake-based build system, tests, container setup, and documentation. Run `cmake` in a `build` directory to configure and build the modules in `src/`. +The project includes tests, a development container, and extensive documentation. ## Zig Build with Modules diff --git a/scripts/install_zig.sh b/scripts/install_zig.sh new file mode 100755 index 0000000..ab7876a --- /dev/null +++ b/scripts/install_zig.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +ZIG_VERSION="0.14.1" +ZIG_DIR="zig-x86_64-linux-${ZIG_VERSION}" +ARCHIVE="zig-linux-x86_64-${ZIG_VERSION}.tar.xz" +DOWNLOAD_URL="https://ziglang.org/builds/${ARCHIVE}" + +if command -v zig >/dev/null 2>&1; then + INSTALLED=$(zig version) + if [ "$INSTALLED" = "$ZIG_VERSION" ]; then + echo "Zig ${ZIG_VERSION} already installed" + exit 0 + fi +fi + +rm -f "$ARCHIVE" + +if [ ! -d "$ZIG_DIR" ]; then + echo "Downloading Zig ${ZIG_VERSION}..." + curl -L -o "$ARCHIVE" "$DOWNLOAD_URL" + mkdir -p "$ZIG_DIR" + tar -xf "$ARCHIVE" -C "$ZIG_DIR" --strip-components=1 +fi + +cat < zig +#!/usr/bin/env bash +"$(pwd)/${ZIG_DIR}/zig" "$@" +SH +chmod +x zig + +echo "Zig ${ZIG_VERSION} installed in $(pwd)/${ZIG_DIR}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index f9db7a1..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(ourlang INTERFACE) -target_include_directories(ourlang INTERFACE ${CMAKE_CURRENT_LIST_DIR}/../include) - -add_executable(ouro_lang main.cc repl_binding.cc) -target_link_libraries(ouro_lang PRIVATE ourlang) - -set_target_properties(ouro_lang PROPERTIES CXX_STANDARD 23 CXX_STANDARD_REQUIRED YES) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 23b0c0b..0000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -enable_testing() - -add_executable(lexer_tests lexer_tests.cc) -target_link_libraries(lexer_tests PRIVATE ourlang) -add_test(NAME LexerTests COMMAND lexer_tests) - -add_executable(codegen_tests codegen_tests.cc) -target_link_libraries(codegen_tests PRIVATE ourlang) -add_test(NAME CodegenTests COMMAND codegen_tests)