Build all artifacts from packlist
Summary: Instead of hardcoding the targets, it will now build all specified types in the "packlist". Reviewed By: jknoxville Differential Revision: D21349762 fbshipit-source-id: 58f4a3bbf0b6ff4dd87eb44bbd7b200127da8017
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2c20f016d4
commit
8818fbe375
@@ -12,7 +12,7 @@ use std::path::PathBuf;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
MissingPackFile(Platform, PackType, PathBuf),
|
MissingPackFile(Platform, PackType, PathBuf),
|
||||||
MissingPackDefinition(Platform, PackType),
|
MissingPlatformDefinition(Platform),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {}
|
impl std::error::Error for Error {}
|
||||||
@@ -27,10 +27,10 @@ impl fmt::Display for Error {
|
|||||||
pack_type,
|
pack_type,
|
||||||
path.to_string_lossy()
|
path.to_string_lossy()
|
||||||
),
|
),
|
||||||
Error::MissingPackDefinition(platform, pack_type) => write!(
|
Error::MissingPlatformDefinition(platform) => write!(
|
||||||
f,
|
f,
|
||||||
"Missing packlist definition for platform {:?} and pack type {:?}.",
|
"Platform {} is not defined in the given packlist.",
|
||||||
platform, pack_type,
|
platform
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,49 +28,34 @@ fn pack(
|
|||||||
pack_list: &PackList,
|
pack_list: &PackList,
|
||||||
output_directory: &std::path::PathBuf,
|
output_directory: &std::path::PathBuf,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut frameworks_path = output_directory.clone();
|
let packtype_paths = pack_list
|
||||||
frameworks_path.push("frameworks.tar");
|
.0
|
||||||
let mut frameworks_tar = tar::Builder::new(File::create(frameworks_path)?);
|
.get(platform)
|
||||||
|
.ok_or_else(|| error::Error::MissingPlatformDefinition(platform.clone()))?;
|
||||||
|
for (pack_type, pack_files) in packtype_paths {
|
||||||
|
print!(
|
||||||
|
"Packing for platform {:?} type {:?} ...",
|
||||||
|
platform, pack_type
|
||||||
|
);
|
||||||
|
let output_path = path::Path::new(output_directory).join(format!("{}.tar", pack_type));
|
||||||
|
let mut tar = tar::Builder::new(File::create(output_path)?);
|
||||||
// MacOS uses symlinks for bundling multiple framework versions and pointing
|
// MacOS uses symlinks for bundling multiple framework versions and pointing
|
||||||
// to the "Current" one.
|
// to the "Current" one.
|
||||||
frameworks_tar.follow_symlinks(false);
|
tar.follow_symlinks(false);
|
||||||
pack_platform(
|
pack_platform(platform, dist_dir, pack_files, pack_type, &mut tar)?;
|
||||||
platform,
|
tar.finish()?;
|
||||||
dist_dir,
|
println!(" done.");
|
||||||
pack_list,
|
}
|
||||||
&PackType::Frameworks,
|
|
||||||
&mut frameworks_tar,
|
|
||||||
)?;
|
|
||||||
frameworks_tar.finish()?;
|
|
||||||
|
|
||||||
// TODO: Instead of hard-coding the two types, just iterate over the packlist.
|
|
||||||
let mut core_path = output_directory.clone();
|
|
||||||
core_path.push("core.tar");
|
|
||||||
let mut core_tar = tar::Builder::new(File::create(core_path)?);
|
|
||||||
pack_platform(
|
|
||||||
platform,
|
|
||||||
dist_dir,
|
|
||||||
pack_list,
|
|
||||||
&PackType::Core,
|
|
||||||
&mut core_tar,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
eprintln!("Written.");
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pack_platform(
|
fn pack_platform(
|
||||||
platform: &Platform,
|
platform: &Platform,
|
||||||
dist_dir: &std::path::PathBuf,
|
dist_dir: &std::path::PathBuf,
|
||||||
pack_list: &PackList,
|
pack_files: &Vec<path::PathBuf>,
|
||||||
pack_type: &PackType,
|
pack_type: &PackType,
|
||||||
tar_builder: &mut tar::Builder<File>,
|
tar_builder: &mut tar::Builder<File>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let pack_files = pack_list
|
|
||||||
.0
|
|
||||||
.get(platform)
|
|
||||||
.and_then(|f| f.get(pack_type))
|
|
||||||
.ok_or_else(|| error::Error::MissingPackDefinition(platform.clone(), pack_type.clone()))?;
|
|
||||||
let base_dir = match platform {
|
let base_dir = match platform {
|
||||||
Platform::Mac => path::Path::new(dist_dir).join("mac"),
|
Platform::Mac => path::Path::new(dist_dir).join("mac"),
|
||||||
// TODO: Verify this.
|
// TODO: Verify this.
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use clap::arg_enum;
|
use clap::arg_enum;
|
||||||
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
arg_enum! {
|
arg_enum! {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
|
||||||
@@ -23,3 +24,13 @@ pub enum PackType {
|
|||||||
Frameworks,
|
Frameworks,
|
||||||
Core,
|
Core,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for PackType {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
use PackType::*;
|
||||||
|
match *self {
|
||||||
|
Frameworks => write!(f, "frameworks"),
|
||||||
|
Core => write!(f, "core"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user