mssql: support windows (#10336)
parent
0615f2e236
commit
3582118b7c
|
@ -0,0 +1,4 @@
|
||||||
|
*
|
||||||
|
|
||||||
|
!.gitignore
|
||||||
|
!mssql.h
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Hacking some headers in windows.
|
||||||
|
// sql headers using UNICODE to change function signatures.
|
||||||
|
// Currently Linux bindings do not use unicode SQL C bindings,
|
||||||
|
// So we turn off the UNICODE to make it compile on windows.
|
||||||
|
// For future Unicode support, please raise a issue.
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <sal.h>
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
// Turn off unicode macro and turn back on, so it only affects sql headers
|
||||||
|
#undef UNICODE
|
||||||
|
#include <sql.h>
|
||||||
|
#include <sqlext.h>
|
||||||
|
#define UNICODE
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <sql.h>
|
||||||
|
#include <sqlext.h>
|
||||||
|
#endif
|
|
@ -4,14 +4,36 @@
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
* ODBC C/C++ library
|
* ODBC C/C++ library
|
||||||
* Linux Install: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
|
* Linux Install:
|
||||||
* `msodbcsql17` and `unixodbc-dev` packages needed
|
* Details: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
|
||||||
* Windows Install: https://docs.microsoft.com/en-us/sql/connect/odbc/microsoft-odbc-driver-for-sql-server
|
* `msodbcsql17` and `unixodbc-dev` packages are needed
|
||||||
|
* Windows Install:
|
||||||
|
* `odbc` lib is included in windows sdk for most of distributions,
|
||||||
|
so there is no need to install it separately
|
||||||
|
* Details: https://docs.microsoft.com/en-us/sql/connect/odbc/microsoft-odbc-driver-for-sql-server
|
||||||
|
|
||||||
|
## Windows Notes
|
||||||
|
### Using `msvc`
|
||||||
|
* Make sure `cl.exe` of `msvc` is accessible from command line.
|
||||||
|
You can run `v` commands in `Visual Studio 2019 Developer Command Prompt` to be safe.
|
||||||
|
* C Headers and dlls can be automatically resolved by `msvc`.
|
||||||
|
### Using `tcc`
|
||||||
|
* Copy those headers to `@VEXEROOT\thirdparty\mssql\include`.
|
||||||
|
The version number `10.0.18362.0` might differ on your system.
|
||||||
|
Command Prompt commands:
|
||||||
|
```cmd
|
||||||
|
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sql.h" thirdparty\mssql\include
|
||||||
|
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sqlext.h" thirdparty\mssql\include
|
||||||
|
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sqltypes.h" thirdparty\mssql\include
|
||||||
|
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sqlucode.h" thirdparty\mssql\include
|
||||||
|
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\sal.h" thirdparty\mssql\include
|
||||||
|
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\concurrencysal.h" thirdparty\mssql\include
|
||||||
|
```
|
||||||
|
* dlls can be automatically resolved by `tcc`
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
* Support Windows
|
|
||||||
* Support Mac
|
* Support Mac
|
||||||
* ORM
|
* Support ORM
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```v ignore
|
```v ignore
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
module mssql
|
module mssql
|
||||||
|
|
||||||
// TODO: implement windows
|
// mssql module does not support tcc on windows
|
||||||
// #flag windows -I@VEXEROOT/thirdparty/msodbcsql17
|
|
||||||
// #flag windows @VEXEROOT/thirdparty/msodbcsql17/lib64
|
// odbc32 lib comes with windows sdk and does not need to be installed separately.
|
||||||
|
// v builder for msvc can resolve the sdk includes search path, so no need to repeat here.
|
||||||
|
#flag windows -lodbc32
|
||||||
|
|
||||||
|
// Special handling of sql headers on windows.
|
||||||
|
// Source is in v third party folder.
|
||||||
|
#flag windows -I@VEXEROOT/thirdparty/mssql/include
|
||||||
|
#include <mssql.h>
|
||||||
|
|
Loading…
Reference in New Issue