Skip to content

Commit

Permalink
Delete support for buck1 path_env and args_env
Browse files Browse the repository at this point in the history
Summary:
These were obsolete in Buck2 (and documented as such).

Buck2 correctly supports putting `$(location ...)` directly into an `env` fixup.

Reviewed By: zertosh, diliop

Differential Revision: D59229229

fbshipit-source-id: 8a5b8003471606d789e6e560373ba1e324b75b07
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Jul 1, 2024
1 parent 9e53dab commit 8837658
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 45 deletions.
10 changes: 0 additions & 10 deletions src/buck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,6 @@ pub struct BuildscriptGenrule {
pub version: Version,
pub features: Selectable<UniverseName, BTreeSet<String>>,
pub env: BTreeMap<String, String>,
pub path_env: BTreeMap<String, String>,
pub args_env: BTreeMap<String, String>,
}

impl Serialize for BuildscriptGenrule {
Expand All @@ -810,25 +808,17 @@ impl Serialize for BuildscriptGenrule {
version,
features,
env,
path_env,
args_env,
} = self;
let mut map = ser.serialize_map(None)?;
map.serialize_entry("name", name)?;
map.serialize_entry("package_name", package_name)?;
if !args_env.is_empty() {
map.serialize_entry("args_env", args_env)?;
}
map.serialize_entry("buildscript_rule", &NameAsLabel(buildscript_rule))?;
if !env.is_empty() {
map.serialize_entry("env", env)?;
}
if !features.is_empty() {
map.serialize_entry("features", features)?;
}
if !path_env.is_empty() {
map.serialize_entry("path_env", path_env)?;
}
map.serialize_entry("version", version)?;
map.end()
}
Expand Down
14 changes: 2 additions & 12 deletions src/fixups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ impl<'meta> Fixups<'meta> {
version: self.package.version.clone(),
features: buck::Selectable::Value(features.clone()),
env: BTreeMap::new(),
path_env: BTreeMap::new(),
args_env: BTreeMap::new(),
};

for fix in fixes {
Expand Down Expand Up @@ -336,32 +334,24 @@ impl<'meta> Fixups<'meta> {
match fix {
// Build and run it, and filter the output for --cfg options
// for the main target's rustc command line
BuildscriptFixup::RustcFlags(RustcFlags { env, path_env, .. }) => {
BuildscriptFixup::RustcFlags(RustcFlags { env, .. }) => {
// Emit the build script itself
res.push(Rule::BuildscriptBinary(buildscript.clone()));

// Emit rule to get its stdout and filter it into args
let buildscript_run = buildscript_run.get_or_insert_with(default_genrule);
buildscript_run.env.extend(env.clone());
buildscript_run.path_env.extend(path_env.clone());
}

// Generated source files - given a list, set up rules to extract them from
// the buildscript.
BuildscriptFixup::GenSrcs(GenSrcs {
env, // env set while running
path_env, // env pointing to pathnames set while running
args_env, // space-separated args like CFLAGS
..
}) => {
BuildscriptFixup::GenSrcs(GenSrcs { env, .. }) => {
// Emit the build script itself
res.push(Rule::BuildscriptBinary(buildscript.clone()));

// Emit rules to extract generated sources
let buildscript_run = buildscript_run.get_or_insert_with(default_genrule);
buildscript_run.env.extend(env.clone());
buildscript_run.path_env.extend(path_env.clone());
buildscript_run.args_env.extend(args_env.clone());
}

// Emit a C++ library build rule (elsewhere - add a dependency to it)
Expand Down
23 changes: 0 additions & 23 deletions src/fixups/buildscript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ pub struct RustcFlags {
// Runtime environment for the gensrc program
#[serde(default)]
pub env: BTreeMap<String, String>,
// Runtime environment for paths that's made absolute
#[serde(default)]
pub path_env: BTreeMap<String, String>,
}

#[derive(Debug, Clone, Deserialize, Serialize, Eq, PartialEq)]
Expand All @@ -106,26 +103,6 @@ pub struct GenSrcs {
// Runtime environment for the gensrc program
#[serde(default)]
pub env: BTreeMap<String, String>,
// Obsolete in buck2. Use "$(location ...)" or "$(exe ...)" in `env` instead.
//
// Used by buck1 for paths that need to get made absolute before the build
// script sees them.
#[serde(default)]
pub path_env: BTreeMap<String, String>,
// Obsolete in buck2. Use "$(location ...)" or "$(exe ...)" in `env` instead.
//
// Used by buck1 for something like CFLAGS, space-separated arguments in
// which some of them may be paths.
//
// The value is split by spaces and anything in the form of $VARIABLE is
// interpolated out of path_env.
//
// Example:
//
// path_env = { _LIBVIRT_INCLUDE = "$(location //path/to/libvirt:include)" }
// args_env = { BINDGEN_EXTRA_CLANG_ARGS = "-I $_LIBVIRT_INCLUDE" }
#[serde(default)]
pub args_env: BTreeMap<String, String>,
}

fn set_true() -> bool {
Expand Down

0 comments on commit 8837658

Please sign in to comment.