Class: Pod::SPM::MacroPrebuilder
- Inherits:
-
Object
- Object
- Pod::SPM::MacroPrebuilder
- Includes:
- Config::Mixin, Executables
- 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
- #generate_metadata ⇒ Object
-
#initialize(options = {}) ⇒ MacroPrebuilder
constructor
A new instance of MacroPrebuilder.
- #macro_dir ⇒ Object
- #macro_downloaded_dir ⇒ Object
- #macro_prebuilt_dir ⇒ Object
- #metadata_path ⇒ Object
- #prebuild_macro_impl ⇒ Object
- #run ⇒ Object
Methods included from Config::SPMConfigMixin
Methods included from Config::PodConfigMixin
Methods included from Config::ProjectConfigMixin
Constructor Details
#initialize(options = {}) ⇒ MacroPrebuilder
Returns a new instance of MacroPrebuilder.
11 12 13 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 11 def initialize( = {}) @name = [:name] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 9 def name @name end |
Instance Method Details
#generate_metadata ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 36 def raise "Package.swift not exist in #{macro_downloaded_dir}" \ unless (macro_downloaded_dir / "Package.swift").exist? raw = Dir.chdir(macro_downloaded_dir) { `swift package dump-package` } .write(raw) = Metadata.from_s(raw) end |
#macro_dir ⇒ Object
24 25 26 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 24 def macro_dir @macro_dir ||= spm_config.macro_root_dir / name end |
#macro_downloaded_dir ⇒ Object
20 21 22 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 20 def macro_downloaded_dir spm_config.macro_downloaded_root_dir / name end |
#macro_prebuilt_dir ⇒ Object
28 29 30 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 28 def macro_prebuilt_dir macro_dir / ".prebuilt" end |
#metadata_path ⇒ Object
32 33 34 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 32 def macro_dir / "metadata.json" end |
#prebuild_macro_impl ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 45 def prebuild_macro_impl return if spm_config.dont_prebuild_macros? config = spm_config.macro_config impl_module_name = .macro_impl_name return if spm_config.dont_prebuild_macros_if_exist? && (macro_prebuilt_dir / config / impl_module_name).exist? UI.section "Building macro implementation: #{impl_module_name} (#{config})...".green do Dir.chdir(macro_downloaded_dir) do swift! ["build", "-c", config, "--product", impl_module_name] end end (macro_prebuilt_dir / config).mkpath FileUtils.copy_entry( macro_downloaded_dir / ".build" / config / impl_module_name, macro_prebuilt_dir / config / impl_module_name ) end |
#run ⇒ Object
15 16 17 18 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 15 def run prebuild_macro_impl end |