summaryrefslogtreecommitdiff
path: root/cras/client/cras-sys/generator/src/main.rs
diff options
context:
space:
mode:
authorpaulhsia <paulhsia@chromium.org>2018-11-02 18:19:41 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-01-13 13:52:18 -0800
commit4b95c40d576d3a1acc4df63afd320eac51d83537 (patch)
tree4f4686e350e1bc3c9a055ad5877ec3120c2e9e9b /cras/client/cras-sys/generator/src/main.rs
parent451f36db3914fb024a21a7322502a2540f62aef7 (diff)
downloadadhd-4b95c40d576d3a1acc4df63afd320eac51d83537.tar.gz
CRAS: cras-sys crate generated from adhd/cras/common
Use bindgen to generate C structure and enum for rust version libcras. Generated from upstream with commit 5fd5e32c111ad28da0bb860d023b281ae16c2094 with steps in generator/README.md BUG=chromium:907520 TEST=Apply full patch set to test $ cras_tests /path/to/playback.raw CQ-DEPEND=CL:1386286 Change-Id: I129fc7a28de4af767c8b87162357f02ec0141c7f Reviewed-on: https://chromium-review.googlesource.com/1314275 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'cras/client/cras-sys/generator/src/main.rs')
-rw-r--r--cras/client/cras-sys/generator/src/main.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/cras/client/cras-sys/generator/src/main.rs b/cras/client/cras-sys/generator/src/main.rs
new file mode 100644
index 00000000..ba6fadd7
--- /dev/null
+++ b/cras/client/cras-sys/generator/src/main.rs
@@ -0,0 +1,30 @@
+// Copyright 2019 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+extern crate bindgen;
+
+use bindgen::builder;
+
+fn gen() {
+ let name = "cras_gen";
+ let bindings = builder()
+ .header("c_headers/cras_messages.h")
+ .header("c_headers/cras_types.h")
+ .header("c_headers/cras_audio_format.h")
+ .whitelist_type("cras_.*")
+ .whitelist_var("cras_.*")
+ .whitelist_type("CRAS_.*")
+ .whitelist_var("CRAS_.*")
+ .whitelist_type("audio_message")
+ .rustified_enum("CRAS_.*")
+ .rustified_enum("_snd_pcm_.*")
+ .generate()
+ .expect(format!("Unable to generate {} code", name).as_str());
+ bindings
+ .write_to_file("lib_gen.rs")
+ .expect("Unable to generate lib.rs file");
+}
+
+fn main() {
+ gen();
+}