From edefc717c8681fa1bc0c675f95889952f8c955c1 Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 5 Jun 2024 11:37:57 +0200 Subject: [PATCH 1/7] added windows CI based on MSYS2 --- .github/workflows/msys2-cross-compile.yml | 20 ++++++++++++++++++++ ci-build.sh | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 .github/workflows/msys2-cross-compile.yml create mode 100644 ci-build.sh diff --git a/.github/workflows/msys2-cross-compile.yml b/.github/workflows/msys2-cross-compile.yml new file mode 100644 index 0000000..9da5cf8 --- /dev/null +++ b/.github/workflows/msys2-cross-compile.yml @@ -0,0 +1,20 @@ +name: MSYS2 +on: [push, pull_request] + +jobs: + msys2-ucrt64: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: mingw-w64-x86_64-gcc mingw-w64-x86_64-glib2 bison flex mingw-w64-x86_64-llvm cmake git make + - name: CI-Build + run: | + echo 'Running in MSYS2!' + ./ci-build.sh \ No newline at end of file diff --git a/ci-build.sh b/ci-build.sh new file mode 100644 index 0000000..8b09b06 --- /dev/null +++ b/ci-build.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cmake . +make release From 3587451b93240de3e5f4f3f0f578318e6160e369 Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 5 Jun 2024 11:49:55 +0200 Subject: [PATCH 2/7] fixed: implicit function _fullpath --- .github/workflows/msys2-cross-compile.yml | 2 +- src/ast/ast.c | 1 + src/io/files.c | 16 +++++++++------- src/io/files.h | 6 +++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/msys2-cross-compile.yml b/.github/workflows/msys2-cross-compile.yml index 9da5cf8..770ea3b 100644 --- a/.github/workflows/msys2-cross-compile.yml +++ b/.github/workflows/msys2-cross-compile.yml @@ -2,7 +2,7 @@ name: MSYS2 on: [push, pull_request] jobs: - msys2-ucrt64: + msys2-mingw64: runs-on: windows-latest defaults: run: diff --git a/src/ast/ast.c b/src/ast/ast.c index 4e3ba6f..6de0c74 100644 --- a/src/ast/ast.c +++ b/src/ast/ast.c @@ -219,6 +219,7 @@ void AST_delete_node(struct AST_Node_t *node) { } if (node->parent != NULL) { + [[maybe_unused]] const struct AST_Node_t* child = AST_detach_child(node->parent, node); assert(child == node); } diff --git a/src/io/files.c b/src/io/files.c index 5f3ad02..d2c889b 100644 --- a/src/io/files.c +++ b/src/io/files.c @@ -16,6 +16,8 @@ #elif defined(_WIN32) || defined(WIN32) #include +// for _fullpath +#include #define MAX_PATH_BYTES _MAX_PATH @@ -122,15 +124,15 @@ void print_diagnostic(ModuleFile *file, TokenLocation *location, Message kind, c free((void *) absolute_path); - const size_t lines = location->line_end - location->line_start + 1; + const unsigned long int lines = location->line_end - location->line_start + 1; - for (size_t l = 0; l < lines; l++) { + for (unsigned long int l = 0; l < lines; l++) { printf(" %4ld | ", location->line_start + l); - size_t chars = 0; + unsigned long int chars = 0; // print line before token group start - size_t limit = min(location->col_start, SEEK_BUF_BYTES); + unsigned long int limit = min(location->col_start, SEEK_BUF_BYTES); while (limit > 1) { custom_fgets(buffer, (int) limit, file->handle); chars += printf("%s", buffer); @@ -168,13 +170,13 @@ void print_diagnostic(ModuleFile *file, TokenLocation *location, Message kind, c } printf(" | "); - for (size_t i = 1; i < location->col_start; i++) { + for (unsigned long int i = 1; i < location->col_start; i++) { printf(" "); } printf("%s", accent_color); printf("^"); - for (size_t i = 0; i < location->col_end - location->col_start; i++) { + for (unsigned long int i = 0; i < location->col_end - location->col_start; i++) { printf("~"); } @@ -320,7 +322,7 @@ const char *get_absolute_path(const char *path) { #elif defined(_WIN32) || defined(WIN32) // use Windows CRT specific function char absolute_path[MAX_PATH_BYTES]; - _fullpath(path, absolute_path, _MAX_PATH); + _fullpath((char*) path, absolute_path, _MAX_PATH); #endif return strdup(absolute_path); diff --git a/src/io/files.h b/src/io/files.h index 61c7ebb..c05f587 100644 --- a/src/io/files.h +++ b/src/io/files.h @@ -15,9 +15,9 @@ #endif typedef struct FileDiagnosticStatistics_t { - size_t error_count; - size_t warning_count; - size_t info_count; + unsigned long int error_count; + unsigned long int warning_count; + unsigned long int info_count; } FileDiagnosticStatistics; typedef struct ModuleFile_t { From f9a18fc1076e49db30387a1aaa0efb7a1bb0efc6 Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 5 Jun 2024 11:54:27 +0200 Subject: [PATCH 3/7] fixed: implicit function _mkdir --- ci-build.sh | 0 src/io/files.c | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 ci-build.sh diff --git a/ci-build.sh b/ci-build.sh old mode 100644 new mode 100755 diff --git a/src/io/files.c b/src/io/files.c index d2c889b..090a2cb 100644 --- a/src/io/files.c +++ b/src/io/files.c @@ -18,6 +18,8 @@ #include // for _fullpath #include +// for _mkdir +#include #define MAX_PATH_BYTES _MAX_PATH @@ -67,9 +69,7 @@ void delete_files(ModuleFileStack *stack) { // seeking the current line in print_diagnostic() #define SEEK_BUF_BYTES 256 -static inline unsigned long int min(unsigned long int a, unsigned long int b) { - return a > b ? b : a; -} +#define min(a, b) ((a) > (b) ? (b) : (a)) // behaves like fgets except that it has defined behavior when n == 1 static void custom_fgets(char *buffer, size_t n, FILE *stream) { From b75ff7e44f1465252d18befcf67c2ffdc97db8da Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 5 Jun 2024 11:59:03 +0200 Subject: [PATCH 4/7] fixed: macro definitions --- src/io/files.c | 4 ++-- src/sys/col.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/io/files.c b/src/io/files.c index 090a2cb..0dac570 100644 --- a/src/io/files.c +++ b/src/io/files.c @@ -13,6 +13,8 @@ #define MAX_PATH_BYTES PATH_MAX +#define min(a, b) ((a) > (b) ? (b) : (a)) + #elif defined(_WIN32) || defined(WIN32) #include @@ -69,8 +71,6 @@ void delete_files(ModuleFileStack *stack) { // seeking the current line in print_diagnostic() #define SEEK_BUF_BYTES 256 -#define min(a, b) ((a) > (b) ? (b) : (a)) - // behaves like fgets except that it has defined behavior when n == 1 static void custom_fgets(char *buffer, size_t n, FILE *stream) { if (n == 1) { diff --git a/src/sys/col.c b/src/sys/col.c index 76260ec..afd78ba 100644 --- a/src/sys/col.c +++ b/src/sys/col.c @@ -71,8 +71,7 @@ int stdout_supports_ansi_esc() { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); if (!GetConsoleMode(hConsole, &mode)) { - ERROR("failed to get console mode"); - return ANSI_ENABLED; + return ASNI_DISABLED; } if ((mode & ENABLE_VIRTUAL_TERMINAL_INPUT) | From 2a3a4aa1590dab6ffe32aed7e61e22586a73e19b Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 5 Jun 2024 21:13:00 +0200 Subject: [PATCH 5/7] added: MSYS2 build for windows to readme --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index faca249..2c93aad 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,26 @@ # Gemstone -Gemstone is a programming language compiler written in C with lex and yacc. +Gemstone is a programming language compiler written in C based on flex and GNU bison. +Is uses LLVM to produce optimized native binaries for many platforms. ## Dependencies (build) ### Windows 11 -For setup instruction see issue #30 +#### MSYS2 +Install MSYS2 under Windows 11. Open the MingGW64 environment. Requires: +Install the following packages: - Microsoft Build Tools 2022 (includes: CMake, MSVC) +``` - WinFlexBison [find it here](https://github.com/lexxmark/winflexbison) (needs to be in PATH) - +pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-glib2 bison flex mingw-w64-x86_64-llvm cmake git make +``` +Clone the repository and build the gemstone compiler: +``` +cmake . && make release +``` ### GNU/Linux Requires: @@ -20,6 +29,8 @@ Requires: - Make - bison - flex +- LLVM +- Glib 2.0 ## Writing Tests From 3e84af44138bfb4c525ca9bce96b93a9c10fffa2 Mon Sep 17 00:00:00 2001 From: servostar <72654954+Servostar@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:25:31 +0200 Subject: [PATCH 6/7] Update README.md --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2c93aad..48646d5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ -# Gemstone -Gemstone is a programming language compiler written in C based on flex and GNU bison. -Is uses LLVM to produce optimized native binaries for many platforms. +
+ + gemstone logo + +
+
+ +## Gemstone + +Gemstone is a programming language compiler (short: GSC) written in C based on flex and GNU bison. +Is uses LLVM to produce optimized native binaries for many platforms and uses its own builtin build system for more complex project management. ## Dependencies (build) @@ -10,11 +18,8 @@ Is uses LLVM to produce optimized native binaries for many platforms. #### MSYS2 Install MSYS2 under Windows 11. Open the MingGW64 environment. -Requires: Install the following packages: -- Microsoft Build Tools 2022 (includes: CMake, MSVC) ``` -- WinFlexBison [find it here](https://github.com/lexxmark/winflexbison) (needs to be in PATH) pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-glib2 bison flex mingw-w64-x86_64-llvm cmake git make ``` Clone the repository and build the gemstone compiler: From ce17efb6ebb92f47fc6c34b5e85915e1d7c021a7 Mon Sep 17 00:00:00 2001 From: Filleo <84237718+flixm16@users.noreply.github.com> Date: Thu, 6 Jun 2024 22:39:04 +0200 Subject: [PATCH 7/7] Update README.md small spelling error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48646d5..daaaf32 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ## Gemstone Gemstone is a programming language compiler (short: GSC) written in C based on flex and GNU bison. -Is uses LLVM to produce optimized native binaries for many platforms and uses its own builtin build system for more complex project management. +It uses LLVM to produce optimized native binaries for many platforms and uses its own builtin build system for more complex project management. ## Dependencies (build)