From ad84126184a3aa915bf758b0d039315d73c8d6db Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Mon, 25 Jan 2021 08:49:54 -0800 Subject: [PATCH] [buck] don't clobber existing BUCK_EXTRA_JAVA_ARGS Summary: The existing code overwrites the `BUCK_EXTRA_JAVA_ARGS` environment var. It's better to extend it with our settings, if present. Reviewed By: artempyanykh Differential Revision: D26045398 fbshipit-source-id: 25588488c --- infer/src/integration/Buck.ml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/infer/src/integration/Buck.ml b/infer/src/integration/Buck.ml index 2979d2940..4c734b9d7 100644 --- a/infer/src/integration/Buck.ml +++ b/infer/src/integration/Buck.ml @@ -11,6 +11,8 @@ module L = Logging let max_command_line_length = 50 +let buck_extra_java_args_env_var = "BUCK_EXTRA_JAVA_ARGS" + let store_args_in_file ~identifier args = let rec exceed_length ~max = function | _ when max < 0 -> @@ -49,8 +51,12 @@ let wrap_buck_call ?(extend_env = []) ~label cmd = Printf.sprintf "trap '' SIGQUIT ; exec %s >'%s'" escaped_cmd stdout_file in let env = - (* Instruct the JVM to avoid using signals. *) - `Extend (("BUCK_EXTRA_JAVA_ARGS", "-Xrs") :: extend_env) + let existing_buck_extra_java_args = Sys.getenv buck_extra_java_args_env_var |> Option.to_list in + let new_buck_extra_java_args = + (* Instruct the JVM to avoid using signals. *) + String.concat ~sep:" " (existing_buck_extra_java_args @ ["-Xrs"]) + in + `Extend ((buck_extra_java_args_env_var, new_buck_extra_java_args) :: extend_env) in let Unix.Process_info.{stdin; stdout; stderr; pid} = Unix.create_process_env ~prog:"sh" ~args:["-c"; sigquit_protected_cmd] ~env ()