Add an option to skip adding Skylark files

By default Tulsi will try to add Skylark sources (.bzl) to the
generated project for user convenience. In order to do this, Tulsi
runs a "bazel query" command which can take a really long time on
big build graphs.

This change adds a project-level flag that when set, will tell Tulsi
to skip Skylark sources, avoid using the query, improving the project
gen time.

--
PiperOrigin-RevId: 178694348
MOS_MIGRATED_REVID=178694348
diff --git a/src/TulsiGenerator/Base.lproj/Options.strings b/src/TulsiGenerator/Base.lproj/Options.strings
index 6d0db9c..db8f040 100644
--- a/src/TulsiGenerator/Base.lproj/Options.strings
+++ b/src/TulsiGenerator/Base.lproj/Options.strings
@@ -37,3 +37,7 @@
 
 "SuppressSwiftUpdateCheck" = "Suppress Xcode Swift update check";
 "SuppressSwiftUpdateCheck_DESC" = "Suppresses Xcode's update notification for projects containing Swift code. This asserts that the Swift code is at least version 2.1.";
+
+"SkipSkylarkFilesQuery" = "Don't add Skylark sources to the project";
+"SkipSkylarkFilesQuery_DESC" = "Avoid running a bazel query to get all BUILD and .bzl files in the build. This could save time during project generation.";
+
diff --git a/src/TulsiGenerator/TulsiOptionSet.swift b/src/TulsiGenerator/TulsiOptionSet.swift
index e1e7c8b..68644b1 100644
--- a/src/TulsiGenerator/TulsiOptionSet.swift
+++ b/src/TulsiGenerator/TulsiOptionSet.swift
@@ -41,7 +41,11 @@
       BazelContinueBuildingAfterError,
 
       // Option to enable ObjC module map workarounds in the generated Xcodeproj.
-      ObjCModuleMapWorkarounds
+      ObjCModuleMapWorkarounds,
+
+      // Skip running a bazel query to find all .bzl files
+      SkipSkylarkFilesQuery
+
 
   // Options for build invocations.
   case BazelBuildOptionsDebug,
@@ -273,6 +277,7 @@
     addStringOption(.BazelBuildStartupOptionsDebug, [.TargetSpecializable, .SupportsInheritKeyword])
     addStringOption(.BazelBuildStartupOptionsRelease, [.TargetSpecializable, .SupportsInheritKeyword])
     addBoolOption(.SuppressSwiftUpdateCheck, .Generic, true)
+    addBoolOption(.SkipSkylarkFilesQuery, .Generic, false)
 
     addStringOption(.CommandlineArguments, [.TargetSpecializable, .SupportsInheritKeyword])
     addStringOption(.EnvironmentVariables, [.TargetSpecializable, .SupportsInheritKeyword])
diff --git a/src/TulsiGenerator/XcodeProjectGenerator.swift b/src/TulsiGenerator/XcodeProjectGenerator.swift
index e0141b8..28ddcb2 100644
--- a/src/TulsiGenerator/XcodeProjectGenerator.swift
+++ b/src/TulsiGenerator/XcodeProjectGenerator.swift
@@ -384,10 +384,13 @@
       progressNotifier.incrementValue()
     }
 
-    profileAction("adding_buildfiles") {
-      let buildfiles = workspaceInfoExtractor.extractBuildfiles(expandedTargetLabels)
-      let paths = buildfiles.map() { $0.asFileName! }
-      generator.generateFileReferencesForFilePaths(paths, pathFilters: config.pathFilters)
+    if let skipSkylarkFiles = config.options[.SkipSkylarkFilesQuery].commonValueAsBool,
+       !skipSkylarkFiles {
+      profileAction("adding_buildfiles") {
+        let buildfiles = workspaceInfoExtractor.extractBuildfiles(expandedTargetLabels)
+        let paths = buildfiles.map() { $0.asFileName! }
+        generator.generateFileReferencesForFilePaths(paths, pathFilters: config.pathFilters)
+      }
     }
 
     // Add RuleEntrys for any test hosts to ensure that selected tests can be executed in Xcode.
diff --git a/src/TulsiGeneratorTests/TulsiOptionSetTests.swift b/src/TulsiGeneratorTests/TulsiOptionSetTests.swift
index 5f1dbb7..c362ae8 100644
--- a/src/TulsiGeneratorTests/TulsiOptionSetTests.swift
+++ b/src/TulsiGeneratorTests/TulsiOptionSetTests.swift
@@ -94,6 +94,7 @@
     parent[.BazelBuildStartupOptionsRelease].projectValue = parentValue
     parent[.ALWAYS_SEARCH_USER_PATHS].projectValue = "YES"
     parent[.SuppressSwiftUpdateCheck].projectValue = "NO"
+    parent[.SkipSkylarkFilesQuery].projectValue = "NO"
 
 
     let childValue = "ChildValue"