Add TARGET_PLATFORM_VERSION to lunch

lunch can now take combos in the form:
$TARGET_PRODUCT
$TARGET_PRODUCT-$TARGET_BUILD_VARIANT
$TARGET_PRODUCT-$TARGET_BUILD_VARIANT-$TARGET_PLATFORM_VERSION

If all 3 are not specified the unspecified ones will take the
default values provided by the build system (eng, and currently
OPR1).

In addition, error handling for invalid products, variants and
versions is moved to the build system.

Bug: 34972208
Test: build/make/tests/envsetup_tests.sh
Change-Id: Ib0aaa98633448ba9bd8df911704c9cb3a8ebbe85
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 3e3b6f0..62e5499 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -58,6 +58,8 @@
 ALL_VERSIONS := O P
 ALL_VERSIONS := $(foreach v,$(ALL_VERSIONS),$(call version-list,$(v)))
 
+DEFAULT_PLATFORM_VERSION := OPR1
+
 # HACK: forward P to PPR1 until the build server config is updated
 ifeq (P,$(TARGET_PLATFORM_VERSION))
   TARGET_PLATFORM_VERSION := PPR1
@@ -67,7 +69,7 @@
   # Default targeted platform version
   # TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional
   # on this
-  TARGET_PLATFORM_VERSION := OPR1
+  TARGET_PLATFORM_VERSION := $(DEFAULT_PLATFORM_VERSION)
 endif
 
 ifeq (,$(filter $(ALL_VERSIONS), $(TARGET_PLATFORM_VERSION)))