mirror of
https://github.com/dgoodlad/rtl8710-sdk.git
synced 2024-12-04 03:50:28 +00:00
Include all the SDK static archives directly
This avoids all sorts of complex linking activity downstream
This commit is contained in:
parent
d639d3b5e4
commit
cf8f8ebdb2
2 changed files with 42 additions and 13 deletions
|
@ -6,9 +6,11 @@ edition = "2018"
|
|||
links = "sdk"
|
||||
|
||||
[dependencies]
|
||||
freertos_rs = { git = "https://github.com/hashmismatch/freertos.rs", rev = "a5b296a64d48db97c711673a825f6a0e5b9d9188" }
|
||||
cty = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
cc = { version = "1.0", features = ["parallel"] }
|
||||
bindgen = "0.49.0"
|
||||
llvm-tools = "0.1.1"
|
||||
glob = "0.3.0"
|
||||
|
|
53
build.rs
53
build.rs
|
@ -1,13 +1,16 @@
|
|||
extern crate bindgen;
|
||||
extern crate cc;
|
||||
extern crate glob;
|
||||
extern crate llvm_tools;
|
||||
|
||||
use glob::glob;
|
||||
use llvm_tools::LlvmTools;
|
||||
use std::env;
|
||||
use std::fmt;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
use llvm_tools::LlvmTools;
|
||||
|
||||
const STDLIB_INCLUDE_PATHS: &[&'static str] = &[
|
||||
"/usr/lib/gcc/arm-none-eabi/5.4.1/include",
|
||||
"/usr/lib/gcc/arm-none-eabi/5.4.1/include-fixed",
|
||||
|
@ -239,8 +242,21 @@ const SDK_C_FILES: &[&'static str] = &[
|
|||
"vendor/sdk/component/common/utilities/xml.c",
|
||||
];
|
||||
|
||||
const SDK_STATIC_LIBS: &[&'static str] = &[
|
||||
"platform",
|
||||
"wlan",
|
||||
"http",
|
||||
"dct",
|
||||
"wps",
|
||||
"rtlstd",
|
||||
"websocket",
|
||||
"xmodem",
|
||||
"mdns"
|
||||
];
|
||||
|
||||
fn main() {
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
let sdk_staticlib_path = PathBuf::from("vendor/sdk/component/soc/realtek/8195a/misc/bsp/lib/common/GCC").canonicalize().unwrap();
|
||||
|
||||
let tools = LlvmTools::new().unwrap();
|
||||
let objcopy = match tools.tool("llvm-objcopy") {
|
||||
|
@ -248,6 +264,23 @@ fn main() {
|
|||
None => panic!("Couldn't find objcopy"),
|
||||
};
|
||||
|
||||
for lib_name in SDK_STATIC_LIBS.iter() {
|
||||
fs::create_dir_all(out_path.join("static").join(lib_name)).expect("Could not create directory");
|
||||
|
||||
Command::new("ar")
|
||||
.arg("x")
|
||||
.arg(sdk_staticlib_path.join(format!("lib_{}.a", lib_name)).to_str().unwrap())
|
||||
.current_dir(out_path.join("static").join(lib_name))
|
||||
.status().unwrap();
|
||||
}
|
||||
|
||||
let sdk_static_lib_object_paths = glob(out_path.join("static/**/*.o").to_str().unwrap()).unwrap().into_iter().filter_map(|entry| {
|
||||
match entry {
|
||||
Ok(path) => Some(path),
|
||||
Err(_) => None,
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
Command::new(objcopy)
|
||||
.args(&["--rename-section", ".data=.loader.data,contents,alloc,load,readonly,data"])
|
||||
.args(&["-I", "binary"])
|
||||
|
@ -287,23 +320,17 @@ fn main() {
|
|||
compiler.include(path);
|
||||
}
|
||||
|
||||
for path in sdk_static_lib_object_paths {
|
||||
compiler.object(path);
|
||||
}
|
||||
|
||||
compiler
|
||||
.object(out_path.join("ram_1.r.o"))
|
||||
.object("vendor/sdk/component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_wlan.a")
|
||||
.files(SDK_C_FILES)
|
||||
.file("src/freertos_rs.c")
|
||||
.compile("sdk");
|
||||
|
||||
println!("cargo:rustc-link-search=native=vendor/sdk/component/soc/realtek/8195a/misc/bsp/lib/common/GCC/");
|
||||
println!("cargo:rustc-link-lib=_platform");
|
||||
println!("cargo:rustc-link-lib=_wlan");
|
||||
println!("cargo:rustc-link-lib=_http");
|
||||
println!("cargo:rustc-link-lib=_dct");
|
||||
println!("cargo:rustc-link-lib=_wps");
|
||||
println!("cargo:rustc-link-lib=_rtlstd");
|
||||
println!("cargo:rustc-link-lib=_websocket");
|
||||
println!("cargo:rustc-link-lib=_xmodem");
|
||||
println!("cargo:rustc-link-lib=_mdns");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("include/wrapper.h")
|
||||
.whitelist_function("wifi_manager_init")
|
||||
|
|
Loading…
Reference in a new issue