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

Fixed duplicates in srcs when subspecs contain overlapping sources #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions lib/cocoapods/bazel/target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ def to_rule_kwargs
end
return [] if h.empty?

h.map do |excludes, globs|
excludes = excludes.empty? ? {} : { exclude: excludes.flat_map(&method(:expand_glob)) }
starlark { function_call(:glob, globs.uniq, **excludes) }
end.reduce(&:+)
globs = h.values.reduce(:+).uniq
excludes = h.keys.reduce(:+).uniq
excludes = excludes.empty? ? {} : { exclude: excludes.flat_map(&method(:expand_glob)) }
starlark { function_call(:glob, globs, **excludes) }
end

kwargs[:srcs] = m[srcs]
Expand Down
1 change: 1 addition & 0 deletions spec/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def match(path)
c.temp_path = c.spec_path + 'tmp'

c.ignores BuildFileMatcher.new('_unused')
c.include_hidden_files = false

c.hook_into :bacon
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
load("@build_bazel_rules_ios//rules:app.bzl", "ios_application")
load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework")
load("@build_bazel_rules_ios//rules:test.bzl", "ios_unit_test")

apple_framework(
name = "DuplicatedSrcs",
srcs = glob(
[
"Sources/**/*.h",
"Sources/**/*.m",
"Sources/**/*.swift",
],
exclude = [
"Sources/a.swift",
"Sources/b.swift",
],
),
infoplists = [{"CFBundleShortVersionString": "1.0.0"}],
platforms = {"ios": "11.0"},
private_headers = glob(
["Sources/Internal/**/*.h"],
exclude = [
"Sources/a.swift",
"Sources/b.swift",
"Sources/a.swift",
],
),
swift_version = "5.2",
visibility = ["//visibility:public"],
)

ios_unit_test(
name = "DuplicatedSrcs-Unit-Tests",
srcs = glob([
"Tests/**/*.h",
"Tests/**/*.m",
"Tests/**/*.swift",
]),
minimum_os_version = "11.0",
module_name = "DuplicatedSrcs_Unit_Tests",
swift_version = "5.2",
deps = [":DuplicatedSrcs"],
)

ios_application(
name = "DuplicatedSrcs-App",
srcs = glob([
"App/**/*.h",
"App/**/*.m",
"App/**/*.swift",
]),
bundle_id = "org.cocoapods.DuplicatedSrcs-App",
families = [
"iphone",
"ipad",
],
linkopts = ["-all_load"],
minimum_os_version = "11.0",
module_name = "DuplicatedSrcs_App",
objc_copts = [
"-Wno-conversion",
"-Wno-error=at-protocol",
"-I/Headers/Private",
],
swift_copts = [
"-DDEBUG",
"-Xcc",
"-I/Headers/Private",
],
swift_version = "5.2",
xcconfig = {
"ARCHS": [
"arm64",
"x86",
],
"VERSIONING_SYSTEM": "apple-generic",
"SWIFT_OPTIMIZATION_LEVEL_Debug": "-Onone",
"SWIFT_OPTIMIZATION_LEVEL_Release": "-Owholemodule",
},
xcconfig_by_build_setting = {
"//Pods/cocoapods-bazel:debug": {"SWIFT_OPTIMIZATION_LEVEL": "-Onone"},
"//Pods/cocoapods-bazel:release": {"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule"},
},
deps = [":DuplicatedSrcs"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
func main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# frozen_string_literal: true

Pod::Spec.new do |s|
s.name = 'DuplicatedSrcs'
s.version = '1.0.0.LOCAL'

s.authors = %w[Square]
s.homepage = 'https://github.com/Square/cocoapods-generate'
s.source = { git: 'https://github.com/Square/cocoapods-generate' }
s.summary = 'Testing pod'

s.swift_versions = %w[5.2]
s.ios.deployment_target = '11.0'

s.source_files = 'Sources/**/*.{h,m,swift}'
s.private_header_files = 'Sources/Internal/**/*.h'

s.info_plist = {
'CFBundleShortVersionString' => '1.0.0'
}

s.test_spec 'Tests' do |ts|
ts.source_files = 'Tests/**/*.{h,m,swift}'
end

s.subspec 'Sub' do |subsp|
subsp.source_files = 'Sources/**/*.{h,m,swift}'
subsp.exclude_files = 'Sources/a.swift', 'Sources/b.swift'
end

s.subspec 'Sub2' do |subsp|
subsp.source_files = 'Sources/**/*.{h,m,swift}'
subsp.exclude_files = 'Sources/a.swift'
end

s.app_spec 'App' do |as|
as.source_files = 'App/**/*.{h,m,swift}'

as.pod_target_xcconfig = {
'ARCHS' => 'arm64 x86',
'HEADER_SEARCH_PATHS'=> "${PODS_ROOT}/Headers/Private",
'OTHER_CFLAGS' => '-Wno-conversion -Wno-error=at-protocol',
'OTHER_LDFLAGS' => '-all_load',
'OTHER_SWIFT_FLAGS' => '-DDEBUG',
'VERSIONING_SYSTEM' => 'apple-generic',
'SWIFT_OPTIMIZATION_LEVEL' => "$(SWIFT_OPTIMIZATION_LEVEL_$(CONFIGURATION))",
'SWIFT_OPTIMIZATION_LEVEL_Debug' => '-Onone',
'SWIFT_OPTIMIZATION_LEVEL_Release' => '-Owholemodule'
}
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Internal header
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Header
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Implementation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// b Swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
Test docstring
that takes two lines
"""

load("@build_bazel_rules_ios//rules:app.bzl", "ios_application")
load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework")
load("@build_bazel_rules_ios//rules:test.bzl", "ios_unit_test")

apple_framework(
name = "DuplicatedSrcs",
srcs = glob(
[
"Sources/**/*.h",
"Sources/**/*.m",
"Sources/**/*.swift",
],
exclude = [
"Sources/a.swift",
"Sources/b.swift",
],
),
infoplists = [{"CFBundleShortVersionString": "1.0.0"}],
platforms = {"ios": "11.0"},
private_headers = glob(
["Sources/Internal/**/*.h"],
exclude = [
"Sources/a.swift",
"Sources/b.swift",
"Sources/a.swift",
],
),
swift_version = "5.2",
visibility = ["//visibility:public"],
)

ios_unit_test(
name = "DuplicatedSrcs-Unit-Tests",
srcs = glob([
"Tests/**/*.h",
"Tests/**/*.m",
"Tests/**/*.swift",
]),
minimum_os_version = "11.0",
module_name = "DuplicatedSrcs_Unit_Tests",
swift_version = "5.2",
deps = [":DuplicatedSrcs"],
)

ios_application(
name = "DuplicatedSrcs-App",
srcs = glob([
"App/**/*.h",
"App/**/*.m",
"App/**/*.swift",
]),
bundle_id = "org.cocoapods.DuplicatedSrcs-App",
families = [
"iphone",
"ipad",
],
linkopts = ["-all_load"],
minimum_os_version = "11.0",
module_name = "DuplicatedSrcs_App",
objc_copts = [
"-Wno-conversion",
"-Wno-error=at-protocol",
"-I/Headers/Private",
],
swift_copts = [
"-DDEBUG",
"-Xcc",
"-I/Headers/Private",
],
swift_version = "5.2",
xcconfig = {
"ARCHS": [
"arm64",
"x86",
],
"VERSIONING_SYSTEM": "apple-generic",
"SWIFT_OPTIMIZATION_LEVEL_Debug": "-Onone",
"SWIFT_OPTIMIZATION_LEVEL_Release": "-Owholemodule",
},
xcconfig_by_build_setting = {
"//Pods/cocoapods-bazel:debug": {"SWIFT_OPTIMIZATION_LEVEL": "-Onone"},
"//Pods/cocoapods-bazel:release": {"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule"},
},
deps = [":DuplicatedSrcs"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
func main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# frozen_string_literal: true

Pod::Spec.new do |s|
s.name = 'DuplicatedSrcs'
s.version = '1.0.0.LOCAL'

s.authors = %w[Square]
s.homepage = 'https://github.com/Square/cocoapods-generate'
s.source = { git: 'https://github.com/Square/cocoapods-generate' }
s.summary = 'Testing pod'

s.swift_versions = %w[5.2]
s.ios.deployment_target = '11.0'

s.source_files = 'Sources/**/*.{h,m,swift}'
s.private_header_files = 'Sources/Internal/**/*.h'

s.info_plist = {
'CFBundleShortVersionString' => '1.0.0'
}

s.test_spec 'Tests' do |ts|
ts.source_files = 'Tests/**/*.{h,m,swift}'
end

s.subspec 'Sub' do |subsp|
subsp.source_files = 'Sources/**/*.{h,m,swift}'
subsp.exclude_files = 'Sources/a.swift', 'Sources/b.swift'
end

s.subspec 'Sub2' do |subsp|
subsp.source_files = 'Sources/**/*.{h,m,swift}'
subsp.exclude_files = 'Sources/a.swift'
end

s.app_spec 'App' do |as|
as.source_files = 'App/**/*.{h,m,swift}'

as.pod_target_xcconfig = {
'ARCHS' => 'arm64 x86',
'HEADER_SEARCH_PATHS'=> "${PODS_ROOT}/Headers/Private",
'OTHER_CFLAGS' => '-Wno-conversion -Wno-error=at-protocol',
'OTHER_LDFLAGS' => '-all_load',
'OTHER_SWIFT_FLAGS' => '-DDEBUG',
'VERSIONING_SYSTEM' => 'apple-generic',
'SWIFT_OPTIMIZATION_LEVEL' => "$(SWIFT_OPTIMIZATION_LEVEL_$(CONFIGURATION))",
'SWIFT_OPTIMIZATION_LEVEL_Debug' => '-Onone',
'SWIFT_OPTIMIZATION_LEVEL_Release' => '-Owholemodule'
}
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Internal header
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Header
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Implementation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// a Swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// b Swift