diff --git a/README.md b/README.md index 98ae406..f1e0cb1 100644 --- a/README.md +++ b/README.md @@ -23,22 +23,25 @@ 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. - 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. 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) 4. Install python requirements with pip `python3 -m pip install -r requirements.txt` 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. - -- For MinGW: - 1. Install gcc and python3 using the package manager. (For Msys2, `pacman -S gcc python3`) + +- For Winlibs (Recommended): + - 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 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). - -- 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 - Install a package manager such as [homebrew](https://brew.sh) - Install python3 and monetdb using homebrew `brew install python3 monetdb` diff --git a/aquery_config.py b/aquery_config.py index 616cb2a..699ad70 100644 --- a/aquery_config.py +++ b/aquery_config.py @@ -44,16 +44,23 @@ def init_config(): if os_platform == 'win': add_dll_dir(cygroot) add_dll_dir(os.path.abspath('./msc-plugin')) - import vswhere - vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath') - if vsloc: - msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe' - build_driver = 'MSBuild' - else: - print('Warning: No Visual Studio installation found.') + if build_driver == 'Auto': + try: + import vswhere + vsloc = vswhere.find(prerelease = True, latest = True, prop = 'installationPath') + if vsloc: + msbuildroot = vsloc[0] + '/MSBuild/Current/Bin/MSBuild.exe' + build_driver = 'MSBuild' + else: + print('Warning: No Visual Studio installation found.') + build_driver = 'Makefile' + except ModuleNotFoundError: + build_driver = 'Makefile' # print("adding path") else: import readline + if build_driver == 'Auto': + build_driver = 'Makefile' if os_platform == 'cygwin': add_dll_dir('./lib') __config_initialized__ = True diff --git a/build.py b/build.py index 79da774..edf09be 100644 --- a/build.py +++ b/build.py @@ -14,7 +14,7 @@ class checksums: libaquery_a : Optional[Union[bytes, bool]] = None pch_hpp_gch : 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 = '' def calc(self, compiler_name, libaquery_a = 'libaquery.a' , pch_hpp_gch = 'server/pch.hpp.gch', diff --git a/monetdb/msvc/monetdb_config.h b/monetdb/msvc/monetdb_config.h index d47fef2..730c019 100644 --- a/monetdb/msvc/monetdb_config.h +++ b/monetdb/msvc/monetdb_config.h @@ -435,7 +435,7 @@ gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result) #define HAVE_SOCKLEN_T 1 #ifndef _MSC_VER -#define SOCKET int +// #define SOCKET int #define closesocket close #endif diff --git a/sdk/aquery.h b/sdk/aquery.h index 2fe0404..4c9c779 100644 --- a/sdk/aquery.h +++ b/sdk/aquery.h @@ -76,8 +76,8 @@ __AQEXPORT__(void) init_session(Context* cxt); #define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {} -#ifdef _MSC_VER -void* _cdecl memcpy(void*, void*, size_t); +#ifdef _WIN32 +#include #else void* memcpy(void*, const void*, unsigned long long); #endif diff --git a/server/server.cpp b/server/server.cpp index c92d25a..c7b130d 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -176,10 +176,10 @@ int dll_main(int argc, char** argv, Context* cxt){ //getlasterror if (!user_module_handle) -#ifndef _MSC_VER +#ifndef _WIN32 puts(dlerror()); #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 user_module_map[mname] = user_module_handle; initialize_module(mname, user_module_handle, cxt); diff --git a/server/table_ext_monetdb.hpp b/server/table_ext_monetdb.hpp index 32c27f9..c128559 100644 --- a/server/table_ext_monetdb.hpp +++ b/server/table_ext_monetdb.hpp @@ -22,7 +22,12 @@ inline constexpr monetdbe_types AQType_2_monetdbe[] = { #else monetdbe_int64_t, #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 }; diff --git a/server/winhelper.cpp b/server/winhelper.cpp index 08fd1a2..ed418af 100644 --- a/server/winhelper.cpp +++ b/server/winhelper.cpp @@ -20,6 +20,10 @@ int dlclose(void* handle) return FreeLibrary(static_cast(handle)); } +int dlerror() { + return GetLastError(); +} + SharedMemory::SharedMemory(const char* fname) { this->hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 2, fname); diff --git a/server/winhelper.h b/server/winhelper.h index 5993943..df9231e 100644 --- a/server/winhelper.h +++ b/server/winhelper.h @@ -5,6 +5,8 @@ static constexpr int RTLD_LAZY = 1; void* dlopen(const char*, int); void* dlsym(void*, const char*); int dlclose(void*); +int dlerror(); + struct SharedMemory { void* hFileMap;