Merge pull request #32 from Servostar/main

Update for branch 4
This commit is contained in:
SirTalksalot75 2024-04-26 16:16:21 +02:00 committed by GitHub
commit cebe5c5bf4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 61 additions and 15 deletions

View File

@ -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

View File

@ -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 #
# ------------------------------------------------ #
@ -56,7 +61,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 +81,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 +113,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 +142,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)

View File

@ -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 .

View File

@ -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:

View File

@ -1,11 +1,11 @@
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

View File

@ -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