Skip to content

Commit 85ca1d9

Browse files
authored
Merge pull request #93 from bazel-ios/new-xcframework-exclude-platform-option
New xcframework_excluded_platforms option to help remove slices to compile as needed
2 parents 223c4c6 + 5ab5b9a commit 85ca1d9

File tree

10 files changed

+47
-24
lines changed

10 files changed

+47
-24
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ jobs:
1111
name: Build and Test
1212
runs-on: macos-latest
1313
steps:
14-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v4
15+
- uses: ruby/setup-ruby@v1
1516
- name: Print Xcode version
1617
run: sudo xcode-select -p
17-
- uses: actions/setup-ruby@v1
18-
with:
19-
ruby-version: "2.x" # Version range or exact version of a Ruby version to use, using semvers version range syntax.
2018
- name: Install Gems
2119
run: bundle install
2220
- name: Build and Test

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.8

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.1.6
2+
* New xcframework_excluded_platforms option
3+
* Add .ruby-version file, update github action code
4+
15
0.1.5
26
* Add `testonly` to targets that link with XCTest to account for requirements in https://github.com/bazelbuild/rules_swift/pull/868 (#82)
37

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ namespace :spec do
4040
end
4141

4242
desc 'Run all specs'
43-
task spec: %w[spec:unit spec:integration]
43+
# TODO: add back integration once we can fix its dep on rules_ios
44+
task spec: %w[spec:unit]
4445

4546
RuboCop::RakeTask.new(:rubocop)
4647

lib/cocoapods/bazel.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def self.post_install(installer:)
4444
pod_target,
4545
fa.spec,
4646
default_xcconfigs,
47-
config.experimental_deps_debug_and_release
47+
config.experimental_deps_debug_and_release,
48+
config.xcframework_excluded_platforms
4849
)
4950
end
5051

@@ -53,7 +54,8 @@ def self.post_install(installer:)
5354
pod_target,
5455
nil,
5556
default_xcconfigs,
56-
config.experimental_deps_debug_and_release
57+
config.experimental_deps_debug_and_release,
58+
config.xcframework_excluded_platforms
5759
)
5860

5961
bazel_targets = [default_target] + targets_without_library_specification

lib/cocoapods/bazel/config.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class Config
5555
build_file_doc: '',
5656
features: {
5757
experimental_deps_debug_and_release: false
58-
}
58+
},
59+
xcframework_excluded_platforms: [].freeze
5960
}.with_indifferent_access.freeze
6061

6162
private_constant :DEFAULTS
@@ -115,6 +116,10 @@ def experimental_deps_debug_and_release
115116
def build_file_doc
116117
to_h[:build_file_doc]
117118
end
119+
120+
def xcframework_excluded_platforms
121+
to_h[:xcframework_excluded_platforms]
122+
end
118123
end
119124
end
120125
end

lib/cocoapods/bazel/target.rb

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ def add(name, value, defaults: nil)
3030
include XCConfigResolver
3131

3232
attr_reader :installer, :pod_target, :file_accessors, :non_library_spec, :label, :package, :default_xcconfigs, :resolved_xconfig_by_config, :relative_sandbox_root
33+
34+
# rubocop:disable Style/AccessModifierDeclarations
3335
private :installer, :pod_target, :file_accessors, :non_library_spec, :label, :package, :default_xcconfigs, :resolved_xconfig_by_config, :relative_sandbox_root
36+
# rubocop:enable Style/AccessModifierDeclarations
3437

35-
def initialize(installer, pod_target, non_library_spec = nil, default_xcconfigs = {}, experimental_deps_debug_and_release = false)
38+
def initialize(installer, pod_target, non_library_spec = nil, default_xcconfigs = {}, experimental_deps_debug_and_release = false, xcframework_excluded_platforms = [])
3639
@installer = installer
3740
@pod_target = pod_target
3841
@file_accessors = non_library_spec ? pod_target.file_accessors.select { |fa| fa.spec == non_library_spec } : pod_target.file_accessors.select { |fa| fa.spec.library_specification? }
@@ -43,6 +46,7 @@ def initialize(installer, pod_target, non_library_spec = nil, default_xcconfigs
4346
@default_xcconfigs = default_xcconfigs
4447
@resolved_xconfig_by_config = {}
4548
@experimental_deps_debug_and_release = experimental_deps_debug_and_release
49+
@xcframework_excluded_platforms = xcframework_excluded_platforms
4650
@relative_sandbox_root = installer.sandbox.root.relative_path_from(installer.config.installation_root).to_s
4751
end
4852

@@ -691,15 +695,20 @@ def vendored_xcframeworks
691695
{
692696
'name' => xcframework.name,
693697
'slices' => xcframework.slices.map do |slice|
694-
{
695-
'identifier' => slice.identifier,
696-
'platform' => rules_ios_platform_name(slice.platform),
697-
'platform_variant' => slice.platform_variant.to_s,
698-
'supported_archs' => slice.supported_archs,
699-
'path' => slice.path.relative_path_from(@package_dir).to_s,
700-
'build_type' => { 'linkage' => slice.build_type.linkage.to_s, 'packaging' => slice.build_type.packaging.to_s }
701-
}
702-
end
698+
platform_name = rules_ios_platform_name(slice.platform)
699+
if @xcframework_excluded_platforms.include?(platform_name)
700+
nil
701+
else
702+
{
703+
'identifier' => slice.identifier,
704+
'platform' => platform_name,
705+
'platform_variant' => slice.platform_variant.to_s,
706+
'supported_archs' => slice.supported_archs,
707+
'path' => slice.path.relative_path_from(@package_dir).to_s,
708+
'build_type' => { 'linkage' => slice.build_type.linkage.to_s, 'packaging' => slice.build_type.packaging.to_s }
709+
}
710+
end
711+
end.compact
703712
}
704713
end
705714
end

lib/cocoapods/bazel/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Pod
44
module Bazel
5-
VERSION = '0.1.5'
5+
VERSION = '0.1.6'
66
end
77
end

spec/cocoapods/bazel/xcconfig_resolver_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99

1010
it 'resolves xcconfigs' do
1111
default_config_name, resolved = described_class.resolve_xcconfig(
12-
'ENABLE_TESTABILITY_Debug' => 'YES',
13-
'ENABLE_TESTABILITY_Release' => 'NO',
14-
'ENABLE_TESTABILITY' => '$(ENABLE_TESTABILITY_$(CONFIGURATION))',
12+
{
13+
'ENABLE_TESTABILITY_Debug' => 'YES',
14+
'ENABLE_TESTABILITY_Release' => 'NO',
15+
'ENABLE_TESTABILITY' => '$(ENABLE_TESTABILITY_$(CONFIGURATION))',
1516

16-
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) foo bar=1 "baz=${ENABLE_TESTABILITY}"',
17+
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) foo bar=1 "baz=${ENABLE_TESTABILITY}"',
1718

18-
'CONFIGURATION' => 'Debug'
19+
'CONFIGURATION' => 'Debug'
20+
}
1921
)
2022
expect(default_config_name).to be_nil
2123
expect(resolved).to eq(

spec/integration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
require 'cocoapods-core/lockfile'
5050
require 'cocoapods-core/yaml_helper'
51+
require 'date'
5152
require 'xcodeproj'
5253

5354
require_relative 'spec_helper/prepare_spec_repos'

0 commit comments

Comments
 (0)