-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Description: Generate Rust bindings for Wintun using bindgen | ||
# Usage: Run this script from the root of the wintun-bindings crate | ||
|
||
bindgen ` | ||
--allowlist-function "Wintun.*" ` | ||
--allowlist-type "WINTUN_.*" ` | ||
--allowlist-var "WINTUN_.*" ` | ||
--blocklist-type "_GUID" ` | ||
--blocklist-type "BOOL" ` | ||
--blocklist-type "BYTE" ` | ||
--blocklist-type "DWORD" ` | ||
--blocklist-type "DWORD64" ` | ||
--blocklist-type "GUID" ` | ||
--blocklist-type "HANDLE" ` | ||
--blocklist-type "LPCWSTR" ` | ||
--blocklist-type "NET_LUID" ` | ||
--blocklist-type "WCHAR" ` | ||
--blocklist-type "wchar_t" ` | ||
--opaque-type "NET_LUID" ` | ||
--dynamic-loading wintun ` | ||
--dynamic-link-require-all wintun/include/wintun_functions.h > src/wintun_raw.rs ` | ||
-- --target=i686-pc-windows-msvc | ||
|
||
# Insert prelude to generated file | ||
$prelude = @' | ||
#![allow(non_snake_case, non_camel_case_types)] | ||
#![cfg(target_os = "windows")] | ||
use windows_sys::core::GUID; | ||
use windows_sys::core::PCWSTR as LPCWSTR; | ||
use windows_sys::Win32::Foundation::BOOL; | ||
use windows_sys::Win32::Foundation::HANDLE; | ||
use windows_sys::Win32::NetworkManagement::Ndis::NET_LUID_LH as NET_LUID; | ||
pub type DWORD = core::ffi::c_ulong; | ||
pub type BYTE = core::ffi::c_uchar; | ||
pub type DWORD64 = core::ffi::c_ulonglong; | ||
'@ | ||
|
||
# Write prelude to a tmp file | ||
$tmpFile = "src/wintun_raw.rs.tmp" | ||
$prelude | Out-File -FilePath $tmpFile -Encoding utf8 | ||
|
||
# Append generated file to tmp file | ||
Get-Content src/wintun_raw.rs | Add-Content -Path $tmpFile | ||
|
||
# Replace generated file with tmp file | ||
Move-Item -Path $tmpFile -Destination src/wintun_raw.rs -Force |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters