pod-builder-y 2.3.1

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.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE.txt +13 -0
  5. data/README.md +385 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +8 -0
  9. data/exe/pod_builder_y +406 -0
  10. data/lib/core_ext/string.rb +5 -0
  11. data/lib/pod_builder/analyze.rb +59 -0
  12. data/lib/pod_builder/analyzer.rb +16 -0
  13. data/lib/pod_builder/command.rb +14 -0
  14. data/lib/pod_builder/command/build.rb +228 -0
  15. data/lib/pod_builder/command/build_all.rb +15 -0
  16. data/lib/pod_builder/command/clean.rb +75 -0
  17. data/lib/pod_builder/command/deintegrate.rb +101 -0
  18. data/lib/pod_builder/command/generate_lldbinit.rb +128 -0
  19. data/lib/pod_builder/command/generate_podspec.rb +22 -0
  20. data/lib/pod_builder/command/info.rb +18 -0
  21. data/lib/pod_builder/command/init.rb +148 -0
  22. data/lib/pod_builder/command/install_sources.rb +79 -0
  23. data/lib/pod_builder/command/none.rb +16 -0
  24. data/lib/pod_builder/command/restore_all.rb +33 -0
  25. data/lib/pod_builder/command/switch.rb +224 -0
  26. data/lib/pod_builder/command/sync_podfile.rb +34 -0
  27. data/lib/pod_builder/command/update.rb +43 -0
  28. data/lib/pod_builder/configuration.rb +300 -0
  29. data/lib/pod_builder/core.rb +222 -0
  30. data/lib/pod_builder/info.rb +90 -0
  31. data/lib/pod_builder/install.rb +505 -0
  32. data/lib/pod_builder/licenses.rb +73 -0
  33. data/lib/pod_builder/podfile.rb +700 -0
  34. data/lib/pod_builder/podfile/pre_actions_swizzles.rb +84 -0
  35. data/lib/pod_builder/podfile_cp.rb +99 -0
  36. data/lib/pod_builder/podfile_item.rb +530 -0
  37. data/lib/pod_builder/podspec.rb +269 -0
  38. data/lib/pod_builder/rome/post_install.rb +446 -0
  39. data/lib/pod_builder/rome/pre_install.rb +6 -0
  40. data/lib/pod_builder/templates/build_podfile.template +70 -0
  41. data/lib/pod_builder/templates/build_podspec.template +19 -0
  42. data/lib/pod_builder/version.rb +4 -0
  43. data/pod-builder.gemspec +37 -0
  44. metadata +240 -0
@@ -0,0 +1,128 @@
1
+ require 'pod_builder/core'
2
+ require 'digest'
3
+
4
+ module PodBuilder
5
+ module Command
6
+ class UpdateLldbInit
7
+ def self.call
8
+ Configuration.check_inited
9
+ if Configuration.build_using_repo_paths
10
+ raise "\n\nlldb shenanigans not supported when 'build_using_repo_paths' is enabled".red
11
+ end
12
+
13
+ arguments = ARGV.dup
14
+
15
+ if arguments.count > 0
16
+ source_path = arguments[0]
17
+ if !is_absolute_path(source_path)
18
+ source_path = PodBuilder::basepath(source_path)
19
+ end
20
+ source_path = File.expand_path(source_path)
21
+
22
+ raise "\n\nSpecified path does not exists" unless File.directory?(source_path)
23
+ end
24
+
25
+ base_path = PodBuilder::basepath
26
+ app_podfile_content = File.read(PodBuilder::project_path("Podfile"))
27
+
28
+ lldbinit_path = File.expand_path(PodBuilder::basepath(Configuration.lldbinit_name))
29
+
30
+ puts "Extracting debug information".yellow
31
+
32
+ FileUtils.mkdir_p(Configuration.build_path)
33
+ compilation_base_path = Pathname.new(Configuration.build_path).realpath.to_s
34
+
35
+ pods_mappings = Hash.new
36
+
37
+ app_podfile_content.each_line do |line|
38
+ unless (name_match = line.match(/^\s*pod ['|"](.*?)['|"](.*)/)) && name_match.size == 3
39
+ next
40
+ end
41
+
42
+ pod_name = name_match[1].split("/").first
43
+
44
+ source = nil
45
+ destination = PodBuilder::basepath # puts some existing path, see lldbinit_content.reverse! comment
46
+ if (path_match = line.match(/:path\s?=>\s?['|"](.*?)['|"]/)) && path_match.size == 2
47
+ pod_path = path_match[1]
48
+ if !is_absolute_path(pod_path)
49
+ pod_path = File.expand_path("#{base_path}/#{pod_path}")
50
+ end
51
+
52
+ is_prebuilt = pod_path.start_with?(PodBuilder::prebuiltpath(pod_name))
53
+ if is_prebuilt
54
+ source = "#{compilation_base_path}/Pods/#{pod_name}"
55
+ destination = PodBuilder::prebuiltpath(pod_name)
56
+
57
+ info_path = "#{pod_path}/#{Configuration.prebuilt_info_filename}"
58
+ next unless File.exists?(info_path)
59
+ data = JSON.parse(File.read(info_path))
60
+
61
+ build_source_path_matches = data["entry"].match(/:path => '(.*?)'/)
62
+ if build_source_path_matches&.size == 2
63
+ build_source_path = build_source_path_matches[1]
64
+ if !is_absolute_path(build_source_path)
65
+ build_source_path = PodBuilder::basepath(build_source_path)
66
+ end
67
+ destination = File.expand_path(build_source_path)
68
+ end
69
+ elsif File.directory?(pod_path)
70
+ source = pod_path
71
+ destination = pod_path
72
+ end
73
+ else
74
+ pod_path = PodBuilder::project_path("Pods/#{pod_name}")
75
+ if File.directory?(pod_path)
76
+ source = pod_path
77
+ destination = pod_path
78
+ end
79
+ end
80
+
81
+ if !source.nil? && File.directory?(destination)
82
+ pods_mappings[source] = destination
83
+ end
84
+ end
85
+
86
+ prebuilt_source_map_entries = []
87
+ other_source_map_entries = []
88
+ pods_mappings.each do |source, destination|
89
+ if source.include?(compilation_base_path)
90
+ prebuilt_source_map_entries.push("settings append target.source-map '#{source}/' '#{destination}/'")
91
+ else
92
+ other_source_map_entries.push("settings append target.source-map '#{source}/' '#{destination}/'")
93
+ end
94
+ end
95
+
96
+ # There is a bug/unexpected behavior related to the target.source-map command
97
+ #
98
+ # If I have debug symbols for the following files:
99
+ # /tmp/pod_builder/Pods/SomeName/... which are now under /new/path/SomeName/
100
+ # /tmp/pod_builder/Pods/SomeNameCommon/... which are now under /new/path/SomeNameCommon/
101
+ #
102
+ # adding a remap as follows
103
+ # settings append '/tmp/pod_builder/Pods/SomeName/' '/new/path/SomeName/'
104
+ #
105
+ # causes breakpoints added to files under /new/path/SomeNameCommon/ to be incorrectly added to
106
+ # /tmp/pod_builder/Pods/SomeName/Common/Somefile
107
+ #
108
+ # LLDB evaluates remap in order so to workaround this issue we have to add a remap of
109
+ # /tmp/pod_builder/Pods/SomeNameCommon/ before remapping /tmp/pod_builder/Pods/SomeName/
110
+ # even if the remap isn't needed!
111
+ lldbinit_content = other_source_map_entries.sort.reverse + prebuilt_source_map_entries.sort.reverse
112
+
113
+ lldbinit_content.insert(0, "settings clear target.source-map\n")
114
+
115
+ File.write(lldbinit_path, lldbinit_content.join("\n"))
116
+
117
+ puts "\n\n🎉 done!\n".green
118
+ return 0
119
+ end
120
+
121
+ private
122
+
123
+ def self.is_absolute_path(path)
124
+ return ["~", "/"].any? { |t| path.start_with?(t) }
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,22 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class GeneratePodspec
6
+ def self.call
7
+ Configuration.check_inited
8
+ PodBuilder::prepare_basepath
9
+
10
+ installer, analyzer = Analyze.installer_at(PodBuilder::basepath, false)
11
+ all_buildable_items = Analyze.podfile_items(installer, analyzer)
12
+
13
+ install_using_frameworks = Podfile::install_using_frameworks(analyzer)
14
+
15
+ Podspec::generate(all_buildable_items, analyzer, install_using_frameworks)
16
+
17
+ puts "\n\n🎉 done!\n".green
18
+ return 0
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ require 'pod_builder/core'
2
+ require 'json'
3
+
4
+ module PodBuilder
5
+ module Command
6
+ class Info
7
+ def self.call
8
+ Configuration.check_inited
9
+
10
+ info = PodBuilder::Info.generate_info()
11
+
12
+ puts JSON.pretty_generate(info)
13
+
14
+ return true
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,148 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class Init
6
+ def self.call
7
+ raise "\n\nAlready initialized\n".red if Configuration.exists
8
+
9
+ xcworkspace = Dir.glob("*.xcworkspace")
10
+ raise "\n\nNo xcworkspace found in current folder\n".red if xcworkspace.count == 0
11
+ raise "\n\nToo many xcworkspaces found in current folder\n#{xcworkspace}\n".red if xcworkspace.count > 1
12
+
13
+ Configuration.project_name = File.basename(xcworkspace.first, ".*")
14
+
15
+ OPTIONS[:prebuild_path] ||= Configuration.base_path
16
+
17
+ if File.expand_path(OPTIONS[:prebuild_path]) != OPTIONS[:prebuild_path] # if not absolute
18
+ OPTIONS[:prebuild_path] = File.expand_path(PodBuilder::project_path(OPTIONS[:prebuild_path]))
19
+ end
20
+
21
+ FileUtils.mkdir_p(OPTIONS[:prebuild_path])
22
+ FileUtils.mkdir_p("#{OPTIONS[:prebuild_path]}/.pod_builder")
23
+ FileUtils.touch("#{OPTIONS[:prebuild_path]}/.pod_builder/pod_builder")
24
+
25
+ write_gitignore
26
+ write_gitattributes
27
+
28
+ project_podfile_path = PodBuilder::project_path("Podfile")
29
+ prebuilt_podfile_path = File.join(OPTIONS[:prebuild_path], "Podfile")
30
+ FileUtils.cp(project_podfile_path, prebuilt_podfile_path)
31
+
32
+ podfile_content = File.read(prebuilt_podfile_path)
33
+
34
+ podfile_content = Podfile.add_install_block(podfile_content)
35
+ podfile_content = Podfile.update_path_entries(podfile_content, Init.method(:podfile_path_transform))
36
+ podfile_content = Podfile.update_project_entries(podfile_content, Init.method(:podfile_path_transform))
37
+ podfile_content = Podfile.update_require_entries(podfile_content, Init.method(:podfile_path_transform))
38
+
39
+ if podfile_content.include?("/node_modules/react-native/")
40
+ podfile_content = Podfile.prepare_for_react_native(podfile_content)
41
+ update_react_native_podspecs()
42
+ end
43
+
44
+ File.write(prebuilt_podfile_path, podfile_content)
45
+
46
+ Configuration.write
47
+
48
+ update_gemfile
49
+
50
+ puts "\n\n🎉 done!\n".green
51
+ return 0
52
+ end
53
+
54
+ private
55
+
56
+ def self.write_gitignore
57
+ source_path_rel_path = "Sources"
58
+ development_pods_config_rel_path = Configuration.dev_pods_configuration_filename
59
+
60
+ git_ignores = ["Pods/",
61
+ "*.xcworkspace",
62
+ "*.xcodeproj",
63
+ "Podfile.lock",
64
+ Configuration.lldbinit_name,
65
+ source_path_rel_path,
66
+ development_pods_config_rel_path]
67
+
68
+ File.write("#{OPTIONS[:prebuild_path]}/.gitignore", git_ignores.join("\n"))
69
+ end
70
+
71
+ def self.write_gitattributes
72
+ git_attributes = ["#{Configuration.prebuilt_info_filename} binary"]
73
+
74
+ File.write("#{OPTIONS[:prebuild_path]}/.gitattributes", git_attributes.join("\n"))
75
+ end
76
+
77
+ def self.podfile_path_transform(path)
78
+ use_absolute_paths = false
79
+ podfile_path = File.join(OPTIONS[:prebuild_path], "Podfile")
80
+ original_basepath = PodBuilder::project_path
81
+
82
+ podfile_base_path = Pathname.new(File.dirname(podfile_path))
83
+
84
+ original_path = Pathname.new(File.join(original_basepath, path))
85
+ replace_path = original_path.relative_path_from(podfile_base_path)
86
+ if use_absolute_paths
87
+ replace_path = replace_path.expand_path(podfile_base_path)
88
+ end
89
+
90
+ return replace_path
91
+ end
92
+
93
+ def self.update_gemfile
94
+ gemfile_path = File.join(PodBuilder::home, "Gemfile")
95
+ unless File.exist?(gemfile_path)
96
+ FileUtils.touch(gemfile_path)
97
+ end
98
+
99
+ source_line = "source 'https://rubygems.org'"
100
+ podbuilder_line = "gem 'pod-builder'"
101
+
102
+ gemfile = File.read(gemfile_path)
103
+
104
+ gemfile_lines = gemfile.split("\n")
105
+ gemfile_lines.select! { |x| !trim_gemfile_line(x).include?(trim_gemfile_line(source_line)) }
106
+ gemfile_lines.select! { |x| !trim_gemfile_line(x).include?(trim_gemfile_line(podbuilder_line)) }
107
+
108
+ gemfile_lines.insert(0, source_line)
109
+ gemfile_lines.push(podbuilder_line)
110
+
111
+ File.write(gemfile_path, gemfile_lines.join("\n"))
112
+
113
+ Dir.chdir(PodBuilder::home)
114
+ system("bundle")
115
+ end
116
+
117
+ def self.trim_gemfile_line(line)
118
+ return line.gsub("\"", "'").gsub(" ", "")
119
+ end
120
+
121
+ def self.update_react_native_podspecs
122
+ # React-Core.podspec
123
+ file = "React-Core.podspec"
124
+ paths = Dir.glob("#{PodBuilder::git_rootpath}/node_modules/**/#{file}")
125
+ raise "Unexpected number of #{file} found" if paths.count != 1
126
+
127
+ content = File.read(paths[0])
128
+ expected_header_search_path_prefix = "s.pod_target_xcconfig = { \"HEADER_SEARCH_PATHS\" => \""
129
+ raise "Expected header search path entry not found" unless content.include?(expected_header_search_path_prefix)
130
+
131
+ content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\\\"$(PODS_ROOT)/Headers/Public/Flipper-Folly\\\" ")
132
+ File.write(paths[0], content)
133
+
134
+ # React-CoreModules.podspec
135
+ file = "React-CoreModules.podspec"
136
+ paths = Dir.glob("#{PodBuilder::git_rootpath}/node_modules/**/#{file}")
137
+ raise "Unexpected number of #{file} found" if paths.count != 1
138
+
139
+ content = File.read(paths[0])
140
+ expected_header_search_path_prefix = "\"HEADER_SEARCH_PATHS\" => \""
141
+ raise "Expected header search path entry not found" unless content.include?(expected_header_search_path_prefix)
142
+
143
+ content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\\\"$(PODS_ROOT)/Headers/Public/Flipper-Folly\\\" ")
144
+ File.write(paths[0], content)
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,79 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class InstallSources
6
+ def self.call
7
+ Configuration.check_inited
8
+ if Configuration.build_using_repo_paths
9
+ raise "\n\nSource cannot be installed because lldb shenanigans not supported when 'build_using_repo_paths' is enabled".red
10
+ end
11
+
12
+ PodBuilder::prepare_basepath
13
+
14
+ install_update_repo = OPTIONS.fetch(:update_repos, true)
15
+ installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
16
+ podfile_items = Analyze.podfile_items(installer, analyzer).select { |x| !x.is_prebuilt }
17
+ podspec_names = podfile_items.map(&:podspec_name)
18
+
19
+ base_path = PodBuilder::prebuiltpath
20
+ framework_files = Dir.glob("#{base_path}/**/*.framework")
21
+
22
+ framework_files.each do |path|
23
+ rel_path = Pathname.new(path).relative_path_from(Pathname.new(base_path)).to_s
24
+
25
+ if podfile_spec = podfile_items.detect { |x| "#{x.root_name}/#{x.prebuilt_rel_path}" == rel_path }
26
+ update_repo(podfile_spec)
27
+ end
28
+ end
29
+
30
+ Clean::install_sources(podfile_items)
31
+
32
+ ARGV << PodBuilder::basepath("Sources")
33
+
34
+ puts "\n\n🎉 done!\n".green
35
+ return 0
36
+ end
37
+
38
+ private
39
+
40
+ def self.update_repo(spec)
41
+ if spec.path != nil || spec.podspec_path != nil
42
+ return
43
+ end
44
+
45
+ dest_path = PodBuilder::basepath("Sources")
46
+ FileUtils.mkdir_p(dest_path)
47
+
48
+ current_dir = Dir.pwd
49
+ Dir.chdir(dest_path)
50
+
51
+ repo_dir = File.join(dest_path, spec.podspec_name)
52
+ if !File.directory?(repo_dir)
53
+ raise "\n\nFailed cloning #{spec.name}".red if !system("git clone #{spec.repo} #{spec.podspec_name}")
54
+ end
55
+
56
+ Dir.chdir(repo_dir)
57
+ puts "Checking out #{spec.podspec_name}".yellow
58
+ raise "\n\nFailed cheking out #{spec.name}".red if !system(git_hard_checkout_cmd(spec))
59
+
60
+ Dir.chdir(current_dir)
61
+ end
62
+
63
+ def self.git_hard_checkout_cmd(spec)
64
+ prefix = "git fetch --all --tags --prune; git reset --hard"
65
+ if spec.tag
66
+ return "#{prefix} tags/#{spec.tag}"
67
+ end
68
+ if spec.commit
69
+ return "#{prefix} #{spec.commit}"
70
+ end
71
+ if spec.branch
72
+ return "#{prefix} origin/#{spec.branch}"
73
+ end
74
+
75
+ return nil
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,16 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class None
6
+ def self.call
7
+ unless !OPTIONS.has_key?(:version)
8
+ puts VERSION
9
+ return 0
10
+ end
11
+
12
+ return -1
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,33 @@
1
+ require 'pod_builder/core'
2
+
3
+ module PodBuilder
4
+ module Command
5
+ class RestoreAll
6
+ def self.call
7
+ unless Configuration.restore_enabled
8
+ raise "\n\nRestore not enabled!".red
9
+ end
10
+
11
+ Configuration.check_inited
12
+ PodBuilder::prepare_basepath
13
+
14
+ begin
15
+ File.rename(PodBuilder::basepath("Podfile"), PodBuilder::basepath("Podfile.tmp2"))
16
+ File.rename(PodBuilder::basepath("Podfile.restore"), PodBuilder::basepath("Podfile"))
17
+
18
+ ARGV << "*"
19
+ OPTIONS[:skip_prebuild_update] = true
20
+ return Command::Build::call
21
+ rescue Exception => e
22
+ raise e
23
+ ensure
24
+ FileUtils.rm_f(PodBuilder::basepath("Podfile.restore"))
25
+ File.rename(PodBuilder::basepath("Podfile"), PodBuilder::basepath("Podfile.restore"))
26
+ File.rename(PodBuilder::basepath("Podfile.tmp2"), PodBuilder::basepath("Podfile"))
27
+ end
28
+
29
+ return -1
30
+ end
31
+ end
32
+ end
33
+ end