From 2498135dc35feea3cfc744c2184148e7684893de Mon Sep 17 00:00:00 2001 From: "Genevieve (Genna) Helsel" Date: Thu, 22 Oct 2026 18:34:30 -0700 Subject: [PATCH] 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 --- build/fbcode_builder/CMake/RustStaticLibrary.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/fbcode_builder/CMake/RustStaticLibrary.cmake b/build/fbcode_builder/CMake/RustStaticLibrary.cmake index 1be4be0d0..09a6006ed 100644 --- a/build/fbcode_builder/CMake/RustStaticLibrary.cmake +++ b/build/fbcode_builder/CMake/RustStaticLibrary.cmake @@ -81,7 +81,7 @@ set_property(GLOBAL APPEND PROPERTY JOB_POOLS rust_job_pool=1) # # ```cmake # rust_static_library( [CRATE ] [PACKAGE ] -# [FEATURES ] [USE_CXX_INCLUDE]) +# [FEATURES ] [USE_CXX_INCLUDE] [ENV ...]) # ``` # # 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}'..."