Warp to Galaxy internal rebrand
This commit is contained in:
@@ -37,7 +37,7 @@ pub struct ChannelState {
|
||||
impl ChannelState {
|
||||
pub fn init() -> Self {
|
||||
let channel = Channel::Oss;
|
||||
let app_id = AppId::new("samsung", "galaxy", "GalaxyOss");
|
||||
let app_id = AppId::new("com", "galaxy", "GalaxyOss");
|
||||
Self {
|
||||
channel,
|
||||
additional_features: Default::default(),
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
[package]
|
||||
name = "warp_channel_config"
|
||||
edition = "2021"
|
||||
description = "Loads per-channel ChannelConfig for Warp's channel binaries"
|
||||
authors.workspace = true
|
||||
publish.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
command.workspace = true
|
||||
serde_json.workspace = true
|
||||
warp_core.workspace = true
|
||||
@@ -1,113 +0,0 @@
|
||||
//! Loads a per-channel [`ChannelConfig`] for Warp's channel binaries.
|
||||
//!
|
||||
//! For non-bundled builds the internal `warp-channel-config` generator is
|
||||
//! invoked at runtime; for `release_bundle` builds the config is embedded at
|
||||
//! compile time via the consuming crate's build script. Shared by the GUI app
|
||||
//! binaries and the `warp_tui` binaries so the loading logic lives in one place.
|
||||
//!
|
||||
//! The `release_bundle` cfg inside [`load_config!`] is evaluated in the
|
||||
//! *consuming* crate, so each binary crate opts into embedding by defining its
|
||||
//! own `release_bundle` feature (and generating `<channel>_config.json` into its
|
||||
//! `OUT_DIR` from a build script).
|
||||
use warp_core::channel::ChannelConfig;
|
||||
|
||||
/// The name of the config generator binary, expected to be on PATH.
|
||||
const CONFIG_BIN_NAME: &str = "warp-channel-config";
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(windows)]
|
||||
macro_rules! path_concat {
|
||||
($path:expr, $file:expr) => {
|
||||
concat!($path, "\\", $file)
|
||||
};
|
||||
}
|
||||
#[macro_export]
|
||||
#[cfg(not(windows))]
|
||||
macro_rules! path_concat {
|
||||
($path:expr, $file:expr) => {
|
||||
concat!($path, "/", $file)
|
||||
};
|
||||
}
|
||||
|
||||
/// Loads the [`ChannelConfig`] for the given channel name.
|
||||
///
|
||||
/// In `release_bundle` builds the config is embedded at compile time (the
|
||||
/// consuming crate's build script must generate `<channel>_config.json` into
|
||||
/// `OUT_DIR`); otherwise the `warp-channel-config` generator is invoked at
|
||||
/// runtime.
|
||||
#[macro_export]
|
||||
macro_rules! load_config {
|
||||
($channel:expr) => {{
|
||||
#[cfg(feature = "release_bundle")]
|
||||
{
|
||||
$crate::load_config_from_embedded(include_str!($crate::path_concat!(
|
||||
env!("OUT_DIR"),
|
||||
concat!($channel, "_config.json")
|
||||
)))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "release_bundle"))]
|
||||
{
|
||||
$crate::load_config_from_generator($channel)
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
/// Invokes the config generator binary at runtime and deserializes its JSON
|
||||
/// output into a [`ChannelConfig`].
|
||||
pub fn load_config_from_generator(channel: &str) -> ChannelConfig {
|
||||
let target_family = if cfg!(target_family = "wasm") {
|
||||
"wasm"
|
||||
} else {
|
||||
"native"
|
||||
};
|
||||
|
||||
let target_os = if cfg!(target_os = "macos") {
|
||||
"macos"
|
||||
} else if cfg!(target_os = "windows") {
|
||||
"windows"
|
||||
} else {
|
||||
"linux"
|
||||
};
|
||||
|
||||
let output = command::blocking::Command::new(CONFIG_BIN_NAME)
|
||||
.arg("--channel")
|
||||
.arg(channel)
|
||||
.arg("--target-family")
|
||||
.arg(target_family)
|
||||
.arg("--target-os")
|
||||
.arg(target_os)
|
||||
.output()
|
||||
.unwrap_or_else(|err| {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
panic!(
|
||||
"\n\n'{CONFIG_BIN_NAME}' was not found on PATH.\n\n\
|
||||
To build internal channels, run:\n\
|
||||
\n\
|
||||
\x20 ./script/install_channel_config\n\n"
|
||||
)
|
||||
}
|
||||
panic!("Failed to execute '{CONFIG_BIN_NAME}': {err}")
|
||||
});
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
panic!("Config generator failed for channel '{channel}':\n{stderr}");
|
||||
}
|
||||
|
||||
serde_json::from_slice(&output.stdout).unwrap_or_else(|err| {
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
panic!(
|
||||
"Failed to parse config generator output for channel '{channel}': {err}\nOutput:\n{stdout}"
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Deserializes a [`ChannelConfig`] from a JSON string embedded at compile time.
|
||||
///
|
||||
/// Used to load channel configuration in release bundles, where configuration
|
||||
/// is embedded at compile time instead of being generated at runtime.
|
||||
pub fn load_config_from_embedded(json: &str) -> ChannelConfig {
|
||||
serde_json::from_str(json)
|
||||
.unwrap_or_else(|err| panic!("Failed to parse embedded channel config: {err}"))
|
||||
}
|
||||
@@ -8,30 +8,11 @@ license.workspace = true
|
||||
autobins = false
|
||||
default-run = "warp-tui-oss"
|
||||
|
||||
# One binary per channel, mirroring the GUI app's `app/src/bin/*` layout. The
|
||||
# OSS bin is the `default-run` so bare `cargo run -p warp_tui` builds without
|
||||
# the internal `warp-channel-config` generator; `./script/run-tui` selects the
|
||||
# local bin when the generator is available.
|
||||
# The OSS binary is the only shipped TUI target.
|
||||
[[bin]]
|
||||
name = "warp-tui-oss"
|
||||
path = "src/bin/oss.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "warp-tui"
|
||||
path = "src/bin/local.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "warp-tui-dev"
|
||||
path = "src/bin/dev.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "warp-tui-preview"
|
||||
path = "src/bin/preview.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "warp-tui-stable"
|
||||
path = "src/bin/stable.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
log.workspace = true
|
||||
@@ -43,7 +24,6 @@ string-offset.workspace = true
|
||||
sum_tree.workspace = true
|
||||
vec1.workspace = true
|
||||
warp = { workspace = true, features = ["tui"] }
|
||||
warp_channel_config.workspace = true
|
||||
warp_core.workspace = true
|
||||
warp_editor.workspace = true
|
||||
warp_terminal.workspace = true
|
||||
@@ -64,8 +44,4 @@ name = "tui_input_demo"
|
||||
required-features = []
|
||||
|
||||
[features]
|
||||
# Declared so the `warp_channel_config::load_config!` macro's
|
||||
# `cfg(feature = "release_bundle")` branch is a known cfg in this crate. Today it
|
||||
# stays off and the local bin uses the runtime generator; wiring the embedded
|
||||
# config path (a `build.rs`) is phase 2 of the channel setup.
|
||||
release_bundle = ["warp/release_bundle"]
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
//! Build script for the `warp_tui` channel binaries.
|
||||
//!
|
||||
//! When the `release_bundle` feature is enabled and the internal
|
||||
//! `warp-channel-config` generator is on PATH, this embeds each channel's config
|
||||
//! JSON into `OUT_DIR` so the per-channel bins can `include_str!` it via
|
||||
//! `warp_channel_config::load_config!`. Mirrors the equivalent logic in
|
||||
//! `app/build.rs`. For non-bundled builds the config is loaded at runtime, so
|
||||
//! there is nothing to embed.
|
||||
//!
|
||||
//! `std::process::Command` is fine in a build script (unlike the shipped binary,
|
||||
//! where it could flash a console on Windows).
|
||||
#![allow(clippy::disallowed_types)]
|
||||
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS");
|
||||
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS must be set");
|
||||
|
||||
generate_channel_config_if_needed(&target_os);
|
||||
}
|
||||
|
||||
/// If the `release_bundle` feature is enabled and `warp-channel-config` is
|
||||
/// available on PATH, invoke the config generator and write each channel's JSON
|
||||
/// to `OUT_DIR` so it can be embedded via `include_str!` in the binary entry
|
||||
/// points.
|
||||
fn generate_channel_config_if_needed(target_os: &str) {
|
||||
if env::var("CARGO_FEATURE_RELEASE_BUNDLE").is_err() {
|
||||
// For non-bundled builds, config is loaded at runtime — nothing to embed.
|
||||
return;
|
||||
}
|
||||
|
||||
let config_bin = "warp-channel-config";
|
||||
|
||||
// If the generator is not on PATH we can't embed configs. This is expected
|
||||
// for external contributors building Warp OSS.
|
||||
if Command::new(config_bin)
|
||||
.arg("--help")
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null())
|
||||
.status()
|
||||
.is_err()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only tracked for bundled builds, where they affect the embedded config.
|
||||
println!("cargo:rerun-if-env-changed=WITH_LOCAL_SERVER");
|
||||
println!("cargo:rerun-if-env-changed=WITH_LOCAL_SESSION_SHARING_SERVER");
|
||||
println!("cargo:rerun-if-env-changed=WITH_SANDBOX_TELEMETRY");
|
||||
println!("cargo:rerun-if-env-changed=SERVER_ROOT_URL");
|
||||
println!("cargo:rerun-if-env-changed=WS_SERVER_URL");
|
||||
|
||||
let out_dir = env::var("OUT_DIR").expect("OUT_DIR must be set");
|
||||
|
||||
// Generate config for every internal channel the TUI ships; each binary's
|
||||
// `include_str!` picks up its own file.
|
||||
for channel in ["local", "dev", "stable", "preview"] {
|
||||
let output = Command::new(config_bin)
|
||||
.arg("--channel")
|
||||
.arg(channel)
|
||||
.arg("--target-family")
|
||||
.arg("native")
|
||||
.arg("--target-os")
|
||||
.arg(target_os)
|
||||
.output()
|
||||
.unwrap_or_else(|err| {
|
||||
panic!("Failed to execute config generator at '{config_bin}': {err}")
|
||||
});
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
panic!("Config generator failed for channel '{channel}':\n{stderr}");
|
||||
}
|
||||
|
||||
let config_path = Path::new(&out_dir).join(format!("{channel}_config.json"));
|
||||
fs::write(&config_path, &output.stdout).unwrap_or_else(|err| {
|
||||
panic!("Failed to write config to {}: {err}", config_path.display())
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
//! Dev-channel `warp-tui` binary (internal nightly builds).
|
||||
//!
|
||||
//! Mirrors `app/src/bin/dev.rs`: loads the internal `dev` channel config and
|
||||
//! layers the dev feature flags, then hands off to the shared TUI entry point.
|
||||
|
||||
use anyhow::Result;
|
||||
use warp_core::channel::{Channel, ChannelState};
|
||||
use warp_core::features;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
ChannelState::set(
|
||||
ChannelState::new(Channel::Dev, warp_channel_config::load_config!("dev"))
|
||||
.with_additional_features(features::DEBUG_FLAGS)
|
||||
.with_additional_features(features::DOGFOOD_FLAGS)
|
||||
.with_additional_features(features::PREVIEW_FLAGS),
|
||||
);
|
||||
|
||||
warp_tui::run()
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//! Local-channel `warp-tui` binary (internal dev builds).
|
||||
//!
|
||||
//! Mirrors `app/src/bin/local.rs`: loads the internal `local` channel config
|
||||
//! (via the `warp-channel-config` generator) and layers the dev feature flags,
|
||||
//! then hands off to the shared TUI entry point. Run it through
|
||||
//! `./script/run-tui`, which installs the generator first; running it directly
|
||||
//! without `warp-channel-config` on PATH will panic with install instructions.
|
||||
|
||||
use anyhow::Result;
|
||||
use warp_core::channel::{Channel, ChannelState};
|
||||
use warp_core::features;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
ChannelState::set(
|
||||
ChannelState::new(Channel::Local, warp_channel_config::load_config!("local"))
|
||||
.with_additional_features(features::DEBUG_FLAGS)
|
||||
.with_additional_features(features::DOGFOOD_FLAGS)
|
||||
.with_additional_features(features::PREVIEW_FLAGS)
|
||||
.with_additional_features(features::LOCAL_FLAGS),
|
||||
);
|
||||
|
||||
warp_tui::run()
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
//! OSS-channel `warp-tui` binary and `default-run` target.
|
||||
//!
|
||||
//! This is what bare `cargo run -p warp_tui` builds, so it hand-builds a
|
||||
//! production config and needs no internal `warp-channel-config` generator
|
||||
//! (mirrors `app/src/bin/oss.rs`). It is a console application (no GUI window,
|
||||
//! no app bundle), so unlike the GUI binaries it sets no `windows_subsystem`
|
||||
//! attribute and embeds no `Info.plist`.
|
||||
//! This is what bare `cargo run -p warp_tui` builds, so it hand-builds an
|
||||
//! OSS production config (mirroring `app/src/bin/oss.rs`). It is a console
|
||||
//! application (no GUI window, no app bundle), so unlike the GUI binaries it
|
||||
//! sets no `windows_subsystem` attribute and embeds no `Info.plist`.
|
||||
|
||||
use anyhow::Result;
|
||||
use warp_core::channel::{Channel, ChannelConfig, ChannelState, OzConfig, WarpServerConfig};
|
||||
@@ -14,7 +13,7 @@ fn main() -> Result<()> {
|
||||
let mut state = ChannelState::new(
|
||||
Channel::Oss,
|
||||
ChannelConfig {
|
||||
app_id: AppId::new("dev", "warp", "WarpTui"),
|
||||
app_id: AppId::new("com", "galaxy", "GalaxyOss"),
|
||||
logfile_name: "warp-tui.log".into(),
|
||||
server_config: WarpServerConfig::disabled(),
|
||||
oz_config: OzConfig::production(),
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
//! Preview-channel `warp-tui` binary.
|
||||
//!
|
||||
//! Mirrors `app/src/bin/preview.rs`: loads the `preview` channel config and
|
||||
//! enables the preview feature flags (plus forced login), then hands off to the
|
||||
//! shared TUI entry point.
|
||||
|
||||
use anyhow::Result;
|
||||
use warp_core::channel::{Channel, ChannelState};
|
||||
use warp_core::features;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
ChannelState::set(
|
||||
ChannelState::new(
|
||||
Channel::Preview,
|
||||
warp_channel_config::load_config!("preview"),
|
||||
)
|
||||
.with_additional_features(features::PREVIEW_FLAGS)
|
||||
.with_additional_features(&[features::FeatureFlag::ForceLogin]),
|
||||
);
|
||||
|
||||
warp_tui::run()
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
//! Stable-channel `warp-tui` binary.
|
||||
//!
|
||||
//! Mirrors `app/src/bin/stable.rs`: loads the `stable` channel config with no
|
||||
//! additional feature flags, then hands off to the shared TUI entry point.
|
||||
|
||||
use anyhow::Result;
|
||||
use warp_core::channel::{Channel, ChannelState};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
ChannelState::set(ChannelState::new(
|
||||
Channel::Stable,
|
||||
warp_channel_config::load_config!("stable"),
|
||||
));
|
||||
|
||||
warp_tui::run()
|
||||
}
|
||||
Reference in New Issue
Block a user