isolate i686 windows with rust-platform-verifier

This commit is contained in:
Clément DOUIN
2024-11-26 07:31:35 +01:00
parent e17c2544f3
commit 065493ac7a
6 changed files with 244 additions and 239 deletions

View File

@@ -10,33 +10,33 @@ jobs:
fail-fast: false
matrix:
include:
- system: aarch64-macos
target: aarch64-apple-darwin
os: macos-14
- system: aarch64-linux
target: aarch64-unknown-linux-musl
os: ubuntu-latest
- system: armv6l-linux
target: armv6l-unknown-linux-musleabihf
os: ubuntu-latest
- system: armv7l-linux
target: armv7l-unknown-linux-musleabihf
os: ubuntu-latest
- system: i686-linux
target: i686-unknown-linux-musl
os: ubuntu-latest
# - system: aarch64-macos
# target: aarch64-apple-darwin
# os: macos-14
# - system: aarch64-linux
# target: aarch64-unknown-linux-musl
# os: ubuntu-latest
# - system: armv6l-linux
# target: armv6l-unknown-linux-musleabihf
# os: ubuntu-latest
# - system: armv7l-linux
# target: armv7l-unknown-linux-musleabihf
# os: ubuntu-latest
# - system: i686-linux
# target: i686-unknown-linux-musl
# os: ubuntu-latest
- system: i686-windows
target: i686-w64-mingw32
os: ubuntu-latest
- system: x86_64-macos
target: x86_64-apple-darwin
os: macos-13
- system: x86_64-linux
target: x86_64-unknown-linux-musl
os: ubuntu-latest
- system: x86_64-windows
target: x86_64-w64-mingw32
os: ubuntu-latest
# - system: x86_64-macos
# target: x86_64-apple-darwin
# os: macos-13
# - system: x86_64-linux
# target: x86_64-unknown-linux-musl
# os: ubuntu-latest
# - system: x86_64-windows
# target: x86_64-w64-mingw32
# os: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

View File

@@ -15,66 +15,67 @@ repository = "https://github.com/pimalaya/himalaya/"
features = ["imap", "maildir", "smtp", "sendmail", "oauth2", "wizard", "pgp-commands", "pgp-native"]
rustdoc-args = ["--cfg", "docsrs"]
[features]
default = [
"imap",
"maildir",
#"notmuch",
"smtp",
#"sendmail",
#"keyring",
#"oauth2",
"wizard",
#"pgp-commands",
#"pgp-gpg",
#"pgp-native",
]
# [features]
# default = [
# "imap",
# "maildir",
# #"notmuch",
# "smtp",
# #"sendmail",
# #"keyring",
# #"oauth2",
# "wizard",
# #"pgp-commands",
# #"pgp-gpg",
# #"pgp-native",
# ]
imap = ["email-lib/imap", "pimalaya-tui/imap"]
maildir = ["email-lib/maildir", "pimalaya-tui/maildir"]
notmuch = ["email-lib/notmuch", "pimalaya-tui/notmuch"]
smtp = ["email-lib/smtp", "pimalaya-tui/smtp"]
sendmail = ["email-lib/sendmail", "pimalaya-tui/sendmail"]
# imap = ["email-lib/imap", "pimalaya-tui/imap"]
# maildir = ["email-lib/maildir", "pimalaya-tui/maildir"]
# notmuch = ["email-lib/notmuch", "pimalaya-tui/notmuch"]
# smtp = ["email-lib/smtp", "pimalaya-tui/smtp"]
# sendmail = ["email-lib/sendmail", "pimalaya-tui/sendmail"]
keyring = ["email-lib/keyring", "pimalaya-tui/keyring", "secret-lib/keyring"]
oauth2 = ["email-lib/oauth2", "pimalaya-tui/oauth2", "keyring"]
wizard = ["email-lib/autoconfig", "pimalaya-tui/wizard"]
# keyring = ["email-lib/keyring", "pimalaya-tui/keyring", "secret-lib/keyring"]
# oauth2 = ["email-lib/oauth2", "pimalaya-tui/oauth2", "keyring"]
# wizard = ["email-lib/autoconfig", "pimalaya-tui/wizard"]
pgp = []
pgp-commands = ["email-lib/pgp-commands", "mml-lib/pgp-commands", "pimalaya-tui/pgp-commands", "pgp"]
pgp-gpg = ["email-lib/pgp-gpg", "mml-lib/pgp-gpg", "pimalaya-tui/pgp-gpg", "pgp"]
pgp-native = ["email-lib/pgp-native", "mml-lib/pgp-native", "pimalaya-tui/pgp-native", "pgp"]
# pgp = []
# pgp-commands = ["email-lib/pgp-commands", "mml-lib/pgp-commands", "pimalaya-tui/pgp-commands", "pgp"]
# pgp-gpg = ["email-lib/pgp-gpg", "mml-lib/pgp-gpg", "pimalaya-tui/pgp-gpg", "pgp"]
# pgp-native = ["email-lib/pgp-native", "mml-lib/pgp-native", "pimalaya-tui/pgp-native", "pgp"]
[build-dependencies]
git2 = { version = "0.19", default-features = false }
serde = { version = "1", features = ["derive"] }
toml = "0.8"
# [build-dependencies]
# git2 = { version = "0.19", default-features = false }
# serde = { version = "1", features = ["derive"] }
# toml = "0.8"
[dependencies]
ariadne = "0.2"
clap = { version = "4.4", features = ["derive", "env", "wrap_help"] }
clap_complete = "4.4"
clap_mangen = "0.2"
color-eyre = "0.6"
email-lib = { version = "=0.26", default-features = false, features = ["tokio-rustls", "derive", "thread"] }
mail-builder = "0.3"
mml-lib = { version = "1", default-features = false, features = ["compiler", "interpreter", "derive"] }
once_cell = "1.16"
pimalaya-tui = { version = "=0.1", default-features = false, features = ["email", "path", "cli", "himalaya", "tracing", "sled"] }
secret-lib = { version = "1", default-features = false, features = ["tokio", "rustls", "command", "derive"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
shellexpand-utils = "=0.2.1"
tokio = { version = "1.23", default-features = false, features = ["macros", "rt-multi-thread"] }
toml = "0.8"
tracing = "0.1"
url = "2.2"
uuid = { version = "0.8", features = ["v4"] }
rustls-platform-verifier = "0.4.0"
# ariadne = "0.2"
# clap = { version = "4.4", features = ["derive", "env", "wrap_help"] }
# clap_complete = "4.4"
# clap_mangen = "0.2"
# color-eyre = "0.6"
# email-lib = { version = "=0.26", default-features = false, features = ["tokio-rustls", "derive", "thread"] }
# mail-builder = "0.3"
# mml-lib = { version = "1", default-features = false, features = ["compiler", "interpreter", "derive"] }
# once_cell = "1.16"
# pimalaya-tui = { version = "=0.1", default-features = false, features = ["email", "path", "cli", "himalaya", "tracing", "sled"] }
# secret-lib = { version = "1", default-features = false, features = ["tokio", "rustls", "command", "derive"] }
# serde = { version = "1", features = ["derive"] }
# serde_json = "1"
# shellexpand-utils = "=0.2.1"
# tokio = { version = "1.23", default-features = false, features = ["macros", "rt-multi-thread"] }
# toml = "0.8"
# tracing = "0.1"
# url = "2.2"
# uuid = { version = "0.8", features = ["v4"] }
[patch.crates-io]
email-lib = { git = "https://github.com/pimalaya/core" }
mml-lib = { git = "https://github.com/pimalaya/core" }
oauth-lib = { git = "https://github.com/pimalaya/core" }
pimalaya-tui = { git = "https://github.com/pimalaya/tui" }
process-lib = { git = "https://github.com/pimalaya/core" }
secret-lib = { git = "https://github.com/pimalaya/core" }
# [patch.crates-io]
# email-lib = { git = "https://github.com/pimalaya/core" }
# mml-lib = { git = "https://github.com/pimalaya/core" }
# oauth-lib = { git = "https://github.com/pimalaya/core" }
# pimalaya-tui = { git = "https://github.com/pimalaya/tui" }
# process-lib = { git = "https://github.com/pimalaya/core" }
# secret-lib = { git = "https://github.com/pimalaya/core" }

214
build.rs
View File

@@ -1,126 +1,126 @@
use std::{
collections::HashMap,
env::{self, VarError},
};
// use std::{
// collections::HashMap,
// env::{self, VarError},
// };
use git2::{DescribeOptions, Repository};
use serde::Deserialize;
// use git2::{DescribeOptions, Repository};
// use serde::Deserialize;
fn main() {
features_env();
target_envs();
git_envs();
}
// fn main() {
// features_env();
// target_envs();
// git_envs();
// }
/// Builds the `CARGO_FEATURES` environment variable.
///
/// This function turns enabled cargo features into a simple string
/// `+feature1 +feature2 +featureN`, which then exposes it via the
/// `CARGO_FEATURES` environment variable.
///
/// It first reads and parses the Cargo.toml in order to extract all
/// available features (omitting "default"). It then checks for
/// enabled features via `CARGO_FEATURE_<name>` to finally collect
/// them into a string.
fn features_env() {
#[derive(Deserialize)]
struct Config {
features: HashMap<String, Vec<String>>,
}
// /// Builds the `CARGO_FEATURES` environment variable.
// ///
// /// This function turns enabled cargo features into a simple string
// /// `+feature1 +feature2 +featureN`, which then exposes it via the
// /// `CARGO_FEATURES` environment variable.
// ///
// /// It first reads and parses the Cargo.toml in order to extract all
// /// available features (omitting "default"). It then checks for
// /// enabled features via `CARGO_FEATURE_<name>` to finally collect
// /// them into a string.
// fn features_env() {
// #[derive(Deserialize)]
// struct Config {
// features: HashMap<String, Vec<String>>,
// }
impl Config {
fn enabled_features(self) -> impl Iterator<Item = String> {
self.features
.into_keys()
.filter(|feature| feature != "default")
.filter(|feature| {
let feature = feature.replace('-', "_").to_uppercase();
env::var(format!("CARGO_FEATURE_{feature}")).is_ok()
})
}
}
// impl Config {
// fn enabled_features(self) -> impl Iterator<Item = String> {
// self.features
// .into_keys()
// .filter(|feature| feature != "default")
// .filter(|feature| {
// let feature = feature.replace('-', "_").to_uppercase();
// env::var(format!("CARGO_FEATURE_{feature}")).is_ok()
// })
// }
// }
let config: Config =
toml::from_str(include_str!("./Cargo.toml")).expect("should parse Cargo.toml");
// let config: Config =
// toml::from_str(include_str!("./Cargo.toml")).expect("should parse Cargo.toml");
let mut features = String::new();
// let mut features = String::new();
for feature in config.enabled_features() {
if !features.is_empty() {
features.push(' ');
}
features.push_str(&format!("+{feature}"));
}
// for feature in config.enabled_features() {
// if !features.is_empty() {
// features.push(' ');
// }
// features.push_str(&format!("+{feature}"));
// }
println!("cargo::rustc-env=CARGO_FEATURES={features}");
}
// println!("cargo::rustc-env=CARGO_FEATURES={features}");
// }
/// Builds environment variables related to the target platform.
///
/// This function basically forwards existing cargo environments
/// related to the target platform.
fn target_envs() {
forward_env("CARGO_CFG_TARGET_OS");
forward_env("CARGO_CFG_TARGET_ENV");
forward_env("CARGO_CFG_TARGET_ARCH");
}
// /// Builds environment variables related to the target platform.
// ///
// /// This function basically forwards existing cargo environments
// /// related to the target platform.
// fn target_envs() {
// forward_env("CARGO_CFG_TARGET_OS");
// forward_env("CARGO_CFG_TARGET_ENV");
// forward_env("CARGO_CFG_TARGET_ARCH");
// }
/// Builds environment variables related to git.
///
/// This function basically tries to forward existing git environment
/// variables. In case of failure, it tries to build them using
/// [`git2`].
fn git_envs() {
// skip the process if the current directory is not a git
// repository (for example, from a nix build root jail)
let Ok(git) = Repository::open(".") else {
println!("cargo::rustc-env=GIT_DESCRIBE=unknown");
println!("cargo::rustc-env=GIT_REV=unknown");
return;
};
// /// Builds environment variables related to git.
// ///
// /// This function basically tries to forward existing git environment
// /// variables. In case of failure, it tries to build them using
// /// [`git2`].
// fn git_envs() {
// // skip the process if the current directory is not a git
// // repository (for example, from a nix build root jail)
// let Ok(git) = Repository::open(".") else {
// println!("cargo::rustc-env=GIT_DESCRIBE=unknown");
// println!("cargo::rustc-env=GIT_REV=unknown");
// return;
// };
if try_forward_env("GIT_DESCRIBE").is_err() {
let mut opts = DescribeOptions::new();
opts.describe_all();
opts.show_commit_oid_as_fallback(true);
// if try_forward_env("GIT_DESCRIBE").is_err() {
// let mut opts = DescribeOptions::new();
// opts.describe_all();
// opts.show_commit_oid_as_fallback(true);
let description = git
.describe(&opts)
.expect("should describe git object")
.format(None)
.expect("should format git object description");
// let description = git
// .describe(&opts)
// .expect("should describe git object")
// .format(None)
// .expect("should format git object description");
println!("cargo::rustc-env=GIT_DESCRIBE={description}");
};
// println!("cargo::rustc-env=GIT_DESCRIBE={description}");
// };
if try_forward_env("GIT_REV").is_err() {
let head = git.head().expect("should get git HEAD");
let commit = head.peel_to_commit().expect("should get git HEAD commit");
let rev = commit.id().to_string();
// if try_forward_env("GIT_REV").is_err() {
// let head = git.head().expect("should get git HEAD");
// let commit = head.peel_to_commit().expect("should get git HEAD commit");
// let rev = commit.id().to_string();
println!("cargo::rustc-env=GIT_REV={rev}");
};
}
// println!("cargo::rustc-env=GIT_REV={rev}");
// };
// }
/// Tries to forward the given environment variable.
///
/// For a more strict version, see [`forward_env`].
fn try_forward_env(key: &str) -> Result<String, VarError> {
let env = env::var(key);
// /// Tries to forward the given environment variable.
// ///
// /// For a more strict version, see [`forward_env`].
// fn try_forward_env(key: &str) -> Result<String, VarError> {
// let env = env::var(key);
if let Ok(val) = &env {
println!("cargo::rustc-env={key}={val}");
}
// if let Ok(val) = &env {
// println!("cargo::rustc-env={key}={val}");
// }
env
}
// env
// }
/// Forwards the given environment variable.
///
/// This function panics in case the forward fails (when the
/// environment variable does not exist for example).
///
/// For a less strict version, see [`try_forward_env`].
fn forward_env(key: &str) {
try_forward_env(key).expect(&format!("should get env {key}"));
}
// /// Forwards the given environment variable.
// ///
// /// This function panics in case the forward fails (when the
// /// environment variable does not exist for example).
// ///
// /// For a less strict version, see [`try_forward_env`].
// fn forward_env(key: &str) {
// try_forward_env(key).expect(&format!("should get env {key}"));
// }

View File

@@ -30,11 +30,11 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-YS8IamapvmdrOPptQh2Ef9Yold0IK1XIeGs0kDIQ5b8=";
NIX_LDFLAGS = lib.optionals (stdenv.hostPlatform.isWindows && stdenv.hostPlatform.isi686) [
"-L${windows.mcfgthreads}/lib"
# "-L${windows.mcfgthreads}/lib"
"-L${windows.mingwrt}/lib"
"-L${windows.w32api}/lib"
"-lmcfgthread"
"-lunwind"
#"-L${windows.w32api}/lib"
#"-lmcfgthread"
#"-lunwind"
];
# unit tests only

View File

@@ -1,10 +1,10 @@
pub mod account;
pub mod cli;
pub mod completion;
pub mod config;
pub mod email;
pub mod folder;
pub mod manual;
// pub mod account;
// pub mod cli;
// pub mod completion;
// pub mod config;
// pub mod email;
// pub mod folder;
// pub mod manual;
#[doc(inline)]
pub use crate::email::{envelope, flag, message};
// #[doc(inline)]
// pub use crate::email::{envelope, flag, message};

View File

@@ -1,47 +1,51 @@
use clap::Parser;
use color_eyre::Result;
use himalaya::{
cli::Cli, config::TomlConfig, envelope::command::list::ListEnvelopesCommand,
message::command::mailto::MessageMailtoCommand,
};
use pimalaya_tui::terminal::{
cli::{printer::StdoutPrinter, tracing},
config::TomlConfig as _,
};
// use clap::Parser;
// use color_eyre::Result;
// use himalaya::{
// cli::Cli, config::TomlConfig, envelope::command::list::ListEnvelopesCommand,
// message::command::mailto::MessageMailtoCommand,
// };
// use pimalaya_tui::terminal::{
// cli::{printer::StdoutPrinter, tracing},
// config::TomlConfig as _,
// };
#[tokio::main]
async fn main() -> Result<()> {
let tracing = tracing::install()?;
// #[tokio::main]
// async fn main() -> Result<()> {
// let tracing = tracing::install()?;
#[cfg(feature = "keyring")]
secret::keyring::set_global_service_name("himalaya-cli");
// #[cfg(feature = "keyring")]
// secret::keyring::set_global_service_name("himalaya-cli");
// if the first argument starts by "mailto:", execute straight the
// mailto message command
let mailto = std::env::args()
.nth(1)
.filter(|arg| arg.starts_with("mailto:"));
// // if the first argument starts by "mailto:", execute straight the
// // mailto message command
// let mailto = std::env::args()
// .nth(1)
// .filter(|arg| arg.starts_with("mailto:"));
if let Some(ref url) = mailto {
let mut printer = StdoutPrinter::default();
let config = TomlConfig::from_default_paths().await?;
// if let Some(ref url) = mailto {
// let mut printer = StdoutPrinter::default();
// let config = TomlConfig::from_default_paths().await?;
return MessageMailtoCommand::new(url)?
.execute(&mut printer, &config)
.await;
}
// return MessageMailtoCommand::new(url)?
// .execute(&mut printer, &config)
// .await;
// }
let cli = Cli::parse();
let mut printer = StdoutPrinter::new(cli.output);
let res = match cli.command {
Some(cmd) => cmd.execute(&mut printer, cli.config_paths.as_ref()).await,
None => {
let config = TomlConfig::from_paths_or_default(cli.config_paths.as_ref()).await?;
ListEnvelopesCommand::default()
.execute(&mut printer, &config)
.await
}
};
// let cli = Cli::parse();
// let mut printer = StdoutPrinter::new(cli.output);
// let res = match cli.command {
// Some(cmd) => cmd.execute(&mut printer, cli.config_paths.as_ref()).await,
// None => {
// let config = TomlConfig::from_paths_or_default(cli.config_paths.as_ref()).await?;
// ListEnvelopesCommand::default()
// .execute(&mut printer, &config)
// .await
// }
// };
// tracing.with_debug_and_trace_notes(res)
// }
fn main() {
println!("Hello, world!");
tracing.with_debug_and_trace_notes(res)
}