Class: Pod::Bazel::Config
- Inherits:
-
Object
- Object
- Pod::Bazel::Config
- Defined in:
- lib/cocoapods/bazel/config.rb
Constant Summary collapse
- EXPERIMENTAL_FEATURES =
[ # When enabled cocoapods-bazel will add one additional config_setting for the 'deps' attribute only # containing both 'debug' and 'release' dependencies. # # In other works when this flag is active cocoapods-bazel will continue to create these: # # - //Pods/cocoapods-bazel:debug # - //Pods/cocoapods-bazel:release # # and generate the same 'select()' statements for all attributes but 'deps'. # # Additionaly these new config_setting values will be created: # # - //Pods/cocoapods-bazel:deps_debug # - //Pods/cocoapods-bazel:deps_release # - //Pods/cocoapods-bazel:deps_debug_and_release # # and used only in the 'deps' attribute. # # This effectively decouple 'deps' from the other attributes from a configuration perspective and allow one to build # with different combinations of these settings. One example of a use case is generating release builds with 'debug' dependencies # available so debug-only features can be used to inspect/validate behaviour in a release build (some call these "dogfood" builds). # # From a conceptual perspective this will generate BUILD files with "all" states and allow one to use bazel features to 'select()' the desired ones. # This intentionally breaks the contract with the .podspec specification since cocoapods does not have the concept of 'select()'-ing configurations. # # Still in the context of the use case above ('dogfood' builds), without this experimental feature one would have to # change the configurations in the .podspec file from: # `s.dependency 'Foo', configurations: %w[Debug]` # to: # `s.dependency 'Foo', configurations: %w[Debug Release]` # and re-run cocoapods-bazel to generate the desired type of build and then re-run it again to go back to the previous state. # # This might be ok for some teams but it prevents others that are interested in using cocoapods-bazel to migrate to Bazel and eventually stop # depending on cocoapods. If the generated BUILD files don't contain "all" states and a 'pod install' is always required it's not trivial how to eventually treat the # BUILD files as source of truth. :experimental_deps_debug_and_release ].freeze
Instance Attribute Summary collapse
-
#to_h ⇒ Object
readonly
Returns the value of attribute to_h.
Class Method Summary collapse
- .enabled_in_podfile?(podfile) ⇒ Boolean
- .from_podfile(podfile) ⇒ Object
- .from_podfile_options(options) ⇒ Object
Instance Method Summary collapse
- #build_file_doc ⇒ Object
- #buildifier ⇒ Object
- #default_xcconfigs ⇒ Object
- #experimental_deps_debug_and_release ⇒ Object
-
#initialize(to_h) ⇒ Config
constructor
A new instance of Config.
- #load_for(macro:) ⇒ Object
Constructor Details
#initialize(to_h) ⇒ Config
Returns a new instance of Config.
95 96 97 |
# File 'lib/cocoapods/bazel/config.rb', line 95 def initialize(to_h) @to_h = to_h end |
Instance Attribute Details
#to_h ⇒ Object (readonly)
Returns the value of attribute to_h.
63 64 65 |
# File 'lib/cocoapods/bazel/config.rb', line 63 def to_h @to_h end |
Class Method Details
.enabled_in_podfile?(podfile) ⇒ Boolean
65 66 67 |
# File 'lib/cocoapods/bazel/config.rb', line 65 def self.enabled_in_podfile?(podfile) podfile.plugins.key?(PLUGIN_KEY) end |
.from_podfile(podfile) ⇒ Object
69 70 71 72 73 |
# File 'lib/cocoapods/bazel/config.rb', line 69 def self.from_podfile(podfile) return unless enabled_in_podfile?(podfile) (podfile.plugins[PLUGIN_KEY]) end |
.from_podfile_options(options) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cocoapods/bazel/config.rb', line 75 def self.() config = new(DEFAULTS.merge() do |_key, old_val, new_val| case old_val when Hash old_val.merge(new_val) # intentionally only 1 level deep of merging else new_val end end) # Validating if only supported/valid experimental features # exist in the Podfile (only applies if :features is not empty) features = config.to_h[:features] || {} features.keys.map(&:to_sym).each do |key| raise "Unrecognized experimental feature '#{key}' in Podfile. Available options are: #{EXPERIMENTAL_FEATURES}" unless EXPERIMENTAL_FEATURES.include?(key) end config end |
Instance Method Details
#build_file_doc ⇒ Object
115 116 117 |
# File 'lib/cocoapods/bazel/config.rb', line 115 def build_file_doc to_h[:build_file_doc] end |
#buildifier ⇒ Object
99 100 101 |
# File 'lib/cocoapods/bazel/config.rb', line 99 def buildifier to_h[:buildifier] end |
#default_xcconfigs ⇒ Object
107 108 109 |
# File 'lib/cocoapods/bazel/config.rb', line 107 def default_xcconfigs to_h[:default_xcconfigs] end |
#experimental_deps_debug_and_release ⇒ Object
111 112 113 |
# File 'lib/cocoapods/bazel/config.rb', line 111 def experimental_deps_debug_and_release to_h[:features][:experimental_deps_debug_and_release] end |
#load_for(macro:) ⇒ Object
103 104 105 |
# File 'lib/cocoapods/bazel/config.rb', line 103 def load_for(macro:) to_h.dig('rules', macro) || raise("no rule configured for #{macro}") end |