Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all code related to “folders” #3100

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
57 changes: 6 additions & 51 deletions test/internal/pbxproj_partials/write_files_and_groups_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ _RESOLVED_REPOSITORIES_FILE_DECLARED_FILE = mock_actions.mock_file(
_FILE_PATHS_FILE = mock_actions.mock_file(
"a_generator_name_pbxproj_partials/file_paths_file",
)
_FOLDER_PATHS_FILE = mock_actions.mock_file(
"a_generator_name_pbxproj_partials/folder_paths_file",
)
_GENERATED_FILE_PATHS_FILE = mock_actions.mock_file(
"a_generator_name_pbxproj_partials/generated_file_paths_file",
)
_GENERATED_FOLDER_PATHS_FILE = mock_actions.mock_file(
"a_generator_name_pbxproj_partials/generated_folder_paths_file",
)

def _write_files_and_groups_test_impl(ctx):
env = unittest.begin(ctx)
Expand All @@ -40,15 +34,11 @@ def _write_files_and_groups_test_impl(ctx):
_KNOWN_REGIONS_DECLARED_FILE: None,
_RESOLVED_REPOSITORIES_FILE_DECLARED_FILE: None,
_FILE_PATHS_FILE: None,
_FOLDER_PATHS_FILE: None,
_GENERATED_FILE_PATHS_FILE: None,
_GENERATED_FOLDER_PATHS_FILE: None,
}
expected_inputs = [
_FILE_PATHS_FILE,
_FOLDER_PATHS_FILE,
_GENERATED_FILE_PATHS_FILE,
_GENERATED_FOLDER_PATHS_FILE,
ctx.attr.execution_root_file,
ctx.attr.selected_model_versions_file,
] + ctx.attr.buildfile_subidentifiers_files
Expand Down Expand Up @@ -79,13 +69,6 @@ def _write_files_and_groups_test_impl(ctx):
)
for (path, owner) in ctx.attr.generated_file_paths.items()
]
generated_folders = [
struct(
path = path,
owner = mock_actions.mock_label(owner),
)
for (path, owner) in ctx.attr.generated_folders.items()
]

# Act

Expand All @@ -103,9 +86,7 @@ def _write_files_and_groups_test_impl(ctx):
execution_root_file = ctx.attr.execution_root_file,
files = depset(files),
file_paths = depset(ctx.attr.file_paths),
folders = depset(ctx.attr.folders),
generated_file_paths = depset(generated_file_paths),
generated_folders = depset(generated_folders),
generator_name = "a_generator_name",
install_path = ctx.attr.install_path,
project_options = ctx.attr.project_options,
Expand Down Expand Up @@ -204,10 +185,8 @@ write_files_and_groups_test = unittest.make(
"execution_root_file": attr.string(mandatory = True),
"file_paths": attr.string_list(mandatory = True),
"files": attr.string_list(mandatory = True),
"folders": attr.string_list(mandatory = True),
"generated_file_paths": attr.string_dict(mandatory = True),
"generated_files": attr.string_dict(mandatory = True),
"generated_folders": attr.string_dict(mandatory = True),
"install_path": attr.string(mandatory = True),
"project_options": attr.string_dict(mandatory = True),
"selected_model_versions_file": attr.string(mandatory = True),
Expand Down Expand Up @@ -239,10 +218,8 @@ def write_files_and_groups_test_suite(name):
execution_root_file,
files = [],
file_paths = [],
folders = [],
generated_file_paths = {},
generated_files = {},
generated_folders = {},
install_path,
project_options,
selected_model_versions_file,
Expand All @@ -262,10 +239,8 @@ def write_files_and_groups_test_suite(name):
execution_root_file = execution_root_file,
files = files,
file_paths = file_paths,
folders = folders,
generated_file_paths = generated_file_paths,
generated_files = generated_files,
generated_folders = generated_folders,
install_path = install_path,
project_options = project_options,
selected_model_versions_file = selected_model_versions_file,
Expand Down Expand Up @@ -321,12 +296,8 @@ def write_files_and_groups_test_suite(name):
"",
# filePathsFile
_FILE_PATHS_FILE.path,
# folderPathsFile
_FOLDER_PATHS_FILE.path,
# generatedFilePathsFile
_GENERATED_FILE_PATHS_FILE.path,
# generatedFolderPathsFile
_GENERATED_FOLDER_PATHS_FILE.path,
# developmentRegion
"en",
# useBaseInternationalization
Expand All @@ -338,9 +309,7 @@ def write_files_and_groups_test_suite(name):
],
expected_writes = {
_FILE_PATHS_FILE: "\n",
_FOLDER_PATHS_FILE: "\n",
_GENERATED_FILE_PATHS_FILE: "\n",
_GENERATED_FOLDER_PATHS_FILE: "\n",
},
)

Expand All @@ -365,22 +334,18 @@ def write_files_and_groups_test_suite(name):
"a/path/to/a/file_path.bundle",
"another/path/to/another/file_path.framework",
],
folders = [
"a/path/to/a/folder",
"another/path/to/another/folder",
],
# @unsorted-dict-items
generated_file_paths = {
"bazel-out/ios-sim-config/bin/a/path/to/a/generated/file_as_file_path": "//a/path/to/a/generated",
"bazel-out/ios-sim-config/bin/another/path/to/another/generated/file_as_file_path": "//another/path/to/another/generated",
"bazel-out/ios-sim-config/bin/a/path/to/a/generated/some.framework": "//a/path/to/a/generated",
"bazel-out/ios-sim-config/bin/another/path/to/another/generated/another.bundle": "//another/path/to/another/generated",
},
# @unsorted-dict-items
generated_files = {
"bazel-out/ios-sim-config/bin/a/path/to/a/generated/file": "//a/path/to/a/generated",
"bazel-out/ios-sim-config/bin/another/path/to/another/generated/file": "//another/path/to/another/generated",
},
generated_folders = {
"bazel-out/ios-sim-config/bin/a/path/to/a/generated/folder": "//a/path/to/a/generated",
"bazel-out/ios-sim-config/bin/another/path/to/another/generated/folder": "//another/path/to/another/generated",
},
install_path = "best/vision.xcodeproj",
project_options = {
"development_region": "enGB",
Expand Down Expand Up @@ -415,12 +380,8 @@ def write_files_and_groups_test_suite(name):
"0",
# filePathsFile
_FILE_PATHS_FILE.path,
# folderPathsFile
_FOLDER_PATHS_FILE.path,
# generatedFilePathsFile
_GENERATED_FILE_PATHS_FILE.path,
# generatedFolderPathsFile
_GENERATED_FOLDER_PATHS_FILE.path,
# developmentRegion
"enGB",
# useBaseInternationalization
Expand All @@ -440,10 +401,6 @@ a/path/to/a/file
another/path/to/another/file
a/path/to/a/file_path.bundle
another/path/to/another/file_path.framework
""",
_FOLDER_PATHS_FILE: """\
a/path/to/a/folder
another/path/to/another/folder
""",
_GENERATED_FILE_PATHS_FILE: """\
file
Expand All @@ -458,12 +415,10 @@ ios-sim-config
file_as_file_path
another/path/to/another/generated
ios-sim-config
""",
_GENERATED_FOLDER_PATHS_FILE: """\
folder
some.framework
a/path/to/a/generated
ios-sim-config
folder
another.bundle
another/path/to/another/generated
ios-sim-config
""",
Expand Down
4 changes: 0 additions & 4 deletions tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,8 @@ _XCSCHEMES = [
"1",
# filePathsFile
"/tmp/pbxproj_partials/file_paths_file",
# folderPathsFile
"/tmp/pbxproj_partials/folder_paths_file",
# generatedFilePathsFile
"/tmp/pbxproj_partials/generated_file_paths_file",
# generatedFolderPathsFile
"/tmp/pbxproj_partials/generated_folder_paths_file",
# developmentRegion
"en",
# useBaseInternationalization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import PBXProj

extension BazelPath {
init(parent: BazelPath, path: String, isFolder: Bool = false) {
init(parent: BazelPath, path: String) {
let newPath: String
if parent.path.isEmpty {
newPath = path
} else {
newPath = "\(parent.path)/\(path)"
}

self.init(newPath, isFolder: isFolder)
self.init(newPath)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ extension ElementCreator.CollectBazelPaths {
parentBazelPath: BazelPath
) -> [BazelPath] {
switch node {
case .file(let name, let isFolder):
case .file(let name):
let bazelPath = BazelPath(
parent: parentBazelPath,
path: name,
isFolder: isFolder
path: name
)
return [bazelPath]
case .group(let name, let children):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ extension ElementCreator {

func callAsFunction(
name: String,
isFolder: Bool,
bazelPath: BazelPath,
bazelPathType: BazelPathType,
transitiveBazelPaths: [BazelPath],
identifierForBazelPaths: String? = nil
) -> GroupChild.ElementAndChildren {
return callable(
/*name:*/ name,
/*isFolder:*/ isFolder,
/*bazelPath:*/ bazelPath,
/*bazelPathType:*/ bazelPathType,
/*transitiveBazelPaths:*/ transitiveBazelPaths,
Expand All @@ -44,7 +42,6 @@ extension ElementCreator {
extension ElementCreator.CreateFile {
typealias Callable = (
_ name: String,
_ isFolder: Bool,
_ bazelPath: BazelPath,
_ bazelPathType: BazelPathType,
_ transitiveBazelPaths: [BazelPath],
Expand All @@ -54,7 +51,6 @@ extension ElementCreator.CreateFile {

static func defaultCallable(
name: String,
isFolder: Bool,
bazelPath: BazelPath,
bazelPathType: BazelPathType,
transitiveBazelPaths: [BazelPath],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ extension ElementCreator {
// MARK: - CreateFileElement.Callable

extension ElementCreator.CreateFileElement {
private static let folderTypeFileExtensions: Set<String?> = [
"bundle",
"docc",
"framework",
"scnassets",
"xcassets",
]

private static let explicitFileTypeExtensions: Set<String?> = [
"bazel",
"bzl",
Expand Down Expand Up @@ -84,16 +76,6 @@ extension ElementCreator.CreateFileElement {
resolvedRepository: ResolvedRepository?
) {
let impliedExt = ext ?? Xcode.impliedExtension(basename: name)
let fileTypeType = calculateFileTypeType(basename: name, extension: impliedExt)
let fileType: String
let sortOrder: Element.SortOrder
if bazelPath.isFolder && !folderTypeFileExtensions.contains(ext) {
fileType = "folder"
sortOrder = .groupLike
} else {
fileType = impliedExt.flatMap(Xcode.pbxProjEscapedFileType) ?? "file"
sortOrder = .fileLike
}

let attributes = createAttributes(
name: name,
Expand All @@ -110,7 +92,9 @@ extension ElementCreator.CreateFileElement {
}
let content = """
{isa = PBXFileReference; \
\(fileTypeType) = \(fileType); \
\(calculateFileTypeType(basename: name, extension: impliedExt)) = \(
impliedExt.flatMap(Xcode.pbxProjEscapedFileType) ?? "file"
); \
\(nameAttribute)\
path = \(attributes.elementAttributes.path.pbxProjEscaped); \
sourceTree = \(attributes.elementAttributes.sourceTree.rawValue); }
Expand All @@ -128,7 +112,7 @@ sourceTree = \(attributes.elementAttributes.sourceTree.rawValue); }
),
content: content
),
sortOrder: sortOrder
sortOrder: .fileLike
),
resolvedRepository: attributes.resolvedRepository
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ extension ElementCreator.CreateGroupChild {
)
}

case .file(let name, let isFolder):
case .file(let name):
return .elementAndChildren(
createFile(
name: name,
isFolder: isFolder,
bazelPath: BazelPath(
parent: parentBazelPath,
path: name,
isFolder: isFolder
path: name
),
bazelPathType: parentBazelPathType,
transitiveBazelPaths: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension ElementCreator.CreateVersionGroup {
for node in nodeChildren {
let childName = node.nameForSpecialGroupChild
let childBazelPath = BazelPath(parent: bazelPath, path: childName)

let transitiveBazelPaths = collectBazelPaths(
node: node,
bazelPath: childBazelPath,
Expand All @@ -105,7 +105,6 @@ extension ElementCreator.CreateVersionGroup {

let result = createFile(
name: childName,
isFolder: false,
bazelPath: childBazelPath,
bazelPathType: bazelPathType,
transitiveBazelPaths: transitiveBazelPaths,
Expand Down
Loading
Loading