aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAri Hausman-Cohen <arihc@google.com>2016-04-18 16:05:27 -0700
committerAri Hausman-Cohen <arihc@google.com>2016-04-19 20:00:58 +0000
commitc357ad7a2fa25390e25497a199028bd118075004 (patch)
tree6e83236bfa434610d58f015d399f8e7ca068e9a6
parent7d2918e6efb0936eb1c45980451678f625b4f638 (diff)
downloadbdk-c357ad7a2fa25390e25497a199028bd118075004.tar.gz
Easier to change Makefile.
The example Makefile from bdk environment setup now sets just 3 variables at the top (BDK, DEVICE, OS) that the user might need to change, preventing the need to change these in multiple places. This is particularly useful for sharing a Makefile between collaborators, as one only needs to change the path to their BDK command. BUG: 27747562 Change-Id: I3533fb36f9217618b0f0212178372db64297a093 TEST: unit tests pass
-rw-r--r--cli/lib/commands/v2/environment/setup.py29
-rw-r--r--cli/lib/core/util.py3
-rw-r--r--cli/lib/project/target.py9
3 files changed, 23 insertions, 18 deletions
diff --git a/cli/lib/commands/v2/environment/setup.py b/cli/lib/commands/v2/environment/setup.py
index af88bed..afe693b 100644
--- a/cli/lib/commands/v2/environment/setup.py
+++ b/cli/lib/commands/v2/environment/setup.py
@@ -29,9 +29,15 @@ from environment import sysroot_util
from environment import toolchain_util
+# Note: this should be kept in sync with project.target.PLATFORM_CACHE_FORMAT
SAMPLE_MAKEFILE_TEMPLATE = """\
-SYSROOT="{sysroot}"
-TOOLCHAIN="{toolchain}"
+BDK={bdk_command}
+DEVICE={board}.{board_version}
+OS={os}.{os_version}
+
+PLATFORM_CACHE:=$(shell $(BDK) config check platform_cache)/$(OS)/$(DEVICE)
+SYSROOT=$(PLATFORM_CACHE)/sysroot
+TOOLCHAIN=$(PLATFORM_CACHE)/toolchain
PKG_CONFIG_VARS=PKG_CONFIG_LIBDIR="$(SYSROOT)/usr/share/pkgconfig"\
PKG_CONFIG_SYSROOT_DIR="$(SYSROOT)"
@@ -58,20 +64,14 @@ class Setup(clicommand.Command):
@staticmethod
def Args(parser):
Setup.AddProductArgs(parser)
+ # TODO(b/28249627): This should be removed and replaced by some form
+ # of config.
parser.add_argument('--pkgconfig_csv',
help='The path to a csv file describing packages '
'for the sysroot (default {}).'.format(
util.GetBDKPath('pkgconfig', 'packages.csv')),
default=util.GetBDKPath('pkgconfig',
'packages.csv'))
- parser.add_argument('--sysroot_dir',
- help='The directory to generate the sysroot in. '
- '(default {}/sysroot).'.format(
- util.PLATFORM_CACHE_FORMAT))
- parser.add_argument('--toolchain_dir',
- help='The directory to generate the toolchain in. '
- '(default {}/toolchain).'.format(
- util.PLATFORM_CACHE_FORMAT))
def Run(self, args):
"""Sets up a sysroot and toolchain."""
@@ -118,9 +118,8 @@ class Setup(clicommand.Command):
board_packages = util.GetOSPath(target.os_version,
'device', device_.vendor, target.board,
'developer', 'packages.csv')
- sysroot_path = args.sysroot_dir or target.platform_cache('sysroot')
- toolchain_path = (args.toolchain_dir or
- target.platform_cache('toolchain'))
+ sysroot_path = target.platform_cache('sysroot')
+ toolchain_path = target.platform_cache('toolchain')
ret = 0
# Generate the sysroot.
@@ -172,6 +171,8 @@ class Setup(clicommand.Command):
if not ret:
print('Finished building environment.')
print('Sample Makefile:\n\n' + SAMPLE_MAKEFILE_TEMPLATE.format(
- sysroot=sysroot_path, toolchain=toolchain_path))
+ bdk_command=util.GetBDKPath('cli/bdk'), os=target.os,
+ os_version=target.os_version, board=target.board,
+ board_version=target.board_version))
return ret
diff --git a/cli/lib/core/util.py b/cli/lib/core/util.py
index a9ecd5c..4b01fe7 100644
--- a/cli/lib/core/util.py
+++ b/cli/lib/core/util.py
@@ -42,9 +42,6 @@ class OSVersionError(Error):
ANDROID_PRODUCTS_MK = 'AndroidProducts.mk'
PROJECT_SPEC_FILENAME = 'project.xml'
-PLATFORM_CACHE_FORMAT = os.path.join('{user_configured_platform_cache}',
- '{os}.{os_version}',
- '{board}.{board_version}')
def GetBDKPath(*relpath_args):
diff --git a/cli/lib/project/target.py b/cli/lib/project/target.py
index 3ad4306..9a28d65 100644
--- a/cli/lib/project/target.py
+++ b/cli/lib/project/target.py
@@ -25,6 +25,13 @@ from core import util
from project import common
+# Note: this should be kept in sync with
+# commands.environment.setup.SAMPLE_MAKEFILE_TEMPLATE
+PLATFORM_CACHE_FORMAT = os.path.join('{user_configured_platform_cache}',
+ '{os}.{os_version}',
+ '{board}.{board_version}')
+
+
class Error(common.Error):
"""General Error for targets."""
@@ -139,7 +146,7 @@ class Target(object):
return board
def platform_cache(self, *relpath):
- return os.path.join(util.PLATFORM_CACHE_FORMAT.format(
+ return os.path.join(PLATFORM_CACHE_FORMAT.format(
user_configured_platform_cache=user_config.USER_CONFIG.platform_cache,
os=self.os,
os_version=self.os_version,