Bug 1279564 - Use get_state_dir() from mozboot; r=glandium
authorGregory Szorc <gps@mozilla.com>
Fri, 10 Jun 2016 09:41:59 -0700
changeset 382021 2812ef2db5977fa7dbebd2330b12a91ff90952c9
parent 382020 cc353a894d96e10c4d78c8d72353760c5288a0ab
child 382282 5b3be977f2a28eaeed03b68c87bd1e7fa898ed25
push id21593
push userbmo:gps@mozilla.com
push dateTue, 28 Jun 2016 17:22:28 +0000
reviewersglandium
bugs1279564
milestone50.0a1
Bug 1279564 - Use get_state_dir() from mozboot; r=glandium Import mozboot.util and use the function from there. MozReview-Commit-ID: B0uzpNff1t9
build/mach_bootstrap.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -171,31 +171,16 @@ CATEGORIES = {
     }
 }
 
 
 # We submit data to telemetry approximately every this many mach invocations
 TELEMETRY_SUBMISSION_FREQUENCY = 10
 
 
-def get_state_dir():
-    """Obtain the path to a directory to hold state.
-
-    Returns a tuple of the path and a bool indicating whether the value came
-    from an environment variable.
-    """
-    state_user_dir = os.path.expanduser('~/.mozbuild')
-    state_env_dir = os.environ.get('MOZBUILD_STATE_PATH', None)
-
-    if state_env_dir:
-        return state_env_dir, True
-    else:
-        return state_user_dir, False
-
-
 def bootstrap(topsrcdir, mozilla_dir=None):
     if mozilla_dir is None:
         mozilla_dir = topsrcdir
 
     # Ensure we are running Python 2.7+. We put this check here so we generate a
     # user-friendly error message rather than a cryptic stack trace on module
     # import.
     if sys.version_info[0] != 2 or sys.version_info[1] < 7:
@@ -208,16 +193,17 @@ def bootstrap(topsrcdir, mozilla_dir=Non
     # environment variable. We detect first run (by lack of this directory
     # existing) and notify the user that it will be created. The logic for
     # creation is much simpler for the "advanced" environment variable use
     # case. For default behavior, we educate users and give them an opportunity
     # to react. We always exit after creating the directory because users don't
     # like surprises.
     sys.path[0:0] = [os.path.join(mozilla_dir, path) for path in SEARCH_PATHS]
     import mach.main
+    from mozboot.util import get_state_dir
 
     def telemetry_handler(context, data):
         # We have not opted-in to telemetry
         if 'BUILD_SYSTEM_TELEMETRY' not in os.environ:
             return
 
         telemetry_dir = os.path.join(get_state_dir()[0], 'telemetry')
         try: