diff options
| author | 2023-09-20 20:07:03 -0700 | |
|---|---|---|
| committer | 2023-09-20 20:07:03 -0700 | |
| commit | 910b9cf1fdd202aa780a75285f84c87bbd3ca659 (patch) | |
| tree | 0bb3f7ed58724e5d2db3d0f46f2503ad2ce9ebf4 | |
| parent | Work on dllimport option for janet. (diff) | |
Distinguish between JANET_API and JANET_EXPORT
One is a way to export symbols, the other a way to reference
API functions. Also include prebuilt dlljanet.dll and dlljanet.lib
for windows to save people the trouble of compiling janet.c themselves.
| -rw-r--r-- | build_win.bat | 6 | ||||
| -rw-r--r-- | src/include/janet.h | 14 | ||||
| -rw-r--r-- | tools/msi/janet.wxs | 6 |
3 files changed, 24 insertions, 2 deletions
diff --git a/build_win.bat b/build_win.bat index d6c56e97..e491262c 100644 --- a/build_win.bat +++ b/build_win.bat @@ -64,6 +64,10 @@ rc /nologo /fobuild\janet_win.res janet_win.rc %JANET_LINK% /out:janet.exe build\janet.obj build\shell.obj build\janet_win.res @if errorlevel 1 goto :BUILDFAIL +@rem Build dynamic library (dlljanet.dll) +%JANET_LINK% /DLL /out:build\dlljanet.dll build\janet.obj +@if errorlevel 1 goto :BUILDFAIL + @rem Build static library (libjanet.lib) %JANET_LINK_STATIC% /out:build\libjanet.lib build\janet.obj @if errorlevel 1 goto :BUILDFAIL @@ -122,6 +126,8 @@ copy janet.def dist\janet.def janet.exe tools\patch-header.janet src\include\janet.h src\conf\janetconf.h build\janet.h copy build\janet.h dist\janet.h copy build\libjanet.lib dist\libjanet.lib +copy build\dlljanet.dll dist\dlljanet.dll +copy build\dlljanet.lib dist\dlljanet.lib @rem Create installer janet.exe -e "(->> janet/version (peg/match ''(* :d+ `.` :d+ `.` :d+)) first print)" > build\version.txt diff --git a/src/include/janet.h b/src/include/janet.h index c4e1c8d5..bdc0993e 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -235,6 +235,15 @@ extern "C" { #endif /* How to export symbols */ +#ifndef JANET_EXPORT +#ifdef JANET_WINDOWS +#define JANET_EXPORT __declspec(dllexport) +#else +#define JANET_EXPORT __attribute__((visibility ("default"))) +#endif +#endif + +/* How declare API functions */ #ifndef JANET_API #ifdef JANET_WINDOWS #ifdef JANET_DLL_IMPORT @@ -734,6 +743,7 @@ JANET_API Janet janet_wrap_integer(int32_t x); ? janet_nanbox_isnumber(x) \ : janet_nanbox_checkauxtype((x), (t))) +/* Use JANET_API so that modules will use a local version of these functions if possible */ JANET_API void *janet_nanbox_to_pointer(Janet x); JANET_API Janet janet_nanbox_from_pointer(void *p, uint64_t tagmask); JANET_API Janet janet_nanbox_from_cpointer(const void *p, uint64_t tagmask); @@ -1952,10 +1962,10 @@ JANET_API void janet_register(const char *name, JanetCFunction cfun); #endif #ifndef JANET_ENTRY_NAME #define JANET_MODULE_ENTRY \ - JANET_MODULE_PREFIX JANET_API JanetBuildConfig _janet_mod_config(void) { \ + JANET_MODULE_PREFIX JANET_EXPORT JanetBuildConfig _janet_mod_config(void) { \ return janet_config_current(); \ } \ - JANET_MODULE_PREFIX JANET_API void _janet_init + JANET_MODULE_PREFIX JANET_EXPORT void _janet_init #else #define JANET_MODULE_ENTRY JANET_MODULE_PREFIX JANET_API void JANET_ENTRY_NAME #endif diff --git a/tools/msi/janet.wxs b/tools/msi/janet.wxs index 9ea2038d..9cddd5a4 100644 --- a/tools/msi/janet.wxs +++ b/tools/msi/janet.wxs @@ -132,6 +132,12 @@ <Component Directory="CDir"> <File Source="dist\libjanet.lib"/> </Component> + <Component Directory="CDir"> + <File Source="dist\dlljanet.dll"/> + </Component> + <Component Directory="CDir"> + <File Source="dist\dlljanet.lib"/> + </Component> <Component Id="LibraryComponent" Directory="LibraryDir" Guid="3860e981-5f94-4002-b5d5-2d9ec0d2792d" KeyPath="yes"> <RemoveFolder Id="RemoveLibraryDir" On="uninstall" /> |
