From ce7f8dd15ad582899b3f694aeb0bb2097de9b94c Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Tue, 25 Jul 2017 00:57:38 -0700 Subject: [PATCH] Run `uname -sm` once, don't use python for HOST_OS_EXTRA This saves 20-50ms for `lunch` (~7-10%), and double that for every build execution. Test: Check HOST_OS_EXTRA on Linux & Mac Change-Id: I863200b2287c8867f40606237895b1d3ad91e1b3 --- core/config.mk | 2 ++ core/envsetup.mk | 12 +++++++++--- core/version_defaults.mk | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/config.mk b/core/config.mk index dbfcc62a04..7d4581d430 100644 --- a/core/config.mk +++ b/core/config.mk @@ -71,6 +71,8 @@ $(warning The build system needs unmodified output of grep.) $(error Please remove --color=always from your $$GREP_OPTIONS) endif +UNAME := $(shell uname -sm) + SRC_TARGET_DIR := $(TOPDIR)build/target SRC_API_DIR := $(TOPDIR)prebuilts/sdk/api SRC_SYSTEM_API_DIR := $(TOPDIR)prebuilts/sdk/system-api diff --git a/core/envsetup.mk b/core/envsetup.mk index 46066e3462..d17e9e05c7 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -97,8 +97,6 @@ endif # compiles except for arm/mips, so the HOST is whatever we are # running on -UNAME := $(shell uname -sm) - # HOST_OS ifneq (,$(findstring Linux,$(UNAME))) HOST_OS := linux @@ -110,7 +108,15 @@ ifneq (,$(findstring Macintosh,$(UNAME))) HOST_OS := darwin endif -HOST_OS_EXTRA:=$(shell python -c "import platform; print(platform.platform())") +HOST_OS_EXTRA := $(shell uname -rsm) +ifeq ($(HOST_OS),linux) + ifneq ($(wildcard /etc/os-release),) + HOST_OS_EXTRA += $(shell source /etc/os-release; echo $$PRETTY_NAME) + endif +else ifeq ($(HOST_OS),darwin) + HOST_OS_EXTRA += $(shell sw_vers -productVersion) +endif +HOST_OS_EXTRA := $(subst $(space),-,$(HOST_OS_EXTRA)) # BUILD_OS is the real host doing the build. BUILD_OS := $(HOST_OS) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 5a89fc97d4..3506fff6e5 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -212,7 +212,7 @@ ifndef BUILD_DATETIME BUILD_DATETIME := $(shell date +%s) endif -ifneq (,$(findstring Darwin,$(shell uname -sm))) +ifneq (,$(findstring Darwin,$(UNAME))) DATE := date -r $(BUILD_DATETIME) else DATE := date -d @$(BUILD_DATETIME)