From 2ceb5c2b041bf501d5d9fc84d27d258ccd32ece7 Mon Sep 17 00:00:00 2001 From: octaspire Date: Tue, 22 Jan 2019 22:29:35 +0200 Subject: [PATCH] Build embedding example, ncurses plugin and socket plugin with MSVC in Windows --- .../octaspire/dern/octaspire_dern_config.h | 2 +- release/how-to-build/windows-msvc.bat | 37 +++++++++ release/octaspire-dern-amalgamated.c | 2 +- release/plugins/dern_ncurses.c | 82 ++++++++++++++++++- release/plugins/dern_socket.c | 36 +++++++- 5 files changed, 151 insertions(+), 8 deletions(-) diff --git a/dev/include/octaspire/dern/octaspire_dern_config.h b/dev/include/octaspire/dern/octaspire_dern_config.h index 65c3398..1c9c527 100644 --- a/dev/include/octaspire/dern/octaspire_dern_config.h +++ b/dev/include/octaspire/dern/octaspire_dern_config.h @@ -18,7 +18,7 @@ limitations under the License. #define OCTASPIRE_DERN_CONFIG_H #define OCTASPIRE_DERN_CONFIG_VERSION_MAJOR "0" -#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "480" +#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "481" #define OCTASPIRE_DERN_CONFIG_VERSION_PATCH "0" #define OCTASPIRE_DERN_CONFIG_VERSION_STR "Octaspire Dern version " \ diff --git a/release/how-to-build/windows-msvc.bat b/release/how-to-build/windows-msvc.bat index f63e081..77bc6b1 100644 --- a/release/how-to-build/windows-msvc.bat +++ b/release/how-to-build/windows-msvc.bat @@ -12,6 +12,18 @@ cl /nologo /W3 /DOCTASPIRE_DERN_AMALGAMATED_UNIT_TEST_IMPLEMENTATION octaspire-d @ECHO cl /W3 /DOCTASPIRE_DERN_AMALGAMATED_UNIT_TEST_IMPLEMENTATION octaspire-dern-amalgamated.c /link /out:octaspire-dern-unit-test-runner.exe +@ECHO ----------------------------------------------------------------- +@ECHO embedding example +@ECHO ----------------------------------------------------------------- +cl /nologo /W2 /I. /DOCTASPIRE_DERN_CONFIG_BINARY_PLUGINS examples\embedding-example.c /link /out:embedding-example.exe +@ECHO. +@ECHO RUN WITH: +@ECHO embedding-example.exe +@ECHO. +@ECHO BUILD WITH: +@ECHO cl /W2 /I. /DOCTASPIRE_DERN_CONFIG_BINARY_PLUGINS examples\embedding-example.c /link /out:embedding-example.exe + + @ECHO ----------------------------------------------------------------- @ECHO interactive Dern REPL: @ECHO ----------------------------------------------------------------- @@ -34,3 +46,28 @@ cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD examples\myli @ECHO. @ECHO BUILD WITH: @ECHO cl /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD examples\mylib.c /link /out:libmylib.dll + + +@ECHO ----------------------------------------------------------------- +@ECHO Dern socket plugin +@ECHO ----------------------------------------------------------------- +cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_socket.c /link ws2_32.lib /out:libdern_socket.dll +@ECHO. +@ECHO RUN WITH: +@ECHO octaspire-dern-repl.exe examples\irc-client-ncurses.dern +@ECHO octaspire-dern-repl.exe examples\irc-client-nuklear.dern +@ECHO. +@ECHO BUILD WITH: +@ECHO cl /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_socket.c /link ws2_32.lib /out:libdern_socket.dll + + +@ECHO ----------------------------------------------------------------- +@ECHO Dern ncurses plugin +@ECHO ----------------------------------------------------------------- +cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_ncurses.c /link pdcurses.lib /out:libdern_ncurses.dll +@ECHO. +@ECHO RUN WITH: +@ECHO octaspire-dern-repl.exe examples\dern-ncurses-example.dern +@ECHO. +@ECHO BUILD WITH: +@ECHO cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_ncurses.c /link pdcurses.lib /out:libdern_ncurses.dll diff --git a/release/octaspire-dern-amalgamated.c b/release/octaspire-dern-amalgamated.c index d93a4b9..2a464ae 100644 --- a/release/octaspire-dern-amalgamated.c +++ b/release/octaspire-dern-amalgamated.c @@ -26336,7 +26336,7 @@ limitations under the License. #define OCTASPIRE_DERN_CONFIG_H #define OCTASPIRE_DERN_CONFIG_VERSION_MAJOR "0" -#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "480" +#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "481" #define OCTASPIRE_DERN_CONFIG_VERSION_PATCH "0" #define OCTASPIRE_DERN_CONFIG_VERSION_STR "Octaspire Dern version " \ diff --git a/release/plugins/dern_ncurses.c b/release/plugins/dern_ncurses.c index 2ab3ed1..ba3716e 100644 --- a/release/plugins/dern_ncurses.c +++ b/release/plugins/dern_ncurses.c @@ -59,12 +59,18 @@ limitations under the License. static char const * const DERN_NCURSES_PLUGIN_NAME = "dern_ncurses"; +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif void dern_ncurses_window_clean_up_callback(void *payload) { octaspire_helpers_verify_not_null(payload); endwin(); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_initscr( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -89,7 +95,9 @@ octaspire_dern_value_t *dern_ncurses_initscr( window); } - +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_getmaxyx( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -164,6 +172,9 @@ octaspire_dern_value_t *dern_ncurses_getmaxyx( octaspire_dern_vm_create_new_value_integer(vm, (int32_t)x)); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_getch( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -235,7 +246,9 @@ octaspire_dern_value_t *dern_ncurses_getch( } case KEY_DC: +#ifndef _MSC_VER case OCTASPIRE_DERN_NCURSES_ADDITIONAL_KEY_DC: +#endif { return octaspire_dern_vm_create_new_value_symbol_from_c_string(vm, "KEY_DC"); } @@ -250,6 +263,9 @@ octaspire_dern_value_t *dern_ncurses_getch( } } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_getstr( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -371,6 +387,9 @@ octaspire_dern_value_t *dern_ncurses_getstr( return octaspire_dern_vm_create_new_value_string(vm, resultStr); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_set_raw( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -412,6 +431,9 @@ octaspire_dern_value_t *dern_ncurses_set_raw( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_set_timeout( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -465,6 +487,9 @@ octaspire_dern_value_t *dern_ncurses_set_timeout( return octaspire_dern_vm_create_new_value_integer(vm, delay); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_set_cbreak( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -505,6 +530,9 @@ octaspire_dern_value_t *dern_ncurses_set_cbreak( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_set_echo( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -545,6 +573,9 @@ octaspire_dern_value_t *dern_ncurses_set_echo( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_set_nl( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -585,6 +616,9 @@ octaspire_dern_value_t *dern_ncurses_set_nl( return octaspire_dern_vm_create_new_value_nil(vm); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_set_cursor( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -685,6 +719,9 @@ octaspire_dern_value_t *dern_ncurses_set_cursor( return octaspire_dern_vm_create_new_value_symbol_from_c_string(vm, "very-visible"); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_set_keypad( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -759,6 +796,9 @@ octaspire_dern_value_t *dern_ncurses_set_keypad( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_erase( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -818,6 +858,9 @@ octaspire_dern_value_t *dern_ncurses_erase( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_clear( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -994,6 +1037,9 @@ static int dern_ncurses_private_print_symbol( return result; } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_print( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1250,6 +1296,9 @@ octaspire_dern_value_t *dern_ncurses_print( abort(); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_halfdelay( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1292,6 +1341,9 @@ octaspire_dern_value_t *dern_ncurses_halfdelay( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_move( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1388,6 +1440,9 @@ octaspire_dern_value_t *dern_ncurses_move( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_attron( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1506,6 +1561,9 @@ octaspire_dern_value_t *dern_ncurses_attron( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_attroff( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1624,6 +1682,9 @@ octaspire_dern_value_t *dern_ncurses_attroff( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_has_colors( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1651,6 +1712,9 @@ octaspire_dern_value_t *dern_ncurses_has_colors( return octaspire_dern_vm_create_new_value_boolean(vm, result); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_init_color( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1713,6 +1777,9 @@ octaspire_dern_value_t *dern_ncurses_init_color( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_init_pair( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1829,6 +1896,9 @@ octaspire_dern_value_t *dern_ncurses_init_pair( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_start_color( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1856,7 +1926,9 @@ octaspire_dern_value_t *dern_ncurses_start_color( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } - +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_refresh( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1884,6 +1956,9 @@ octaspire_dern_value_t *dern_ncurses_refresh( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_ncurses_endwin( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -1911,6 +1986,9 @@ octaspire_dern_value_t *dern_ncurses_endwin( return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif bool dern_ncurses_init( octaspire_dern_vm_t * const vm, octaspire_dern_environment_t * const targetEnv, diff --git a/release/plugins/dern_socket.c b/release/plugins/dern_socket.c index 5457f60..1f84ffd 100644 --- a/release/plugins/dern_socket.c +++ b/release/plugins/dern_socket.c @@ -14,15 +14,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ******************************************************************************/ -#include "octaspire-dern-amalgamated.c" #ifdef _WIN32 -#include -#else +#include // winsock2.h must be included before windows.h +#endif + +#include "octaspire-dern-amalgamated.c" + +#ifndef _WIN32 #include #include #include #include +#include #endif + #ifdef __FreeBSD__ #include #endif @@ -33,7 +38,6 @@ limitations under the License. #include #include #include -#include #include static char const * const DERN_SOCKET_PLUGIN_NAME = "dern_socket"; @@ -65,12 +69,18 @@ static char const *dern_socket_private_format_win32_error_message(void) } #endif +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif void dern_socket_socket_clean_up_callback(void *payload) { octaspire_helpers_verify_not_null(payload); close((intptr_t)payload); } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_socket_new_ipv4_stream_socket( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -324,6 +334,9 @@ octaspire_dern_value_t *dern_socket_new_ipv4_stream_socket( #endif } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_socket_close( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -413,6 +426,9 @@ octaspire_dern_value_t *dern_socket_close( #endif } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_socket_accept( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -536,6 +552,9 @@ octaspire_dern_value_t *dern_socket_accept( #endif } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_socket_receive( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -711,6 +730,9 @@ octaspire_dern_value_t *dern_socket_receive( #endif } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif octaspire_dern_value_t *dern_socket_send( octaspire_dern_vm_t * const vm, octaspire_dern_value_t * const arguments, @@ -874,6 +896,9 @@ octaspire_dern_value_t *dern_socket_send( #endif } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif bool dern_socket_init( octaspire_dern_vm_t * const vm, octaspire_dern_environment_t * const targetEnv, @@ -1046,6 +1071,9 @@ bool dern_socket_init( return true; } +#ifdef _MSC_VER +extern __declspec(dllexport) +#endif bool dern_socket_clean( octaspire_dern_vm_t * const vm, octaspire_dern_environment_t * const targetEnv) -- 2.45.2