1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-22 14:30:27 +00:00

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.
This commit is contained in:
Calvin Rose 2023-09-20 20:07:03 -07:00
parent b10aaceab0
commit 910b9cf1fd
3 changed files with 24 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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" />