Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: recipes.py

Issue 1570333002: 'recipes.py isolate' command to build an isolate of the current package's toolchain (Closed) Base URL: git@github.com:luci/recipes-py.git@master
Patch Set: moar review comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: recipes.py
diff --git a/recipes.py b/recipes.py
index 5f6a2091752e774da566aa7db97a8df0e558ab6b..270ba8dfecab027d6c5f04774f29e6acfd51318e 100755
--- a/recipes.py
+++ b/recipes.py
@@ -218,6 +218,36 @@ def info(args):
print package_spec.recipes_path
+def isolate(package_deps, args):
+ from recipe_engine import package
+
+ repo_root, config_file = get_package_config(args)
+ context = package.PackageContext.from_proto_file(repo_root, config_file)
+ base_path = package_deps.root_package.recipes_dir
+ def norm(p):
+ return os.path.relpath(p, base_path)
+ recipes_tool = norm(os.path.join(
+ package_deps.get_package('recipe_engine').recipes_dir,
+ 'recipes.py'))
+
+ overrides = sorted(
+ '-O %s=%s' % (k, norm(v)) for k, v in args.project_override.iteritems())
M-A Ruel 2016/01/16 23:30:48 Actually, you want ['-O', '%s=%s'] otherwise this
+
+ print json.dumps({
+ 'variables': {
+ 'files': sorted(
+ norm(f) for f in package_deps.root_package.all_files(context)),
+ 'command': [
+ 'python',
+ recipes_tool,
+ '--package',
+ norm(package_deps.root_package.repo_spec.proto_file(context).path),
+ '--no-fetch',
+ ] + overrides,
+ },
+ }, indent=2, separators=(',', ': '), sort_keys=True)
+
+
def main():
from recipe_engine import package
@@ -244,6 +274,7 @@ def main():
help='Path to the script used to bootstrap this tool (internal use only)')
parser.add_argument('-O', '--project-override', metavar='ID=PATH',
action=ProjectOverrideAction,
+ default={},
help='Override a project repository path with a local one.')
subp = parser.add_subparsers()
@@ -315,6 +346,12 @@ def main():
'--recipes-dir', action='store_true',
help='Get the subpath where the recipes live relative to repository root')
+ isolate_p = subp.add_parser(
+ 'isolate',
+ help='Write an isolate file to stdout for the recipe toolchain of the '
+ 'current project')
+ isolate_p.set_defaults(command='isolate')
+
args = parser.parse_args()
if args.verbose:
@@ -343,6 +380,8 @@ def main():
return doc(package_deps, args)
elif args.command == 'info':
return info(args)
+ elif args.command == 'isolate':
+ return isolate(package_deps, args)
else:
print """Dear sir or madam,
It has come to my attention that a quite impossible condition has come
« recipe_engine/package.py ('K') | « recipes.extra ('k') | unittests/errors_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698