censorius 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +66 -0
- data/lib/censorius.rb +138 -0
- data/lib/censorius/version.rb +5 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fae995832209c05c987ee10832a84697c712fa0625591bb048850e3e47833fb7
|
4
|
+
data.tar.gz: 5a9c760e0b96e41287f822b164ac7cb96793af5bc0cb9ad0ea8269f89d3f7a65
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7df4123bb5cee2b459b51e02bd1942dfab90a8674bbb21680d2ea40116051154dc91fb564ee642810ed0c862ce1cf6e5c47de1aed66b9970ef59987997bee53
|
7
|
+
data.tar.gz: 0c6c58313257a420935df61938e794f362a61dc681586a69f1a5c1c58ad47bba810e34622bd10dccaa5c34982dc741f8d08ae028e7464d4c8d4e5ea9ca6e626d
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Censorius
|
2
|
+
|
3
|
+
Censorius is a small gem that generates deterministic and stable UUID paths for [Xcodeproj](https://github.com/CocoaPods/Xcodeproj). It's meant to be used either with [CocoaPods](https://github.com/CocoaPods/CocoaPods) or [Xcake](https://github.com/igor-makarov/xcake) to reduce meaningless Xcode project file differences, and therefore make Xcode incremental builds after project generation shorter.
|
4
|
+
|
5
|
+
It is meant as a replacement for the `Xcodeproj::Project#predictabilize_uuids` method, which generates deterministic UUIDs in a way that is very unstable on even the smallest changes.
|
6
|
+
|
7
|
+
Censorius covers all meaningful PBX file format elements.
|
8
|
+
|
9
|
+
## Why the name "Censorius"?
|
10
|
+
|
11
|
+
In ancient Rome, a [censor](https://en.wikipedia.org/wiki/Roman_censor) was an official appointed to conduct the census, a process by which all of Rome's subjects were enumerated, and all their property was noted for the purpose of taxation.
|
12
|
+
|
13
|
+
[Cato the Censor](https://en.wikipedia.org/wiki/Cato_the_Elder) was a Roman censor, who was mostly known for his catchphrase "Carthago delenda est" ("Carthage must be destroyed"), referring to the Carthaginian Empire that kept threatening and attacking Rome.
|
14
|
+
|
15
|
+
The gem is named "Censorius" because it is my hope that with this final effort of conducting an object census of the Xcode project file, all the problems of the PBX file format will finally go away. _PBX delenda est._
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'censorius'
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### With CocoaPods
|
28
|
+
|
29
|
+
In your `Podfile`:
|
30
|
+
```ruby
|
31
|
+
require 'censorius'
|
32
|
+
#
|
33
|
+
# Define your dependencies...
|
34
|
+
#
|
35
|
+
# Remove the `deterministic_uuids` option if you're using it.
|
36
|
+
#
|
37
|
+
post_install do |installer|
|
38
|
+
installer.generated_projects.each do |project|
|
39
|
+
Censorius::UUIDGenerator.new([project]).generate!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
### With Xcake
|
45
|
+
In your `Cakefile`:
|
46
|
+
```ruby
|
47
|
+
require 'censorius'
|
48
|
+
#
|
49
|
+
# Define your targets...
|
50
|
+
#
|
51
|
+
project.before_save do |main_project|
|
52
|
+
Censorius::UUIDGenerator.new([main_project]).generate!
|
53
|
+
end
|
54
|
+
|
55
|
+
```
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/igor-makarov/censorius. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/igor-makarov/censorius/blob/master/CODE_OF_CONDUCT.md).
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
63
|
+
|
64
|
+
## Code of Conduct
|
65
|
+
|
66
|
+
Everyone interacting in the Censorius project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/igor-makarov/censorius/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/censorius.rb
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'xcodeproj'
|
5
|
+
|
6
|
+
require_relative 'censorius/version'
|
7
|
+
|
8
|
+
module Censorius
|
9
|
+
# The main generator class
|
10
|
+
class UUIDGenerator < Xcodeproj::Project::UUIDGenerator
|
11
|
+
def generate_all_paths_by_objects(projects)
|
12
|
+
projects.each do |project|
|
13
|
+
generate_paths(project.root_object, project.path.basename.to_s)
|
14
|
+
without_path = project.objects.select { |o| @paths_by_object[o].nil? }
|
15
|
+
raise "Without paths: #{without_path}" unless without_path.empty?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_paths(object, parent_path = '') # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
20
|
+
case object
|
21
|
+
when Xcodeproj::Project::Object::PBXProject
|
22
|
+
generate_paths_project(object)
|
23
|
+
when Xcodeproj::Project::Object::AbstractTarget
|
24
|
+
generate_paths_target(object, parent_path)
|
25
|
+
when Xcodeproj::Project::Object::PBXGroup
|
26
|
+
generate_paths_group(object)
|
27
|
+
when Xcodeproj::Project::Object::PBXFileReference
|
28
|
+
generate_paths_file_reference(object)
|
29
|
+
when Xcodeproj::Project::Object::XCConfigurationList
|
30
|
+
generate_paths_configuration_list(object, parent_path)
|
31
|
+
when Xcodeproj::Project::Object::XCBuildConfiguration
|
32
|
+
generate_paths_configuration(object, parent_path)
|
33
|
+
when Xcodeproj::Project::Object::AbstractBuildPhase
|
34
|
+
generate_paths_phase(object, parent_path)
|
35
|
+
when Xcodeproj::Project::Object::PBXBuildFile
|
36
|
+
generate_paths_build_file(object, parent_path)
|
37
|
+
when Xcodeproj::Project::Object::PBXContainerItemProxy
|
38
|
+
generate_paths_container_item_proxy(object, parent_path)
|
39
|
+
when Xcodeproj::Project::Object::PBXTargetDependency
|
40
|
+
generate_paths_target_dependency(object, parent_path)
|
41
|
+
when Xcodeproj::Project::Object::PBXReferenceProxy
|
42
|
+
generate_paths_reference_proxy(object, parent_path)
|
43
|
+
else
|
44
|
+
raise "Unrecognized: #{object.class}, at: #{parent_path}"
|
45
|
+
end
|
46
|
+
|
47
|
+
@paths_by_object[object]
|
48
|
+
end
|
49
|
+
|
50
|
+
def generate_paths_project(project)
|
51
|
+
@paths_by_object[project] = path = "PBXProject(#{project.name})"
|
52
|
+
generate_paths(project.main_group, path)
|
53
|
+
generate_paths(project.build_configuration_list, path)
|
54
|
+
project.targets.each do |target|
|
55
|
+
generate_paths(target, path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def generate_paths_configuration_list(configuration_list, parent_path)
|
60
|
+
@paths_by_object[configuration_list] = path = "#{parent_path}/XCConfigurationList"
|
61
|
+
configuration_list.build_configurations.each do |config|
|
62
|
+
generate_paths(config, path)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def generate_paths_configuration(configuration, parent_path)
|
67
|
+
@paths_by_object[configuration] = "#{parent_path}/XCBuildConfiguration(#{configuration.name})"
|
68
|
+
end
|
69
|
+
|
70
|
+
def generate_paths_target(target, parent_path)
|
71
|
+
@paths_by_object[target] = path = "#{parent_path}/#{target.class.name.split('::').last}(#{target.name})"
|
72
|
+
target.build_phases.each do |phase|
|
73
|
+
generate_paths(phase, path)
|
74
|
+
end
|
75
|
+
generate_paths(target.build_configuration_list, path)
|
76
|
+
target.dependencies.each do |dependency|
|
77
|
+
generate_paths(dependency, path)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def generate_paths_phase(phase, parent_path)
|
82
|
+
@paths_by_object[phase] = path = "#{parent_path}/#{phase.class.name.split('::').last}(#{phase.display_name})"
|
83
|
+
phase.files.each do |file|
|
84
|
+
generate_paths(file, path)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def generate_paths_build_file(build_file, parent_path)
|
89
|
+
file_ref_path = generate_paths(build_file.file_ref)
|
90
|
+
@paths_by_object[build_file] = "#{parent_path}/PBXBuildFile(#{file_ref_path})"
|
91
|
+
end
|
92
|
+
|
93
|
+
def generate_paths_group(group)
|
94
|
+
project_path = @paths_by_object[group.project.root_object]
|
95
|
+
@paths_by_object[group] = path = "#{project_path}/PBXGroup(#{group.hierarchy_path || '/'})"
|
96
|
+
group.children.each do |child|
|
97
|
+
generate_paths(child, path)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def generate_paths_file_reference(file_reference)
|
102
|
+
project_path = @paths_by_object[file_reference.project.root_object]
|
103
|
+
@paths_by_object[file_reference] = "#{project_path}/PBXFileReference(#{file_reference.full_path})"
|
104
|
+
end
|
105
|
+
|
106
|
+
def generate_paths_target_dependency(dependency, parent_path)
|
107
|
+
raise "Unsupported: #{dependency}" unless dependency.target_proxy
|
108
|
+
|
109
|
+
@paths_by_object[dependency] = path = "#{parent_path}/PBXTargetDependency(#{dependency.name})"
|
110
|
+
generate_paths(dependency.target_proxy, path)
|
111
|
+
end
|
112
|
+
|
113
|
+
def generate_paths_container_item_proxy(proxy, parent_path)
|
114
|
+
params = [
|
115
|
+
"type: #{proxy.proxy_type}",
|
116
|
+
"containerPortal: #{proxy.container_portal_annotation.strip}",
|
117
|
+
"remoteInfo: #{proxy.remote_info}"
|
118
|
+
]
|
119
|
+
@paths_by_object[proxy] = "#{parent_path}/PBXContainerItemProxy(#{params.join(', ')})"
|
120
|
+
end
|
121
|
+
|
122
|
+
def generate_paths_reference_proxy(proxy, parent_path)
|
123
|
+
@paths_by_object[proxy] = path = "#{parent_path}/PBXReferenceProxy(#{proxy.source_tree}/#{proxy.path})"
|
124
|
+
generate_paths(proxy.remote_ref, path) if proxy.remote_ref
|
125
|
+
end
|
126
|
+
|
127
|
+
def write_debug_paths
|
128
|
+
return if @projects.empty?
|
129
|
+
|
130
|
+
debug_info = @paths_by_object
|
131
|
+
.to_a
|
132
|
+
.map(&:last)
|
133
|
+
.sort
|
134
|
+
file_name = @projects.count == 1 ? File.basename(@projects.first.path, '.*') : 'multi'
|
135
|
+
File.write("#{file_name}.txt", debug_info.join("\n"))
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: censorius
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Makarov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: xcodeproj
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.20.0
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.20.0
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1'
|
33
|
+
description: PBX Delendare Est.
|
34
|
+
email:
|
35
|
+
- igormaka@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- README.md
|
41
|
+
- lib/censorius.rb
|
42
|
+
- lib/censorius/version.rb
|
43
|
+
homepage: https://github.com/igor-makarov/censorius
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata:
|
47
|
+
homepage_uri: https://github.com/igor-makarov/censorius
|
48
|
+
source_code_uri: https://github.com/igor-makarov/censorius
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.4.0
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.1.4
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: A PBX UUID generator to end all generators.
|
68
|
+
test_files: []
|