Fixed windows build

dev
bill sun 2 years ago
parent 3229a54bd4
commit 2ed0fd7863

@ -23,7 +23,7 @@ AQuery is tested on mainstream operating systems such as Windows, macOS and Linu
There're multiple options to run AQuery on Windows. You can use the native toolchain from Microsoft Visual Studio or gcc from Cygwin/MinGW or run it under Windows Subsystem for Linux. There're multiple options to run AQuery on Windows. You can use the native toolchain from Microsoft Visual Studio or gcc from Cygwin/MinGW or run it under Windows Subsystem for Linux.
- For WSL, Docker or Linux virtual machines, see Linux, Docker sections below - For WSL, Docker or Linux virtual machines, see Linux, Docker sections below
- For Visual Studio: - For Visual Studio (Recommended):
1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store. 1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store.
2. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected. 2. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected.
3. Clone AQuery repo from [Github](https://github.com/sunyinqi0508/AQuery2) 3. Clone AQuery repo from [Github](https://github.com/sunyinqi0508/AQuery2)
@ -31,14 +31,17 @@ There're multiple options to run AQuery on Windows. You can use the native toolc
5. Change the build driver from aquery_config.py to "MSBuild" 5. Change the build driver from aquery_config.py to "MSBuild"
6. The libraries and headers for Monetdb are already included in msc-plugins, however you can also choose to download them from [Monetdb Easy Setup](https://www.monetdb.org/easy-setup/) and put them in the same place. 6. The libraries and headers for Monetdb are already included in msc-plugins, however you can also choose to download them from [Monetdb Easy Setup](https://www.monetdb.org/easy-setup/) and put them in the same place.
- For MinGW: - For Winlibs (Recommended):
1. Install gcc and python3 using the package manager. (For Msys2, `pacman -S gcc python3`) - Download latest winlibs toolchain from the [official website](https://winlibs.com/)
- Since winlibs is linked with native windows runtime libraries (UCRT or MSVCRT), it offers better interoperatibility with other libraries built with MSVC such as python and monetdb.
- Other steps can be either the same as Visual Studio or Cygwin/Mingw (below) without ABI break.
- For CygWin/MinGW:
1. Install gcc and python3 using its **builtin package manager** instead of the one from python.org or windows store. (For Msys2, `pacman -S gcc python3`)
2. Clone AQuery repo from Github 2. Clone AQuery repo from Github
3. Install python requirements 3. Install python requirements
4. The prebuilt binaries are included in ./lib directory. However, you could also rebuild them from [source](https://github.com/MonetDB/MonetDB). 4. The prebuilt binaries are included in ./lib directory. However, you could also rebuild them from [source](https://github.com/MonetDB/MonetDB).
- Note that it might be possible to use python from python.org or Microsoft store with gcc from MinGW. However, it might not work because of ABI breakage. So the better way is to use gcc with MinGW python from pacman or use clang/MSVC instead.
### macOS ### macOS
- Install a package manager such as [homebrew](https://brew.sh) - Install a package manager such as [homebrew](https://brew.sh)
- Install python3 and monetdb using homebrew `brew install python3 monetdb` - Install python3 and monetdb using homebrew `brew install python3 monetdb`

@ -44,16 +44,23 @@ def init_config():
if os_platform == 'win': if os_platform == 'win':
add_dll_dir(cygroot) add_dll_dir(cygroot)
add_dll_dir(os.path.abspath('./msc-plugin')) add_dll_dir(os.path.abspath('./msc-plugin'))
import vswhere if build_driver == 'Auto':
vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath') try:
if vsloc: import vswhere
msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe' vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath')
build_driver = 'MSBuild' if vsloc:
else: msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe'
print('Warning: No Visual Studio installation found.') build_driver = 'MSBuild'
else:
print('Warning: No Visual Studio installation found.')
build_driver = 'Makefile'
except ModuleNotFoundError:
build_driver = 'Makefile'
# print("adding path") # print("adding path")
else: else:
import readline import readline
if build_driver == 'Auto':
build_driver = 'Makefile'
if os_platform == 'cygwin': if os_platform == 'cygwin':
add_dll_dir('./lib') add_dll_dir('./lib')
__config_initialized__ = True __config_initialized__ = True

@ -14,7 +14,7 @@ class checksums:
libaquery_a : Optional[Union[bytes, bool]] = None libaquery_a : Optional[Union[bytes, bool]] = None
pch_hpp_gch : Optional[Union[bytes, bool]] = None pch_hpp_gch : Optional[Union[bytes, bool]] = None
server : Optional[Union[bytes, bool]] = None server : Optional[Union[bytes, bool]] = None
sources : Union[Dict[str, bytes], bool] = None sources : Optional[Union[Dict[str, bytes], bool]] = None
env : str = '' env : str = ''
def calc(self, compiler_name, libaquery_a = 'libaquery.a' , def calc(self, compiler_name, libaquery_a = 'libaquery.a' ,
pch_hpp_gch = 'server/pch.hpp.gch', pch_hpp_gch = 'server/pch.hpp.gch',

@ -435,7 +435,7 @@ gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
#define HAVE_SOCKLEN_T 1 #define HAVE_SOCKLEN_T 1
#ifndef _MSC_VER #ifndef _MSC_VER
#define SOCKET int // #define SOCKET int
#define closesocket close #define closesocket close
#endif #endif

@ -76,8 +76,8 @@ __AQEXPORT__(void) init_session(Context* cxt);
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {} #define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
#ifdef _MSC_VER #ifdef _WIN32
void* _cdecl memcpy(void*, void*, size_t); #include <cstring>
#else #else
void* memcpy(void*, const void*, unsigned long long); void* memcpy(void*, const void*, unsigned long long);
#endif #endif

@ -176,10 +176,10 @@ int dll_main(int argc, char** argv, Context* cxt){
//getlasterror //getlasterror
if (!user_module_handle) if (!user_module_handle)
#ifndef _MSC_VER #ifndef _WIN32
puts(dlerror()); puts(dlerror());
#else #else
printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, GetLastError()); printf("Fatal Error: Module %s failed to load with error code %d.\n", mname, dlerror());
#endif #endif
user_module_map[mname] = user_module_handle; user_module_map[mname] = user_module_handle;
initialize_module(mname, user_module_handle, cxt); initialize_module(mname, user_module_handle, cxt);

@ -22,7 +22,12 @@ inline constexpr monetdbe_types AQType_2_monetdbe[] = {
#else #else
monetdbe_int64_t, monetdbe_int64_t,
#endif #endif
monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool, monetdbe_int128_t, monetdbe_int16_t, monetdbe_int8_t, monetdbe_bool,
#ifdef HAVE_HGE
monetdbe_int128_t,
#else
monetdbe_int64_t,
#endif
monetdbe_timestamp, monetdbe_int64_t, monetdbe_int64_t monetdbe_timestamp, monetdbe_int64_t, monetdbe_int64_t
}; };

@ -20,6 +20,10 @@ int dlclose(void* handle)
return FreeLibrary(static_cast<HMODULE>(handle)); return FreeLibrary(static_cast<HMODULE>(handle));
} }
int dlerror() {
return GetLastError();
}
SharedMemory::SharedMemory(const char* fname) SharedMemory::SharedMemory(const char* fname)
{ {
this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname); this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname);

@ -5,6 +5,8 @@ static constexpr int RTLD_LAZY = 1;
void* dlopen(const char*, int); void* dlopen(const char*, int);
void* dlsym(void*, const char*); void* dlsym(void*, const char*);
int dlclose(void*); int dlclose(void*);
int dlerror();
struct SharedMemory struct SharedMemory
{ {
void* hFileMap; void* hFileMap;

Loading…
Cancel
Save