Skip to content

Commit

Permalink
[eclipse-iceoryx#210] Create simple playground example
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff authored and elBoberido committed Jun 1, 2024
1 parent 2626216 commit 4fc24f8
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ members = [
"iceoryx2-bb/testing",
"iceoryx2-bb/trait-tests",

"iceoryx2-lang/c",

"iceoryx2-cal",
"iceoryx2",
"iceoryx2-pal/concurrency-sync",
Expand Down Expand Up @@ -54,10 +56,13 @@ iceoryx2-pal-configuration = { version = "0.3.0", path = "iceoryx2-pal/configura

iceoryx2-cal = { version = "0.3.0", path = "iceoryx2-cal" }

iceoryx2-lang-c = { version = "0.3.0", path = "iceoryx2-lang-c" }

iceoryx2 = { version = "0.3.0", path = "iceoryx2/" }

bindgen = { version = "0.69.4" }
bitflags = { version = "2.5.0" }
cbindgen = { version = "0.26.0" }
cc = { version = "1.0.98" }
cdr = { version = "0.2.4" }
clap = { version = "4.5.4", features = ["derive"] }
Expand Down
26 changes: 26 additions & 0 deletions iceoryx2-lang/c/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "iceoryx2-lang-c"
categories.workspace = true
description.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
path = "src/lib.rs"
name = "iceoryx2_lang_c"
crate-type = ["cdylib", "staticlib"]

[build-dependencies]
cbindgen = { workspace = true }

[dependencies]
iceoryx2 = { workspace = true }
4 changes: 4 additions & 0 deletions iceoryx2-lang/c/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* compile: `gcc example.c -Ltarget/debug -liceoryx2_lang_c`
* set library path: `set -gx LD_LIBRARY_PATH $HOME/Development/iceoryx2/target/debug/`

* see: https://github.com/corrosion-rs/corrosion
19 changes: 19 additions & 0 deletions iceoryx2-lang/c/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extern crate cbindgen;

use std::env;

use cbindgen::Config;

fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

let mut config = Config::default();
config.language = cbindgen::Language::C;

cbindgen::Builder::new()
.with_crate(crate_dir)
.with_config(config)
.generate()
.expect("Unable to generate c bindings")
.write_to_file("iceoryx2.h");
}
6 changes: 6 additions & 0 deletions iceoryx2-lang/c/iceoryx2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

void zero_copy_service_list(void);
4 changes: 4 additions & 0 deletions iceoryx2-lang/c/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[no_mangle]
pub extern "C" fn zero_copy_service_list() {
println!("hello world");
}

0 comments on commit 4fc24f8

Please sign in to comment.