Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "nicer" cfgs #38

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::process::Command;
use std::{env, error::Error, fs::File, io::Read};

fn finalize_nanos_configuration(command: &mut cc::Build, bolos_sdk: &String) -> String {
println!("cargo:rustc-cfg=nanos");
command
.target("thumbv6m-none-eabi")
.define("ST31", None)
Expand All @@ -25,7 +24,6 @@ fn finalize_nanos_configuration(command: &mut cc::Build, bolos_sdk: &String) ->
}

fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &String) -> String {
println!("cargo:rustc-cfg=nanox");
command
.target("thumbv6m-none-eabi")
.define("ST33", None)
Expand Down Expand Up @@ -86,7 +84,6 @@ fn finalize_nanox_configuration(command: &mut cc::Build, bolos_sdk: &String) ->
}

fn finalize_nanosplus_configuration(command: &mut cc::Build, bolos_sdk: &String) -> String {
println!("cargo:rustc-cfg=nanosplus");
command
.target("thumbv8m.main-none-eabi")
.define("ST33K1M5", None)
Expand Down
6 changes: 4 additions & 2 deletions nanos.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
},
"relocation-model": "ropi",
"singlethread": true,
"target-pointer-width": "32"
}
"target-pointer-width": "32",
"os": "nanos",
"target-family": [ "bolos" ]
}
6 changes: 4 additions & 2 deletions nanosplus.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
},
"relocation-model": "ropi-rwpi",
"singlethread": true,
"target-pointer-width": "32"
}
"target-pointer-width": "32",
"os": "nanosplus",
"target-family": [ "bolos" ]
}
7 changes: 5 additions & 2 deletions nanox.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
},
"relocation-model": "ropi-rwpi",
"singlethread": true,
"target-pointer-width": "32"
}
"target-pointer-width": "32",
"os": "nanox",
"target-family": [ "bolos" ]

}
6 changes: 3 additions & 3 deletions src/io.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::bindings::*;
#[cfg(nanox)]
#[cfg(target_os = "nanox")]
use crate::ble;
use crate::buttons::{get_button_event, ButtonEvent, ButtonsState};

Expand Down Expand Up @@ -136,7 +136,7 @@ impl Comm {
seph::seph_send(&[seph::SephTags::RawAPDU as u8, len[0], len[1]]);
seph::seph_send(&self.apdu_buffer[..self.tx]);
}
#[cfg(nanox)]
#[cfg(target_os = "nanox")]
APDU_BLE => {
ble::send(&self.apdu_buffer[..self.tx]);
}
Expand Down Expand Up @@ -266,7 +266,7 @@ impl Comm {
seph::handle_capdu_event(&mut self.apdu_buffer, &spi_buffer)
}

#[cfg(nanox)]
#[cfg(target_os = "nanox")]
seph::Events::BleReceive => ble::receive(&mut self.apdu_buffer, &spi_buffer),

seph::Events::TickerEvent => return Event::Ticker,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

pub mod bindings;

#[cfg(nanox)]
#[cfg(target_os = "nanox")]
pub mod ble;

pub mod buttons;
Expand Down
6 changes: 3 additions & 3 deletions src/nvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ macro_rules! atomic_storage {
};
}

#[cfg(nanos)]
#[cfg(target_os = "nanos")]
atomic_storage!(64);
#[cfg(nanox)]
#[cfg(target_os = "nanox")]
atomic_storage!(256);
#[cfg(nanosplus)]
#[cfg(target_os = "nanosplus")]
atomic_storage!(512);

pub enum AtomicStorageElem {
Expand Down
4 changes: 2 additions & 2 deletions src/seph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::bindings::*;
use crate::usbbindings::*;

#[cfg(nanox)]
#[cfg(target_os = "nanox")]
use crate::ble;

#[repr(u8)]
Expand Down Expand Up @@ -245,7 +245,7 @@ pub fn handle_event(apdu_buffer: &mut [u8], spi_buffer: &[u8]) {
handle_usb_ep_xfer_event(apdu_buffer, spi_buffer);
}
}
#[cfg(nanox)]
#[cfg(target_os = "nanox")]
Events::BleReceive => ble::receive(apdu_buffer, spi_buffer),
Events::CAPDUEvent => handle_capdu_event(apdu_buffer, spi_buffer),
Events::TickerEvent => { /* unsafe{ G_io_app.ms += 100; } */ }
Expand Down