Set up infra for different packing mode
Summary: Electron 12 broke packing again because one file was renamed. I'm now setting up a separate mode for using globs and ignores to create artifact bundles. This will work like a reverse gitignore file. However, to keep the logic simple, I'll keep the old mode for MacOS where the folder structure lends itself to comprehensive, exact lists. **This doesn't actually change anything just yet apart from the "packfile" format. The next diff will add the new packing mode. Feedback is always welcome but there's no need for super close scrutiny.** Reviewed By: mweststrate Differential Revision: D27191506 fbshipit-source-id: 663cef8b93eef6c2dbb56ef66de51ea9551412dd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
94e85b54c8
commit
ca55e68c89
@@ -20,7 +20,7 @@ use std::collections::BTreeMap;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, BufReader, BufWriter, Write};
|
use std::io::{self, BufReader, BufWriter, Write};
|
||||||
use std::path;
|
use std::path;
|
||||||
use types::{HashSum, PackType, Platform};
|
use types::{HashSum, PackMode, PackType, Platform};
|
||||||
|
|
||||||
const DEFAULT_PACKLIST: &str = include_str!("packlist.yaml");
|
const DEFAULT_PACKLIST: &str = include_str!("packlist.yaml");
|
||||||
// This is to ensure that all progress bar prefixes are aligned.
|
// This is to ensure that all progress bar prefixes are aligned.
|
||||||
@@ -29,7 +29,13 @@ const PROGRESS_PREFIX_LEN: usize = 24;
|
|||||||
type PackListPlatform = BTreeMap<PackType, Vec<path::PathBuf>>;
|
type PackListPlatform = BTreeMap<PackType, Vec<path::PathBuf>>;
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
struct PackList(pub BTreeMap<Platform, PackListPlatform>);
|
struct PackListSpec {
|
||||||
|
mode: PackMode,
|
||||||
|
files: PackListPlatform,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
struct PackList(pub BTreeMap<Platform, PackListSpec>);
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
#[derive(Debug, serde::Serialize)]
|
||||||
struct PackFile {
|
struct PackFile {
|
||||||
@@ -61,16 +67,18 @@ fn pack(
|
|||||||
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",
|
||||||
width = PROGRESS_PREFIX_LEN
|
width = PROGRESS_PREFIX_LEN
|
||||||
));
|
));
|
||||||
let packtype_paths = pack_list
|
let packlist_spec = pack_list
|
||||||
.0
|
.0
|
||||||
.get(&platform)
|
.get(&platform)
|
||||||
.ok_or(error::Error::MissingPlatformDefinition(platform))?;
|
.ok_or(error::Error::MissingPlatformDefinition(platform))?;
|
||||||
let res = packtype_paths
|
let files = &packlist_spec.files;
|
||||||
|
let res = files
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.map(|(&pack_type, pack_files)| {
|
.map(|(&pack_type, pack_files)| {
|
||||||
let output_path = path::Path::new(output_directory).join(format!("{}.tar", pack_type));
|
let output_path = path::Path::new(output_directory).join(format!("{}.tar", pack_type));
|
||||||
@@ -83,7 +91,7 @@ fn pack(
|
|||||||
// 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.
|
||||||
tar.follow_symlinks(false);
|
tar.follow_symlinks(false);
|
||||||
pack_platform(platform, dist_dir, pack_files, pack_type, &mut tar)?;
|
pack_platform(platform, &base_dir, pack_files, pack_type, &mut tar)?;
|
||||||
pb.inc(1);
|
pb.inc(1);
|
||||||
tar.finish()?;
|
tar.finish()?;
|
||||||
pb.inc(1);
|
pb.inc(1);
|
||||||
@@ -96,19 +104,21 @@ 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<P: AsRef<path::Path>>(
|
fn pack_platform<P: AsRef<path::Path>>(
|
||||||
platform: Platform,
|
platform: Platform,
|
||||||
dist_dir: &std::path::Path,
|
base_dir: &path::Path,
|
||||||
pack_files: &[P],
|
pack_files: &[P],
|
||||||
pack_type: PackType,
|
pack_type: PackType,
|
||||||
tar_builder: &mut tar::Builder<File>,
|
tar_builder: &mut tar::Builder<File>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let base_dir = 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"),
|
|
||||||
};
|
|
||||||
|
|
||||||
for f in pack_files {
|
for f in pack_files {
|
||||||
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() {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
mac:
|
mac:
|
||||||
|
mode: exact
|
||||||
|
files:
|
||||||
frameworks:
|
frameworks:
|
||||||
- Flipper.app/Contents/Frameworks/
|
- Flipper.app/Contents/Frameworks/
|
||||||
- Flipper.app/Contents/MacOS
|
- Flipper.app/Contents/MacOS
|
||||||
@@ -8,6 +10,8 @@ mac:
|
|||||||
- Flipper.app/Contents/Info.plist
|
- Flipper.app/Contents/Info.plist
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
|
mode: exact
|
||||||
|
files:
|
||||||
frameworks:
|
frameworks:
|
||||||
- chrome-sandbox
|
- chrome-sandbox
|
||||||
- chrome_100_percent.pak
|
- chrome_100_percent.pak
|
||||||
@@ -29,6 +33,8 @@ linux:
|
|||||||
- resources
|
- resources
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
|
mode: exact
|
||||||
|
files:
|
||||||
frameworks:
|
frameworks:
|
||||||
- chrome_100_percent.pak
|
- chrome_100_percent.pak
|
||||||
- chrome_200_percent.pak
|
- chrome_200_percent.pak
|
||||||
|
|||||||
@@ -35,6 +35,26 @@ pub enum PackType {
|
|||||||
Core,
|
Core,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
serde::Deserialize,
|
||||||
|
serde::Serialize
|
||||||
|
)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum PackMode {
|
||||||
|
/// All paths need to be specified.
|
||||||
|
Exact,
|
||||||
|
/// Can use `*` and `!` syntax to specify patterns for inclusion and exclusion.
|
||||||
|
/// Only works on the root folder level.
|
||||||
|
Glob,
|
||||||
|
}
|
||||||
|
|
||||||
impl Display for PackType {
|
impl Display for PackType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
|
|||||||
Reference in New Issue
Block a user