Class: Pod::SPM::MacroPrebuilder
- Inherits:
-
Object
- Object
- Pod::SPM::MacroPrebuilder
- Includes:
- Executables, MacroConfigMixin
- Defined in:
- lib/cocoapods-spm/macro/prebuilder.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MacroPrebuilder
constructor
A new instance of MacroPrebuilder.
- #prebuild_macro_impl ⇒ Object
- #run ⇒ Object
Methods included from MacroConfigMixin
#macro_dir, #macro_downloaded_dir, #macro_prebuilt_dir, #macro_scratch_dir, #metadata, #metadata_path
Methods included from PathMixn
Methods included from Config::SPMConfigMixin
#local_macro_pod?, #local_macro_pod_dir, #macro_pods, #spm_config
Methods included from Config::PodConfigMixin
Methods included from Config::ProjectConfigMixin
Constructor Details
#initialize(options = {}) ⇒ MacroPrebuilder
Returns a new instance of MacroPrebuilder.
12 13 14 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 12 def initialize( = {}) @name = [:name] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 10 def name @name end |
Instance Method Details
#prebuild_macro_impl ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 20 def prebuild_macro_impl return if spm_config.dont_prebuild_macros? config = spm_config.macro_config impl_module_name = .macro_impl_name prebuilt_binary = macro_prebuilt_dir / "#{impl_module_name}-#{config}" if spm_config.dont_prebuild_macros_if_exist? && prebuilt_binary.exist? return UI. "Macro binary exists at #{prebuilt_binary} -> Skip prebuilding macro" end UI.section "Building macro implementation: #{impl_module_name} (#{config})...".green do swift! ["--version"] swift! [ "build", "-c", config, "--product", impl_module_name, "--package-path", macro_downloaded_dir, "--scratch-path", macro_scratch_dir, ] # Workaround: When building a macro, the debug.yaml under the scratch dir contains some corrupted info, # causing the following failure when building the next macro: # No target named 'OrcamImpl-debug.exe' in build description # Idk what this file is for, but deleting it helps macro_scratch_dir.glob("*.yaml").each { |p| p.delete if p.exist? } end prebuilt_binary.parent.mkpath macro_downloaded_build_config_dir = macro_scratch_dir / config macro_build_binary_file_path = macro_downloaded_build_config_dir / impl_module_name unless macro_build_binary_file_path.exist? macro_build_binary_file_path = macro_downloaded_build_config_dir / "#{impl_module_name}-tool" end FileUtils.copy_entry( macro_build_binary_file_path, prebuilt_binary ) end |
#run ⇒ Object
16 17 18 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 16 def run prebuild_macro_impl end |