Fix the docs.rs build take 2
This commit is contained in:
@@ -6,6 +6,10 @@ file. This change log follows the conventions of
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Docs.rs build should now pass. Take #2.
|
||||
|
||||
## [v0.1.1] - 2022-10-23
|
||||
|
||||
### Fixed
|
||||
|
@@ -30,4 +30,5 @@ simconnect-sdk = { path = "../simconnect-sdk" }
|
||||
trybuild = { version = "1.0", features = ["diff"] }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-pc-windows-msvc"]
|
||||
default-target = "x86_64-pc-windows-msvc"
|
||||
targets = []
|
||||
|
@@ -25,6 +25,6 @@ thiserror = "1.0"
|
||||
simconnect-sdk-derive = { version = "=0.1.1", path = "../simconnect-sdk-derive", optional = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
targets = ["x86_64-pc-windows-msvc"]
|
||||
features = ["derive"]
|
||||
default-target = "x86_64-pc-windows-msvc"
|
||||
targets = []
|
||||
|
@@ -2,16 +2,23 @@ use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=simconnect-sdk/ffi/include/SimConnect.h");
|
||||
println!("cargo:rerun-if-changed=simconnect-sdk/ffi/lib/SimConnect.lib");
|
||||
println!("cargo:rerun-if-changed=simconnect-sdk/ffi/lib/SimConnect.dll");
|
||||
println!("cargo:rerun-if-changed=ffi/include/Wrapper.h");
|
||||
println!("cargo:rerun-if-changed=ffi/include/WrapperFake.h");
|
||||
println!("cargo:rerun-if-changed=ffi/include/SimConnect.h");
|
||||
println!("cargo:rerun-if-changed=ffi/lib/SimConnect.lib");
|
||||
println!("cargo:rerun-if-changed=ffi/lib/SimConnect.dll");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
println!("cargo:rustc-link-search={}", out_path.to_string_lossy());
|
||||
println!("cargo:rustc-link-lib=static=SimConnect");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("ffi/include/SimConnect.h")
|
||||
let builder = if let Ok(_) = env::var("DOCS_RS") {
|
||||
bindgen::Builder::default().header("ffi/include/WrapperFake.h")
|
||||
} else {
|
||||
bindgen::Builder::default().header("ffi/include/Wrapper.h")
|
||||
};
|
||||
|
||||
let bindings = builder
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.clang_args(&["-x", "c++"])
|
||||
.allowlist_function("SimConnect_Open")
|
||||
|
@@ -4,8 +4,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "Windows.h"
|
||||
|
||||
#ifndef _SIMCONNECT_H_
|
||||
#define _SIMCONNECT_H_
|
||||
|
||||
|
2
simconnect-sdk/ffi/include/Wrapper.h
Normal file
2
simconnect-sdk/ffi/include/Wrapper.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <Windows.h>
|
||||
#include "SimConnect.h"
|
31
simconnect-sdk/ffi/include/WrapperFake.h
Normal file
31
simconnect-sdk/ffi/include/WrapperFake.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// fake defs in lieu of Windows.h that is used for the docs.rs build
|
||||
#define MAX_PATH 260
|
||||
#define FALSE 0
|
||||
#define CONST const
|
||||
#define CALLBACK __stdcall
|
||||
#define DECLARE_HANDLE(name) \
|
||||
struct name##__ \
|
||||
{ \
|
||||
int unused; \
|
||||
}; \
|
||||
typedef struct name##__ *name
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned char BYTE;
|
||||
typedef int BOOL;
|
||||
typedef long LONG;
|
||||
typedef LONG HRESULT;
|
||||
typedef void *HANDLE;
|
||||
typedef char CHAR;
|
||||
typedef CONST CHAR *LPCSTR;
|
||||
typedef struct _GUID
|
||||
{
|
||||
unsigned long Data1;
|
||||
unsigned short Data2;
|
||||
unsigned short Data3;
|
||||
unsigned char Data4[8];
|
||||
} GUID;
|
||||
|
||||
DECLARE_HANDLE(HWND);
|
||||
|
||||
#include "SimConnect.h"
|
@@ -2,7 +2,6 @@
|
||||
//! SimConnect SDK in Rust.
|
||||
//!
|
||||
//! ## Usage
|
||||
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! simconnect-sdk = { version = "0.1", features = ["derive"] }
|
||||
@@ -97,8 +96,6 @@ pub use simconnect::SimConnect;
|
||||
pub use simconnect_object_ext::SimConnectObjectExt;
|
||||
|
||||
#[cfg(feature = "simconnect-sdk-derive")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "simconnect-sdk-derive")))]
|
||||
extern crate simconnect_sdk_derive;
|
||||
#[cfg(feature = "simconnect-sdk-derive")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "simconnect-sdk-derive")))]
|
||||
pub use simconnect_sdk_derive::*;
|
||||
|
Reference in New Issue
Block a user