Added target for MSVC DLLs for use in Visual Studio
This commit is contained in:
17
Makefile
17
Makefile
@@ -140,7 +140,7 @@ else
|
||||
STRIP=strip
|
||||
endif
|
||||
ifeq ($(LIBZT_DEBUG),1)
|
||||
CFLAGS+=-g
|
||||
#CFLAGS+=-g
|
||||
LIBZT_DEFS+=-DLIBZT_DEBUG
|
||||
endif
|
||||
ifeq ($(NS_DEBUG),1)
|
||||
@@ -285,11 +285,14 @@ utilities:
|
||||
$(ZT_DEFS) $(ZT_INCLUDES) $(LIBZT_INCLUDES) $(STACK_DRIVER_DEFS)
|
||||
|
||||
|
||||
dll: lwip lwip_driver libzt_socket_layer utilities $(ZTO_OBJS)
|
||||
win_dll: lwip lwip_driver libzt_socket_layer utilities $(ZTO_OBJS)
|
||||
# First we use mingw to build our DLL
|
||||
@mkdir -p $(BUILD) obj
|
||||
mv *.o obj
|
||||
windres -i src/dll_desc.rc -o obj/dll_desc.o
|
||||
$(CXX) $(CXXFLAGS) -shared -o libzt.dll obj/*.o -s -shared -Wl,--subsystem,windows $(WINDEFS)
|
||||
windres -i res/libztdll.rc -o obj/libztdllres.o
|
||||
$(CXX) $(CXXFLAGS) -shared -o $(BUILD)/libzt.dll obj/*.o -Wl,--output-def,$(BUILD)/libzt.def,--out-implib,$(BUILD)/libzt.a $(WINDEFS)
|
||||
# Then do the following to generate the mSVC DLL from the def file (which was generated from the MinGW DLL):
|
||||
# lib /machine:x64 /def:libzt.def
|
||||
|
||||
ifeq ($(STACK_PICO),1)
|
||||
static_lib: picotcp picotcp_driver libzt_socket_layer utilities $(ZTO_OBJS)
|
||||
@@ -379,6 +382,9 @@ intercept:
|
||||
-shared -o $(BUILD)/intercept.so $< -ldl
|
||||
@./check.sh $(BUILD)/intercept.so
|
||||
@date +"Build script finished on %F %T"
|
||||
dlltest:
|
||||
$(CXX) $(CXXFLAGS)
|
||||
|
||||
|
||||
##############################################################################
|
||||
## Misc ##
|
||||
@@ -392,8 +398,9 @@ standardize:
|
||||
|
||||
clean:
|
||||
-rm -rf .depend
|
||||
-rm -f *.o *.s .depend* *.core core
|
||||
-rm -f *.o *.s *.exp *.lib .depend* *.core core
|
||||
-rm -rf $(BUILD)/*
|
||||
-rm -rf obj/*
|
||||
-find . -type f \( -name '*.a' -o -name '*.o' -o -name '*.so' -o -name \
|
||||
'*.o.d' -o -name '*.out' -o -name '*.log' -o -name '*.dSYM' \) -delete
|
||||
|
||||
|
||||
@@ -33,9 +33,12 @@
|
||||
#ifndef LIBZT_DEBUG_HPP
|
||||
#define LIBZT_DEBUG_HPP
|
||||
|
||||
#if defined(__MINGW32__) || !defined(_WIN32)
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(__linux__)
|
||||
@@ -107,8 +110,12 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_STACK(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||
"STACK[%ld]: %17s:%5d:%20s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||
#endif
|
||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
||||
#define DEBUG_STACK(fmt, args, ...) fprintf(stderr, ZT_YEL "STACK[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define DEBUG_STACK(fmt, args...) fprintf(stderr, ZT_YEL "STACK[%ld]: %17s:%5d:%25s: " fmt \
|
||||
#define DEBUG_STACK(fmt, args ...) fprintf(stderr, ZT_YEL "STACK[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
|
||||
@@ -119,9 +126,13 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_TEST(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||
"TEST : %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||
#endif
|
||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
||||
#define DEBUG_TEST(fmt, args, ...) fprintf(stderr, ZT_CYN "TEST [%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define DEBUG_TEST(fmt, args...) fprintf(stderr, ZT_CYN "TEST [%ld]: %17s:%5d:%25s: " fmt \
|
||||
"\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_TEST(fmt, args ...) fprintf(stderr, ZT_CYN "TEST [%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_TEST(fmt, args...)
|
||||
@@ -132,9 +143,13 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_ERROR(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||
"ERROR: %17s:%5d:%20s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||
#endif
|
||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
||||
#define DEBUG_ERROR(fmt, args, ...) fprintf(stderr, ZT_RED "ERROR[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define DEBUG_ERROR(fmt, args...) fprintf(stderr, ZT_RED \
|
||||
"ERROR[%ld]: %17s:%5d:%25s: " fmt "\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_ERROR(fmt, args ...) fprintf(stderr, ZT_RED "ERROR[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_ERROR(fmt, args...)
|
||||
@@ -145,9 +160,13 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_INFO(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||
"INFO : %17s:%5d:%20s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||
#endif
|
||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
||||
#define DEBUG_INFO(fmt, args, ...) fprintf(stderr, ZT_WHT "INFO [%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define DEBUG_INFO(fmt, args...) fprintf(stderr, \
|
||||
"INFO [%ld]: %17s:%5d:%25s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_INFO(fmt, args ...) fprintf(stderr, ZT_WHT "INFO [%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_INFO(fmt, args...)
|
||||
@@ -158,9 +177,13 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_TRANS(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||
"TRANS: %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||
#endif
|
||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
||||
#define DEBUG_TRANS(fmt, args, ...) fprintf(stderr, ZT_GRN "TRANS[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define DEBUG_TRANS(fmt, args...) fprintf(stderr, ZT_GRN "TRANS[%ld]: %17s:%5d:%25s: " fmt \
|
||||
"\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_TRANS(fmt, args ...) fprintf(stderr, ZT_GRN "TRANS[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_TRANS(fmt, args...)
|
||||
@@ -171,15 +194,28 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_EXTRA(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||
"EXTRA: %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||
#endif
|
||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
||||
#define DEBUG_EXTRA(fmt, args, ...) fprintf(stderr, ZT_WHT "EXTRA[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define DEBUG_EXTRA(fmt, args...) fprintf(stderr, \
|
||||
"EXTRA[%ld]: %17s:%5d:%25s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_EXTRA(fmt, args ...) fprintf(stderr, ZT_WHT "EXTRA[%ld]: %17s:%5d:%25s: " fmt \
|
||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_EXTRA(fmt, args...)
|
||||
#endif
|
||||
|
||||
#else // !LIBZT_DEBUG || !__NATIVE_TEST__
|
||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
||||
#define DEBUG_ERROR(fmt, args, ...)
|
||||
#define DEBUG_TEST(fmt, args, ...)
|
||||
#define DEBUG_INFO(fmt, args, ...)
|
||||
#define DEBUG_BLANK(fmt, args, ...)
|
||||
#define DEBUG_ATTN(fmt, args, ...)
|
||||
#define DEBUG_TRANS(fmt, args, ...)
|
||||
#define DEBUG_EXTRA(fmt, args, ...)
|
||||
#else
|
||||
#define DEBUG_ERROR(fmt, args...)
|
||||
#define DEBUG_TEST(fmt, args...)
|
||||
#define DEBUG_INFO(fmt, args...)
|
||||
@@ -187,6 +223,7 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#define DEBUG_ATTN(fmt, args...)
|
||||
#define DEBUG_TRANS(fmt, args...)
|
||||
#define DEBUG_EXTRA(fmt, args...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // _H
|
||||
|
||||
@@ -33,18 +33,6 @@
|
||||
#ifndef LIBZT_H
|
||||
#define LIBZT_H
|
||||
|
||||
#if defined(__MING32__) || defined(__MING64__)
|
||||
#ifdef ADD_EXPORTS
|
||||
#define ZT_SOCKET_API __declspec(dllexport)
|
||||
#else
|
||||
#define ZT_SOCKET_API __declspec(dllimport)
|
||||
#endif
|
||||
#define ZTCALL __cdecl
|
||||
#else
|
||||
#define ZT_SOCKET_API
|
||||
#define ZTCALL
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
@@ -56,6 +44,26 @@
|
||||
#include "Debug.hpp"
|
||||
#include "Defs.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DLL export for Windows (and other cruft) */
|
||||
/****************************************************************************/
|
||||
|
||||
#if (defined(_WIN32) || defined(_WIN64)) && !(defined(__MINGW32__) || defined(__MINGW64__))
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
|
||||
#if defined(__MING32__) || defined(__MING64__)
|
||||
#ifdef ADD_EXPORTS
|
||||
#define ZT_SOCKET_API __declspec(dllexport)
|
||||
#else
|
||||
#define ZT_SOCKET_API __declspec(dllimport)
|
||||
#endif
|
||||
#define ZTCALL __cdecl
|
||||
#else
|
||||
#define ZT_SOCKET_API
|
||||
#define ZTCALL
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/* ZeroTier Service Controls */
|
||||
/****************************************************************************/
|
||||
@@ -66,7 +74,6 @@ extern "C" {
|
||||
|
||||
// forward declarations from ZT1Service.h
|
||||
ZT_SOCKET_API int ZTCALL zts_get_device_id(char *devID);
|
||||
|
||||
ZT_SOCKET_API void ZTCALL init_network_stack();
|
||||
|
||||
/**
|
||||
|
||||
2
makelib.bat
Normal file
2
makelib.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
REM For conversion of MinGW DLL to MSVC lib
|
||||
lib /machine:x64 /def:build\mingw32_nt-6.2\libzt.def /OUT:build\mingw32_nt-6.2\libzt.lib
|
||||
36
res/libztdll.rc
Normal file
36
res/libztdll.rc
Normal file
@@ -0,0 +1,36 @@
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
#pragma code_page(1252)
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,9,1,7
|
||||
PRODUCTVERSION 2,2,2,2
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "My Company.\0"
|
||||
VALUE "FileDescription", "My File\0"
|
||||
VALUE "FileVersion", "1.9.1.7\0"
|
||||
VALUE "InternalName", "my-real-file\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2012 My Company Ltd.\0"
|
||||
VALUE "OriginalFilename", "my.dll\0"
|
||||
VALUE "PrivateBuild", "820\0"
|
||||
VALUE "ProductName", "My Company: my dll\0"
|
||||
VALUE "ProductVersion", "2.2.2.2\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x809, 1200
|
||||
END
|
||||
END
|
||||
@@ -1,35 +0,0 @@
|
||||
#include <windows.h>
|
||||
|
||||
// DLL version information.
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,1,5,0
|
||||
PRODUCTVERSION 1,1,5,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG | VS_FF_PRERELEASE
|
||||
#else
|
||||
FILEFLAGS 0
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "ZeroTier, Inc."
|
||||
VALUE "FileDescription", "ZeroTier Socket API library."
|
||||
VALUE "FileVersion", "1.1.5.0"
|
||||
VALUE "InternalName", "libzt"
|
||||
VALUE "LegalCopyright", "©2017 ZeroTier, Inc."
|
||||
VALUE "OriginalFilename", "libzt.dll"
|
||||
VALUE "ProductName", "libzt"
|
||||
VALUE "ProductVersion", "1.1.5.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x809, 1200
|
||||
END
|
||||
END
|
||||
Reference in New Issue
Block a user