Skip to content

Add support for windows with MSVC toolchain #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ 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.
- uses: actions/checkout@v4
- name: Install Lua (${{ matrix.lua }})
run: |
pip install hererocks
hererocks lua_install -r@3a142ce --${{ matrix.lua }}
hererocks lua_install -r@28f9d98 --${{ matrix.lua }} --target ${{ matrix.target }}
- name: Build lua-simdjson
run: |
.\lua_install\bin\activate
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ test/
*.dll
*.o
*.d

# msvc
*.obj
*.lib
*.exp
27 changes: 27 additions & 0 deletions Makefile.win
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions lua-simdjson-0.0.6-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ build = {
build_variables = {
LUA_LIBDIR="$(LUA_LIBDIR)",
LUALIB="$(LUALIB)",
LD="$(LD)",
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/luasimdjson.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#include <lua.hpp>

#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*);
static int active_implementation(lua_State*);
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*);
}