spinjector 0.0.4 → 0.0.5
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/Examples/Configuration/hello_world_input +0 -0
- data/Examples/Configuration/hello_world_output +0 -0
- data/Examples/Configuration/helloworld_explicit_script.yaml +9 -0
- data/Examples/Configuration/helloworld_short.yaml +1 -0
- data/Examples/Configuration/spinjector_configuration.yaml +17 -10
- data/Examples/Images/build_phases.png +0 -0
- data/Examples/Images/hello_world_explicit.png +0 -0
- data/README.md +38 -10
- data/lib/spinjector.rb +35 -4
- data/spinjector.gemspec +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13754e7fa2165ee93579dd1d2064c9eb5e692ef67a2e2b7cd59f8a755b14a21b
|
4
|
+
data.tar.gz: 21e6d78086b4ed644eaf628c1548fc6570f198d2ad3aaf224d51da41e4d065ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f44c4b944a3a1859d5e2d9396bcc5a4ca4820d4d1b1f9633f1657b5b4f4430a60ab26bdedfa725bccba05c695a109d9e2d8e254c247a45b4d651639a88733463
|
7
|
+
data.tar.gz: 45a06ffa00166fa35326be22ac1156f1930d42e5737906e6c0f3d9a34c904ff3d5490bf3ab3e5f3403d18e9ac6bfd2f9e9f589b6a62e1b85dae45e6bdb709952
|
File without changes
|
File without changes
|
@@ -1,11 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
scripts:
|
2
|
+
foo:
|
3
|
+
name: "Foo"
|
4
|
+
script_path: "Scripts/helloworld.sh"
|
5
|
+
bar:
|
6
|
+
name: "Bar"
|
7
|
+
script: |
|
8
|
+
echo Bar
|
9
|
+
execution_position: :after_compile
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
targets:
|
12
|
+
TargetNameA:
|
13
|
+
- foo
|
14
|
+
- "helloworld.yaml"
|
15
|
+
- bar
|
16
|
+
- "helloworld_explicit_script.yaml"
|
17
|
+
TargetNameB:
|
18
|
+
- "helloworld_short.yaml"
|
Binary file
|
Binary file
|
data/README.md
CHANGED
@@ -12,33 +12,58 @@ gem install spinjector
|
|
12
12
|
First, create a YAML configuration file under `./Configuration/spinjector_configuration.yaml` (default path where spinjector looks for a configuration file).
|
13
13
|
|
14
14
|
```
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
scripts:
|
16
|
+
foo:
|
17
|
+
name: "Foo"
|
18
|
+
script: |
|
19
|
+
echo Foo
|
20
|
+
execution_position: :after_compile
|
21
|
+
|
22
|
+
targets:
|
23
|
+
TargetNameA:
|
24
|
+
- foo
|
25
|
+
- "helloworld.yaml"
|
26
|
+
- "helloworld_explicit_script.yaml"
|
27
|
+
TargetNameB:
|
28
|
+
- "helloworld_short.yaml"
|
29
|
+
- foo
|
30
|
+
|
21
31
|
```
|
22
32
|
|
23
33
|
## Script configuration file
|
24
|
-
Then, for each script you want to inject in your Xcode project
|
25
|
-
-
|
34
|
+
Then, for each script you want to inject in your Xcode project:
|
35
|
+
- You can use `scripts` section in the global configuration file to define your script directly (eg. `foo`)...
|
36
|
+
|
37
|
+
- ...Or create a script configuration file (eg. `helloworld.yaml`)
|
38
|
+
|
26
39
|
```
|
27
40
|
name: "Hello World" # required. Script phase name.
|
41
|
+
|
42
|
+
# One and only one :script_path or :script may appear.
|
43
|
+
# For now, it makes no sense to have 2 differents script sources.
|
28
44
|
script_path: "Script/helloworld.sh" # required. Script file path.
|
45
|
+
script: | # required. Script.
|
46
|
+
<some code lines>
|
47
|
+
<other code lines>
|
48
|
+
|
29
49
|
input_paths: # optional.
|
30
50
|
- ""
|
51
|
+
|
31
52
|
output_paths: # optional.
|
32
53
|
- ""
|
54
|
+
|
33
55
|
input_file_list_paths: # optional.
|
34
56
|
- ""
|
57
|
+
|
35
58
|
output_file_list_paths: # optional.
|
36
59
|
- ""
|
60
|
+
|
37
61
|
dependency_file: # optional.
|
62
|
+
|
38
63
|
execution_position: # optional. [:before-compile | :after-compile | :before-headers | :after-headers].
|
39
64
|
```
|
40
65
|
|
41
|
-
-
|
66
|
+
- If you use the `script_path option, create the script file
|
42
67
|
```
|
43
68
|
echo Hello World
|
44
69
|
```
|
@@ -47,5 +72,8 @@ echo Hello World
|
|
47
72
|
Finally, inject script phases
|
48
73
|
```
|
49
74
|
spinjector [-c] <path-to-your-global-configuration-file>
|
50
|
-
|
51
75
|
```
|
76
|
+
|
77
|
+
Enjoy your build phases
|
78
|
+

|
79
|
+

|
data/lib/spinjector.rb
CHANGED
@@ -42,9 +42,19 @@ end
|
|
42
42
|
#
|
43
43
|
def inject_script_phases(project, configuration_file_path)
|
44
44
|
configuration_file = load_yml_content(configuration_file_path)
|
45
|
-
|
45
|
+
# Check if there are scripts in the global configuration file
|
46
|
+
implicit_scripts = configuration_file["scripts"] || []
|
47
|
+
configuration_file["targets"].each do |target_name, script_paths|
|
46
48
|
script_phases = (script_paths || []).flat_map do |script_path|
|
47
|
-
|
49
|
+
if !implicit_scripts.empty? and !implicit_scripts[script_path].nil?
|
50
|
+
# Target uses script from the global configuration file
|
51
|
+
script = implicit_scripts[script_path]
|
52
|
+
else
|
53
|
+
# Target uses script from a dedicated configuration file
|
54
|
+
script = load_yml_content(script_path)
|
55
|
+
end
|
56
|
+
raise "[Error] Could not find script #{script_path}" unless !script.nil?
|
57
|
+
script
|
48
58
|
end
|
49
59
|
warn "[Warning] No script phases found for #{target_name} target. You can add them in your configuration file at #{configuration_file_path}" unless !script_phases.empty?
|
50
60
|
target = app_target(project, target_name)
|
@@ -77,8 +87,8 @@ def create_script_phases(script_phases, target)
|
|
77
87
|
script_phases.each do |script_phase|
|
78
88
|
name_with_prefix = BUILD_PHASE_PREFIX + script_phase["name"]
|
79
89
|
phase = target.new_shell_script_build_phase(name_with_prefix)
|
80
|
-
|
81
|
-
phase.shell_script =
|
90
|
+
shell_script = get_script(script_phase)
|
91
|
+
phase.shell_script = shell_script
|
82
92
|
phase.shell_path = script_phase["shell_path"] || '/bin/sh'
|
83
93
|
phase.input_paths = script_phase["input_paths"]
|
84
94
|
phase.output_paths = script_phase["output_paths"]
|
@@ -96,6 +106,27 @@ def create_script_phases(script_phases, target)
|
|
96
106
|
end
|
97
107
|
end
|
98
108
|
|
109
|
+
# @param [Hash] script_phase the script phase defined in configuration files
|
110
|
+
# @return [String] script to add in script phase
|
111
|
+
#
|
112
|
+
# If script is in a dedicated file, find the URL under <script_path>.
|
113
|
+
# Otherwise, it may be written directly in the configuration file, find it under <script>.
|
114
|
+
#
|
115
|
+
def get_script(script_phase)
|
116
|
+
if !script_phase["script"].nil? and !script_phase["script_path"].nil?
|
117
|
+
raise "[Error] Script phase #{script_phase["name"]} contains 2 script sources. Please use one of :script_path or :script option"
|
118
|
+
end
|
119
|
+
if !script_phase["script_path"].nil?
|
120
|
+
raise "[Error] File #{script_phase["script_path"]} does not exist" unless File.exist?(script_phase["script_path"])
|
121
|
+
File.read(script_phase["script_path"])
|
122
|
+
elsif !script_phase["script"].nil?
|
123
|
+
script_phase["script"]
|
124
|
+
else
|
125
|
+
warn "[Warning] Script phase #{script_phase["name"]} contains no script"
|
126
|
+
return ""
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
99
130
|
# @param [Xcodeproj::Project::Object::PBXNativeTarget] target where build phases should be reordered
|
100
131
|
# @param [Hash] script_phase to reorder
|
101
132
|
# @param [Symbol] execution_position could be :before_compile, :after_compile, :before_headers, :after_headers
|
data/spinjector.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spinjector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Berthier, Fabernovel
|
@@ -60,9 +60,14 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- Examples/Configuration/hello_world_input
|
64
|
+
- Examples/Configuration/hello_world_output
|
63
65
|
- Examples/Configuration/helloworld.yaml
|
66
|
+
- Examples/Configuration/helloworld_explicit_script.yaml
|
64
67
|
- Examples/Configuration/helloworld_short.yaml
|
65
68
|
- Examples/Configuration/spinjector_configuration.yaml
|
69
|
+
- Examples/Images/build_phases.png
|
70
|
+
- Examples/Images/hello_world_explicit.png
|
66
71
|
- Examples/Scripts/helloworld.sh
|
67
72
|
- README.md
|
68
73
|
- bin/spinjector
|