Class: Pod::SPM::MacroPrebuilder
- Inherits:
-
Object
- Object
- Pod::SPM::MacroPrebuilder
- Includes:
- Config::Mixin
- 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::Mixin
Constructor Details
#initialize(options = {}) ⇒ MacroPrebuilder
Returns a new instance of MacroPrebuilder.
10 11 12 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 10 def initialize( = {}) @name = [:name] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 8 def name @name end |
Instance Method Details
#generate_metadata ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 35 def raise "Package.swift not exist in #{macro_downloaded_dir}" \ unless (macro_downloaded_dir / "Package.swift").exist? cmd = "cd #{macro_downloaded_dir} " \ "&& swift package dump-package " \ "> #{.relative_path_from(macro_downloaded_dir)}" `#{cmd}` @metadata = Metadata.from_file() end |
#macro_dir ⇒ Object
23 24 25 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 23 def macro_dir @macro_dir ||= spm_config.macro_root_dir / name end |
#macro_downloaded_dir ⇒ Object
19 20 21 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 19 def macro_downloaded_dir spm_config.macro_downloaded_root_dir / name end |
#macro_prebuilt_dir ⇒ Object
27 28 29 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 27 def macro_prebuilt_dir macro_dir / ".prebuilt" end |
#metadata_path ⇒ Object
31 32 33 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 31 def macro_dir / "metadata.json" end |
#prebuild_macro_impl ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 47 def prebuild_macro_impl return if spm_config.dont_prebuild_macros? config = spm_config.macro_config impl_module_name = @metadata.macro_impl_name return if spm_config.dont_prebuild_macros_if_exist? && (macro_prebuilt_dir / config / impl_module_name).exist? UI.puts "Building macro implementation: #{impl_module_name} (#{config})...".green `cd #{macro_downloaded_dir} && swift build -c #{config}` (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
14 15 16 17 |
# File 'lib/cocoapods-spm/macro/prebuilder.rb', line 14 def run prebuild_macro_impl end |