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
This commit is contained in:
Héctor Ramos 2021-07-13 10:13:56 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 9d2fedc6e2
Коммит 3fefe043b4
1 изменённых файлов: 12 добавлений и 6 удалений

Просмотреть файл

@ -160,17 +160,19 @@ def use_react_native_codegen!(spec, options={})
# Library name (e.g. FBReactNativeSpec) # Library name (e.g. FBReactNativeSpec)
modules_library_name = spec.name modules_library_name = spec.name
# Output dir, relative to podspec that invoked this method
modules_output_dir = "React/#{modules_library_name}/#{modules_library_name}" modules_output_dir = "React/#{modules_library_name}/#{modules_library_name}"
generated_dirs = [ modules_output_dir ]
generated_filenames = [ "#{modules_library_name}.h", "#{modules_library_name}-generated.mm" ]
generated_files = generated_filenames.map { |filename| "#{modules_output_dir}/#{filename}" }
# Run the codegen as part of the Xcode build pipeline. # Run the codegen as part of the Xcode build pipeline.
env_vars = "SRCS_DIR='#{js_srcs}'" env_vars = "SRCS_DIR='#{js_srcs}'"
env_vars += " MODULES_OUTPUT_DIR='#{prefix}/#{modules_output_dir}'" env_vars += " MODULES_OUTPUT_DIR='#{prefix}/#{modules_output_dir}'"
env_vars += " MODULES_LIBRARY_NAME='#{modules_library_name}'" env_vars += " MODULES_LIBRARY_NAME='#{modules_library_name}'"
generated_dirs = [ modules_output_dir ]
generated_filenames = [ "#{modules_library_name}.h", "#{modules_library_name}-generated.mm" ]
generated_files = generated_filenames.map { |filename| "#{modules_output_dir}/#{filename}" }
if ENV['USE_FABRIC'] == '1' if ENV['USE_FABRIC'] == '1'
# We use a different library name for components, as well as an additional set of files. # We use a different library name for components, as well as an additional set of files.
# Eventually, we want these to be part of the same library as #{modules_library_name} above. # 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={})
generated_files = generated_files.concat(components_generated_filenames.map { |filename| "#{components_output_dir}/#{filename}" }) generated_files = generated_files.concat(components_generated_filenames.map { |filename| "#{components_output_dir}/#{filename}" })
end end
# Prepare filesystem by creating empty files that will be picked up as references by CocoaPods.
spec.prepare_command = "mkdir -p #{generated_dirs.map {|dir| "'../../#{dir}'"}.join(" ")} && touch #{generated_files.map {|file| "'../../#{file}'"}.join(" ")}"
spec.script_phase = { spec.script_phase = {
:name => 'Generate Specs', :name => 'Generate Specs',
:input_files => [js_srcs], :input_files => [js_srcs],
:output_files => ["${DERIVED_FILE_DIR}/codegen-#{modules_library_name}.log"].concat(generated_files.map { |filename| "#{prefix}/#{filename}"} ), :output_files => ["${DERIVED_FILE_DIR}/codegen-#{modules_library_name}.log"].concat(generated_files.map { |filename| "#{prefix}/#{filename}"} ),
:script => "set -o pipefail\n\nbash -l -c '#{env_vars} ${PODS_TARGET_SRCROOT}/../../scripts/generate-specs.sh' 2>&1 | tee \"${SCRIPT_OUTPUT_FILE_0}\"", # The final generated files will be created when this script is invoked at Xcode build time.
:script => %{set -o pipefail
bash -l -c '#{env_vars} $\{PODS_TARGET_SRCROOT\}/../../scripts/generate-specs.sh' 2>&1 | tee "${SCRIPT_OUTPUT_FILE_0}"},
:execution_position => :before_compile, :execution_position => :before_compile,
:show_env_vars_in_log => true :show_env_vars_in_log => true
} }
spec.prepare_command = "mkdir -p #{generated_dirs.map {|dir| "'../../#{dir}'"}.join(" ")} && touch #{generated_files.map {|file| "'../../#{file}'"}.join(" ")}"
end end