Skip to content

Commit

Permalink
Fixed issues while compiling on Linux
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijit Gadgil <[email protected]>
  • Loading branch information
agadgil-progress committed Jul 30, 2024
1 parent b307d3a commit 612cb36
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
10 changes: 5 additions & 5 deletions components/hab/src/cli_v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap_v4 as clap;

use clap::Parser;

use habitat_common::ui::UI;
use habitat_common::{FeatureFlag, ui::UI};

use crate::{cli::AFTER_HELP,
error::Result as HabResult,
Expand Down Expand Up @@ -73,9 +73,9 @@ enum Hab {
}

impl Hab {
async fn do_cli_command(&self, ui: &mut UI) -> HabResult<()> {
async fn do_cli_command(&self, ui: &mut UI, feature_flags: FeatureFlag) -> HabResult<()> {
match self {
Self::Pkg(pkg_command) => pkg_command.do_command(ui).await,
Self::Pkg(pkg_command) => pkg_command.do_command(ui, feature_flags).await,
_ => todo!(),
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ pub(crate) struct SvcStartCommand;
#[derive(Clone, Debug, Parser)]
pub(crate) struct SvcStopCommand;

pub async fn cli_driver(ui: &mut UI) -> HabResult<()> {
pub async fn cli_driver(ui: &mut UI, feature_flags: FeatureFlag) -> HabResult<()> {
let cli = Hab::parse();
cli.do_cli_command(ui).await
cli.do_cli_command(ui, feature_flags).await
}
6 changes: 3 additions & 3 deletions components/hab/src/cli_v4/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap_v4 as clap;
use clap::{Parser,
Subcommand};

use habitat_common::ui::UI;
use habitat_common::{FeatureFlag, ui::UI};

use crate::error::Result as HabResult;

Expand Down Expand Up @@ -108,12 +108,12 @@ pub(super) enum PkgCommand {
}

impl PkgCommand {
pub(crate) async fn do_command(&self, ui: &mut UI) -> HabResult<()> {
pub(crate) async fn do_command(&self, ui: &mut UI, feature_flags: FeatureFlag) -> HabResult<()> {
match self {
Self::Binds(opts) => opts.do_binds(),
Self::Binlink(opts) => opts.do_binlink(ui),
Self::Path(opts) => opts.do_path(),
Self::Build(opts) => opts.do_build(ui).await,
Self::Build(opts) => opts.do_build(ui, feature_flags).await,
Self::Config(opts) => opts.do_config(),
Self::Env(opts) => opts.do_env(),
Self::Hash(opts) => opts.do_hash(),
Expand Down
10 changes: 6 additions & 4 deletions components/hab/src/cli_v4/pkg/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use habitat_core::{crypto,
origin::Origin};

use crate::{command::pkg::build,
error::Result as HabResult};
error::Result as HabResult, error::Error as HabError};

use crate::cli_v4::utils::CacheKeyPath;

Expand Down Expand Up @@ -68,7 +68,9 @@ pub(crate) struct PkgBuildOptions {
}

impl PkgBuildOptions {
pub(super) async fn do_build(&self, ui: &mut UI) -> HabResult<()> {
// Required because of lot of `cfg`...
#[allow(unused_variables)]
pub(super) async fn do_build(&self, ui: &mut UI, feature_flags: FeatureFlag) -> HabResult<()> {
if !self.hab_origin_keys.is_empty() {
crypto::init()?;
let key_cache = KeyCache::new::<PathBuf>((&self.cache_key_path).into());
Expand All @@ -81,10 +83,10 @@ impl PkgBuildOptions {

let native_package = false;

#[cfg(target_os = "linux")]
#[cfg(target_family = "unix")]
let native_package = if self.native_package {
if !feature_flags.contains(FeatureFlag::NATIVE_PACKAGE_SUPPORT) {
return Err(Error::ArgumentError(String::from("`--native-package` is \
return Err(HabError::ArgumentError(String::from("`--native-package` is \
only available when \
`HAB_FEAT_NATIVE_PACKAGE_SUPPORT` \
is set")));
Expand Down
7 changes: 4 additions & 3 deletions components/hab/src/main_v4.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#[cfg(feature = "v4")]
use habitat_common::ui::{UIWriter,
UI};
use habitat_common::{FeatureFlag, ui::{UIWriter,
UI}};

#[cfg(feature = "v4")]
use hab::cli_driver;

#[cfg(feature = "v4")]
pub(crate) async fn main_v4() {
let mut ui = UI::default_with_env();
if let Err(e) = cli_driver(&mut ui).await {
let features = FeatureFlag::from_env(&mut ui);
if let Err(e) = cli_driver(&mut ui, features).await {
let exit_code = e.exit_code();
ui.fatal(e).unwrap();
std::process::exit(exit_code)
Expand Down

0 comments on commit 612cb36

Please sign in to comment.