1
0
mirror of https://github.com/facebook/proxygen.git synced 2026-10-24 01:33:54 +03:00

RustStaticLibrary: accept ENV in rust_static_library too

Summary:
D125255421 gave `rust_executable()` an `ENV` list of variables to set for `cargo build`, but `rust_static_library()` doesn't have one, so a project can't give a static library's cargo build the same settings. eden needs both of its cargo builds to see the thrift compiler and thrift files it builds with, which D125301420 passes through `ENV`.

___

landed-with-radar-review

Differential Revision: D125301419

fbshipit-source-id: 26475db4897366e92206d622a5c6287bc39bd0dd
This commit is contained in:
Genevieve (Genna) Helsel
2026-10-22 18:34:30 -07:00
committed by meta-codesync[bot]
parent 1b52a9bfc3
commit 2498135dc3

View File

@@ -81,7 +81,7 @@ set_property(GLOBAL APPEND PROPERTY JOB_POOLS rust_job_pool=1)
#
# ```cmake
# rust_static_library(<TARGET> [CRATE <CRATE_NAME>] [PACKAGE <PACKAGE_NAME>]
# [FEATURES <FEATURE_NAME>] [USE_CXX_INCLUDE])
# [FEATURES <FEATURE_NAME>] [USE_CXX_INCLUDE] [ENV <NAME=VALUE>...])
# ```
#
# Parameters:
@@ -99,6 +99,8 @@ set_property(GLOBAL APPEND PROPERTY JOB_POOLS rust_job_pool=1)
# Name of the Rust feature to enable.
# - USE_CXX_INCLUDE:
# Include cxx.rs include path in `${TARGET}` INTERFACE.
# - ENV:
# A list of `NAME=VALUE` pairs to set in the environment of `cargo build`.
#
# This function creates two targets:
# - "${TARGET}": an interface library target contains the static library built
@@ -110,7 +112,7 @@ set_property(GLOBAL APPEND PROPERTY JOB_POOLS rust_job_pool=1)
# headers with the interface library.
#
function(rust_static_library TARGET)
fb_cmake_parse_args(ARG "USE_CXX_INCLUDE" "CRATE;PACKAGE;FEATURES" "" "${ARGN}")
fb_cmake_parse_args(ARG "USE_CXX_INCLUDE" "CRATE;PACKAGE;FEATURES" "ENV" "${ARGN}")
if(DEFINED ARG_CRATE)
set(crate_name "${ARG_CRATE}")
@@ -151,6 +153,7 @@ function(rust_static_library TARGET)
"${CMAKE_COMMAND}" -E env
"CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}"
${extra_cargo_env}
${ARG_ENV}
${CARGO_COMMAND}
${cargo_flags}
COMMENT "Building Rust crate '${crate_name}'..."