This project demonstrates issues that can hopefully be addressed in Tulsi:
- Missing
swift_test
support - Invalid
.tulsigen
configuration file generation - Missing source file paths in generated
.tulsigen
file
DemoProject.tulsiproj
and DemoProject.tulsigen
artifacts have been committed to the repository to provide a baseline state from which to observe the file generation-related issues.
This project was created to add context to the bazelbuild/tulsi Issue opened here.
The Makefile
contains a few commands to build and test targets, and generate a Tulsi project.
Execute the following to build both demo targets:
make build
Execute the following to run demo target tests:
make test
Execute the following to generate a Tulsi project using the demo test target:
make tulsiproj
Execute the following to open the generated Tulsi project:
make tulsiproj_open
Using make tulsiproj
, we observe that Tulsi produces an invalid .tulsigen
configuration file for the given target. Here is the warning we receive:
Failed to read the given generator config: Config file at /tulsi-swift-test-demo/demo-target/DemoProject.tulsiproj/Configs/DemoProject.tulsigen is invalid: Invalid additional file path: //demo-target/BUILD
In order to fix this, we have to remove the //
prefix from "//demo-target/BUILD"
within additionalFilePaths
:
Before:
"additionalFilePaths" : [
"//demo-target/BUILD"
],
After:
"additionalFilePaths" : [
"demo-target/BUILD"
],
Note: Repeated invocations of make tulsiproj
reset this fix.
Using make tulsiproj
, we observe that Tulsi produces a .tulsigen
configuration file that is missing paths to target source files:
"sourceFilters" : [
"./..."
]
In order to fix this, we have to manually add paths to source file directories:
"sourceFilters" : [
"demo-target",
"demo-target/Sources",
"demo-target/Tests"
]
Note: Repeated invocations of make tulsiproj
reset this fix.
Although Tulsi appears to handle swift_library targets correctly, it fails to generate a Tulsi project for swift_test targets. Here is the warning we receive after executing make tulsiproj_open
:
[Error] Generate[FAIL]: 10.6267s Unsupported target type: swift_test (target //demo-target:DemoTargetTests)
Xcode project generation failed
In order to fix this temporarily, we have to define new swift_library and macos_unit_test libraries for this test target:
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test")
swift_library(
name = "DemoTargetTestsLibrary",
srcs = glob(["Tests/*.swift"]),
deps = [":DemoTarget"]
module_name = "DemoTargetTestsLibrary",
visibility = ["//visibility:private"],
)
macos_unit_test(
name = "DemoTargetTests",
deps = [":DemoTargetTestsLibrary"],
minimum_os_version = "10.15",
visibility = ["//visibility:public"]
)