[fx] Add a fint_set optional feature
If enabled, `fx set` will use fint under the hood instead of calling `gn
gen` directly. It's no-op for now, I'll fill in the logic in later CLs.
This will eventually replace the existing `fx set` logic.
Bug: 68465
Change-Id: I6cc2ddb13e2f85d6232003a98018f4d8d31f97dd
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/476037
Reviewed-by: Gary Boone <gboone@google.com>
Reviewed-by: Renato Mangini Dias <mangini@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Oliver Newman <olivernewman@google.com>
diff --git a/tools/build/BUILD.gn b/tools/build/BUILD.gn
index e2ed68e..3ac1b6b 100644
--- a/tools/build/BUILD.gn
+++ b/tools/build/BUILD.gn
@@ -19,6 +19,7 @@
deps = [
":build_tests",
+ "fx-set:tests",
"ninjago:tests",
]
}
diff --git a/tools/build/fx-set/BUILD.gn b/tools/build/fx-set/BUILD.gn
new file mode 100644
index 0000000..c8b21fd
--- /dev/null
+++ b/tools/build/fx-set/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2021 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/go/go_binary.gni")
+import("//build/go/go_library.gni")
+import("//build/go/go_test.gni")
+
+go_library("main") {
+ source_dir = "cmd"
+
+ sources = [
+ "main.go",
+ "main_test.go",
+ ]
+}
+
+go_binary("fx-set") {
+ gopackage = "go.fuchsia.dev/fuchsia/tools/build/fx-set/cmd"
+
+ deps = [ ":main" ]
+}
+
+go_test("tests") {
+ output_name = "fx_set_tests"
+ gopackages = [ "go.fuchsia.dev/fuchsia/tools/build/fx-set/cmd" ]
+ deps = [ ":main" ]
+}
diff --git a/tools/build/fx-set/cmd/main.go b/tools/build/fx-set/cmd/main.go
new file mode 100644
index 0000000..0dac903
--- /dev/null
+++ b/tools/build/fx-set/cmd/main.go
@@ -0,0 +1,13 @@
+// Copyright 2021 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package main
+
+import (
+ "fmt"
+)
+
+func main() {
+ fmt.Println("fint_set experiment enabled")
+}
diff --git a/tools/build/fx-set/cmd/main_test.go b/tools/build/fx-set/cmd/main_test.go
new file mode 100644
index 0000000..2d9f6cf
--- /dev/null
+++ b/tools/build/fx-set/cmd/main_test.go
@@ -0,0 +1,5 @@
+// Copyright 2021 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package main
diff --git a/tools/devshell/lib/fx-optional-features.sh b/tools/devshell/lib/fx-optional-features.sh
index 7d82e33..6fce48e 100644
--- a/tools/devshell/lib/fx-optional-features.sh
+++ b/tools/devshell/lib/fx-optional-features.sh
@@ -7,6 +7,7 @@
echo \
"incremental" \
"ffx_discovery" \
+ "fint_set" \
"legacy_fastboot"
}
@@ -15,6 +16,7 @@
case "$1" in
"incremental") return 1 ;;
"ffx_discovery") return 0 ;;
+ "fint_set") return 1 ;;
"legacy_fastboot") return 0 ;;
esac
@@ -37,6 +39,11 @@
"Device discovery based on ffx instead of device-finder."
)
;;
+ "fint_set")
+ h=(
+ "Use 'fint' in 'fx set' for a build process more similar to infra."
+ )
+ ;;
"legacy_fastboot")
h=(
"Device provisioning based on legacy fastboot instead of ffx."
diff --git a/tools/devshell/set b/tools/devshell/set
index 6210e53..1eddaeb 100755
--- a/tools/devshell/set
+++ b/tools/devshell/set
@@ -162,6 +162,14 @@
fx-standard-switches "$@"
set -- "${FX_ARGV[@]}"
+ if is_feature_enabled "fint_set"; then
+ go="${PREBUILT_GO_DIR}/bin/go"
+
+ cd "${FUCHSIA_DIR}/tools"
+ "$go" run ./build/fx-set/cmd "$@"
+ return 0
+ fi
+
if [[ $# -lt 1 ]]; then
fx-error Missing an explicit PRODUCT.BOARD goal.
explain-goal-argument