cocoapods-bazel 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -1
- data/README.md +23 -7
- data/bin/pod_install_bazel_build +1 -1
- data/lib/cocoapods/bazel/target.rb +55 -14
- data/lib/cocoapods/bazel/util.rb +12 -0
- data/lib/cocoapods/bazel/version.rb +1 -1
- data/lib/cocoapods/bazel/xcconfig_resolver.rb +4 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3286b561998f4b34e299da4b3d8214ff2fe4d81446c1fc7ec71752a2c992052d
|
4
|
+
data.tar.gz: 969cb842bba28405f2d0c9450eaccf6e7914925754ccb6e5b40e55ee890f28a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b004b7b58351034111a546e53f0884257511de7ba3506c7e711000ea860e0e16d95bfd85b5091fc369eed434c7d32e102e4216b65fdaca6c17bae54da226795
|
7
|
+
data.tar.gz: 90bc0315f257f0157c17c0f1da74edea822e8593a81f4ef786adef96c2059f78f5e2e91525a79a488029791d614838a83062f4eb083509e5e784108b44074eb0
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.1.4
|
2
|
+
|
3
|
+
* Fix issues with glob evaluation (#64, #65)
|
4
|
+
* Get specs running on M1 hardware (#73)
|
5
|
+
* Expose CocoaPods environment variables PODS_ROOT and PODS_TARGET_SRCROOT (#67)
|
6
|
+
* Mark app specs with public visibility for usage as test apps (#77)
|
7
|
+
* README updates for buildifier option and link fixing (#69, #78)
|
8
|
+
* Remove non-existent globs to support using --incompatible_disallow_empty_glob (#80, #79)
|
9
|
+
|
1
10
|
0.1.3
|
2
11
|
|
3
12
|
* Add ability to insert a docstring at top of generated build files (#58)
|
@@ -9,4 +18,4 @@
|
|
9
18
|
|
10
19
|
0.1.1
|
11
20
|
|
12
|
-
* Raise error and offer suggestion if pod path is outside of current workspace
|
21
|
+
* Raise error and offer suggestion if pod path is outside of current workspace
|
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|

|
3
3
|
|
4
4
|
|
5
|
-
Cocoapods::Bazel is a Cocoapods plugin that makes it easy to use [Bazel](https://bazel.build) instead of Xcode to build your iOS project. It automatically generates Bazel's `BUILD
|
5
|
+
Cocoapods::Bazel is a Cocoapods plugin that makes it easy to use [Bazel](https://bazel.build) instead of Xcode to build your iOS project. It automatically generates Bazel's `BUILD` files.
|
6
|
+
|
7
|
+
`cocoapods-bazel` can be setup to translate CocoaPod targets to provided Bazel rules. For example, you can use `cocaopods-bazel` to load framework targets using [rules_ios](https://github.com/bazel-ios/rules_ios). It's also flexible enough to allow users to use their own custom rules if needed.
|
6
8
|
|
7
9
|
> :warning: **This is alpha software.** We are developing this plugin in the open so you should only use it if you know what you are doing and are willing to help develop it.
|
8
10
|
|
@@ -16,19 +18,23 @@ gem 'cocoapods-bazel'
|
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
19
|
-
|
21
|
+
```sh
|
22
|
+
bundle install
|
23
|
+
```
|
20
24
|
|
21
25
|
Or install it yourself as:
|
22
26
|
|
23
|
-
|
27
|
+
```sh
|
28
|
+
gem install cocoapods-bazel
|
29
|
+
```
|
24
30
|
|
25
31
|
## Usage
|
26
32
|
|
27
|
-
This plugin will run extra steps after post_install to generate BUILD
|
33
|
+
This plugin will run extra steps after post_install to generate `BUILD` files for Bazel.
|
28
34
|
|
29
|
-
To enable the plugin,
|
35
|
+
To enable the plugin, you can add something like the following section to your `Podfile`:
|
30
36
|
|
31
|
-
```
|
37
|
+
```ruby
|
32
38
|
plugin 'cocoapods-bazel', {
|
33
39
|
rules: {
|
34
40
|
'apple_framework' => { load: '@build_bazel_rules_ios//rules:framework.bzl', rule: 'apple_framework' }.freeze,
|
@@ -50,9 +56,19 @@ There are some experimental features that are opt-in and can be enabled adding t
|
|
50
56
|
|
51
57
|
Note that tests for the experimental features are located under `spec/integration/experimental_features` and these should mostly replicate the tests under `spec/integration/monorepo` but with the features on. Also it's a place to create tests specific to a experimental feature that not necessarily will affect the default usage of `cocoapods-bazel`.
|
52
58
|
|
59
|
+
## BUILD file formatting
|
60
|
+
|
61
|
+
When the `BUILD.bazel` files are generated you may choose to have `cocoapods-bazel` format the files using [buildifier](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md). This formatting is enabled by default if a `buildifier` executable is found using `which buildifier`.
|
62
|
+
|
63
|
+
You can disable buildifier formatting with `buildifier: false` in the options of the `cocoapods-bazel` plugin.
|
64
|
+
|
65
|
+
Additionally, if you'd like to use a custom `buildifier` executable you can provide the `cocoapods-bazel` plugin options with an array of arguments to execute to format files.
|
66
|
+
|
67
|
+
For example, if you have `buildifier` runnable target you've defined in Bazel with the name `buildifier` you can run this specific version with: `buildifier: ['bazel', 'run', 'buildifier', '--']`. (Note the `--` allows bazel to forward arguments to the buildifier target).
|
68
|
+
|
53
69
|
## Contributing
|
54
70
|
|
55
|
-
Bug reports and pull requests are welcome on GitHub
|
71
|
+
Bug reports and pull requests are welcome on GitHub [here](https://github.com/bazel-ios/cocoapods-bazel).
|
56
72
|
|
57
73
|
## License
|
58
74
|
|
data/bin/pod_install_bazel_build
CHANGED
@@ -23,4 +23,4 @@ ARGV.replace %w[install]
|
|
23
23
|
|
24
24
|
load Gem.bin_path('cocoapods', 'pod')
|
25
25
|
|
26
|
-
exec 'bazelisk', '--ignore_all_rc_files', 'build', '--verbose_failures', '...'
|
26
|
+
exec 'bazelisk', '--ignore_all_rc_files', 'build', '--verbose_failures', '--cpu=ios_x86_64', '--experimental_worker_allow_json_protocol', '...'
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'set'
|
4
|
+
|
3
5
|
require_relative 'xcconfig_resolver'
|
4
6
|
|
5
7
|
module Pod
|
@@ -27,8 +29,8 @@ module Pod
|
|
27
29
|
|
28
30
|
include XCConfigResolver
|
29
31
|
|
30
|
-
attr_reader :installer, :pod_target, :file_accessors, :non_library_spec, :label, :package, :default_xcconfigs, :resolved_xconfig_by_config
|
31
|
-
private :installer, :pod_target, :file_accessors, :non_library_spec, :label, :package, :default_xcconfigs, :resolved_xconfig_by_config
|
32
|
+
attr_reader :installer, :pod_target, :file_accessors, :non_library_spec, :label, :package, :default_xcconfigs, :resolved_xconfig_by_config, :relative_sandbox_root
|
33
|
+
private :installer, :pod_target, :file_accessors, :non_library_spec, :label, :package, :default_xcconfigs, :resolved_xconfig_by_config, :relative_sandbox_root
|
32
34
|
|
33
35
|
def initialize(installer, pod_target, non_library_spec = nil, default_xcconfigs = {}, experimental_deps_debug_and_release = false)
|
34
36
|
@installer = installer
|
@@ -41,6 +43,7 @@ module Pod
|
|
41
43
|
@default_xcconfigs = default_xcconfigs
|
42
44
|
@resolved_xconfig_by_config = {}
|
43
45
|
@experimental_deps_debug_and_release = experimental_deps_debug_and_release
|
46
|
+
@relative_sandbox_root = installer.sandbox.root.relative_path_from(installer.config.installation_root).to_s
|
44
47
|
end
|
45
48
|
|
46
49
|
def bazel_label(relative_to: nil)
|
@@ -55,7 +58,6 @@ module Pod
|
|
55
58
|
end
|
56
59
|
|
57
60
|
def build_settings_label(config)
|
58
|
-
relative_sandbox_root = @installer.sandbox.root.relative_path_from(@installer.config.installation_root).to_s
|
59
61
|
cocoapods_bazel_path = File.join(relative_sandbox_root, 'cocoapods-bazel')
|
60
62
|
|
61
63
|
"//#{cocoapods_bazel_path}:#{config}"
|
@@ -342,7 +344,7 @@ module Pod
|
|
342
344
|
fa.spec_consumer.resource_bundles.each do |name, file_patterns|
|
343
345
|
bundle = bundles[name] ||= {}
|
344
346
|
patterns_by_exclude = bundle[fa.spec_consumer.exclude_files] ||= []
|
345
|
-
patterns_by_exclude.concat(file_patterns.flat_map { |g| expand_glob(g, expand_directories:
|
347
|
+
patterns_by_exclude.concat(file_patterns.flat_map { |g| expand_glob(g, expand_directories: true) })
|
346
348
|
end
|
347
349
|
end.tap do |bundles|
|
348
350
|
kwargs[:resource_bundles] = bundles.map do |bundle_name, patterns_by_excludes|
|
@@ -521,34 +523,53 @@ module Pod
|
|
521
523
|
def expand_glob(glob, extensions: nil, expand_directories: false)
|
522
524
|
if (m = glob.match(/\{([^\{\}]+)\}/))
|
523
525
|
m[1].split(',').flat_map do |alt|
|
524
|
-
expand_glob("#{m.pre_match}#{alt}#{m.post_match}")
|
526
|
+
expand_glob("#{m.pre_match}#{alt.strip}#{m.post_match}", extensions: extensions, expand_directories: expand_directories)
|
525
527
|
end.uniq
|
526
528
|
elsif (m = glob.match(/\[([^\[\]]+)\]/))
|
527
529
|
m[1].each_char.flat_map do |alt|
|
528
|
-
expand_glob("#{m.pre_match}#{alt}#{m.post_match}")
|
530
|
+
expand_glob("#{m.pre_match}#{alt.strip}#{m.post_match}", extensions: extensions, expand_directories: expand_directories)
|
529
531
|
end.uniq
|
530
532
|
elsif extensions && File.extname(glob).empty?
|
531
533
|
glob = glob.chomp('**/*') # If we reach here and the glob ends with **/*, we need to avoid duplicating it (we do not want to end up with **/*/**/*)
|
532
534
|
if File.basename(glob) == '*'
|
533
|
-
extensions.map
|
535
|
+
extensions.map do |ext|
|
536
|
+
combined = "#{glob}.#{ext}"
|
537
|
+
combined if Dir.glob(File.join(@package_dir, combined)).any?
|
538
|
+
end.compact
|
534
539
|
else
|
535
540
|
extensions.map do |ext|
|
536
|
-
File.join(glob, '**', "*.#{ext}")
|
537
|
-
|
541
|
+
combined = File.join(glob, '**', "*.#{ext}")
|
542
|
+
combined if Dir.glob(File.join(@package_dir, combined)).any?
|
543
|
+
end.compact
|
538
544
|
end
|
539
545
|
elsif expand_directories
|
540
546
|
if glob.end_with?('/**/*')
|
541
|
-
|
547
|
+
glob_with_valid_matches(glob)
|
542
548
|
elsif glob.end_with?('/*')
|
543
549
|
[glob.sub(%r{/\*$}, '/**/*')]
|
550
|
+
elsif should_skip_directory_expansion(glob)
|
551
|
+
glob_with_valid_matches(glob)
|
544
552
|
else
|
545
|
-
[glob
|
553
|
+
[glob.chomp('/') + '/**/*']
|
546
554
|
end
|
547
555
|
else
|
548
|
-
|
556
|
+
glob_with_valid_matches(glob)
|
549
557
|
end
|
550
558
|
end
|
551
559
|
|
560
|
+
# Returns `[glob]` if the given pattern has at least 1 match on disk, otherwise returns an empty array
|
561
|
+
def glob_with_valid_matches(glob)
|
562
|
+
Dir.glob(File.join(@package_dir, glob)).any? ? [glob] : []
|
563
|
+
end
|
564
|
+
|
565
|
+
# We should expand only folder globs, not expand file globs.
|
566
|
+
# E.g., xib files glob "*.xib" should not be expanded to "*.xib/**/*", otherise nothing will be matched
|
567
|
+
def should_skip_directory_expansion(glob)
|
568
|
+
extension = File.extname(glob)
|
569
|
+
expansion_extentions = Set['.xcassets', '.xcdatamodeld', '.lproj']
|
570
|
+
!expansion_extentions.include?(extension)
|
571
|
+
end
|
572
|
+
|
552
573
|
def rules_ios_platform_name(platform)
|
553
574
|
name = platform.string_name.downcase
|
554
575
|
return 'macos' if name == 'osx'
|
@@ -570,7 +591,7 @@ module Pod
|
|
570
591
|
def test_kwargs
|
571
592
|
{
|
572
593
|
bundle_id: resolved_value_by_build_setting('PRODUCT_BUNDLE_IDENTIFIER'),
|
573
|
-
env: pod_target.scheme_for_spec(non_library_spec).fetch(:environment_variables, {}),
|
594
|
+
env: resolve_env(pod_target.scheme_for_spec(non_library_spec).fetch(:environment_variables, {})),
|
574
595
|
infoplists_by_build_setting: pod_target_infoplists_by_build_setting,
|
575
596
|
infoplists: common_pod_target_infoplists(additional_plist: nil_if_empty(non_library_spec.consumer(pod_target.platform).info_plist)),
|
576
597
|
minimum_os_version: build_os_version || pod_target.deployment_target_for_non_library_spec(non_library_spec),
|
@@ -578,6 +599,25 @@ module Pod
|
|
578
599
|
}
|
579
600
|
end
|
580
601
|
|
602
|
+
# Resolves the given environment by resolving CocoaPod specific environment variables.
|
603
|
+
# Given an environment with unresolved env values, this function resolves them and returns the new env.
|
604
|
+
def resolve_env(env)
|
605
|
+
# These environment variables are resolved by CocoaPods, they tend to be used in tests and other
|
606
|
+
# scripts, as such we must resolve them before translating the targets environment.
|
607
|
+
resolved_cocoapods_env = {
|
608
|
+
'PODS_ROOT' => "//#{relative_sandbox_root}",
|
609
|
+
'PODS_TARGET_SRCROOT' => ':'
|
610
|
+
}.freeze
|
611
|
+
|
612
|
+
# Removes the : bazel prefix for current directory.
|
613
|
+
sub_prefix = ->(s) { s.sub(%r{\A:/}, '') }
|
614
|
+
|
615
|
+
env.each_with_object({}) do |(k, v), resolved_env|
|
616
|
+
resolved_val = Pod::Bazel::Util.resolve_value(v, resolved_values: resolved_cocoapods_env)
|
617
|
+
resolved_env[k] = sub_prefix[resolved_val]
|
618
|
+
end
|
619
|
+
end
|
620
|
+
|
581
621
|
def build_os_version
|
582
622
|
# If there's a SWIFT_DEPLOYMENT_TARGET version set, use that for the
|
583
623
|
# minimum version. It's not currently supported or desirable in rules_ios to have
|
@@ -621,7 +661,8 @@ module Pod
|
|
621
661
|
settings_bundle: [],
|
622
662
|
strings: [],
|
623
663
|
version: [],
|
624
|
-
watch_application: []
|
664
|
+
watch_application: [],
|
665
|
+
visibility: ['//visibility:public']
|
625
666
|
}
|
626
667
|
|
627
668
|
# If the user has set a different build os set that here
|
data/lib/cocoapods/bazel/util.rb
CHANGED
@@ -10,6 +10,18 @@ module Pod
|
|
10
10
|
sort_keys.sort_by { |k| [k.phase, k.split, k.value, k.original_index] }.map(&:value)
|
11
11
|
end
|
12
12
|
|
13
|
+
# Recursively resolves the variables in string with the given resolved values.
|
14
|
+
#
|
15
|
+
# Example: Given string = "${PODS_ROOT}/Foo", resolved_values = {"PODS_ROOT": "//Pods"}
|
16
|
+
# this function returns "//Pods/Foo".
|
17
|
+
def resolve_value(string, resolved_values:)
|
18
|
+
return string unless string =~ /\$(?:\{([_a-zA-Z0-0]+?)\}|\(([_a-zA-Z0-0]+?)\))/
|
19
|
+
|
20
|
+
match, key = Regexp.last_match.values_at(0, 1, 2).compact
|
21
|
+
sub = resolved_values.fetch(key, '')
|
22
|
+
resolve_value(string.gsub(match, sub), resolved_values: resolved_values)
|
23
|
+
end
|
24
|
+
|
13
25
|
class SortKey
|
14
26
|
attr_reader :phase, :split, :value, :original_index
|
15
27
|
|
@@ -8,8 +8,10 @@ module Pod
|
|
8
8
|
def resolved_build_setting_value(setting, settings:)
|
9
9
|
return unless (value = settings[setting])
|
10
10
|
|
11
|
+
# Removes the : bazel prefix for current directory.
|
11
12
|
sub_prefix = ->(s) { s.sub(%r{\A:/}, '') }
|
12
|
-
|
13
|
+
|
14
|
+
resolved = Pod::Bazel::Util.resolve_value(value, resolved_values: settings)
|
13
15
|
if Pod::Target::BuildSettings::PLURAL_SETTINGS.include?(setting)
|
14
16
|
resolved.shellsplit.reject(&:empty?).map(&sub_prefix)
|
15
17
|
else
|
@@ -17,20 +19,13 @@ module Pod
|
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
def resolve_string_with_build_settings(string, settings:)
|
21
|
-
return string unless string =~ /\$(?:\{([_a-zA-Z0-0]+?)\}|\(([_a-zA-Z0-0]+?)\))/
|
22
|
-
|
23
|
-
match, key = Regexp.last_match.values_at(0, 1, 2).compact
|
24
|
-
sub = settings.fetch(key, '')
|
25
|
-
resolve_string_with_build_settings(string.gsub(match, sub), settings: settings)
|
26
|
-
end
|
27
|
-
|
28
22
|
UNRESOLVED_SETTINGS = [
|
29
23
|
'CONFIGURATION', # not needed, only used to help resolve other settings that may use it in substitutions
|
30
24
|
'HEADER_SEARCH_PATHS', # serialized into copts, handled natively by Xcode instead of via xcspecs
|
31
25
|
'OTHER_CFLAGS', # serialized separately as objc_copts
|
32
26
|
'OTHER_SWIFT_FLAGS', # serialized separately as swift_copts
|
33
27
|
'OTHER_LDFLAGS', # serialized separately as linkopts
|
28
|
+
'PODS_ROOT', # not needed, used to help resolve the Pods root path relative to the current package
|
34
29
|
'PODS_TARGET_SRCROOT', # not needed, used to help resolve file references relative to the current package
|
35
30
|
'SDKROOT', # not needed since the SDKROOT gets propagated via the apple configuration transition
|
36
31
|
'SRCROOT', # not needed, used to help resolve file references relative to the current workspace
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-bazel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shawn Chen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-01
|
12
|
+
date: 2022-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.1.
|
96
|
+
rubygems_version: 3.1.6
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: A plugin for CocoaPods that generates Bazel build files for pods
|