From 6d9a7d118353a70bd08ecf6d6381aab7e8903f64 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 17 Jul 2024 16:52:23 +0100 Subject: [PATCH 1/4] [make] Fix library suffix on windows --- .gitignore | 3 ++- Makefile | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d01e942..f51e955 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ test/ -*.so \ No newline at end of file +*.so +*.dll diff --git a/Makefile b/Makefile index dbd00f9..94a15a5 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,28 @@ LIBS_PATH = -L$(LUA_LIBDIR) LIBS = -lpthread FLAGS = -std=c++11 -Wall $(LIBFLAG) $(CFLAGS) -all: simdjson.so +ifeq ($(OS),Windows_NT) + LIBEXT = dll +else + UNAME := $(shell uname -s) + ifeq ($(findstring MINGW,$(UNAME)),MINGW) + LIBEXT = dll + else ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) + LIBEXT = dll + else + LIBEXT = so + endif +endif -simdjson.so: +TARGET = simdjson.$(LIBEXT) + +all: $(TARGET) + +$(TARGET): $(CXX) $(SRC) $(FLAGS) $(INCLUDE) $(LIBS_PATH) $(LIBS) -o $@ clean: - rm *.so + rm *.$(LIBEXT) -install: simdjson.so - cp simdjson.so $(INST_LIBDIR) +install: $(TARGET) + cp $(TARGET) $(INST_LIBDIR) From ea8d54ea36a1a57fca58377c876c0b0982fb4ff1 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 17 Jul 2024 16:53:09 +0100 Subject: [PATCH 2/4] [make] Fix lua linking on windows On windows, we need to explicitly link against lua.dll --- Makefile | 5 ++++- lua-simdjson-0.0.2-1.rockspec | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 94a15a5..a0d5662 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ SRC = src/luasimdjson.cpp src/simdjson.cpp INCLUDE = -I$(LUA_INCDIR) -LIBS_PATH = -L$(LUA_LIBDIR) LIBS = -lpthread FLAGS = -std=c++11 -Wall $(LIBFLAG) $(CFLAGS) +ifdef LUA_LIBDIR +FLAGS += $(LUA_LIBDIR)/$(LUALIB) +endif + ifeq ($(OS),Windows_NT) LIBEXT = dll else diff --git a/lua-simdjson-0.0.2-1.rockspec b/lua-simdjson-0.0.2-1.rockspec index 5e28ff9..3e29d82 100644 --- a/lua-simdjson-0.0.2-1.rockspec +++ b/lua-simdjson-0.0.2-1.rockspec @@ -32,4 +32,12 @@ build = { INST_LUADIR="$(LUADIR)", INST_CONFDIR="$(CONFDIR)", }, + platforms = { + windows = { + build_variables = { + LUA_LIBDIR="$(LUA_LIBDIR)", + LUALIB="$(LUALIB)", + } + } + } } From e712f61e8d5bb4ea3df4b03705dfea3111d89779 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 17 Jul 2024 17:39:12 +0100 Subject: [PATCH 3/4] [ci] Add windows config --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2435dbe..709e59a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,3 +33,27 @@ jobs: export PATH=$PATH:$PWD/lua_install/bin luarocks install busted busted --verbose + + windows: + strategy: + fail-fast: false + matrix: + lua: [lua=5.1, lua=5.2, lua=5.3, lua=5.4, luajit=2.0, luajit=2.1] + runs-on: windows-2022 + steps: + # Checks-out the repository under $GITHUB_WORKSPACE. + - uses: actions/checkout@v3 + - name: Install Lua (${{ matrix.lua }}) + run: | + pip install hererocks + hererocks lua_install -r^ --${{ matrix.lua }} + - name: Build lua-simdjson + run: | + .\lua_install\bin\activate + luarocks make + - name: Run tests + run: | + .\lua_install\bin\activate + luarocks install lua-cjson2 + luarocks install busted + busted --verbose From 1958042ca921c2d1a7894d95aff11f9a76abc69e Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 17 Jul 2024 18:58:33 +0100 Subject: [PATCH 4/4] [ci] Add work around for VS2022 bug with luarocks Since lua was built with VS2022, the luarocks install script uses `MSVCR80` as the default runtime which causes problems when loading dlls. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 709e59a..ebd978c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,6 @@ jobs: - name: Run tests run: | .\lua_install\bin\activate - luarocks install lua-cjson2 - luarocks install busted + luarocks install MSVCRT="m" lua-cjson2 + luarocks install MSVCRT="m" busted busted --verbose