aboutsummaryrefslogtreecommitdiff
path: root/brunch/lib/commands/product/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'brunch/lib/commands/product/build.py')
-rw-r--r--brunch/lib/commands/product/build.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/brunch/lib/commands/product/build.py b/brunch/lib/commands/product/build.py
index 9509b17..cfbba79 100644
--- a/brunch/lib/commands/product/build.py
+++ b/brunch/lib/commands/product/build.py
@@ -18,10 +18,13 @@
import argparse
import os
+import time
from cli import clicommand
from core import config
from core import util
+from metrics.data_types import brillo_ga_hits
+from metrics import send_hits
class Build(clicommand.Command):
"""Build a product project from the current directory"""
@@ -58,15 +61,42 @@ class Build(clicommand.Command):
# Don't pass along the first '--' since it was meant for argparse.
args.make_args.count('--') and args.make_args.remove('--')
+ # If user options haven't been set up yet, do so.
+ # TODO(arihc): move this to install script instead of here.
+ user_store = config.UserStore()
+ if not user_store.complete():
+ user_store.initialize()
+
+ envcmd = 'make'
+ start_time = time.time()
+
if args.submodule == True:
print "Building submodule only . . ."
ret = os.system('make -f %s/tools/bdk/build/wrap-product.mk %s ' \
'HERE="%s" ENVCMD=mm BUILDTYPE=%s %s' %
(sdk_path, no_java, os.getcwd(), args.buildtype,
util.AsShellArgs(args.make_args)))
+ envcmd = 'mm'
else:
# Change to the product path and build the whole product.
ret = os.system('cd %s;make -f %s/tools/bdk/build/wrap-product.mk %s BUILDTYPE=%s %s' %
(args.product_path, sdk_path, no_java, args.buildtype,
util.AsShellArgs(args.make_args)))
+
+ end_time = time.time()
+ build_time = int(end_time - start_time)
+
+ # Determine the envcmd for reporting purposes
+ for arg in args.make_args:
+ split_arg = arg.split('=')
+ if split_arg[0] == 'ENVCMD' and len(split_arg) > 1:
+ envcmd = split_arg[1]
+
+ # TODO(arihc): also check for not --help, since this is what build_time > 0
+ # is primarily checking for, and the wrapper runs lunch first,
+ # making basically all builds > 0 time.
+ if user_store.metrics_opt_in != '0' and ret == 0 and build_time > 0:
+ send_hits.SendHitAndRetries(brillo_ga_hits.BuildTiming(envcmd,
+ build_time))
+
return util.GetExitCode(ret)