From 2f0ca38423d98b17acc765b6876d9d3769414064 Mon Sep 17 00:00:00 2001 From: skyostil Date: Fri, 17 Apr 2015 11:12:36 -0700 Subject: [PATCH] cr: Add 'gn' command The gn command lets you invoke gn without having to type the out directory manually, e.g. $ cr gn args instead of $ gn args out_linux/Debug Review URL: https://codereview.chromium.org/1092783006 Cr-Commit-Position: refs/heads/master@{#325678} --- tools/cr/cr/commands/gn.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tools/cr/cr/commands/gn.py diff --git a/tools/cr/cr/commands/gn.py b/tools/cr/cr/commands/gn.py new file mode 100644 index 000000000000..70d2d06eb185 --- /dev/null +++ b/tools/cr/cr/commands/gn.py @@ -0,0 +1,39 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""A module for the gn command.""" + +import os + +import cr + + +class GnCommand(cr.Command): + """The implementation of the gn command. + + The gn command is meant for running the gn tool without having to manually + specify an out directory. + """ + + def __init__(self): + super(GnCommand, self).__init__() + self.help = 'Run gn with the currently selected out directory' + self.description = (""" + Runs the gn command with the currently selected out directory as the + second argument. + """) + + def AddArguments(self, subparsers): + parser = super(GnCommand, self).AddArguments(subparsers) + self.ConsumeArgs(parser, 'gn') + return parser + + def Run(self): + out_path = os.path.join(cr.context['CR_SRC'], + cr.context['CR_OUT_FULL']) + args = cr.context.remains + if args: + cr.Host.Execute('gn', args[0], out_path, *args[1:]) + else: + cr.Host.Execute('gn') -- 2.11.4.GIT