Add buildgen rust binding
This commit is contained in:
parent
a33004a4c9
commit
1eed614ded
18 changed files with 118 additions and 0 deletions
1
archLinuxPkg/.gitignore
vendored
Normal file
1
archLinuxPkg/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.pkg.tar.xz
|
43
archLinuxPkg/PKGBUILD
Normal file
43
archLinuxPkg/PKGBUILD
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Maintainer: Your Name <youremail@domain.com>
|
||||
pkgname=UDPConnection
|
||||
pkgver=1.0
|
||||
pkgrel=1
|
||||
epoch=
|
||||
pkgdesc="A C library that provides a UDP connection"
|
||||
arch=('x86_64')
|
||||
url=""
|
||||
license=('MIT')
|
||||
groups=()
|
||||
depends=()
|
||||
makedepends=()
|
||||
checkdepends=()
|
||||
optdepends=()
|
||||
provides=()
|
||||
conflicts=()
|
||||
replaces=()
|
||||
backup=()
|
||||
options=()
|
||||
install=
|
||||
changelog=
|
||||
source=()
|
||||
noextract=()
|
||||
md5sums=()
|
||||
validpgpkeys=()
|
||||
|
||||
prepare() {
|
||||
echo >&/dev/null
|
||||
}
|
||||
|
||||
build() {
|
||||
cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DBUILD_SHARED_LIBS=True \
|
||||
-G Ninja \
|
||||
../../c_impl/
|
||||
ninja
|
||||
}
|
||||
|
||||
package() {
|
||||
DESTDIR="$pkgdir/" ninja install
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.7)
|
||||
project(UDPConnection)
|
||||
|
||||
set(UDPConnection_VERSION 1.0)
|
||||
|
||||
set(UDPConnection_SOURCES
|
||||
src/UDPConnection.c
|
||||
src/UDPC_Deque.c
|
||||
|
@ -19,6 +21,8 @@ endif()
|
|||
|
||||
add_library(UDPConnection ${UDPConnection_SOURCES})
|
||||
|
||||
set_target_properties(UDPConnection PROPERTIES VERSION ${UDPConnection_VERSION})
|
||||
|
||||
target_compile_features(UDPConnection PUBLIC c_std_11)
|
||||
target_link_libraries(UDPConnection PUBLIC pthread)
|
||||
|
||||
|
@ -35,3 +39,11 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|||
target_link_libraries(NetworkTest PUBLIC UDPConnection)
|
||||
target_include_directories(NetworkTest PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
endif()
|
||||
|
||||
install(TARGETS UDPConnection CONFIGURATIONS Release DESTINATION lib)
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/UDPConnection.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/UDPC_Defines.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/UDPC_Deque.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/UDPC_HashMap.h
|
||||
DESTINATION include)
|
2
rust_binding/.gitignore
vendored
Normal file
2
rust_binding/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
Cargo.lock
|
||||
target/
|
10
rust_binding/Cargo.toml
Normal file
10
rust_binding/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "udpc_rs"
|
||||
version = "0.1.0"
|
||||
authors = ["Stephen Seo <seo.disparate@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.42.2"
|
44
rust_binding/build.rs
Normal file
44
rust_binding/build.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
use bindgen;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rustc-link-lib=UDPConnection");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("wrapper.h")
|
||||
.whitelist_type("UDPC_callback_connected")
|
||||
.whitelist_type("UDPC_callback_disconnected")
|
||||
.whitelist_type("UDPC_callback_received")
|
||||
.whitelist_type("UDPC_Context")
|
||||
.whitelist_function("UDPC_init")
|
||||
.whitelist_function("UDPC_init_threaded_update")
|
||||
.whitelist_function("UDPC_destroy")
|
||||
.whitelist_function("UDPC_set_callback_connected")
|
||||
.whitelist_function("UDPC_set_callback_disconnected")
|
||||
.whitelist_function("UDPC_set_callback_received")
|
||||
.whitelist_function("UDPC_check_events")
|
||||
.whitelist_function("UDPC_client_initiate_connection")
|
||||
.whitelist_function("UDPC_queue_send")
|
||||
.whitelist_function("UDPC_get_queue_send_available")
|
||||
.whitelist_function("UDPC_get_accept_new_connections")
|
||||
.whitelist_function("UDPC_set_accept_new_connections")
|
||||
.whitelist_function("UDPC_get_protocol_id")
|
||||
.whitelist_function("UDPC_set_protocol_id")
|
||||
.whitelist_function("UDPC_get_error")
|
||||
.whitelist_function("UDPC_get_error_str")
|
||||
.whitelist_function("UDPC_set_logging_type")
|
||||
.whitelist_function("UDPC_update")
|
||||
.whitelist_function("UDPC_strtoa")
|
||||
.opaque_type("UDPC_Context")
|
||||
.opaque_type("UDPC_Deque")
|
||||
.opaque_type("UDPC_HashMap")
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
5
rust_binding/src/lib.rs
Normal file
5
rust_binding/src/lib.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
1
rust_binding/wrapper.h
Normal file
1
rust_binding/wrapper.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../c_impl/src/UDPConnection.h"
|
Loading…
Reference in a new issue