-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feature/allow_dupli…
…cate_bundles_in_container
- Loading branch information
Showing
11 changed files
with
473 additions
and
145 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ | |
|
||
[workspace] | ||
members = [ | ||
"celix_bindings", | ||
"hello_world_activator", | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
[package] | ||
name = "celix_bindings" | ||
version = "0.0.1" | ||
|
||
[build-dependencies] | ||
bindgen = "0.66.1" | ||
|
||
[lib] | ||
name = "celix_bindings" | ||
path = "src/lib.rs" | ||
crate-type = ["rlib"] |
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,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
extern crate bindgen; | ||
|
||
use std::error::Error; | ||
use std::path::PathBuf; | ||
use std::fs::File; | ||
use std::io::{self, BufRead}; | ||
use std::env; | ||
|
||
fn print_include_paths() -> Result<Vec<String>, Box<dyn Error>> { | ||
let build_dir = PathBuf::from(env::var("CORROSION_BUILD_DIR").unwrap()); | ||
let include_path_file = build_dir.join("include_paths.txt"); | ||
|
||
//let include_path_file = Path::new("include_paths.txt"); | ||
let file = File::open(&include_path_file)?; | ||
let reader = io::BufReader::new(file); | ||
let mut include_paths = Vec::new(); | ||
let line = reader.lines().next().ok_or("Expected at least one line")??; | ||
for path in line.split(';') { | ||
include_paths.push(path.to_string()); | ||
} | ||
Ok(include_paths) | ||
} | ||
|
||
fn main() { | ||
println!("cargo:info=Start build.rs for celix_bindings"); | ||
let include_paths = print_include_paths().unwrap(); | ||
|
||
let mut builder = bindgen::Builder::default() | ||
.header("src/celix_bindings.h"); | ||
|
||
// Add framework and utils include paths | ||
for path in &include_paths { | ||
builder = builder.clang_arg(format!("-I{}", path)); | ||
} | ||
|
||
// Gen bindings | ||
let bindings = builder | ||
.generate() | ||
.expect("Unable to generate bindings"); | ||
|
||
|
||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
bindings | ||
.write_to_file(out_path.join("celix_bindings.rs")) | ||
.expect("Couldn't write Apache Celix bindings!"); | ||
} |
32 changes: 32 additions & 0 deletions
32
misc/experimental/rust/celix_bindings/src/celix_bindings.h
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,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/** | ||
* @file celix_bindings.h | ||
* @brief A header files that includes all Apache Celix headers used to create bindings. | ||
*/ | ||
|
||
#include "celix_errno.h" | ||
#include "celix_properties.h" | ||
#include "celix_filter.h" | ||
|
||
#include "celix_bundle_context.h" | ||
#include "celix_framework.h" | ||
#include "celix_framework_factory.h" | ||
#include "celix_framework_utils.h" |
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,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#[allow(non_camel_case_types, non_snake_case, non_upper_case_globals, dead_code)] | ||
mod bindings { | ||
include!(concat!(env!("OUT_DIR"), "/celix_bindings.rs")); | ||
} | ||
pub use bindings::*; | ||
|
||
//Note C #defines (compile-time constants) are not all generated in the bindings. | ||
pub const CELIX_SUCCESS: celix_status_t = 0; | ||
pub const CELIX_BUNDLE_EXCEPTION: celix_status_t = 70001; | ||
|
||
// Move to celix_api lib | ||
pub mod celix { | ||
|
||
#[warn(unused_imports)] | ||
pub enum LogLevel { | ||
Trace = ::bindings::celix_log_level_CELIX_LOG_LEVEL_TRACE as isize, | ||
Debug = ::bindings::celix_log_level_CELIX_LOG_LEVEL_DEBUG as isize, | ||
Info = ::bindings::celix_log_level_CELIX_LOG_LEVEL_INFO as isize, | ||
Warn = ::bindings::celix_log_level_CELIX_LOG_LEVEL_WARNING as isize, | ||
Error = ::bindings::celix_log_level_CELIX_LOG_LEVEL_ERROR as isize, | ||
} | ||
} |
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