target_to_git: Use environment options

Bug: 600
Change-Id: Ib8498731cc57b6e15d1c46ac826ea86e1562cf13
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/79907
Reviewed-by: Oliver Newman <olivernewman@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/recipes/target_to_git.proto b/recipes/target_to_git.proto
index ff9ed2a..2bb6caa 100644
--- a/recipes/target_to_git.proto
+++ b/recipes/target_to_git.proto
@@ -17,6 +17,7 @@
 package recipes.pigweed.target_to_git;
 
 import "recipe_modules/pigweed/build/options.proto";
+import "recipe_modules/pigweed/environment/options.proto";
 
 message InputProperties {
   // Root directory within the build tree to add to a git repository.
@@ -34,4 +35,7 @@
 
   // Build module options.
   recipe_modules.pigweed.build.Options build_options = 6;
+
+  // Environment module options.
+  recipe_modules.pigweed.environment.Options environment_options = 7;
 }
diff --git a/recipes/target_to_git.py b/recipes/target_to_git.py
index 1f97ecb..b67d757 100644
--- a/recipes/target_to_git.py
+++ b/recipes/target_to_git.py
@@ -40,9 +40,9 @@
 
 def RunSteps(api, props):
     api.checkout()
-    api.environment.init(api.checkout.root)
+    env = api.environment.init(api.checkout.root, props.environment_options)
 
-    with api.environment():
+    with env():
         api.build(api.checkout.root, props.build_options)
 
     export_repo = api.path['start_dir'].join('export_repo')