Skip to content

Commit 5d3bbe9

Browse files
committed
Back to fixing the Windows build.
1 parent 322e722 commit 5d3bbe9

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

.appveyor.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ install:
1717
$Env:PATH = "C:\Miniconda36-x64;C:\Miniconda36-x64\Scripts;$Env:PATH"
1818
$Env:PYTHONUNBUFFERED = 1
1919
conda config --set always_yes true
20+
conda update -n base conda
2021
conda update --quiet --all
2122
conda install --quiet matplotlib
23+
pip install -U pip
2224
New-Item -ItemType directory build
2325
Set-Location build
2426
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@@ -31,7 +33,7 @@ install:
3133
pip uninstall -y . # Just get the dependencies.
3234
python setup.py bdist_wheel
3335
pip install $(Get-Item dist\*.whl)
34-
# end-syntax: ps1
36+
# end-syntax: ps1
3537
3638
test_script: |
3739
rem begin-syntax: dosbatch

src/_os.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
#if defined __linux__ || defined __APPLE__
44
#include <dlfcn.h>
5+
#else
6+
#include <Windows.h>
57
#endif
68

79
namespace mplcairo::os {
810

911
#if defined __linux__ || defined __APPLE__
10-
void* dlopen(char const* filename) {
12+
using library_t = void*;
13+
using symbol_t = void*;
14+
15+
library_t dlopen(char const* filename) {
1116
return ::dlopen(filename, RTLD_LAZY);
1217
}
1318

14-
bool dlclose(void* handle) {
19+
bool dlclose(library_t handle) {
1520
return ::dlclose(handle);
1621
}
1722

18-
void* dlsym(void* handle, char const* symbol) {
23+
symbol_t dlsym(library_t handle, char const* symbol) {
1924
return ::dlsym(handle, symbol);
2025
}
2126

@@ -24,15 +29,18 @@ char const* dlerror() {
2429
}
2530

2631
#elif _WIN32
27-
void* dlopen(char const* filename) {
32+
using library_t = HMODULE;
33+
using symbol_t = FARPROC;
34+
35+
library_t dlopen(char const* filename) {
2836
return LoadLibrary(filename);
2937
}
3038

31-
bool dlclose(void* handle) {
39+
bool dlclose(library_t handle) {
3240
return !FreeLibrary(handle);
3341
}
3442

35-
void* dlsym(void* handle, char const* symbol) {
43+
symbol_t dlsym(library_t handle, char const* symbol) {
3644
return GetProcAddress(handle, symbol);
3745
}
3846

src/_os.h

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
#ifdef _WIN32
2+
#include <Windows.h>
3+
#endif
4+
15
namespace mplcairo::os {
26

3-
void* dlopen(char const* filename);
4-
bool dlclose(void* handle);
5-
void* dlsym(void* handle, char const* symbol);
7+
#if defined __linux__ || defined __APPLE__
8+
using library_t = void*;
9+
using symbol_t = void*;
10+
#elif defined _WIN32
11+
using library_t = HMODULE;
12+
using symbol_t = FARPROC;
13+
#endif
14+
library_t dlopen(char const* filename);
15+
bool dlclose(library_t handle);
16+
symbol_t dlsym(library_t handle, char const* symbol);
617
char const* dlerror();
718

819
}

src/_raqm.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#include "_os.h"
33
#include "_macros.h"
44

5+
#include <stdexcept>
6+
57
namespace mplcairo {
68

79
namespace raqm {
810

911
namespace {
10-
void* _handle;
12+
os::library_t _handle;
1113
}
1214

1315
#define DEFINE_API(name) decltype(raqm_##name)* name{};
@@ -23,7 +25,7 @@ void load_raqm() {
2325
"libraqm.so.0";
2426
#elif defined __APPLE__
2527
"libraqm.dylib";
26-
#elif defined _win32
28+
#elif defined _WIN32
2729
"libraqm";
2830
#endif
2931
raqm::_handle = os::dlopen(filename);

0 commit comments

Comments
 (0)