mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-07 08:12:38 +00:00
Generate cxx binding in build.rs
This commit is contained in:
@@ -9,6 +9,7 @@ path = "lib.rs"
|
||||
|
||||
[build-dependencies]
|
||||
protobuf-codegen = "3.2.0"
|
||||
cxx-gen = { path = "../external/cxx-rs/gen/lib" }
|
||||
|
||||
[dependencies]
|
||||
base = { path = "../base" }
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
use protobuf_codegen::Customize;
|
||||
|
||||
use crate::gen::gen_cxx_binding;
|
||||
|
||||
#[path = "../base/gen.rs"]
|
||||
mod gen;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=update_metadata.proto");
|
||||
protobuf_codegen::Codegen::new()
|
||||
@@ -9,4 +14,6 @@ fn main() {
|
||||
.customize(Customize::default().gen_mod_rs(false))
|
||||
.out_dir(".")
|
||||
.run_from_script();
|
||||
|
||||
gen_cxx_binding("boot-rs");
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ mod update_metadata;
|
||||
#[cxx::bridge(namespace = "rust")]
|
||||
pub mod ffi {
|
||||
extern "C++" {
|
||||
include!("compress.hpp");
|
||||
pub unsafe fn decompress(in_: *const u8, in_size: u64, fd: i32) -> bool;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "boot-rs.hpp"
|
||||
|
||||
#define HEADER_FILE "header"
|
||||
#define KERNEL_FILE "kernel"
|
||||
#define RAMDISK_FILE "ramdisk.cpio"
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "magiskboot.hpp"
|
||||
#include "compress.hpp"
|
||||
|
||||
#include "boot-rs.cpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void print_formats() {
|
||||
|
||||
Reference in New Issue
Block a user