Skip to content

Commit 179464d

Browse files
committed
Put target files into dedicated folders
1 parent a2979b1 commit 179464d

21 files changed

+27
-512
lines changed

ledger_secure_sdk_sys/apex_p.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

ledger_secure_sdk_sys/apex_p_layout.ld

Lines changed: 0 additions & 10 deletions
This file was deleted.

ledger_secure_sdk_sys/build.rs

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct Device<'a> {
4343
pub cflags: Vec<String>,
4444
pub glyphs_folders: Vec<PathBuf>,
4545
pub arm_libs: String,
46-
pub linker_script: &'a str,
46+
pub linker_script: String,
4747
}
4848

4949
impl std::fmt::Display for DeviceName {
@@ -140,7 +140,7 @@ impl SDKBuilder<'_> {
140140
},
141141
target: "thumbv8m.main-none-eabi",
142142
defines: {
143-
let mut v = header2define("c_sdk_build_nanosplus.defines");
143+
let mut v = header2define(format!("{}/devices/nanosplus/c_sdk_build_nanosplus.defines", env!("CARGO_MANIFEST_DIR")).as_str());
144144
if env::var_os("CARGO_FEATURE_NANO_NBGL").is_some() {
145145
println!("cargo:warning=NBGL is built");
146146
v.push((String::from("HAVE_NBGL"), None));
@@ -155,8 +155,7 @@ impl SDKBuilder<'_> {
155155
v
156156
},
157157
cflags: {
158-
let mut m_path = String::from(env!("CARGO_MANIFEST_DIR"));
159-
m_path.push_str("/c_sdk_build_nanosplus.cflags");
158+
let m_path = format!("{}/devices/nanosplus/c_sdk_build_nanosplus.cflags", env!("CARGO_MANIFEST_DIR"));
160159
let f = File::open(m_path)
161160
.expect("Failed to open c_sdk_build_nanosplus.cflags file");
162161
let reader = BufReader::new(f);
@@ -167,7 +166,7 @@ impl SDKBuilder<'_> {
167166
},
168167
glyphs_folders: Vec::new(),
169168
arm_libs: Default::default(),
170-
linker_script: "nanosplus_layout.ld",
169+
linker_script: format!("{}/devices/nanosplus/nanosplus_layout.ld", env!("CARGO_MANIFEST_DIR"))
171170
},
172171
"nanox" => Device {
173172
name: DeviceName::NanoX,
@@ -177,7 +176,7 @@ impl SDKBuilder<'_> {
177176
},
178177
target: "thumbv6m-none-eabi",
179178
defines: {
180-
let mut v = header2define("c_sdk_build_nanox.defines");
179+
let mut v = header2define(format!("{}/devices/nanox/c_sdk_build_nanox.defines", env!("CARGO_MANIFEST_DIR")).as_str());
181180
if env::var_os("CARGO_FEATURE_NANO_NBGL").is_some() {
182181
println!("cargo:warning=NBGL is built");
183182
v.push((String::from("HAVE_NBGL"), None));
@@ -192,10 +191,8 @@ impl SDKBuilder<'_> {
192191
v
193192
},
194193
cflags: {
195-
let mut m_path = String::from(env!("CARGO_MANIFEST_DIR"));
196-
m_path.push_str("/c_sdk_build_nanox.cflags");
197-
let f =
198-
File::open(m_path).expect("Failed to open c_sdk_build_nanox.cflags file");
194+
let m_path = format!("{}/devices/nanox/c_sdk_build_nanox.cflags", env!("CARGO_MANIFEST_DIR"));
195+
let f = File::open(m_path).expect("Failed to open c_sdk_build_nanox.cflags file");
199196
let reader = BufReader::new(f);
200197
reader
201198
.lines()
@@ -204,7 +201,7 @@ impl SDKBuilder<'_> {
204201
},
205202
glyphs_folders: Vec::new(),
206203
arm_libs: Default::default(),
207-
linker_script: "nanox_layout.ld",
204+
linker_script: format!("{}/devices/nanox/nanox_layout.ld", env!("CARGO_MANIFEST_DIR")),
208205
},
209206
"stax" => Device {
210207
name: DeviceName::Stax,
@@ -213,12 +210,10 @@ impl SDKBuilder<'_> {
213210
Err(_) => return Err(SDKBuildError::MissingSDKPath),
214211
},
215212
target: "thumbv8m.main-none-eabi",
216-
defines: header2define("c_sdk_build_stax.defines"),
213+
defines: header2define(format!("{}/devices/stax/c_sdk_build_stax.defines", env!("CARGO_MANIFEST_DIR")).as_str()),
217214
cflags: {
218-
let mut m_path = String::from(env!("CARGO_MANIFEST_DIR"));
219-
m_path.push_str("/c_sdk_build_stax.cflags");
220-
let f =
221-
File::open(m_path).expect("Failed to open c_sdk_build_stax.cflags file");
215+
let m_path = format!("{}/devices/stax/c_sdk_build_stax.cflags", env!("CARGO_MANIFEST_DIR"));
216+
let f = File::open(m_path).expect("Failed to open c_sdk_build_stax.cflags file");
222217
let reader = BufReader::new(f);
223218
reader
224219
.lines()
@@ -227,7 +222,7 @@ impl SDKBuilder<'_> {
227222
},
228223
glyphs_folders: Vec::new(),
229224
arm_libs: Default::default(),
230-
linker_script: "stax_layout.ld",
225+
linker_script: format!("{}/devices/stax/stax_layout.ld", env!("CARGO_MANIFEST_DIR")),
231226
},
232227
"flex" => Device {
233228
name: DeviceName::Flex,
@@ -236,12 +231,10 @@ impl SDKBuilder<'_> {
236231
Err(_) => return Err(SDKBuildError::MissingSDKPath),
237232
},
238233
target: "thumbv8m.main-none-eabi",
239-
defines: header2define("c_sdk_build_flex.defines"),
234+
defines: header2define(format!("{}/devices/flex/c_sdk_build_flex.defines", env!("CARGO_MANIFEST_DIR")).as_str()),
240235
cflags: {
241-
let mut m_path = String::from(env!("CARGO_MANIFEST_DIR"));
242-
m_path.push_str("/c_sdk_build_flex.cflags");
243-
let f =
244-
File::open(m_path).expect("Failed to open c_sdk_build_flex.cflags file");
236+
let m_path = format!("{}/devices/flex/c_sdk_build_flex.cflags", env!("CARGO_MANIFEST_DIR"));
237+
let f = File::open(m_path).expect("Failed to open c_sdk_build_flex.cflags file");
245238
let reader = BufReader::new(f);
246239
reader
247240
.lines()
@@ -250,7 +243,7 @@ impl SDKBuilder<'_> {
250243
},
251244
glyphs_folders: Vec::new(),
252245
arm_libs: Default::default(),
253-
linker_script: "flex_layout.ld",
246+
linker_script: format!("{}/devices/flex/flex_layout.ld", env!("CARGO_MANIFEST_DIR")),
254247
},
255248
"apex_p" => Device {
256249
name: DeviceName::ApexP,
@@ -259,12 +252,10 @@ impl SDKBuilder<'_> {
259252
Err(_) => return Err(SDKBuildError::MissingSDKPath),
260253
},
261254
target: "thumbv8m.main-none-eabi",
262-
defines: header2define("c_sdk_build_apex_p.defines"),
255+
defines: header2define(format!("{}/devices/apex_p/c_sdk_build_apex_p.defines", env!("CARGO_MANIFEST_DIR")).as_str()),
263256
cflags: {
264-
let mut m_path = String::from(env!("CARGO_MANIFEST_DIR"));
265-
m_path.push_str("/c_sdk_build_apex_p.cflags");
266-
let f =
267-
File::open(m_path).expect("Failed to open c_sdk_build_apex_p.cflags file");
257+
let m_path = format!("{}/devices/apex_p/c_sdk_build_apex_p.cflags", env!("CARGO_MANIFEST_DIR"));
258+
let f = File::open(m_path).expect("Failed to open c_sdk_build_apex_p.cflags file");
268259
let reader = BufReader::new(f);
269260
reader
270261
.lines()
@@ -273,7 +264,7 @@ impl SDKBuilder<'_> {
273264
},
274265
glyphs_folders: Vec::new(),
275266
arm_libs: Default::default(),
276-
linker_script: "apex_p_layout.ld",
267+
linker_script: format!("{}/devices/apex_p/apex_p_layout.ld", env!("CARGO_MANIFEST_DIR")),
277268
},
278269
_ => {
279270
return Err(SDKBuildError::UnsupportedDevice);
@@ -519,11 +510,11 @@ impl SDKBuilder<'_> {
519510
// Target specific files
520511
let csdk_target_name = self.device.name.to_string();
521512
let header = match self.device.name {
522-
DeviceName::NanoSPlus => String::from("c_sdk_build_nanosplus.defines"),
523-
DeviceName::NanoX => String::from("c_sdk_build_nanox.defines"),
524-
DeviceName::Stax => String::from("c_sdk_build_stax.defines"),
525-
DeviceName::Flex => String::from("c_sdk_build_flex.defines"),
526-
DeviceName::ApexP => String::from("c_sdk_build_apex_p.defines"),
513+
DeviceName::NanoSPlus => String::from("devices/nanosplus/c_sdk_build_nanosplus.defines"),
514+
DeviceName::NanoX => String::from("devices/nanox/c_sdk_build_nanox.defines"),
515+
DeviceName::Stax => String::from("devices/stax/c_sdk_build_stax.defines"),
516+
DeviceName::Flex => String::from("devices/flex/c_sdk_build_flex.defines"),
517+
DeviceName::ApexP => String::from("devices/apex_p/c_sdk_build_apex_p.defines"),
527518
};
528519

529520
bindings = bindings.clang_arg(format!("-I{bsdk}/target/{csdk_target_name}/include/"));
@@ -614,8 +605,8 @@ impl SDKBuilder<'_> {
614605
println!("cargo:rustc-link-search={}", out_dir.display());
615606
// copy
616607
std::fs::copy(
617-
self.device.linker_script,
618-
out_dir.join(self.device.linker_script),
608+
self.device.linker_script.as_str(),
609+
out_dir.join(self.device.linker_script.split("/").last().unwrap()),
619610
)
620611
.unwrap();
621612
std::fs::copy("link.ld", out_dir.join("link.ld")).unwrap();

ledger_secure_sdk_sys/c_sdk_build_apex_p.cflags

Lines changed: 0 additions & 21 deletions
This file was deleted.

ledger_secure_sdk_sys/c_sdk_build_apex_p.defines

Lines changed: 0 additions & 36 deletions
This file was deleted.

ledger_secure_sdk_sys/c_sdk_build_flex.cflags

Lines changed: 0 additions & 21 deletions
This file was deleted.

ledger_secure_sdk_sys/c_sdk_build_flex.defines

Lines changed: 0 additions & 37 deletions
This file was deleted.

ledger_secure_sdk_sys/c_sdk_build_nanosplus.cflags

Lines changed: 0 additions & 21 deletions
This file was deleted.

ledger_secure_sdk_sys/c_sdk_build_nanosplus.defines

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)