-
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.
Replaces `experimental_mixed_langauge_library` in rules_apple. Meant to support SE-0403. Signed-off-by: Brentley Jones <github@brentleyjones.com>
- Loading branch information
1 parent
6a105e4
commit be8bc73
Showing
25 changed files
with
1,157 additions
and
8 deletions.
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
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,48 @@ | ||
load("//mixed_language:mixed_language_library.bzl", "mixed_language_library") | ||
load("//swift:swift_library.bzl", "swift_library") | ||
load("//swift:swift_test.bzl", "swift_test") | ||
|
||
mixed_language_library( | ||
name = "MixedAnswer", | ||
hdrs = ["MixedAnswer.h"], | ||
clang_srcs = [ | ||
"MixedAnswer.m", | ||
"MixedAnswerPrivate.m", | ||
"MixedAnswerPrivate.h", | ||
], | ||
enable_modules = True, | ||
module_name = "MixedAnswer", | ||
swift_srcs = [ | ||
"MixedAnswer.swift", | ||
], | ||
target_compatible_with = ["@platforms//os:macos"], | ||
) | ||
|
||
swift_library( | ||
name = "SwiftLibDependingOnMixedLib", | ||
srcs = [ | ||
"SwiftLibDependingOnMixedLib.swift", | ||
], | ||
module_name = "SwiftLibDependingOnMixedLib", | ||
deps = [":MixedAnswer"], | ||
) | ||
|
||
mixed_language_library( | ||
name = "MixedTestsLib", | ||
testonly = True, | ||
clang_srcs = [ | ||
"MixedTests.m", | ||
], | ||
swift_srcs = [ | ||
"MixedTests.swift", | ||
], | ||
target_compatible_with = ["@platforms//os:macos"], | ||
deps = [ | ||
":SwiftLibDependingOnMixedLib", | ||
], | ||
) | ||
|
||
swift_test( | ||
name = "MixedTests", | ||
deps = [":MixedTestsLib"], | ||
) |
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,7 @@ | ||
@import Foundation; | ||
|
||
@interface MixedAnswerObjc : NSObject | ||
|
||
+ (NSString *)mixedAnswerObjc; | ||
|
||
@end |
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,11 @@ | ||
#import "examples/apple/mixed_language/MixedAnswer.h" | ||
#import "examples/apple/mixed_language/MixedAnswerPrivate.h" | ||
#import "examples/apple/mixed_language/MixedAnswer-Swift.h" | ||
|
||
@implementation MixedAnswerObjc | ||
|
||
+ (NSString *)mixedAnswerObjc { | ||
return [NSString stringWithFormat:@"%@_%@ and %@", @"mixedAnswerObjc", [MixedAnswerSwift swiftToObjcMixedAnswer], [MixedAnswerPrivateObjc mixedAnswerPrivateObjc]]; | ||
} | ||
|
||
@end |
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,16 @@ | ||
import Foundation | ||
|
||
@objc | ||
public class MixedAnswerSwift: NSObject { | ||
|
||
public | ||
static func swiftMixedAnswer() -> String { | ||
"\(MixedAnswerObjc.mixedAnswerObjc() ?? "invalid")_swiftMixedAnswer" | ||
} | ||
|
||
@objc | ||
public | ||
static func swiftToObjcMixedAnswer() -> String { | ||
"swiftToObjcMixedAnswer" | ||
} | ||
} |
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,7 @@ | ||
@import Foundation; | ||
|
||
@interface MixedAnswerPrivateObjc : NSObject | ||
|
||
+ (NSString *)mixedAnswerPrivateObjc; | ||
|
||
@end |
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,10 @@ | ||
#import "examples/apple/mixed_language/MixedAnswerPrivate.h" | ||
#import "examples/apple/mixed_language/MixedAnswer-Swift.h" | ||
|
||
@implementation MixedAnswerPrivateObjc | ||
|
||
+ (NSString *)mixedAnswerPrivateObjc { | ||
return [NSString stringWithFormat:@"%@_%@", @"mixedAnswerPrivateObjc", [MixedAnswerSwift swiftToObjcMixedAnswer]]; | ||
} | ||
|
||
@end |
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,27 @@ | ||
// Copyright 2017 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 <Foundation/Foundation.h> | ||
#import <XCTest/XCTest.h> | ||
|
||
@interface MixedTests : XCTestCase | ||
@end | ||
|
||
@implementation MixedTests | ||
|
||
- (void)testAlwaysPass { | ||
XCTAssertTrue(YES); | ||
} | ||
|
||
@end |
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,29 @@ | ||
// Copyright 2018 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 SwiftLibDependingOnMixedLib | ||
import XCTest | ||
|
||
class MixedTests: XCTestCase { | ||
func testValuesSwift() { | ||
XCTAssertEqual( | ||
SwiftLibDependingOnMixedLib.callSwiftMixedAnswer(), | ||
"mixedAnswerObjc_swiftToObjcMixedAnswer and mixedAnswerPrivateObjc_swiftToObjcMixedAnswer_swiftMixedAnswer" | ||
) | ||
XCTAssertEqual( | ||
SwiftLibDependingOnMixedLib.callObjcMixedAnswer(), | ||
"mixedAnswerObjc_swiftToObjcMixedAnswer and mixedAnswerPrivateObjc_swiftToObjcMixedAnswer" | ||
) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
examples/apple/mixed_language/SwiftLibDependingOnMixedLib.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,11 @@ | ||
import MixedAnswer | ||
|
||
public class SwiftLibDependingOnMixedLib { | ||
public static func callSwiftMixedAnswer() -> String { | ||
MixedAnswerSwift.swiftMixedAnswer() | ||
} | ||
|
||
public static func callObjcMixedAnswer() -> String? { | ||
MixedAnswerObjc.mixedAnswerObjc() | ||
} | ||
} |
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,26 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["notice"]) | ||
|
||
bzl_library( | ||
name = "mixed_language", | ||
deps = [ | ||
":mixed_language_library", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "mixed_language_library", | ||
srcs = ["mixed_language_library.bzl"], | ||
deps = [ | ||
"//mixed_language/internal:library", | ||
"//mixed_language/internal:module_map", | ||
"//mixed_language/internal:umbrella_header", | ||
"//swift:swift_interop_hint", | ||
"//swift:swift_library", | ||
"//swift/internal:compiling", | ||
"@bazel_skylib//lib:paths", | ||
], | ||
) |
Oops, something went wrong.