diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/BUILD | 1 | ||||
-rw-r--r-- | examples/swift/BUILD | 19 | ||||
-rw-r--r-- | examples/swift/BarLib/BUILD | 15 | ||||
-rw-r--r-- | examples/swift/BarLib/mul.swift | 8 | ||||
-rw-r--r-- | examples/swift/constants.swift | 4 | ||||
-rw-r--r-- | examples/swift/foo.swift | 9 |
6 files changed, 56 insertions, 0 deletions
diff --git a/examples/BUILD b/examples/BUILD index 8bfbc19524..781c81a46c 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -11,5 +11,6 @@ filegroup( "//examples/py:srcs", "//examples/py_native:srcs", "//examples/shell:srcs", + "//examples/swift:srcs", ], ) diff --git a/examples/swift/BUILD b/examples/swift/BUILD new file mode 100644 index 0000000000..e2cbb195e2 --- /dev/null +++ b/examples/swift/BUILD @@ -0,0 +1,19 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # Apache 2.0 + +load("//tools/build_defs/apple:swift.bzl", "swift_library") + +swift_library( + name = "swift_lib", + srcs = glob(["*.swift"]), + deps = ["//examples/swift/BarLib"], +) + +filegroup( + name = "srcs", + srcs = glob(["**"]) + [ + "//examples/swift/BarLib:srcs", + ], + visibility = ["//examples:__pkg__"], +) diff --git a/examples/swift/BarLib/BUILD b/examples/swift/BarLib/BUILD new file mode 100644 index 0000000000..d575a879f1 --- /dev/null +++ b/examples/swift/BarLib/BUILD @@ -0,0 +1,15 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # Apache 2.0 + +load("//tools/build_defs/apple:swift.bzl", "swift_library") + +swift_library( + name = "BarLib", + srcs = ["mul.swift"], +) + +filegroup( + name = "srcs", + srcs = glob(["**"]), +) diff --git a/examples/swift/BarLib/mul.swift b/examples/swift/BarLib/mul.swift new file mode 100644 index 0000000000..1f1df40512 --- /dev/null +++ b/examples/swift/BarLib/mul.swift @@ -0,0 +1,8 @@ +/// Class used to multiply stuff. +public class Multiplier { + public init() {} + + public func multiply(a: Int, _ b: Int) -> Int { + return a * b + } +} diff --git a/examples/swift/constants.swift b/examples/swift/constants.swift new file mode 100644 index 0000000000..6c16d34a82 --- /dev/null +++ b/examples/swift/constants.swift @@ -0,0 +1,4 @@ +class Constants { + static var x = 2 + static var y = 3 +}
\ No newline at end of file diff --git a/examples/swift/foo.swift b/examples/swift/foo.swift new file mode 100644 index 0000000000..067c6730cd --- /dev/null +++ b/examples/swift/foo.swift @@ -0,0 +1,9 @@ +import class BarLib.Multiplier + +public class Foo { + public init() {} + + public func multiply() -> Int { + return Multiplier().multiply(Constants.x, Constants.y) + } +} |