From aa7c62f0215b51a3c22a66dc59fb60000b86c7b1 Mon Sep 17 00:00:00 2001 From: servostar Date: Mon, 22 Apr 2024 13:15:33 +0200 Subject: [PATCH 1/7] Devkit now pulls source from main branch of the repository Added git to SDK Bumped version from 0.2.0 to 0.2.1 --- Dockerfile | 9 ++++----- sdk/Dockerfile | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1d5ce4b..ce2db20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ -FROM servostar/gemstone:sdk-0.2.0-alpine-3.19.1 +FROM servostar/gemstone:sdk-0.2.1-alpine-3.19.1 LABEL authors="servostar" -LABEL version="0.2.0" +LABEL version="0.2.1" LABEL description="docker image for setting up the build pipeline on SDK" LABEL website="https://github.com/Servostar/gemstone" -COPY --chown=lorang src /home/lorang/src -COPY --chown=lorang CMakeLists.txt /home/lorang/ +RUN git clone https://github.com/Servostar/gemstone.git /home/lorang -RUN cmake . \ No newline at end of file +RUN cmake . diff --git a/sdk/Dockerfile b/sdk/Dockerfile index 098f659..4dbeb1f 100644 --- a/sdk/Dockerfile +++ b/sdk/Dockerfile @@ -1,13 +1,13 @@ FROM alpine:3.19.1 LABEL authors="servostar" -LABEL version="0.2.0" +LABEL version="0.2.1" LABEL description="base image for building the gemstone programming language compiler" LABEL website="https://github.com/Servostar/gemstone" # install dependencies -RUN apk add build-base gcc make cmake bison flex +RUN apk add build-base gcc make cmake bison flex git # create user for build RUN adduser --disabled-password lorang WORKDIR /home/lorang -USER lorang \ No newline at end of file +USER lorang From ebb29807c85533d73f076a76b00171c289df02c7 Mon Sep 17 00:00:00 2001 From: servostar Date: Mon, 22 Apr 2024 13:31:20 +0200 Subject: [PATCH 2/7] bumped SDK version to 0.2.1 --- .github/workflows/build-check-sdk.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check-sdk.yaml b/.github/workflows/build-check-sdk.yaml index aed27d4..5b8f2aa 100644 --- a/.github/workflows/build-check-sdk.yaml +++ b/.github/workflows/build-check-sdk.yaml @@ -2,7 +2,7 @@ name: "Build check gemstone in SDK" run-name: SDK build check to ${{ inputs.deploy_target }} by @${{ github.actor }} on: [push, pull_request] env: - SDK: 0.1.0-alma-9.3 + SDK: 0.2.1-alpine-3.19.1 jobs: build-check-sdk: runs-on: ubuntu-latest From 501f6f1602f03cc876a2dc95db680ef011c85102 Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 24 Apr 2024 22:31:35 +0200 Subject: [PATCH 3/7] file name macro searches for last char instead of last string --- src/sys/log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sys/log.h b/src/sys/log.h index 691a38e..aa18c88 100644 --- a/src/sys/log.h +++ b/src/sys/log.h @@ -24,7 +24,7 @@ // generally not defined by GCC < 11.3 and MSVC #ifndef __FILE_NAME__ #if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) -#define __FILE_NAME__ (strrstr(__FILE__, "\\") ? strrstr(__FILE__, "\\") + 1 : __FILE__) +#define __FILE_NAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) #else #define __FILE_NAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) #endif From d673d1de0a6bf53b0b85c45e50a3bf852e574781 Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 24 Apr 2024 22:36:58 +0200 Subject: [PATCH 4/7] removed dependency of unistd.h from lexer --- src/lex/lexer.l | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lex/lexer.l b/src/lex/lexer.l index 8823195..c1efd4f 100644 --- a/src/lex/lexer.l +++ b/src/lex/lexer.l @@ -12,6 +12,9 @@ %option nounput %option noinput +/* prevent depency of unistd.h */ +%option nounistd + %% "\n" yyLineNumber++; From 8cd1f2fb0d5ef0c010f941ec33d082b21d3bf92c Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 24 Apr 2024 22:37:21 +0200 Subject: [PATCH 5/7] added compile flags which differ for MSVC and other compiler (GCC/Clang) --- CMakeLists.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31b5c87..7f27873 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,11 @@ add_custom_command(OUTPUT ${YACC_GENERATED_SOURCE_FILE} file(GLOB_RECURSE SOURCE_FILES src/*.c) # define default compile flags -set(FLAGS -Wall -Wextra -Wconversion -Wpedantic) +if (MSVC) + set(FLAGS /Wall /W3 /permissive) +else() + set(FLAGS -Wall -Wextra -Wconversion -Wpedantic) +endif() # ------------------------------------------------ # # Target RELEASE # @@ -72,13 +76,20 @@ set_target_properties(release OUTPUT_NAME "gsc" RUNTIME_OUTPUT_DIRECTORY "bin/release") +# FIXME: cannot compile with /O2 because of /RTC1 flag +if (MSVC) + set(RELEASE_FLAGS) +else() + set(RELEASE_FLAGS -m64 -O3 -fprefetch-loop-arrays -mrecip) +endif() + # compiler flags targeting a 64-bit GCC release environment # flags: # - m64: build for 64-bit # - O3: optimization level 3 # - fprefetch-loop-arrays: pre load arrays used in loops by using prefetch instruction # - mrecip: make use RCPSS and RSQRTSS instructions -target_compile_options(release PUBLIC ${FLAGS} -m64 -O3 -fprefetch-loop-arrays -mrecip) +target_compile_options(release PUBLIC ${FLAGS} ${RELEASE_FLAGS}) # add src directory as include path target_include_directories(release PUBLIC src) @@ -97,8 +108,14 @@ set_target_properties(debug OUTPUT_NAME "gsc" RUNTIME_OUTPUT_DIRECTORY "bin/debug") +if (MSVC) + set(DEBUG_FLAGS /DEBUG) +else() + set(DEBUG_FLAGS -g) +endif() + # compiler flags targeting a GCC debug environment -target_compile_options(debug PUBLIC ${FLAGS} -g) +target_compile_options(debug PUBLIC ${FLAGS} ${DEBUG_FLAGS}) # add src directory as include path target_include_directories(debug PUBLIC src) @@ -120,9 +137,15 @@ set_target_properties(check OUTPUT_NAME "gsc" RUNTIME_OUTPUT_DIRECTORY "bin/check") +if (MSVC) + set(CHECK_FLAGS /DEBUG /WX) +else() + set(DEBUG_FLAGS -g /Werror) +endif() + # compiler flags targeting a GCC debug environment # extra -Werror flag to treat warnings as error to make github action fail on warning -target_compile_options(check PUBLIC ${FLAGS} -g -Werror) +target_compile_options(check PUBLIC ${FLAGS} ${DEBUG_FLAGS}) # add src directory as include path target_include_directories(check PUBLIC src) From df927cf7d62fdb6f1ee3ce37575b32044270e4ea Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 24 Apr 2024 22:47:59 +0200 Subject: [PATCH 6/7] fixed flag error and made option nounistd in lexer depend on compiler used --- CMakeLists.txt | 7 ++++++- src/lex/lexer.l | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f27873..1cfeefc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,11 @@ add_custom_command(OUTPUT ${LEX_GENERATED_SOURCE_FILE} COMMENT "generate C source file for lexer" VERBATIM) +# remove dependency when compiling with MSVC on windows +if (MSVC) + add_compile_definitions(YY_NO_UNISTD_H) +endif() + # ------------------------------------------------ # # Yacc # # ------------------------------------------------ # @@ -140,7 +145,7 @@ set_target_properties(check if (MSVC) set(CHECK_FLAGS /DEBUG /WX) else() - set(DEBUG_FLAGS -g /Werror) + set(DEBUG_FLAGS -g -Werror) endif() # compiler flags targeting a GCC debug environment diff --git a/src/lex/lexer.l b/src/lex/lexer.l index c1efd4f..8823195 100644 --- a/src/lex/lexer.l +++ b/src/lex/lexer.l @@ -12,9 +12,6 @@ %option nounput %option noinput -/* prevent depency of unistd.h */ -%option nounistd - %% "\n" yyLineNumber++; From 6f30be17e9d9f2c94f96ceca5578753a737b81c1 Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 24 Apr 2024 23:58:15 +0200 Subject: [PATCH 7/7] added dependency section in README --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 854f2f2..a1e442b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,25 @@ Gemstone is a programming language compiler written in C with lex and yacc. +## Dependencies (build) + +### Windows 11 + +For setup instruction see issue #30 + +Requires: +- Microsoft Build Tools 2022 (includes: CMake, MSVC) +- WinFlexBison [find it here](https://github.com/lexxmark/winflexbison) (needs to be in PATH) + +### GNU/Linux + +Requires: +- GCC +- CMake +- Make +- bison +- flex + ## Development with VSCode/Codium Recommended extensions for getting a decent experience are the following: @@ -55,4 +74,4 @@ Currently, the SDK is based on Almalinux 9.3, an open source distro binary compa The following images can be found in the offical repository at [Docker Hub](https://hub.docker.com/r/servostar/gemstone): - SDK -- Devkit \ No newline at end of file +- Devkit