cocoapods-amimono 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/cocoapods-amimono/gem_version.rb +1 -1
- data/lib/cocoapods-amimono/integrator.rb +36 -34
- data/lib/cocoapods-amimono/patcher.rb +42 -8
- data/lib/cocoapods_plugin.rb +12 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55367906ce81e287ef9418f45edf5b4d88d5ce00
|
4
|
+
data.tar.gz: 1e56ba267843312e80b12c4d8a7b6d6c9f76faa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58247c18d5c9274e759bc45582b60ba9d41a4b2b7f36e282079cc63d951dcda9a3fca4f1b26d40b7365ce0b3fae631eefa9938ea4683a751d1323ca73763e1e7
|
7
|
+
data.tar.gz: 72d9dd1ec10d12a11c7ba68fca3c953f67cbba5c06271f895b57ba0f01af8b3434656ebdbd4a246f4b530f0d99175a72acf019d8cc68e70193210a27fe51dbd8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -51,7 +51,7 @@ Add the following to your `post_install` hook:
|
|
51
51
|
```ruby
|
52
52
|
post_install do |installer|
|
53
53
|
require 'cocoapods-amimono/patcher'
|
54
|
-
Amimono::Patcher.
|
54
|
+
Amimono::Patcher.patch!(installer: installer)
|
55
55
|
...
|
56
56
|
```
|
57
57
|
|
@@ -2,25 +2,20 @@ module Amimono
|
|
2
2
|
class Integrator
|
3
3
|
|
4
4
|
FILELIST_SCRIPT = <<-SCRIPT.strip_heredoc
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
File.write("\#{configuration}\#{platform}-\#{architecture}.objects.filelist", filelist)
|
22
|
-
end
|
23
|
-
end
|
5
|
+
IFS=" " read -r -a SPLIT <<< "$ARCHS"
|
6
|
+
for ARCH in "${SPLIT[@]}"; do
|
7
|
+
cd "$OBJROOT/Pods.build"
|
8
|
+
filelist=""
|
9
|
+
for dependency in "${DEPENDENCIES[@]}"; do
|
10
|
+
path="${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}/${dependency}.build/Objects-normal/${ARCH}/*.o"
|
11
|
+
for obj_file in $path; do
|
12
|
+
filelist+="${OBJROOT}/Pods.build/${obj_file}"
|
13
|
+
filelist+=$'\\n'
|
14
|
+
done
|
15
|
+
done
|
16
|
+
filelist=${filelist\%$'\\n'}
|
17
|
+
echo "$filelist" > "${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}-${ARCH}.objects.filelist"
|
18
|
+
done
|
24
19
|
SCRIPT
|
25
20
|
|
26
21
|
AMIMONO_FILELIST_BUILD_PHASE = '[Amimono] Create filelist per architecture'
|
@@ -43,36 +38,43 @@ module Amimono
|
|
43
38
|
end
|
44
39
|
end
|
45
40
|
|
46
|
-
def update_build_phases(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
def update_build_phases(aggregated_targets:)
|
42
|
+
# All user projects should be the same I hope
|
43
|
+
user_project = aggregated_targets.first.user_project
|
44
|
+
aggregated_targets.each do |aggregated_target|
|
45
|
+
# This pick is probably wrong, but works for most of the simple cases
|
46
|
+
user_target = aggregated_target.user_targets.first
|
47
|
+
# Remove the `Embed Pods Frameworks` build phase
|
48
|
+
remove_embed_pods_frameworks(user_target: user_target)
|
49
|
+
# Create or update [Amimono] build phase
|
50
|
+
create_or_update_amimono_phase(user_target: user_target, phase_name: AMIMONO_FILELIST_BUILD_PHASE, script: generate_filelist_script(aggregated_target: aggregated_target))
|
51
|
+
puts "[Amimono] Build phases updated for target #{aggregated_target.cocoapods_target_label}"
|
52
|
+
end
|
53
53
|
user_project.save
|
54
54
|
end
|
55
55
|
|
56
56
|
private
|
57
57
|
|
58
|
-
def remove_embed_pods_frameworks(
|
59
|
-
embed_pods_frameworks_build_phase =
|
58
|
+
def remove_embed_pods_frameworks(user_target:)
|
59
|
+
embed_pods_frameworks_build_phase = user_target.build_phases.find { |build_phase| build_phase.display_name.include? 'Embed Pods Frameworks' }
|
60
60
|
return if embed_pods_frameworks_build_phase.nil?
|
61
61
|
embed_pods_frameworks_build_phase.remove_from_project
|
62
62
|
end
|
63
63
|
|
64
|
-
def create_or_update_amimono_phase(
|
65
|
-
amimono_filelist_build_phase =
|
66
|
-
amimono_filelist_build_phase.shell_path = '/
|
64
|
+
def create_or_update_amimono_phase(user_target:, phase_name:, script:)
|
65
|
+
amimono_filelist_build_phase = user_target.build_phases.find { |build_phase| build_phase.display_name.include? phase_name } || user_target.new_shell_script_build_phase(phase_name)
|
66
|
+
amimono_filelist_build_phase.shell_path = '/bin/bash'
|
67
67
|
amimono_filelist_build_phase.shell_script = script
|
68
|
-
|
69
|
-
|
68
|
+
user_target.build_phases.insert(1, amimono_filelist_build_phase)
|
69
|
+
user_target.build_phases.uniq!
|
70
70
|
end
|
71
71
|
|
72
72
|
def generate_filelist_script(aggregated_target:)
|
73
73
|
dependencies = aggregated_target.specs.map(&:name).reject { |dependency| dependency.include? '/'}
|
74
74
|
puts "[Amimono] #{dependencies.count} dependencies found"
|
75
|
-
|
75
|
+
bash_array = dependencies.map { |dependency| "'#{dependency}'" }.join ' '
|
76
|
+
declare_statement = "declare -a DEPENDENCIES=(%s);\n" % bash_array
|
77
|
+
declare_statement + FILELIST_SCRIPT
|
76
78
|
end
|
77
79
|
end
|
78
80
|
end
|
@@ -2,18 +2,52 @@ module Amimono
|
|
2
2
|
# This class will patch your project's copy resources script to match the one that would be
|
3
3
|
# generated as if the `use_frameworks!` flag wouldn't be there
|
4
4
|
class Patcher
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
resources = resources_by_config(aggregated_target: aggregated_target, project: project)
|
10
|
-
generator = Pod::Generator::CopyResourcesScript.new(resources, aggregated_target.platform)
|
11
|
-
generator.save_as(path)
|
12
|
-
puts "[Amimono] Copy resources script patched"
|
5
|
+
|
6
|
+
def self.patch!(installer:)
|
7
|
+
patch_copy_resources_script(installer: installer)
|
8
|
+
patch_vendored_build_settings(installer: installer)
|
13
9
|
end
|
14
10
|
|
15
11
|
private
|
16
12
|
|
13
|
+
def self.patch_vendored_build_settings(installer:)
|
14
|
+
aggregated_targets = installer.aggregate_targets.reject { |target| target.label.include? 'Test' }
|
15
|
+
aggregated_targets.each do |aggregated_target|
|
16
|
+
path = installer.sandbox.target_support_files_dir aggregated_target.label
|
17
|
+
Dir.entries(path).select { |entry| entry.end_with? 'xcconfig' }.each do |entry|
|
18
|
+
full_path = path + entry
|
19
|
+
xcconfig = Xcodeproj::Config.new full_path
|
20
|
+
# Another option would be to inspect installer.analysis_result.result.target_inspections
|
21
|
+
# But this also works and it's simpler
|
22
|
+
configuration = entry.split('.')[-2]
|
23
|
+
pod_targets = aggregated_target.pod_targets_for_build_configuration configuration
|
24
|
+
generate_vendored_build_settings(pod_targets: pod_targets, xcconfig: xcconfig)
|
25
|
+
xcconfig.save_as full_path
|
26
|
+
end
|
27
|
+
puts "[Amimono] Vendored build settings patched for target #{aggregated_target.label}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.patch_copy_resources_script(installer:)
|
32
|
+
project = installer.sandbox.project
|
33
|
+
aggregated_targets = installer.aggregate_targets.reject { |target| target.label.include? 'Test' }
|
34
|
+
aggregated_targets.each do |aggregated_target|
|
35
|
+
path = aggregated_target.copy_resources_script_path
|
36
|
+
resources = resources_by_config(aggregated_target: aggregated_target, project: project)
|
37
|
+
generator = Pod::Generator::CopyResourcesScript.new(resources, aggregated_target.platform)
|
38
|
+
generator.save_as(path)
|
39
|
+
puts "[Amimono] Copy resources script patched for target #{aggregated_target.label}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Copied over from https://github.com/CocoaPods/CocoaPods/blob/e5afc825eeafa60933a1299f52eb764c267cc9b2/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb#L152-L158
|
44
|
+
# with some modifications to this particular use case
|
45
|
+
def self.generate_vendored_build_settings(pod_targets:, xcconfig:)
|
46
|
+
pod_targets.each do |pod_target|
|
47
|
+
Pod::Generator::XCConfig::XCConfigHelper.add_settings_for_file_accessors_of_target(pod_target, xcconfig)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
17
51
|
# Copied over from https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb#L115-L131
|
18
52
|
# with some modifications to this particular use case
|
19
53
|
def self.resources_by_config(aggregated_target:, project:)
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -2,20 +2,19 @@ require 'cocoapods-amimono/command'
|
|
2
2
|
require 'cocoapods-amimono/integrator'
|
3
3
|
|
4
4
|
Pod::HooksManager.register('cocoapods-amimono', :post_install) do |installer_context|
|
5
|
-
#
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
target.cocoapods_target_label
|
5
|
+
# We exclude all targets that contain `Test`, which might not work for some test targets
|
6
|
+
# that doesn't include that word
|
7
|
+
pods_targets = installer_context.umbrella_targets.reject { |target| target.cocoapods_target_label.include? 'Test' }
|
8
|
+
target_info = Hash.new
|
9
|
+
pods_targets.each do |pods_target|
|
10
|
+
puts "[Amimono] Pods target found: #{pods_target.cocoapods_target_label}"
|
11
|
+
target_info[pods_target] = installer_context.sandbox.target_support_files_dir pods_target.cocoapods_target_label
|
11
12
|
end
|
12
|
-
puts "[Amimono] Pods target found: #{pods_target.cocoapods_target_label}"
|
13
|
-
|
14
|
-
path = installer_context.sandbox.target_support_files_dir pods_target.cocoapods_target_label
|
15
13
|
|
16
14
|
integrator = Amimono::Integrator.new
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
target_info.each do |pods_target, path|
|
16
|
+
integrator.update_xcconfigs(aggregated_target_sandbox_path: path)
|
17
|
+
puts "[Amimono] xcconfigs updated with filelist for target #{pods_target.cocoapods_target_label}"
|
18
|
+
end
|
19
|
+
integrator.update_build_phases(aggregated_targets: target_info.keys)
|
21
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-amimono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renzo Crisostomo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|