-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C link rust #3
Draft
hisergiorojas
wants to merge
2
commits into
vfx-rs:main
Choose a base branch
from
hisergiorojas:c-link-rust
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
C link rust #3
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -8,3 +8,6 @@ edition = "2021" | |
|
||
[dependencies] | ||
libc = "0.2" | ||
|
||
[build-dependencies] | ||
bindgen = "0.59.2" | ||
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,54 @@ | ||
extern crate bindgen; | ||
|
||
use std::path::PathBuf; | ||
use std::{env, path::Path}; | ||
use std::process::Command; | ||
|
||
fn main() { | ||
|
||
let opentimeline_dir = | ||
env::var("OPENTIMELINE_DIR").expect("'OPENTIMELINE_DIR' envvar is not defined"); | ||
let opentimeline_lib_path = Path::new(&opentimeline_dir).join("lib"); | ||
let opentimeline_include_path = | ||
Path::new(&opentimeline_dir).join("include").join("opentimelineio"); | ||
|
||
let copentime_dir = | ||
env::var("COPENTIME_DIR").expect("'COPENTIME_DIR' envvar is not defined"); | ||
let copentime_lib_path = Path::new(&copentime_dir).join("lib"); | ||
let copentime_include_path = | ||
Path::new(&copentime_dir).join("include").join("copentime"); | ||
|
||
let copentimeline_dir = | ||
env::var("COPENTIMELINE_DIR").expect("'COPENTIMELINE_DIR' envvar is not defined"); | ||
let copentimeline_lib_path = Path::new(&copentimeline_dir).join("lib"); | ||
let copentimeline_include_path = | ||
Path::new(&copentimeline_dir).join("include").join("copentimelineio"); | ||
|
||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
println!("cargo:rustc-link-search=native={}", opentimeline_lib_path.display()); // the "-L" flag | ||
println!("cargo:rustc-link-lib=dylib=opentimelineio"); // the "-l" flag | ||
|
||
println!("cargo:rustc-link-search=native={}", copentime_lib_path.display()); | ||
println!("cargo:rustc-link-lib=static=copentime"); | ||
|
||
println!("cargo:rustc-link-search=native={}", copentimeline_lib_path.display()); | ||
println!("cargo:rustc-link-lib=static=copentimelineio"); | ||
|
||
let bindings = bindgen::Builder::default() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to the bindgen note. |
||
.header("wrapper.h") | ||
.allowlist_function("*") | ||
.allowlist_type("*") | ||
.allowlist_var("*") | ||
.generate() | ||
// Unwrap the Result and panic on failure. | ||
.expect("Unable to generate bindings"); | ||
|
||
|
||
// Write the bindings to the $OUT_DIR/bindings.rs file. | ||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
|
||
bindings | ||
.write_to_file(out_path.join("bindings.rs")) | ||
.expect("Couldn't write bindings!"); | ||
} |
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,51 @@ | ||
#include <copentime/errorStatus.h> | ||
#include <copentime/optionalOpenTime.h> | ||
#include <copentime/rationalTime.h> | ||
#include <copentime/timeRange.h> | ||
#include <copentime/timeTransform.h> | ||
|
||
#include <copentimelineio/any.h> | ||
#include <copentimelineio/anyDictionary.h> | ||
#include <copentimelineio/anyVector.h> | ||
#include <copentimelineio/clip.h> | ||
#include <copentimelineio/composable.h> | ||
#include <copentimelineio/composableRetainerVector.h> | ||
#include <copentimelineio/composableVector.h> | ||
#include <copentimelineio/composition.h> | ||
#include <copentimelineio/deserialization.h> | ||
#include <copentimelineio/effect.h> | ||
#include <copentimelineio/effectRetainerVector.h> | ||
#include <copentimelineio/effectVector.h> | ||
#include <copentimelineio/errorStatus.h> | ||
#include <copentimelineio/externalReference.h> | ||
#include <copentimelineio/freezeFrame.h> | ||
#include <copentimelineio/gap.h> | ||
#include <copentimelineio/generatorReference.h> | ||
#include <copentimelineio/item.h> | ||
#include <copentimelineio/linearTimeWarp.h> | ||
#include <copentimelineio/mapComposableTimeRange.h> | ||
#include <copentimelineio/marker.h> | ||
#include <copentimelineio/markerRetainerVector.h> | ||
#include <copentimelineio/markerVector.h> | ||
#include <copentimelineio/mediaReference.h> | ||
#include <copentimelineio/missingReference.h> | ||
#include <copentimelineio/optionalPairRationalTime.h> | ||
#include <copentimelineio/retainerPairComposable.h> | ||
#include <copentimelineio/safely_typed_any.h> | ||
#include <copentimelineio/serializableCollection.h> | ||
#include <copentimelineio/serializableObject.h> | ||
#include <copentimelineio/serializableObjectRetainerVector.h> | ||
#include <copentimelineio/serializableObjectVector.h> | ||
#include <copentimelineio/serializableObjectWithMetadata.h> | ||
#include <copentimelineio/serialization.h> | ||
#include <copentimelineio/stack.h> | ||
#include <copentimelineio/stackAlgorithm.h> | ||
#include <copentimelineio/timeEffect.h> | ||
#include <copentimelineio/timeline.h> | ||
#include <copentimelineio/track.h> | ||
#include <copentimelineio/trackAlgorithm.h> | ||
#include <copentimelineio/trackVector.h> | ||
#include <copentimelineio/transition.h> | ||
#include <copentimelineio/typeInfo.h> | ||
#include <copentimelineio/typeRegistry.h> | ||
#include <copentimelineio/unknownSchema.h> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to have the generated Rust interface included in the project, so consumers of the library don't have to depend on bindgen + its dependencies.