-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example with deps in
swift_import
- Loading branch information
1 parent
61e2c46
commit 7b92e4d
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
load("//swift:swift_library.bzl", "swift_library") | ||
load( | ||
"//test/fixtures:common.bzl", | ||
"FIXTURE_TAGS", | ||
) | ||
load( | ||
"//test/rules:swift_library_artifact_collector.bzl", | ||
"swift_library_artifact_collector", | ||
) | ||
|
||
package( | ||
default_testonly = True, | ||
default_visibility = ["//test:__subpackages__"], | ||
) | ||
|
||
licenses(["notice"]) | ||
|
||
# Checking in pre-built artifacts like a `.swiftinterface` and static libraries | ||
# would require different artifacts for every platform the test might run on. | ||
# Instead, build it on-demand but forward the outputs using the "artifact | ||
# collector" rule below to make them act as if they were pre-built outputs when | ||
# referenced by the `swift_import` rule. | ||
# | ||
# These must be in a separate package than the `swift_import` target because | ||
# that rule propagates its pre-built inputs in `DefaultInfo`. | ||
|
||
swift_library( | ||
name = "toy_module_consumer", | ||
srcs = ["ToyConsumer.swift"], | ||
library_evolution = True, | ||
module_name = "ToyModuleConsumer", | ||
tags = FIXTURE_TAGS, | ||
deps = ["//test/fixtures/module_interface/library:toy_module_library"], | ||
) | ||
|
||
swift_library_artifact_collector( | ||
name = "toy_module_consumer_artifact_collector", | ||
static_library = "toy_consumer_outputs/libToyModuleConsumer.a", | ||
swiftdoc = "toy_consumer_outputs/ToyModuleConsumer.swiftdoc", | ||
swiftinterface = "toy_consumer_outputs/ToyModuleConsumer.swiftinterface", | ||
tags = FIXTURE_TAGS, | ||
target = ":toy_module_consumer", | ||
target_compatible_with = ["@platforms//os:macos"], | ||
) | ||
|
||
swift_library( | ||
name = "toy_module_consumer_without_library_evolution", | ||
srcs = ["ToyConsumer.swift"], | ||
library_evolution = False, | ||
module_name = "ToyModuleConsumerNoEvolution", | ||
tags = FIXTURE_TAGS, | ||
) |
19 changes: 19 additions & 0 deletions
19
test/fixtures/module_interface/library_consumer/ToyConsumer.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2024 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import ToyModule | ||
|
||
public func printToyValue() { | ||
print(ToyValue(number: 42)) | ||
} |