From f84c1a94e3396b228caf7c88d3723742b25a15af Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Wed, 19 Aug 2020 16:30:16 -0700 Subject: Move include/libprofcollectd.rs * It shouldn't be C++ export_include_dirs. * Rust library source file is usually lib.rs in its own or src directory. Bug: 163175424 Test: make Change-Id: Ia4a7e7f43ce03b2d9d5fd18a0d3f3f36e633abe5 --- profcollectd/libprofcollectd/Android.bp | 2 +- .../libprofcollectd/include/libprofcollectd.rs | 62 ---------------------- profcollectd/libprofcollectd/lib.rs | 62 ++++++++++++++++++++++ 3 files changed, 63 insertions(+), 63 deletions(-) delete mode 100644 profcollectd/libprofcollectd/include/libprofcollectd.rs create mode 100644 profcollectd/libprofcollectd/lib.rs diff --git a/profcollectd/libprofcollectd/Android.bp b/profcollectd/libprofcollectd/Android.bp index ead6ea6c..fa02cf5f 100644 --- a/profcollectd/libprofcollectd/Android.bp +++ b/profcollectd/libprofcollectd/Android.bp @@ -25,7 +25,7 @@ rust_library { name: "libprofcollectd_rust", stem: "liblibprofcollectd", crate_name: "libprofcollectd", - srcs: ["include/libprofcollectd.rs"], + srcs: ["lib.rs"], rustlibs: ["libprofcollectd_bindgen"], shared_libs: ["libprofcollectd"], } diff --git a/profcollectd/libprofcollectd/include/libprofcollectd.rs b/profcollectd/libprofcollectd/include/libprofcollectd.rs deleted file mode 100644 index 90bca990..00000000 --- a/profcollectd/libprofcollectd/include/libprofcollectd.rs +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (C) 2020 The Android Open Source Project -// -// Licensed 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. -// - -//! Safe Rust interface over the libprofcollectd_bindgen FFI functions. -//! The methods are safe to call since they do not touch or modify Rust side's -//! memory or threads. - -/// Initialise profcollectd service. -/// * `start` - Immediately schedule collection after service is initialised. -pub fn init_service(start: bool) { - unsafe { - profcollectd_bindgen::InitService(start); - } -} - -/// Schedule periodic profile collection. -pub fn schedule_collection() { - unsafe { - profcollectd_bindgen::ScheduleCollection(); - } -} - -/// Terminate periodic profile collection. -pub fn terminate_collection() { - unsafe { - profcollectd_bindgen::TerminateCollection(); - } -} - -/// Immediately schedule a one-off trace. -pub fn trace_once() { - unsafe { - profcollectd_bindgen::TraceOnce(); - } -} - -/// Process the profiles. -pub fn process() { - unsafe { - profcollectd_bindgen::Process(); - } -} - -/// Read configs from environment variables. -pub fn read_config() { - unsafe { - profcollectd_bindgen::ReadConfig(); - } -} diff --git a/profcollectd/libprofcollectd/lib.rs b/profcollectd/libprofcollectd/lib.rs new file mode 100644 index 00000000..90bca990 --- /dev/null +++ b/profcollectd/libprofcollectd/lib.rs @@ -0,0 +1,62 @@ +// +// Copyright (C) 2020 The Android Open Source Project +// +// Licensed 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. +// + +//! Safe Rust interface over the libprofcollectd_bindgen FFI functions. +//! The methods are safe to call since they do not touch or modify Rust side's +//! memory or threads. + +/// Initialise profcollectd service. +/// * `start` - Immediately schedule collection after service is initialised. +pub fn init_service(start: bool) { + unsafe { + profcollectd_bindgen::InitService(start); + } +} + +/// Schedule periodic profile collection. +pub fn schedule_collection() { + unsafe { + profcollectd_bindgen::ScheduleCollection(); + } +} + +/// Terminate periodic profile collection. +pub fn terminate_collection() { + unsafe { + profcollectd_bindgen::TerminateCollection(); + } +} + +/// Immediately schedule a one-off trace. +pub fn trace_once() { + unsafe { + profcollectd_bindgen::TraceOnce(); + } +} + +/// Process the profiles. +pub fn process() { + unsafe { + profcollectd_bindgen::Process(); + } +} + +/// Read configs from environment variables. +pub fn read_config() { + unsafe { + profcollectd_bindgen::ReadConfig(); + } +} -- cgit v1.2.3