Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Does a better job about getting timing for installing generated heade…
Browse files Browse the repository at this point in the history
…rs by throwing it out on a thread.

DELTA=20 (4 added, 8 deleted, 8 changed)
DELTA_BY_EXTENSION=py=12
PiperOrigin-RevId: 203025058
  • Loading branch information
dmaclach authored and dierksen committed Jul 12, 2018
1 parent caa68e9 commit ebf3108
Show file tree
Hide file tree
Showing 98 changed files with 14 additions and 13,753 deletions.
3 changes: 2 additions & 1 deletion src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl
Expand Up @@ -494,7 +494,8 @@ def _minimum_os_for_platform(ctx, platform_type_str):
return min_os

platform_type = getattr(apple_common.platform_type, platform_type_str)
min_os = (ctx.attr._tulsi_xcode_config[apple_common.XcodeVersionConfig].minimum_os_for_platform_type(platform_type))
min_os = (ctx.attr._tulsi_xcode_config[apple_common.XcodeVersionConfig]
.minimum_os_for_platform_type(platform_type))

if not min_os:
return None
Expand Down
28 changes: 12 additions & 16 deletions src/TulsiGenerator/Scripts/bazel_build.py
Expand Up @@ -28,6 +28,7 @@
import subprocess
import sys
import textwrap
import threading
import time
import zipfile

Expand Down Expand Up @@ -680,25 +681,18 @@ def Run(self, args):
if exit_code:
return exit_code

# We expect artifact installation to take longer than header installation,
# so we spawn the genfiles installation subprocess first, spawn and wait on
# artifact installation, and then finally wait on genfiles installation
# (which is hopefully already done). Note that this makes the timer for
# genfiles installation inaccurate (it will always be longer than the
# artifact installation timer).
genfiles_timer = Timer('Installing generated headers',
'installing_generated_headers').Start()
genfiles_process = self._StartInstallingGeneratedHeaders(outputs)

# Generated headers are installed on a thread since we are launching
# a separate process to do so. This gives us clean timings.
install_thread = threading.Thread(
target=self._StartInstallingGeneratedHeaders, args=(outputs,))
install_thread.start()
timer = Timer('Installing artifacts', 'installing_artifacts').Start()
exit_code = self._InstallArtifact(outputs_data)
timer.End()
install_thread.join()
if exit_code:
return exit_code

genfiles_process.wait()
genfiles_timer.End()

exit_code, dsym_paths = self._InstallDSYMBundles(
self.built_products_dir, outputs_data)
if exit_code:
Expand Down Expand Up @@ -1147,9 +1141,10 @@ def _FindEmbeddedBundle(self, bundle_name, bundle_extension, bundle_path):
return path
return None

def _StartInstallingGeneratedHeaders(self, outputs):
def _InstallGeneratedHeaders(self, outputs):
"""Invokes install_genfiles.py to install generated Bazel files."""

genfiles_timer = Timer('Installing generated headers',
'installing_generated_headers').Start()
# Resolve the path to the install_genfiles.py script.
# It should be in the same directory as this script.
path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
Expand All @@ -1161,7 +1156,8 @@ def _StartInstallingGeneratedHeaders(self, outputs):
self._PrintVerbose('Spawning subprocess install_genfiles.py to copy '
'generated files in the background...')
process = subprocess.Popen(args)
return process
process.wait()
genfiles_timer.End()

def _InstallBundle(self, source_path, output_path):
"""Copies the bundle at source_path to output_path."""
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit ebf3108

Please sign in to comment.