spinjector 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a068bf03bec2f55c4ba35e21837e5646448925c15022befe1fe0cc78f4421ea7
4
- data.tar.gz: 480fb32fd1468e9aaa2de729ffc06e21340e254fd4bc90ad2e235ff7c90e477b
3
+ metadata.gz: 13754e7fa2165ee93579dd1d2064c9eb5e692ef67a2e2b7cd59f8a755b14a21b
4
+ data.tar.gz: 21e6d78086b4ed644eaf628c1548fc6570f198d2ad3aaf224d51da41e4d065ba
5
5
  SHA512:
6
- metadata.gz: 62be7e320e8094f6f434d082c9ee030c8fb7de9f3214d28137d538b4b16e603c67d108d895f0f7cad954474667aac604e961b2ced5191c6bcc4a26f6b11ab660
7
- data.tar.gz: 7dbd3c4596b209de43caecab5db28248b330d87ca925ab6bcf8c1d55d73fb64a1886eadaa5949ca14a8df5cc82237eeb2473ba8e8aea7c9e25368f9015e1fc95
6
+ metadata.gz: f44c4b944a3a1859d5e2d9396bcc5a4ca4820d4d1b1f9633f1657b5b4f4430a60ab26bdedfa725bccba05c695a109d9e2d8e254c247a45b4d651639a88733463
7
+ data.tar.gz: 45a06ffa00166fa35326be22ac1156f1930d42e5737906e6c0f3d9a34c904ff3d5490bf3ab3e5f3403d18e9ac6bfd2f9e9f589b6a62e1b85dae45e6bdb709952
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ name: "HelloWorldExplicit"
2
+ script: |
3
+ echo Hello
4
+ echo World
5
+ input_paths:
6
+ - "Configuration/hello_world_input"
7
+ output_paths:
8
+ - "Configuration/hello_world_output"
9
+ execution_position: :before_compile
@@ -1,2 +1,3 @@
1
1
  name: "HelloWorldShort"
2
2
  script_path: "Scripts/helloworld.sh"
3
+ execution_position: :after_compile
@@ -1,11 +1,18 @@
1
- # TargetNameFoo:
2
- # - <script path A> to inject
3
- # - <script path B> to inject
4
- # TargetNameBar:
5
- # - <script path A> to inject
6
- # - <script path C> to inject
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
- TargetNameA:
9
- - "helloworld.yaml"
10
- TargetNameB:
11
- - "helloworld_short.yaml"
11
+ targets:
12
+ TargetNameA:
13
+ - foo
14
+ - "helloworld.yaml"
15
+ - bar
16
+ - "helloworld_explicit_script.yaml"
17
+ TargetNameB:
18
+ - "helloworld_short.yaml"
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
- TargetNameFoo:
16
- - <scriptA config path> to inject
17
- - <scriptB config path> to inject
18
- TargetNameBar:
19
- - <scriptA config path> to inject
20
- - <scriptC config path> to inject
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, create:
25
- - A configuration file for this script
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
- - The script file defined under `script_path` in your script configuration file
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
+ ![Image of your build phases](/Examples/Images/build_phases.png)
79
+ ![Image of hello world 2 build phase](/Examples/Images/hello_world_explicit.png)
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
- configuration_file.each do |target_name, script_paths|
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
- load_yml_content(script_path)
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
- script = File.read(script_phase["script_path"])
81
- phase.shell_script = 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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'spinjector'
3
- s.version = '0.0.4'
3
+ s.version = '0.0.5'
4
4
  s.executables << 'spinjector'
5
5
  s.summary = "Inject script phases into your Xcode project"
6
6
  s.description = ""
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
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