Skip to content

Commit

Permalink
add signing profile config
Browse files Browse the repository at this point in the history
  • Loading branch information
andersondanilo committed Apr 7, 2021
1 parent 34687b2 commit d47ef9d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
9 changes: 8 additions & 1 deletion res/default-cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[tizen]
is_emulator = false
device_triple = "arm-linux-gnueabi"
emulator_triple = "i586-linux-gnueabi"
sync_files = ["shared", "res", "tizen-manifest.xml"]

[tizen.device]
tizen_triple = "arm-linux-gnueabi"
security_profile = "default"

[tizen.emulator]
tizen_triple = "i586-linux-gnueabi"
security_profile = "default"

[tizen.target.arm-linux-gnueabi]
rust_triple = "arm-unknown-linux-gnueabi"

Expand Down
7 changes: 6 additions & 1 deletion src/cargo-tizen/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ pub fn run(tizen_env: &TizenEnv, args: &ArgMatches) -> Result<i32, TizenError> {
remove_tizen_output_if_exists(&tizen_output_dir, assume_yes)?;
create_tizen_output(&tizen_env)?;

let tizen_args = vec![
let mut tizen_args = vec![
"package".to_string(),
"-t".to_string(),
"tpk".to_string(),
"--project".to_string(),
tizen_output_dir.to_str().unwrap().to_string(),
];

if !tizen_env.security_profile.is_empty() && tizen_env.security_profile != "default" {
tizen_args.push("--sign".to_string());
tizen_args.push(tizen_env.security_profile.clone());
}

let mut handle = run_command(
&tizen_env,
&args,
Expand Down
40 changes: 34 additions & 6 deletions src/cargo-tizen/tizen_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct TizenEnv {
pub cargo_pkg_name: String,
pub sync_files: Vec<String>,
pub is_release: bool,
pub security_profile: String,
}

impl TizenEnv {
Expand Down Expand Up @@ -60,6 +61,7 @@ impl TizenEnv {
let app_label = config_provider.get_value(&ConfigType::AppLabel)?;
let app_ui_type = config_provider.get_value(&ConfigType::AppUiType)?;
let sync_files = config_provider.get_value(&ConfigType::SyncFiles)?;
let security_profile = config_provider.get_value(&ConfigType::SecurityProfile)?;

let cargo_pkg_name = match config_provider.get_cargo_value("package.name") {
Some(s) => s,
Expand Down Expand Up @@ -95,6 +97,7 @@ impl TizenEnv {
sync_files: sync_files_array,
app_label: app_label.value.clone(),
app_ui_type: app_ui_type.value.clone(),
security_profile: security_profile.value.clone(),
is_release,
raw_config_values: vec![
studio_path,
Expand All @@ -105,6 +108,7 @@ impl TizenEnv {
tizen_triple,
device_triple,
emulator_triple,
security_profile,
toolchain,
rust_triple,
toolchain_path,
Expand Down Expand Up @@ -236,6 +240,7 @@ pub enum ConfigType {
AppLabel,
AppUiType,
SyncFiles,
SecurityProfile,
}

pub enum ConfigFrom {
Expand Down Expand Up @@ -282,7 +287,11 @@ impl<'a> ConfigProvider<'a> {
}

fn get_value(&self, config_type: &ConfigType) -> Result<ConfigValue, TizenError> {
let dynamic_key: Option<String> = match config_type {
self.get_custom_value(&config_type, self.get_dynamic_key(&config_type))
}

fn get_dynamic_key(&self, config_type: &ConfigType) -> Option<String> {
match config_type {
ConfigType::RustTriple => match self.get_value(&ConfigType::SelectedTriple) {
Ok(selected_triple) => Some(format!(
"tizen.target.{}.rust_triple",
Expand All @@ -304,10 +313,30 @@ impl<'a> ConfigProvider<'a> {
)),
Err(_) => None,
},
ConfigType::SecurityProfile => match self.get_value(&ConfigType::IsEmulator) {
Ok(is_emulator) => Some(format!(
"tizen.{}.security_profile",
if str_to_bool(&is_emulator.value) {
"emulator"
} else {
"device"
}
)),
Err(_) => None,
},
ConfigType::EmulatorTriple => match self.get_value(&ConfigType::IsEmulator) {
Ok(is_emulator) => Some(format!(
"tizen.{}.tizen_triple",
if str_to_bool(&is_emulator.value) {
"emulator"
} else {
"device"
}
)),
Err(_) => None,
},
_ => None,
};

self.get_custom_value(&config_type, dynamic_key)
}
}

fn get_custom_value(
Expand Down Expand Up @@ -480,7 +509,7 @@ impl<'a> ConfigProvider<'a> {
let mut path = PathBuf::from(&self.get_value(&ConfigType::StudioPath)?.value);
path.push("platforms");
path.push(format!("tizen-{}", api_version));
path.push(format!("{}", app_profile));
path.push(&app_profile);
path.push("rootstraps");
path.push(format!(
"{}-{}-{}.core",
Expand Down Expand Up @@ -601,7 +630,6 @@ impl<'a> ConfigProvider<'a> {
ConfigType::AppExec => None,
ConfigType::RootstrapPath => Some("tizen.rootstrap_path".to_string()),
ConfigType::DeviceTriple => Some("tizen.device_triple".to_string()),
ConfigType::EmulatorTriple => Some("tizen.emulator_triple".to_string()),
ConfigType::SelectedTriple => Some("tizen.selected_triple".to_string()),
ConfigType::Toolchain => Some("tizen.toolchain".to_string()),
ConfigType::TizenBin => Some("tizen.bin_path".to_string()),
Expand Down

0 comments on commit d47ef9d

Please sign in to comment.