Move basedir to config file
Summary: This allows us to extend this more easily to server builds, too. Reviewed By: lblasa Differential Revision: D35901750 fbshipit-source-id: 7030846ad485d709cf4c2e95f0cad287f98b051b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0e7de40263
commit
3c6a5c58f9
@@ -62,7 +62,7 @@ struct Args {
|
|||||||
no_compression: bool,
|
no_compression: bool,
|
||||||
|
|
||||||
/// Platform to build for
|
/// Platform to build for
|
||||||
#[clap(value_name = "PLATFORM", arg_enum)]
|
#[clap(value_name = "PLATFORM")]
|
||||||
platform: Platform,
|
platform: Platform,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +71,7 @@ type PackListPlatform = BTreeMap<PackType, Vec<String>>;
|
|||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
struct PackListSpec {
|
struct PackListSpec {
|
||||||
mode: PackMode,
|
mode: PackMode,
|
||||||
|
basedir: path::PathBuf,
|
||||||
files: PackListPlatform,
|
files: PackListPlatform,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,13 +102,12 @@ fn default_progress_bar(len: u64) -> indicatif::ProgressBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn pack(
|
fn pack(
|
||||||
platform: Platform,
|
platform: &Platform,
|
||||||
dist_dir: &std::path::Path,
|
dist_dir: &std::path::Path,
|
||||||
pack_list: &PackList,
|
pack_list: &PackList,
|
||||||
output_directory: &std::path::Path,
|
output_directory: &std::path::Path,
|
||||||
) -> Result<Vec<(PackType, path::PathBuf)>> {
|
) -> Result<Vec<(PackType, path::PathBuf)>> {
|
||||||
let pb = default_progress_bar(pack_list.0.len() as u64 * 2 - 1);
|
let pb = default_progress_bar(pack_list.0.len() as u64 * 2 - 1);
|
||||||
let base_dir = platform_base_dir(dist_dir, platform);
|
|
||||||
pb.set_prefix(&format!(
|
pb.set_prefix(&format!(
|
||||||
"{:width$}",
|
"{:width$}",
|
||||||
"Packing archives",
|
"Packing archives",
|
||||||
@@ -115,8 +115,9 @@ fn pack(
|
|||||||
));
|
));
|
||||||
let packlist_spec = pack_list
|
let packlist_spec = pack_list
|
||||||
.0
|
.0
|
||||||
.get(&platform)
|
.get(platform)
|
||||||
.ok_or(error::Error::MissingPlatformDefinition(platform))?;
|
.ok_or_else(|| error::Error::MissingPlatformDefinition(platform.clone()))?;
|
||||||
|
let base_dir = path::Path::new(dist_dir).join(&packlist_spec.basedir);
|
||||||
let files = &packlist_spec.files;
|
let files = &packlist_spec.files;
|
||||||
let res = files
|
let res = files
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
@@ -148,16 +149,8 @@ fn pack(
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn platform_base_dir(dist_dir: &path::Path, platform: Platform) -> path::PathBuf {
|
|
||||||
match platform {
|
|
||||||
Platform::Mac => path::Path::new(dist_dir).join("mac"),
|
|
||||||
Platform::Linux => path::Path::new(dist_dir).join("linux-unpacked"),
|
|
||||||
Platform::Windows => path::Path::new(dist_dir).join("win-unpacked"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pack_platform_glob(
|
fn pack_platform_glob(
|
||||||
platform: Platform,
|
platform: &Platform,
|
||||||
base_dir: &path::Path,
|
base_dir: &path::Path,
|
||||||
pack_files: &[String],
|
pack_files: &[String],
|
||||||
pack_type: PackType,
|
pack_type: PackType,
|
||||||
@@ -185,7 +178,9 @@ fn pack_platform_glob(
|
|||||||
let full_path = path::Path::new(&base_dir).join(&path);
|
let full_path = path::Path::new(&base_dir).join(&path);
|
||||||
if !full_path.exists() {
|
if !full_path.exists() {
|
||||||
bail!(error::Error::MissingPackFile(
|
bail!(error::Error::MissingPackFile(
|
||||||
platform, pack_type, full_path,
|
platform.to_string(),
|
||||||
|
pack_type,
|
||||||
|
full_path,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if full_path.is_file() {
|
if full_path.is_file() {
|
||||||
@@ -199,7 +194,7 @@ fn pack_platform_glob(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn pack_platform_exact(
|
fn pack_platform_exact(
|
||||||
platform: Platform,
|
platform: &Platform,
|
||||||
base_dir: &path::Path,
|
base_dir: &path::Path,
|
||||||
pack_files: &[String],
|
pack_files: &[String],
|
||||||
pack_type: PackType,
|
pack_type: PackType,
|
||||||
@@ -209,7 +204,9 @@ fn pack_platform_exact(
|
|||||||
let full_path = path::Path::new(&base_dir).join(f);
|
let full_path = path::Path::new(&base_dir).join(f);
|
||||||
if !full_path.exists() {
|
if !full_path.exists() {
|
||||||
bail!(error::Error::MissingPackFile(
|
bail!(error::Error::MissingPackFile(
|
||||||
platform, pack_type, full_path,
|
platform.to_string(),
|
||||||
|
pack_type,
|
||||||
|
full_path,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if full_path.is_file() {
|
if full_path.is_file() {
|
||||||
@@ -247,7 +244,7 @@ fn main() -> Result<(), anyhow::Error> {
|
|||||||
serde_yaml::from_str(&pack_list_str).expect("Failed to deserialize YAML packlist.");
|
serde_yaml::from_str(&pack_list_str).expect("Failed to deserialize YAML packlist.");
|
||||||
std::fs::create_dir_all(&args.output)
|
std::fs::create_dir_all(&args.output)
|
||||||
.with_context(|| format!("Failed to create output directory '{:?}'.", &args.output))?;
|
.with_context(|| format!("Failed to create output directory '{:?}'.", &args.output))?;
|
||||||
let archive_paths = pack(args.platform, &args.dist, &pack_list, &args.output)?;
|
let archive_paths = pack(&args.platform, &args.dist, &pack_list, &args.output)?;
|
||||||
let compressed_archive_paths = if args.no_compression {
|
let compressed_archive_paths = if args.no_compression {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
mac:
|
mac:
|
||||||
mode: exact
|
mode: exact
|
||||||
|
basedir: mac
|
||||||
files:
|
files:
|
||||||
frameworks:
|
frameworks:
|
||||||
- Flipper.app/Contents/Frameworks/
|
- Flipper.app/Contents/Frameworks/
|
||||||
@@ -11,6 +12,7 @@ mac:
|
|||||||
|
|
||||||
linux:
|
linux:
|
||||||
mode: glob
|
mode: glob
|
||||||
|
basedir: linux-unpacked
|
||||||
files:
|
files:
|
||||||
frameworks:
|
frameworks:
|
||||||
- '!resources/'
|
- '!resources/'
|
||||||
@@ -20,6 +22,7 @@ linux:
|
|||||||
|
|
||||||
windows:
|
windows:
|
||||||
mode: glob
|
mode: glob
|
||||||
|
basedir: win-unpacked
|
||||||
files:
|
files:
|
||||||
frameworks:
|
frameworks:
|
||||||
- '!resources/'
|
- '!resources/'
|
||||||
|
|||||||
@@ -6,24 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
use std::str;
|
||||||
|
|
||||||
#[derive(
|
// TODO: Make this a newtype.
|
||||||
Debug,
|
pub type Platform = String;
|
||||||
Copy,
|
|
||||||
Clone,
|
|
||||||
PartialEq,
|
|
||||||
Eq,
|
|
||||||
PartialOrd,
|
|
||||||
Ord,
|
|
||||||
serde::Deserialize,
|
|
||||||
clap::ArgEnum
|
|
||||||
)]
|
|
||||||
#[serde(rename_all = "lowercase")]
|
|
||||||
pub enum Platform {
|
|
||||||
Mac,
|
|
||||||
Linux,
|
|
||||||
Windows,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
|
|||||||
Reference in New Issue
Block a user