Skip to content

Commit 1b7f95b

Browse files
hramoskelset
authored andcommittedAug 11, 2021
Reorganize codegen script for clarity
Summary: This changeset is limited to whitespace and reordering changes that have no effect on the output or execution of the script. The sole purpose of this changeset is to apply these trivial changes prior to making some larger adjustments to the script in a followup. With these changes, the ordering of statements more closely matches the order they are executed in (e.g. prepare_command before the script_phase). Changelog: [Internal] Reviewed By: RSNara Differential Revision: D29527804 fbshipit-source-id: d161ed31321d68baf420457c7aa0aa23a6fc98d2
1 parent 041365e commit 1b7f95b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

‎scripts/react_native_pods.rb

+12-6
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,19 @@ def use_react_native_codegen!(spec, options={})
160160

161161
# Library name (e.g. FBReactNativeSpec)
162162
modules_library_name = spec.name
163+
164+
# Output dir, relative to podspec that invoked this method
163165
modules_output_dir = "React/#{modules_library_name}/#{modules_library_name}"
164166

167+
generated_dirs = [ modules_output_dir ]
168+
generated_filenames = [ "#{modules_library_name}.h", "#{modules_library_name}-generated.mm" ]
169+
generated_files = generated_filenames.map { |filename| "#{modules_output_dir}/#{filename}" }
170+
165171
# Run the codegen as part of the Xcode build pipeline.
166172
env_vars = "SRCS_DIR='#{js_srcs}'"
167173
env_vars += " MODULES_OUTPUT_DIR='#{prefix}/#{modules_output_dir}'"
168174
env_vars += " MODULES_LIBRARY_NAME='#{modules_library_name}'"
169175

170-
generated_dirs = [ modules_output_dir ]
171-
generated_filenames = [ "#{modules_library_name}.h", "#{modules_library_name}-generated.mm" ]
172-
generated_files = generated_filenames.map { |filename| "#{modules_output_dir}/#{filename}" }
173-
174176
if ENV['USE_FABRIC'] == '1'
175177
# We use a different library name for components, as well as an additional set of files.
176178
# Eventually, we want these to be part of the same library as #{modules_library_name} above.
@@ -190,13 +192,17 @@ def use_react_native_codegen!(spec, options={})
190192
generated_files = generated_files.concat(components_generated_filenames.map { |filename| "#{components_output_dir}/#{filename}" })
191193
end
192194

195+
# Prepare filesystem by creating empty files that will be picked up as references by CocoaPods.
196+
spec.prepare_command = "mkdir -p #{generated_dirs.map {|dir| "'../../#{dir}'"}.join(" ")} && touch #{generated_files.map {|file| "'../../#{file}'"}.join(" ")}"
197+
193198
spec.script_phase = {
194199
:name => 'Generate Specs',
195200
:input_files => [js_srcs],
196201
:output_files => ["${DERIVED_FILE_DIR}/codegen-#{modules_library_name}.log"].concat(generated_files.map { |filename| "#{prefix}/#{filename}"} ),
197-
:script => "set -o pipefail\n\nbash -l -c '#{env_vars} ${PODS_TARGET_SRCROOT}/../../scripts/generate-specs.sh' 2>&1 | tee \"${SCRIPT_OUTPUT_FILE_0}\"",
202+
# The final generated files will be created when this script is invoked at Xcode build time.
203+
:script => %{set -o pipefail
204+
bash -l -c '#{env_vars} $\{PODS_TARGET_SRCROOT\}/../../scripts/generate-specs.sh' 2>&1 | tee "${SCRIPT_OUTPUT_FILE_0}"},
198205
:execution_position => :before_compile,
199206
:show_env_vars_in_log => true
200207
}
201-
spec.prepare_command = "mkdir -p #{generated_dirs.map {|dir| "'../../#{dir}'"}.join(" ")} && touch #{generated_files.map {|file| "'../../#{file}'"}.join(" ")}"
202208
end

0 commit comments

Comments
 (0)
Please sign in to comment.