Skip to content

Commit

Permalink
refactor: Remove Windows support
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Please use WSL (Ubuntu 22.04) to use gifscript on Windows.
MSYS2/MinGW will not be formally supported platforms by me.
Any _fixes_ for the MSYS2/MinGW platform will be accepted, assuming there is no maintenance burdern due to the changes :)
  • Loading branch information
F0bes committed Apr 3, 2024
1 parent e0cf3fb commit 61bb98b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 53 deletions.
49 changes: 13 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ endif()

find_package(RAGEL REQUIRED)

if(WIN32)
find_program(LEMON-PARSER "lemon" REQUIRED)
if(NOT ${LEMON-PARSER} STREQUAL LEMON-PARSER-NOTFOUND)
message("lemon parser (lemon.exe) not found. If using VCPKG install lemon-parser-generator and add `$VCPKG_ROOT\\packages\\lemon-parser-generator_x64-windows\\tools\\lemon` (or wherever lemon.exe is) to your $PATH.")
endif()
endif()

set(CORE_DIR ${CMAKE_SOURCE_DIR}/core)
set(CORE_INCLUDE ${CORE_DIR}/include)
set(CORE_SRC ${CORE_DIR}/src)
Expand All @@ -41,11 +34,9 @@ FetchContent_Declare(fmt
)
FetchContent_MakeAvailable(fmt)

if(NOT WIN32)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE AND NOT DISABLE_CLANG_TIDY AND NOT WIN32)
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*,modernize-*,performance-*,portability-*,bugprone-*,clang-analyzer-*)
endif()
if(CLANG_TIDY_EXE AND NOT DISABLE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*,modernize-*,performance-*,portability-*,bugprone-*,clang-analyzer-*)
endif()

RAGEL_TARGET(gifscript
Expand Down Expand Up @@ -93,36 +84,22 @@ set_source_files_properties(${GENERATED_SOURCES} ${FRONTEND_DIR}/tpircsfig.cpp P
SKIP_LINTING ON
)

if(WIN32)
target_compile_options(gifscript_core PRIVATE /std:c++latest)
target_compile_options(gifscript PRIVATE /std:c++latest)
else()
execute_process(
COMMAND git describe --tags --abbrev=4 --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
execute_process(
COMMAND git describe --tags --abbrev=4 --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(CONCAT GIT_VERSION "\"" ${GIT_VERSION} "\"")
message("git version: ${GIT_VERSION}")
target_compile_options(gifscript_core PRIVATE -Wall -Werror -Wno-unused-const-variable ${CPP_23_ARG})
target_compile_options(gifscript PRIVATE -DGIT_VERSION=${GIT_VERSION} -Wall -Werror -Wno-unused-const-variable ${CPP_23_ARG})
target_compile_options(tpircsfig PRIVATE -DGIT_VERSION=${GIT_VERSION} -Wall -Werror -Wno-unused-const-variable ${CPP_23_ARG})
endif()

string(CONCAT GIT_VERSION "\"" ${GIT_VERSION} "\"")
message("git version: ${GIT_VERSION}")
target_compile_options(gifscript_core PRIVATE -Wall -Werror -Wno-unused-const-variable ${CPP_23_ARG})
target_compile_options(gifscript PRIVATE -DGIT_VERSION=${GIT_VERSION} -Wall -Werror -Wno-unused-const-variable ${CPP_23_ARG})
target_compile_options(tpircsfig PRIVATE -DGIT_VERSION=${GIT_VERSION} -Wall -Werror -Wno-unused-const-variable ${CPP_23_ARG})

target_include_directories(gifscript PUBLIC ${fmt_SOURCE_DIR}/include)
target_link_libraries(gifscript_core PUBLIC fmt::fmt)

# CMake on windows causes issues with the lemon parser template file
# We need to get the location of the current lemon parser executable
# And (on vcpkg at least) the location of the template file is in the same
# discord as the lemon executable

if(WIN32)
get_filename_component(LEMON_PARSER_DIR ${LEMON-PARSER} DIRECTORY)
set(LEMON_PARSER_TEMPLATE "-T${LEMON_PARSER_DIR}/lempar.c")
endif()

add_custom_command(
OUTPUT parser.c parser.h
COMMAND lemon -q ${CORE_SRC}/parser.y -d${CMAKE_CURRENT_BINARY_DIR} ${LEMON_PARSER_TEMPLATE}
Expand Down
5 changes: 0 additions & 5 deletions core/include/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ namespace logger
}
};

#ifndef _WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-security"
#endif
template <typename... Args>
void log(fmt_location format, fmt::color fgcol, Args&&... args)
{
Expand All @@ -32,10 +30,7 @@ namespace logger

delete[] buf;
}
#ifndef _WIN32
#pragma GCC diagnostic pop
#endif

template <typename... Args>
void info(fmt_location format, Args&&... args)
{
Expand Down
8 changes: 2 additions & 6 deletions frontends/gifscript.rl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
#include "gifscript_backend.hpp"

#include "logger.hpp"
#ifndef WIN32

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif

#include "parser.c"

#ifndef WIN32
#pragma GCC diagnostic pop
#endif

#include "registers.hpp"
#include "machine.hpp"

Expand Down
7 changes: 1 addition & 6 deletions frontends/tpircsfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@
#include "gifscript_backend.hpp"
#include "version.hpp"
#include "parser.h"
#ifndef WIN32

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif

#include "parser.c"

#ifndef WIN32
#pragma GCC diagnostic pop
#endif

static bool valid = true;
static Backend* backend = nullptr;
Expand Down

0 comments on commit 61bb98b

Please sign in to comment.