From b28adf665518b9c239f26ae9d291bc1288c1a112 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 19 Feb 2025 19:10:41 +0000 Subject: [PATCH 1/7] Add nmake file for building with windows MSVC --- .gitignore | 5 +++++ Makefile.win | 27 +++++++++++++++++++++++++++ lua-simdjson-0.0.6-1.rockspec | 1 + 3 files changed, 33 insertions(+) create mode 100644 Makefile.win diff --git a/.gitignore b/.gitignore index 58ac899..ee3c8b0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,8 @@ test/ *.dll *.o *.d + +# msvc +*.obj +*.lib +*.exp diff --git a/Makefile.win b/Makefile.win new file mode 100644 index 0000000..4eafad4 --- /dev/null +++ b/Makefile.win @@ -0,0 +1,27 @@ +OBJ = src/luasimdjson.obj src/simdjson.obj +CPPFLAGS = -I$(LUA_INCDIR) +CXXFLAGS = -EHsc -std:c++17 $(CFLAGS) +LDFLAGS = $(LIBFLAG) + +!ifdef LUA_LIBDIR +LDLIBS = $(LUA_LIBDIR)/$(LUALIB) +!endif + +TARGET = simdjson.dll + +all: $(TARGET) + +src/luasimdjson.obj: src/luasimdjson.h src/simdjson.h +src/simdjson.obj: src/simdjson.h + +.cpp.obj:: + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -Fo:"src\\" + +$(TARGET): $(OBJ) + $(LD) $(LDFLAGS) $** -out:$@ $(LDLIBS) + +clean: + del *.dll src\*.obj *.lib *.exp 2>nul + +install: $(TARGET) + copy $(TARGET) $(INST_LIBDIR) diff --git a/lua-simdjson-0.0.6-1.rockspec b/lua-simdjson-0.0.6-1.rockspec index 2436420..b93d502 100644 --- a/lua-simdjson-0.0.6-1.rockspec +++ b/lua-simdjson-0.0.6-1.rockspec @@ -36,6 +36,7 @@ build = { build_variables = { LUA_LIBDIR="$(LUA_LIBDIR)", LUALIB="$(LUALIB)", + LD="$(LD)", } } } From f02ddc34e71dcbce967c76a501cc77c684a010d9 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 19 Feb 2025 19:10:58 +0000 Subject: [PATCH 2/7] Fix function export for msvc build --- src/luasimdjson.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/luasimdjson.h b/src/luasimdjson.h index 5b133d2..e9203ae 100644 --- a/src/luasimdjson.h +++ b/src/luasimdjson.h @@ -1,4 +1,11 @@ #include + +#ifdef _MSC_VER +#define LUASIMDJSON_EXPORT __declspec(dllexport) +#else +#define LUASIMDJSON_EXPORT extern +#endif + extern "C" { static int parse(lua_State*); static int parse_file(lua_State*); @@ -6,15 +13,14 @@ extern "C" { static int ParsedObject_open(lua_State*); static int ParsedObject_open_file(lua_State*); - static const struct luaL_Reg luasimdjson[] = { {"parse", parse}, {"parseFile", parse_file}, {"activeImplementation", active_implementation}, {"open", ParsedObject_open}, {"openFile", ParsedObject_open_file}, - + {NULL, NULL}, }; - int luaopen_simdjson (lua_State*); + LUASIMDJSON_EXPORT int luaopen_simdjson(lua_State*); } \ No newline at end of file From 5df7935b3b13716fff690c06d43fb9dfed7fcea6 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 19 Feb 2025 19:11:23 +0000 Subject: [PATCH 3/7] Add MSVC target to test matrix --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b19f923..87df3de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,7 @@ jobs: fail-fast: false matrix: lua: [lua=5.1, lua=5.2, lua=5.3, lua=5.4, luajit=2.0, luajit=2.1] + target: [mingw,vs] runs-on: windows-2022 steps: # Checks-out the repository under $GITHUB_WORKSPACE. @@ -53,7 +54,7 @@ jobs: - name: Install Lua (${{ matrix.lua }}) run: | pip install hererocks - hererocks lua_install -r@3a142ce --${{ matrix.lua }} + hererocks lua_install -r@3a142ce --${{ matrix.lua }} --target ${{ matrix.target }} - name: Build lua-simdjson run: | .\lua_install\bin\activate From 4281b1c4732ba5702ec881061356a019352dbd40 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 19 Feb 2025 20:46:03 +0000 Subject: [PATCH 4/7] [ci] Use patched luarocks to fix msvc setup --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87df3de..538fe3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: - name: Install Lua (${{ matrix.lua }}) run: | pip install hererocks - hererocks lua_install -r@3a142ce --${{ matrix.lua }} --target ${{ matrix.target }} + hererocks lua_install -rhttps://github.com/tobil4sk/luarocks@46903c2 --${{ matrix.lua }} --target ${{ matrix.target }} - name: Build lua-simdjson run: | .\lua_install\bin\activate From 5f517178a5c8089ca09ff7ba5457bd671ffd8ed6 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Thu, 20 Feb 2025 15:19:09 +0000 Subject: [PATCH 5/7] [ci] Add workaround for missing compat53 --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 538fe3b..261d367 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,10 @@ jobs: run: | pip install hererocks hererocks lua_install -rhttps://github.com/tobil4sk/luarocks@46903c2 --${{ matrix.lua }} --target ${{ matrix.target }} + + # Workaround for: https://github.com/luarocks/luarocks/issues/1726 + .\lua_install\bin\activate + luarocks install compat53 - name: Build lua-simdjson run: | .\lua_install\bin\activate From 9d8b6e360e6bf267c8e1ed482fc3cdcdee99e296 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Mon, 24 Feb 2025 22:49:27 +0000 Subject: [PATCH 6/7] [ci] Use patched luarocks to avoid compat53 issue --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 261d367..6c90f03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,11 +54,8 @@ jobs: - name: Install Lua (${{ matrix.lua }}) run: | pip install hererocks - hererocks lua_install -rhttps://github.com/tobil4sk/luarocks@46903c2 --${{ matrix.lua }} --target ${{ matrix.target }} - - # Workaround for: https://github.com/luarocks/luarocks/issues/1726 - .\lua_install\bin\activate - luarocks install compat53 + # patched luarocks: https://github.com/luarocks/luarocks/pull/1757 + hererocks lua_install -rhttps://github.com/tobil4sk/luarocks@vendor-lua-compat53 --${{ matrix.lua }} --target ${{ matrix.target }} - name: Build lua-simdjson run: | .\lua_install\bin\activate From 64527bd3a35a371dd3f04ac703bee043c59f0bbc Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Mon, 24 Feb 2025 23:21:42 +0000 Subject: [PATCH 7/7] [ci] Update to upstream version of luarocks The patch for the lua compat53 issue has been merged now --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c90f03..05c1259 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,8 +54,7 @@ jobs: - name: Install Lua (${{ matrix.lua }}) run: | pip install hererocks - # patched luarocks: https://github.com/luarocks/luarocks/pull/1757 - hererocks lua_install -rhttps://github.com/tobil4sk/luarocks@vendor-lua-compat53 --${{ matrix.lua }} --target ${{ matrix.target }} + hererocks lua_install -r@28f9d98 --${{ matrix.lua }} --target ${{ matrix.target }} - name: Build lua-simdjson run: | .\lua_install\bin\activate