Add BUILD files and bazel targets for Tulsi.
PiperOrigin-RevId: 194969373
diff --git a/.gitignore b/.gitignore
index 6471e5b..8590517 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
# Build artifacts
src/build/
+/bazel-*
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..6828cc5
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,73 @@
+# Description:
+# Tulsi, an Xcode project generator for Bazel-bazed projects.
+
+package(default_visibility = ["//:__subpackages__"])
+
+licenses(["notice"]) # Apache 2.0
+
+exports_files(["LICENSE"])
+
+load(
+ ":version.bzl",
+ "fill_info_plist",
+ "TULSI_VERSION_MAJOR",
+)
+load("@build_bazel_rules_apple//apple:versioning.bzl", "apple_bundle_version")
+
+fill_info_plist(
+ name = "info_plist",
+ out = "Info.plist",
+ template = "//src/Tulsi:Info.plist",
+)
+
+apple_bundle_version(
+ name = "AppVersion",
+ build_label_pattern = "{project}_{date}_[A-Za-z]*{buildnum}",
+ build_version = "%s.{date}.{buildnum}" % TULSI_VERSION_MAJOR,
+ capture_groups = {
+ "project": "[^_]*",
+ "date": "\d+",
+ "buildnum": "\d+",
+ },
+ fallback_build_label = "tulsi_999999999_build88",
+)
+
+genrule(
+ name = "combine_strings",
+ srcs = [
+ "//src/Tulsi:en.lproj/Localizable.strings",
+ "//src/TulsiGenerator:en.lproj/Localizable.strings",
+ ],
+ outs = [
+ "en.lproj/Localizable.strings",
+ ],
+ cmd = (
+ "cat $(location //src/Tulsi:en.lproj/Localizable.strings) > $(location en.lproj/Localizable.strings); " +
+ "echo '\n\n' >> $(location en.lproj/Localizable.strings); " +
+ "cat $(location //src/TulsiGenerator:en.lproj/Localizable.strings) >> $(location en.lproj/Localizable.strings); "
+ ),
+)
+
+filegroup(
+ name = "strings",
+ srcs = [
+ "en.lproj/Localizable.strings",
+ "//src/TulsiGenerator:en.lproj/Options.strings",
+ ],
+)
+
+load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application")
+
+macos_application(
+ name = "tulsi",
+ app_icons = ["//src/Tulsi:Icon"],
+ bundle_id = "com.google.Tulsi",
+ bundle_name = "Tulsi",
+ infoplists = [":Info.plist"],
+ minimum_os_version = "10.12",
+ strings = [":strings"],
+ version = ":AppVersion",
+ deps = [
+ "//src/Tulsi:tulsi_lib",
+ ],
+)
diff --git a/LICENSE.txt b/LICENSE
similarity index 100%
rename from LICENSE.txt
rename to LICENSE
diff --git a/Tulsi.tulsiproj/Configs/Tulsi.tulsigen b/Tulsi.tulsiproj/Configs/Tulsi.tulsigen
new file mode 100644
index 0000000..12329a0
--- /dev/null
+++ b/Tulsi.tulsiproj/Configs/Tulsi.tulsigen
@@ -0,0 +1,33 @@
+{
+ "additionalFilePaths" : [
+ "BUILD"
+ ],
+ "projectName" : "Tulsi",
+ "buildTargets" : [
+ "\/\/:tulsi",
+ "\/\/src/TulsiGeneratorTests:TulsiGeneratorTests"
+ ],
+ "optionSet" : {
+ "BazelBuildStartupOptionsDebug" : {
+ "p" : "$(inherited)"
+ },
+ "BazelBuildStartupOptionsFastbuild" : {
+ "p" : "$(inherited)"
+ },
+ "BazelBuildStartupOptionsRelease" : {
+ "p" : "$(inherited)"
+ },
+ "BazelBuildOptionsDebug" : {
+ "p" : "$(inherited)"
+ },
+ "BazelBuildOptionsFastbuild" : {
+ "p" : "$(inherited)"
+ },
+ "BazelBuildOptionsRelease" : {
+ "p" : "$(inherited)"
+ }
+ },
+ "sourceFilters" : [
+ "src/..."
+ ]
+}
\ No newline at end of file
diff --git a/Tulsi.tulsiproj/project.tulsiconf b/Tulsi.tulsiproj/project.tulsiconf
new file mode 100644
index 0000000..12458dc
--- /dev/null
+++ b/Tulsi.tulsiproj/project.tulsiconf
@@ -0,0 +1,12 @@
+{
+ "configDefaults" : {
+ "optionSet" : {
+
+ }
+ },
+ "projectName" : "Tulsi",
+ "packages" : [
+ ""
+ ],
+ "workspaceRoot" : ".."
+}
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..845392a
--- /dev/null
+++ b/WORKSPACE
@@ -0,0 +1,17 @@
+git_repository(
+ name = "bazel_skylib",
+ remote = "https://github.com/bazelbuild/bazel-skylib.git",
+ tag = "0.3.1",
+)
+
+git_repository(
+ name = "build_bazel_rules_apple",
+ remote = "https://github.com/bazelbuild/rules_apple.git",
+ tag = "0.4.0",
+)
+
+http_file(
+ name = "xctestrunner",
+ executable = 1,
+ url = "https://github.com/google/xctestrunner/releases/download/0.2.2/ios_test_runner.par",
+)
\ No newline at end of file
diff --git a/src/Tulsi/BUILD b/src/Tulsi/BUILD
new file mode 100644
index 0000000..4435e1a
--- /dev/null
+++ b/src/Tulsi/BUILD
@@ -0,0 +1,42 @@
+package(default_visibility = ["//:__subpackages__"])
+
+licenses(["notice"])
+
+load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
+
+exports_files(["Info.plist"])
+
+filegroup(
+ name = "Icon",
+ srcs = glob(["Assets.xcassets/AppIcon.appiconset/*"]),
+)
+
+exports_files(["en.lproj/Localizable.strings"])
+
+filegroup(
+ name = "tulsi_srcs",
+ srcs = glob(["*.swift"]),
+)
+
+filegroup(
+ name = "tulsi_resources",
+ srcs = glob(
+ [
+ "*.lproj/*",
+ "Assets.xcassets/**/*",
+ ],
+ exclude = [
+ "Assets.xcassets/AppIcon.appiconset/*",
+ "en.lproj/Localizable.strings",
+ ],
+ ),
+)
+
+swift_library(
+ name = "tulsi_lib",
+ srcs = [":tulsi_srcs"],
+ module_name = "Tulsi",
+ resources = [":tulsi_resources"],
+ tags = ["nobuilder"],
+ deps = ["//src/TulsiGenerator:tulsi_generator_lib"],
+)
diff --git a/src/TulsiGenerator/BUILD b/src/TulsiGenerator/BUILD
new file mode 100644
index 0000000..136797a
--- /dev/null
+++ b/src/TulsiGenerator/BUILD
@@ -0,0 +1,38 @@
+package(default_visibility = ["//:__subpackages__"])
+
+licenses(["notice"]) # Apache 2.0
+
+load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
+
+exports_files(
+ [
+ "en.lproj/Localizable.strings",
+ "en.lproj/Options.strings",
+ ],
+)
+
+filegroup(
+ name = "tulsi_generator_srcs",
+ srcs = glob(["*.swift"]),
+)
+
+filegroup(
+ name = "tulsi_generator_resources",
+ srcs = glob([
+ "GeneratedProjectResources/*",
+ "*.entitlements",
+ ]) + [
+ "//src/TulsiGenerator/Bazel:WORKSPACE",
+ "//src/TulsiGenerator/Scripts",
+ "//src/tools/bazel_cache_reader",
+ ],
+)
+
+swift_library(
+ name = "tulsi_generator_lib",
+ srcs = [":tulsi_generator_srcs"],
+ module_name = "TulsiGenerator",
+ resources = [":tulsi_generator_resources"],
+ structured_resources = ["//src/TulsiGenerator/Bazel:tulsi"],
+ tags = ["nobuilder"],
+)
diff --git a/src/TulsiGenerator/Bazel/BUILD b/src/TulsiGenerator/Bazel/BUILD
new file mode 100644
index 0000000..6716704
--- /dev/null
+++ b/src/TulsiGenerator/Bazel/BUILD
@@ -0,0 +1,24 @@
+licenses(["notice"]) # Apache 2.0
+
+package(default_visibility = ["//:__subpackages__"])
+
+exports_files(
+ ["WORKSPACE"],
+)
+
+genrule(
+ name = "aspect_build",
+ srcs = [":tulsi/aspect.BUILD"],
+ outs = ["tulsi/BUILD"],
+ cmd = "cp $< $@",
+ visibility = ["//visibility:private"],
+)
+
+filegroup(
+ name = "tulsi",
+ srcs = [
+ "tulsi/tulsi_aspects.bzl",
+ "tulsi/tulsi_aspects_paths.bzl",
+ ":aspect_build",
+ ],
+)
diff --git a/src/TulsiGenerator/Scripts/BUILD b/src/TulsiGenerator/Scripts/BUILD
new file mode 100644
index 0000000..a742638
--- /dev/null
+++ b/src/TulsiGenerator/Scripts/BUILD
@@ -0,0 +1,67 @@
+# Tulsi Generator Scripts
+
+package(default_visibility = ["//:__subpackages__"])
+
+licenses(["notice"])
+
+filegroup(
+ name = "Scripts",
+ srcs = glob(
+ ["**/*"],
+ exclude = [
+ "BUILD",
+ "**/*_tests.py",
+ ],
+ ),
+)
+
+py_binary(
+ name = "bazel_build_events",
+ srcs = ["bazel_build_events.py"],
+)
+
+py_test(
+ name = "bazel_build_events_tests",
+ size = "small",
+ srcs = ["bazel_build_events_tests.py"],
+ deps = [":bazel_build_events"],
+)
+
+py_binary(
+ name = "symbol_cache_schema",
+ srcs = ["symbol_cache_schema.py"],
+)
+
+py_binary(
+ name = "update_symbol_cache",
+ srcs = ["update_symbol_cache.py"],
+ deps = [":symbol_cache_schema"],
+)
+
+py_binary(
+ name = "clean_symbol_cache",
+ srcs = ["clean_symbol_cache.py"],
+ deps = [":symbol_cache_schema"],
+)
+
+py_binary(
+ name = "install_genfiles",
+ srcs = ["install_genfiles.py"],
+)
+
+py_test(
+ name = "install_genfiles_tests",
+ size = "small",
+ srcs = ["install_genfiles_tests.py"],
+ deps = [":install_genfiles"],
+)
+
+py_binary(
+ name = "bootstrap_lldbinit",
+ srcs = ["bootstrap_lldbinit.py"],
+)
+
+test_suite(
+ name = "all_tests",
+ visibility = ["//visibility:public"],
+)
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/ComplexSingle.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/ComplexSingle.BUILD
index 263dfa1..e891184 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/ComplexSingle.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/ComplexSingle.BUILD
@@ -22,7 +22,7 @@
)
load(
- "//tools/build_defs/apple:ios.bzl",
+ "@build_bazel_rules_apple//apple:ios.bzl",
"apple_product_type",
"ios_application",
"ios_extension",
@@ -30,7 +30,7 @@
"ios_ui_test",
)
load(
- "//tools/build_defs/apple:tvos.bzl",
+ "@build_bazel_rules_apple//apple:tvos.bzl",
"tvos_application",
"tvos_extension",
)
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/Mac.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/Mac.BUILD
index 69bf1a1..92ed4a4 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/Mac.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/Mac.BUILD
@@ -15,14 +15,14 @@
# MacOS mock BUILD file for testing.
load(
- "//tools/build_defs/apple:macos.bzl",
+ "@build_bazel_rules_apple//apple:macos.bzl",
"macos_application",
"macos_command_line_application",
"macos_extension",
"macos_unit_test",
"macos_ui_test",
)
-load("//tools/build_defs/apple:versioning.bzl", "apple_bundle_version")
+load("@build_bazel_rules_apple//apple:versioning.bzl", "apple_bundle_version")
macos_application(
name = "MyMacOSApp",
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/PlatformDependent.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/PlatformDependent.BUILD
index 31a5b4f..22c3227 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/PlatformDependent.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/PlatformDependent.BUILD
@@ -15,7 +15,7 @@
# Mock BUILD file for aspect testing.
load(
- "//tools/build_defs/apple:ios.bzl",
+ "@build_bazel_rules_apple//apple:ios.bzl",
"apple_product_type",
"ios_application",
"ios_extension",
@@ -23,7 +23,7 @@
"ios_ui_test",
"ios_legacy_test",
)
-load("//tools/build_defs/apple:swift.bzl", "swift_library")
+load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
ios_application(
name = "SkylarkApplication",
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/Simple.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/Simple.BUILD
index 1c2e1e5..95ad2bf 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/Simple.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/Simple.BUILD
@@ -15,7 +15,7 @@
# Simple mock BUILD file for aspect testing.
load(
- "//tools/build_defs/apple:ios.bzl",
+ "@build_bazel_rules_apple//apple:ios.bzl",
"ios_application",
"ios_unit_test",
)
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/SimpleBad.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/SimpleBad.BUILD
index 755bed9..d22406b 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/SimpleBad.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/SimpleBad.BUILD
@@ -15,7 +15,7 @@
# Bad mock BUILD file for aspect testing.
load(
- "//tools/build_defs/apple:ios.bzl",
+ "@build_bazel_rules_apple//apple:ios.bzl",
"ios_application",
)
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/Swift.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/Swift.BUILD
index f2851b9..483b671 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/Swift.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/Swift.BUILD
@@ -15,10 +15,10 @@
# mock BUILD file using Swift targets for aspect testing.
load(
- "//tools/build_defs/apple:ios.bzl",
+ "@build_bazel_rules_apple//apple:ios.bzl",
"ios_application",
)
-load("//tools/build_defs/apple:swift.bzl", "swift_library")
+load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
ios_application(
name = "Application",
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/One/TestOne.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/One/TestOne.BUILD
index c92d930..57544a0 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/One/TestOne.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/One/TestOne.BUILD
@@ -14,7 +14,7 @@
# Simple mock test.
-load("//tools/build_defs/apple:ios.bzl", "ios_unit_test")
+load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
test_suite(
name = "explicit_XCTests",
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/TestSuiteRoot.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/TestSuiteRoot.BUILD
index fd10d95..babaaae 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/TestSuiteRoot.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/TestSuiteRoot.BUILD
@@ -19,7 +19,7 @@
)
load(
- "//tools/build_defs/apple:ios.bzl",
+ "@build_bazel_rules_apple//apple:ios.bzl",
"ios_application",
"ios_unit_test",
)
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Three/TestThree.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Three/TestThree.BUILD
index fbdf19b..b9cfc72 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Three/TestThree.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Three/TestThree.BUILD
@@ -14,7 +14,7 @@
# Simple mock test.
-load("//tools/build_defs/apple:ios.bzl", "ios_unit_test")
+load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
test_suite(
name = "tagged_tests",
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Two/TestTwo.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Two/TestTwo.BUILD
index 558b535..611d045 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Two/TestTwo.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/TestSuite/Two/TestTwo.BUILD
@@ -14,7 +14,7 @@
# Simple mock test.
-load("//tools/build_defs/apple:ios.bzl", "ios_unit_test")
+load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
objc_library(
name = "XCTestLib",
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/Watch.BUILD b/src/TulsiGeneratorIntegrationTests/Resources/Watch.BUILD
index 50ef425..d1fcafd 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/Watch.BUILD
+++ b/src/TulsiGeneratorIntegrationTests/Resources/Watch.BUILD
@@ -15,10 +15,10 @@
# WatchOS mock BUILD file for aspect testing.
load(
- "//tools/build_defs/apple:ios.bzl",
+ "@build_bazel_rules_apple//apple:ios.bzl",
"ios_application",
)
-load("//tools/build_defs/apple:watchos.bzl", "watchos_application", "watchos_extension")
+load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_application", "watchos_extension")
ios_application(
name = "Application",
diff --git a/src/TulsiGeneratorTests/BUILD b/src/TulsiGeneratorTests/BUILD
new file mode 100644
index 0000000..a08cd32
--- /dev/null
+++ b/src/TulsiGeneratorTests/BUILD
@@ -0,0 +1,16 @@
+licenses(["notice"]) # Apache 2.0
+
+load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
+load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test")
+
+swift_library(
+ name = "TulsiGeneratorTestsLib",
+ testonly = 1,
+ srcs = glob(["*.swift"]),
+ deps = ["//src/TulsiGenerator:tulsi_generator_lib"],
+)
+
+macos_unit_test(
+ name = "TulsiGeneratorTests",
+ deps = [":TulsiGeneratorTestsLib"],
+)
diff --git a/src/tools/bazel_cache_reader/BUILD b/src/tools/bazel_cache_reader/BUILD
new file mode 100644
index 0000000..ab73d3d
--- /dev/null
+++ b/src/tools/bazel_cache_reader/BUILD
@@ -0,0 +1,19 @@
+licenses(["notice"]) # Apache 2.0
+
+package(default_visibility = ["//:__subpackages__"])
+
+load("@build_bazel_rules_apple//apple:macos.bzl", "macos_command_line_application")
+
+objc_library(
+ name = "bazel_cache_reader_lib",
+ srcs = ["bazel_cache_reader/main.c"],
+ sdk_dylibs = [
+ "libsqlite3",
+ ],
+)
+
+macos_command_line_application(
+ name = "bazel_cache_reader",
+ minimum_os_version = "10.12",
+ deps = [":bazel_cache_reader_lib"],
+)
diff --git a/version.bzl b/version.bzl
new file mode 100644
index 0000000..b39c90f
--- /dev/null
+++ b/version.bzl
@@ -0,0 +1,50 @@
+"""version.bzl: Contains constants and rules for Tulsi versioning.
+"""
+
+# Version number (recorded into the Info.plist)
+TULSI_VERSION_MAJOR = "0"
+
+TULSI_VERSION_FIXLEVEL = "194259773"
+
+TULSI_VERSION_DATE = "20180425"
+
+TULSI_VERSION_COPYRIGHT = "2015-2018"
+
+TULSI_PRODUCT_NAME = "Tulsi"
+
+#
+# Build things out of the parts.
+#
+TULSI_VERSIONINFO_LONG = "%s.%s.%s" % (
+ TULSI_VERSION_MAJOR,
+ TULSI_VERSION_DATE,
+ TULSI_VERSION_FIXLEVEL,
+)
+
+TULSI_VERSIONINFO_ABOUT = "%s %s\n © %s The Tulsi Authors." % (
+ TULSI_PRODUCT_NAME,
+ TULSI_VERSIONINFO_LONG,
+ TULSI_VERSION_COPYRIGHT,
+)
+
+def fill_info_plist_impl(ctx):
+ ctx.actions.expand_template(
+ template = ctx.file.template,
+ output = ctx.outputs.out,
+ substitutions = {
+ "$(TULSI_VERSIONINFO_ABOUT)": TULSI_VERSIONINFO_ABOUT,
+ "$(PRODUCT_MODULE_NAME)": TULSI_PRODUCT_NAME,
+ },
+ )
+
+fill_info_plist = rule(
+ attrs = {
+ "template": attr.label(
+ mandatory = True,
+ allow_files = True,
+ single_file = True,
+ ),
+ "out": attr.output(mandatory = True),
+ },
+ implementation = fill_info_plist_impl,
+)