Bug 1474869 - Move taskgraph cache files to topsrcdir/.cache.
MozReview-Commit-ID: HHpygzkD3VF
--- a/.hgignore
+++ b/.hgignore
@@ -181,8 +181,11 @@ subinclude:servo/.hgignore
# https://bz.mercurial-scm.org/show_bug.cgi?id=5322
^comm/
# Ignore various raptor performance framework files
^testing/raptor/.raptor-venv
^testing/raptor/raptor-venv
^testing/raptor/raptor/tests/.*.json
^testing/raptor/webext/raptor/auto_gen_test_config.js
+
+# Ignore tryselect cache
+^.cache/
--- a/tools/tryselect/preset.py
+++ b/tools/tryselect/preset.py
@@ -3,20 +3,22 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import ConfigParser
import os
import subprocess
-from mozboot.util import get_state_dir
+from mozbuild.base import MozbuildObject
-CONFIG_PATH = os.path.join(get_state_dir()[0], "autotry.ini")
+here = os.path.abspath(os.path.dirname(__file__))
+build = MozbuildObject.from_environment(cwd=here)
+CONFIG_PATH = os.path.join(build.topsrcdir, ".cache", "autotry.ini")
def list_presets(section=None):
config = ConfigParser.RawConfigParser()
data = []
if config.read([CONFIG_PATH]):
sections = [section] if section else config.sections()
@@ -58,12 +60,15 @@ def save(section, name, data):
config = ConfigParser.RawConfigParser()
config.read([CONFIG_PATH])
if not config.has_section(section):
config.add_section(section)
config.set(section, name, data)
+ if not os.path.isfile(CONFIG_PATH):
+ if not os.path.isdir(os.path.dirname(CONFIG_PATH)):
+ os.makedirs(os.path.dirname(CONFIG_PATH))
with open(CONFIG_PATH, "w") as f:
config.write(f)
print('preset saved, run with: --preset={}'.format(name))
--- a/tools/tryselect/tasks.py
+++ b/tools/tryselect/tasks.py
@@ -2,17 +2,16 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
-from mozboot.util import get_state_dir
from mozbuild.base import MozbuildObject
from mozpack.files import FileFinder
import taskgraph
from taskgraph.generator import TaskGraphGenerator
from taskgraph.parameters import (
ParameterMismatch,
load_parameters_file,
@@ -44,17 +43,17 @@ def invalidate(cache, root):
if tmod > cmod:
os.remove(cache)
def generate_tasks(params, full, root):
params = params or "project=mozilla-central"
- cache_dir = os.path.join(get_state_dir()[0], 'cache', 'taskgraph')
+ cache_dir = os.path.join(build.topsrcdir, '.cache', 'taskgraph')
attr = 'full_task_set' if full else 'target_task_set'
cache = os.path.join(cache_dir, attr)
invalidate(cache, root)
if os.path.isfile(cache):
with open(cache, 'r') as fh:
return fh.read().splitlines()
--- a/tools/tryselect/test/setup.sh
+++ b/tools/tryselect/test/setup.sh
@@ -1,18 +1,19 @@
export topsrcdir=$TESTDIR/../../../
export MOZBUILD_STATE_PATH=$TMP/mozbuild
+mkdir -p $MOZBUILD_STATE_PATH
export MACHRC=$TMP/machrc
cat > $MACHRC << EOF
[try]
default=syntax
EOF
-cachedir=$MOZBUILD_STATE_PATH/cache/taskgraph
+cachedir=$topsrcdir/.cache/taskgraph
mkdir -p $cachedir
cat > $cachedir/target_task_set << EOF
test/foo-opt
test/foo-debug
build-baz
EOF