Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions uberpoet/blazeprojectgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ def gen_lib_module(self, module_index, module_node, loc_per_unit, language):
# Make Module Directories
module_dir_path = join(self.app_root, module_node.name)
files_dir_path = join(module_dir_path, "Sources")
test_files_dir_path = join(module_dir_path, "Tests")
makedir(module_dir_path)
makedir(files_dir_path)
makedir(test_files_dir_path)

# Write BUCK or BUILD Files
build_name = "BUCK" if self.flavor == 'buck' else "BUILD"
Expand All @@ -225,6 +227,11 @@ def gen_lib_module(self, module_index, module_node, loc_per_unit, language):
self.write_file(file_path, file_obj.text)
file_obj.text = "" # Save memory after write

# Write Swift Test Files
file_path = join(test_files_dir_path, "Empty.swift")
self.write_file(file_path, file_obj.text)
file_obj.text = "" # Save memory after write

module_node.extra_info = files

return files
6 changes: 5 additions & 1 deletion uberpoet/filegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
@import Foundation;
"""

swift_system_import_template = """
import Foundation
"""

objc_header_template = """
@interface MyClass_{0} : NSObject

Expand Down Expand Up @@ -346,7 +350,7 @@ def gen_file(self, class_count, function_count, import_list=None):
func_out, func_nums = self.gen_func(function_count, "7")
class_out, class_nums = self.gen_class(class_count, 5, import_list)

chunks = [uber_poet_header, imports_out, func_out, class_out]
chunks = [uber_poet_header, swift_system_import_template, imports_out, func_out, class_out]

return FileResult("\n".join(chunks), func_nums, class_nums)

Expand Down
30 changes: 4 additions & 26 deletions uberpoet/resources/mockbazelapptemplate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@
# This code was @generated by Uber Poet, a mock application generator.
# Check it out at https://github.com/uber/uber-poet

load("@build_bazel_rules_ios//rules:app.bzl", "ios_application")
load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

apple_framework(
swift_library(
name = "AppContainer",
srcs = glob([
"Sources/**/*.h",
"Sources/**/*.m",
"Sources/**/*.swift",
]),
platforms = {{"ios": "12.0"}},
swift_version = "5.0",
srcs = glob(["*.swift"]),
visibility = ["//visibility:public"],
deps = [
{1}
Expand All @@ -38,28 +32,12 @@ apple_framework(

ios_application(
name = "App",
srcs = glob([
"*.h",
"*.m",
"*.swift",
]),
bundle_id = "com.uber.UberMockApp",
families = [
"iphone",
"ipad",
],
infoplists = ["Info.plist"],
minimum_os_version = "12.0",
sdk_frameworks = [
"Foundation",
"UIKit",
],
linkopts = [
"-ObjC"
],
swift_version = "5.0",
xcconfig = {{
"SWIFT_WHOLE_MODULE_OPTIMIZATION": "{2}",
}},
deps = [":AppContainer"],
)
32 changes: 19 additions & 13 deletions uberpoet/resources/mockbazellibtemplate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,32 @@
# This code was @generated by Uber Poet, a mock application generator.
# Check it out at https://github.com/uber/uber-poet

load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

apple_framework(
swift_library(
name = "{0}",
module_name = "{0}",
srcs = glob([
"Sources/**/*.h",
"Sources/**/*.m",
"Sources/**/*.swift",
]),
sdk_frameworks = [
"Foundation",
"UIKit",
],
platforms = {{"ios": "12.0"}},
swift_version = "5.0",
visibility = ["//visibility:public"],
xcconfig = {{
"SWIFT_WHOLE_MODULE_OPTIMIZATION[config=Debug]": "{2}",
}},
deps = [
{1}
],
)

swift_library(
name = "{0}TestsLib",
module_name = "{0}TestsLib",
srcs = glob([
"Tests/**/*.swift",
]),
deps = [":{0}"],
)

ios_unit_test(
name = "{0}Tests",
minimum_os_version = "12.0",
deps = [":{0}TestsLib"],
)
38 changes: 14 additions & 24 deletions uberpoet/resources/mockbazelworkspace
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,13 @@
workspace(name = "App")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//tools/rules:repository_rules.bzl", "github_repo")

github_repo(
name = "build_bazel_rules_ios",
project = "bazel-ios",
ref = "b439882984e3e756f8a54a589b6aa3e7071bb502",
repo = "rules_ios",
sha256 = "5615afd1e20cb33cb26a57c6dc3a0cc586d4571480ec0b24377c9b781337d6de",
)

load(
"@build_bazel_rules_ios//rules:repositories.bzl",
"rules_ios_dependencies",
http_archive(
name = "build_bazel_rules_apple",
sha256 = "77e8bf6fda706f420a55874ae6ee4df0c9d95da6c7838228b26910fc82eea5a2",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.32.0/rules_apple.0.32.0.tar.gz",
)

rules_ios_dependencies()

load(
"@bazel_skylib//:workspace.bzl",
"bazel_skylib_workspace",
)

bazel_skylib_workspace()

load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
Expand All @@ -84,6 +67,13 @@ load(

swift_rules_dependencies()

load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
Expand All @@ -92,8 +82,8 @@ load(
apple_support_dependencies()

load(
"@com_google_protobuf//:protobuf_deps.bzl",
"protobuf_deps",
"@bazel_skylib//:workspace.bzl",
"bazel_skylib_workspace",
)

protobuf_deps()
bazel_skylib_workspace()