diff options
author | Ari Hausman-Cohen <arihc@google.com> | 2015-11-16 19:22:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-11-16 19:22:24 +0000 |
commit | 82b16398ab56bfd27e816bb50409d30bfa94e087 (patch) | |
tree | dbc716e79d6a43b8285a253894cfad30b3324770 | |
parent | eaea07a3a71e32bb8c18cde53a3808a9e2cb45d7 (diff) | |
parent | e6861b5aa6d182938676d6381f8d645cbdae45ba (diff) | |
download | bdk-82b16398ab56bfd27e816bb50409d30bfa94e087.tar.gz |
Merge "Merging tools and core."
-rw-r--r-- | brunch/lib/DESIGN.md | 4 | ||||
-rw-r--r-- | brunch/lib/bsp/package.py | 2 | ||||
-rw-r--r-- | brunch/lib/bsp/status.py | 5 | ||||
-rw-r--r-- | brunch/lib/commands/product/build.py | 6 | ||||
-rw-r--r-- | brunch/lib/core/popen.py (renamed from brunch/lib/tools/popen.py) | 0 | ||||
-rw-r--r-- | brunch/lib/core/product.py | 4 | ||||
-rw-r--r-- | brunch/lib/core/product_templates.py | 8 | ||||
-rw-r--r-- | brunch/lib/core/util.py | 13 | ||||
-rw-r--r-- | brunch/lib/metrics/data_types/brillo_ga_hits.py | 4 | ||||
-rw-r--r-- | brunch/lib/metrics/data_types/generalized_ga/hit.py | 6 | ||||
-rw-r--r-- | brunch/lib/tools/__init__.py | 17 | ||||
-rw-r--r-- | brunch/lib/tools/bdk_root.py | 31 | ||||
-rw-r--r-- | brunch/lib/tools/setup.py | 58 |
13 files changed, 28 insertions, 130 deletions
diff --git a/brunch/lib/DESIGN.md b/brunch/lib/DESIGN.md index a579e1e..b305a81 100644 --- a/brunch/lib/DESIGN.md +++ b/brunch/lib/DESIGN.md @@ -5,11 +5,11 @@ brunch/ lib/ # python top level package cli/ # Cli package commands/ # Sub command logic + core/ # package for general tools and setup logic productspec/ # package for product spec logic metrics/ # package for metrics bsp/ # package for bsp downloading - tools/ # package for helpers - product # package for product managment + product/ # package for product managment brunch.py # main python entry point brunch # shell script entry point diff --git a/brunch/lib/bsp/package.py b/brunch/lib/bsp/package.py index af562f2..6f9490d 100644 --- a/brunch/lib/bsp/package.py +++ b/brunch/lib/bsp/package.py @@ -26,7 +26,7 @@ import sys import uuid import status -from tools import popen +from core import popen PACKAGE_KEY_TYPE = 'package_type' PACKAGE_KEY_NAME = 'name' diff --git a/brunch/lib/bsp/status.py b/brunch/lib/bsp/status.py index d10fc8d..07fac7a 100644 --- a/brunch/lib/bsp/status.py +++ b/brunch/lib/bsp/status.py @@ -18,8 +18,7 @@ import os import package as package_types -from tools import bdk_root -from tools import popen +from core import util # Statuses should be numbered low to high, where a higher status # of a single package within a BSP dominates a lower status @@ -53,7 +52,7 @@ def CheckDeviceStatus(device_manifest): INSTALLED if the BSP has no packages. """ status = INSTALLED - install_root = bdk_root.BDKRoot() + install_root = util.GetBDKPath() for package in device_manifest["packages"]: status = max(status, package.Status(install_root)) diff --git a/brunch/lib/commands/product/build.py b/brunch/lib/commands/product/build.py index 016134c..aa9d236 100644 --- a/brunch/lib/commands/product/build.py +++ b/brunch/lib/commands/product/build.py @@ -42,7 +42,7 @@ class Build(clicommand.Command): help='Arguments to pass through to make') def Run(self, args): - sdk_path = util.GetBDKPath() + sdk_path = util.GetDevToolsPath() store = config.ProductFileStore(args.product_path) @@ -72,14 +72,14 @@ class Build(clicommand.Command): if args.submodule == True: print "Building submodule only . . ." - ret = os.system('make -f %s/tools/bdk/build/wrap-product.mk %s ' \ + ret = os.system('make -f %s/build/wrap-product.mk %s ' \ 'HERE="%s" ENVCMD=mm BUILDTYPE=%s %s' % (sdk_path, no_java, os.getcwd(), args.buildtype, util.AsShellArgs(args.make_args))) envcmd = 'mm' else: # Change to the product path and build the whole product. - ret = os.system('cd %s;make -f %s/tools/bdk/build/wrap-product.mk %s BUILDTYPE=%s %s' % + ret = os.system('cd %s;make -f %s/build/wrap-product.mk %s BUILDTYPE=%s %s' % (args.product_path, sdk_path, no_java, args.buildtype, util.AsShellArgs(args.make_args))) diff --git a/brunch/lib/tools/popen.py b/brunch/lib/core/popen.py index 10b4cbe..10b4cbe 100644 --- a/brunch/lib/tools/popen.py +++ b/brunch/lib/core/popen.py diff --git a/brunch/lib/core/product.py b/brunch/lib/core/product.py index 1e64e78..88333a7 100644 --- a/brunch/lib/core/product.py +++ b/brunch/lib/core/product.py @@ -142,7 +142,9 @@ class Environment(object): """Generates a file which will run brunch product envsetup""" bdk_path = util.GetBDKPath() bdk_version = util.GetBDKVersion() + tools_path = util.GetDevToolsPath() with open(os.path.join(self._product_dir, 'envsetup.sh'), 'w') as f: f.write(product_templates.ENVSETUP.substitute( self._config.dict(), bdk_path=bdk_path, - product_path=self._product_dir)) + product_path=self._product_dir, + tools_path=tools_path)) diff --git a/brunch/lib/core/product_templates.py b/brunch/lib/core/product_templates.py index 27df9bc..0f46a27 100644 --- a/brunch/lib/core/product_templates.py +++ b/brunch/lib/core/product_templates.py @@ -110,10 +110,9 @@ ENVSETUP = string.Template("""\ _envsetup_load() { # Allow the environment to override the BDK path. local bdk="$${BDK_PATH:-${bdk_path}}" - if ! test -x "$${bdk}/tools/bdk/brunch/brunch"; then + if ! test -e "$${bdk}/build/core/main.mk"; then echo "The BDK cannot be found." 1>&2 - echo "Please supply its path in the BDK_PATH environment variable or " 1>&2 - echo "run 'brunch product reconfig'" 1>&2 + echo "Please supply its path in the BDK_PATH environment variable." 1>&2 return 1 fi @@ -137,9 +136,10 @@ _envsetup_load() { fi # Find a free file descriptor and use it rather than a tempfile. + local bdk_tools="$${BDK_TOOLS_PATH:-${tools_path}}" fd=$$((`ls /dev/fd/ | sort -n | tail -1` + 1)) eval 'exec '$$fd'<<EOFEOF - $$($${bdk}/tools/bdk/brunch/brunch product envsetup \\ + $$($${bdk_tools}/brunch/brunch product envsetup \\ --product_path="$${product_path}") EOFEOF' . /dev/fd/$$fd diff --git a/brunch/lib/core/util.py b/brunch/lib/core/util.py index f2d5b7d..f825a4a 100644 --- a/brunch/lib/core/util.py +++ b/brunch/lib/core/util.py @@ -41,11 +41,20 @@ def GetBrunchConfigDir(): _BRUNCH_BASE = path return path -def GetBDKPath(): +def GetBDKPath(relpath = None): """Find the base of the BDK""" core_path = os.path.dirname(core.__file__) - return os.path.abspath(os.path.join(core_path, + result = os.path.abspath(os.path.join(core_path, '..', '..', '..', '..', '..')) + if relpath: + result = os.path.join(result, relpath) + return result + +def GetDevToolsPath(relpath = None): + result = GetBDKPath('tools/bdk') + if relpath: + result = os.path.join(result, relpath) + return result USER_DB = os.path.join(GetBrunchConfigDir(), 'config.db') METRICS_DB = os.path.join(GetBrunchConfigDir(), 'metrics.db') diff --git a/brunch/lib/metrics/data_types/brillo_ga_hits.py b/brunch/lib/metrics/data_types/brillo_ga_hits.py index c597b74..293d853 100644 --- a/brunch/lib/metrics/data_types/brillo_ga_hits.py +++ b/brunch/lib/metrics/data_types/brillo_ga_hits.py @@ -29,10 +29,8 @@ import platform import generalized_ga from core import util from core import config -from tools import bdk_root -# TODO(arihc)(b/24873929): BDK might not be in tools/bdk in the future. -_BDK_VERSION_FILE = bdk_root.FromBDKRoot('tools/bdk/VERSION') +_BDK_VERSION_FILE = util.GetDevToolsPath('VERSION') _BRILLO_APP_ID = 'UA-67119306-1' _BRILLO_APP_NAME = 'brunch' diff --git a/brunch/lib/metrics/data_types/generalized_ga/hit.py b/brunch/lib/metrics/data_types/generalized_ga/hit.py index b7f5d8b..293aa58 100644 --- a/brunch/lib/metrics/data_types/generalized_ga/hit.py +++ b/brunch/lib/metrics/data_types/generalized_ga/hit.py @@ -23,8 +23,7 @@ additional fields as necessary. import urllib -from tools import bdk_root -from tools import popen +from core import popen class Hit(object): """An abstract class for Analytics hit details. @@ -62,9 +61,6 @@ class Hit(object): def GetFields(self): """Returns all fields as a dictionary of { param : value }.""" - # TODO(arihc): remove this, support for grandfathered saved data - if not hasattr(self, 'app_name'): - self.app_name = 'brunch' params = {'v' : self.version, 'tid' : self.app_id, 'an' : self.app_name, diff --git a/brunch/lib/tools/__init__.py b/brunch/lib/tools/__init__.py deleted file mode 100644 index c6e55b5..0000000 --- a/brunch/lib/tools/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (C) 2015 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -"""Tools for other Brunch modules.""" diff --git a/brunch/lib/tools/bdk_root.py b/brunch/lib/tools/bdk_root.py deleted file mode 100644 index 4d5bc7e..0000000 --- a/brunch/lib/tools/bdk_root.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (C) 2015 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -"""Finds the root of a bdk installation.""" - -import os - -def BDKRoot(): - """Returns the directory at the top of the source tree.""" - path = os.path.realpath(__file__) - # TODO(arihc)(b/24873929): adjust this function for when brunch - # is external to the bdk. - while not os.path.isdir(os.path.join(path, "tools/bdk")): - (path, _) = os.path.split(path) - return path - -def FromBDKRoot(path): - """Returns an absolute path given a path relative to BDK root.""" - return os.path.join(BDKRoot(), path) diff --git a/brunch/lib/tools/setup.py b/brunch/lib/tools/setup.py deleted file mode 100644 index 9e96d14..0000000 --- a/brunch/lib/tools/setup.py +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (C) 2015 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -"""A script that sets up the BDK. A small early piece of install.""" - -import sys -import uuid - -from core import config -from metrics import send_hits - -def SetUp(): - """Sets up necessary pieces of the BDK. - - This is currently designed so that it can be called multiple times - without causing a failure. - """ - # Basic folder setup - user_config = config.UserStore() - - # Get opt in for metrics if it's not set - if not user_config.metrics_opt_in: - # Check for opt in - print ("To help improve the quality of this product, we collect\n" - "anonymized data on how the BDK is used. You may choose to opt out\n" - "of this collection now (by choosing 'N' at the below prompt),\n" - "or at any point in the future by running the following command:\n" - " brunch config metrics disable") - opt_in = None - while opt_in is None: - print 'Do you want to help improve the Project Brillo BDK?' - print '(Y/n) ', - sys.stdout.flush() - choice = sys.stdin.readline().strip().upper() - if not choice or choice == 'Y': - opt_in = True - elif choice == 'N': - opt_in = False - user_config.metrics_opt_in = opt_in - - # Generate a user id if it's not set - if not user_config.uid: - user_config.uid = str(uuid.uuid4()) - -if __name__ == '__main__': - SetUp() |