From 8e8f01f8b578c72c197dcb1cd93ae321ebf3cdf8 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 23 May 2023 21:30:30 -0700 Subject: [PATCH] Move project common code into include --- native/src/base/build.rs | 1 + native/src/base/consts.rs | 9 --------- native/src/base/lib.rs | 2 -- native/src/boot/build.rs | 2 +- native/src/core/build.rs | 2 +- native/src/core/lib.rs | 3 ++- native/src/core/logging.rs | 1 + native/src/include/consts.rs | 8 ++++++++ native/src/{base => include}/gen.rs | 0 native/src/init/build.rs | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 native/src/base/consts.rs create mode 100644 native/src/include/consts.rs rename native/src/{base => include}/gen.rs (100%) diff --git a/native/src/base/build.rs b/native/src/base/build.rs index f9862b8bc..59d58759c 100644 --- a/native/src/base/build.rs +++ b/native/src/base/build.rs @@ -1,5 +1,6 @@ use crate::gen::gen_cxx_binding; +#[path = "../include/gen.rs"] mod gen; fn main() { diff --git a/native/src/base/consts.rs b/native/src/base/consts.rs deleted file mode 100644 index d8ce98f2f..000000000 --- a/native/src/base/consts.rs +++ /dev/null @@ -1,9 +0,0 @@ -// We expose constant values as macros so that all constants are literals -// An advantage for doing this is that we can use concat!() on these values - -#[macro_export] -macro_rules! LOGFILE { - () => { - "/cache/magisk.log" - }; -} diff --git a/native/src/base/lib.rs b/native/src/base/lib.rs index f1f286c55..cb5bc0e67 100644 --- a/native/src/base/lib.rs +++ b/native/src/base/lib.rs @@ -2,13 +2,11 @@ pub use libc; -pub use consts::*; pub use files::*; pub use logging::*; pub use misc::*; pub use xwrap::*; -mod consts; mod files; mod logging; mod misc; diff --git a/native/src/boot/build.rs b/native/src/boot/build.rs index f30aefc15..3adc5210c 100644 --- a/native/src/boot/build.rs +++ b/native/src/boot/build.rs @@ -2,7 +2,7 @@ use protobuf_codegen::Customize; use crate::gen::gen_cxx_binding; -#[path = "../base/gen.rs"] +#[path = "../include/gen.rs"] mod gen; fn main() { diff --git a/native/src/core/build.rs b/native/src/core/build.rs index e9f2d1cf6..f80a90e0b 100644 --- a/native/src/core/build.rs +++ b/native/src/core/build.rs @@ -1,6 +1,6 @@ use crate::gen::gen_cxx_binding; -#[path = "../base/gen.rs"] +#[path = "../include/gen.rs"] mod gen; fn main() { diff --git a/native/src/core/lib.rs b/native/src/core/lib.rs index 25ff2d486..0ba7ff887 100644 --- a/native/src/core/lib.rs +++ b/native/src/core/lib.rs @@ -1,8 +1,9 @@ -pub use base; use daemon::*; use logging::*; use std::ffi::CStr; +#[path = "../include/consts.rs"] +mod consts; mod daemon; mod logging; diff --git a/native/src/core/logging.rs b/native/src/core/logging.rs index 571e28c62..9afbb8f0d 100644 --- a/native/src/core/logging.rs +++ b/native/src/core/logging.rs @@ -20,6 +20,7 @@ use base::*; use crate::daemon::{MagiskD, MAGISKD}; use crate::logging::LogFile::{Actual, Buffer}; +use crate::LOGFILE; #[allow(dead_code, non_camel_case_types)] #[derive(FromPrimitive, ToPrimitive)] diff --git a/native/src/include/consts.rs b/native/src/include/consts.rs new file mode 100644 index 000000000..a57d0272a --- /dev/null +++ b/native/src/include/consts.rs @@ -0,0 +1,8 @@ +// Expose constant strings as macros so that we can use concat!() on these values + +#[macro_export] +macro_rules! LOGFILE { + () => { + "/cache/magisk.log" + }; +} diff --git a/native/src/base/gen.rs b/native/src/include/gen.rs similarity index 100% rename from native/src/base/gen.rs rename to native/src/include/gen.rs diff --git a/native/src/init/build.rs b/native/src/init/build.rs index 21b31a551..2b7192615 100644 --- a/native/src/init/build.rs +++ b/native/src/init/build.rs @@ -1,6 +1,6 @@ use crate::gen::gen_cxx_binding; -#[path = "../base/gen.rs"] +#[path = "../include/gen.rs"] mod gen; fn main() {