Bug 1279564 - Use get_state_dir() from mozboot; r=glandium
Import mozboot.util and use the function from there.
MozReview-Commit-ID: B0uzpNff1t9
--- 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: