# Product Type definitions
#
# NOTE: After changing this file, be sure to update 'product_defs.mk':
#     python product_defs.py > product_defs.mk
# And check-in the updated 'product_defs.mk' to source control.

# PLATFORM determines which of the make/<PLATFORM>_defs.mk file gets used.

params = ['PLATFORM','ARCH','CONFIG_ES','KVERS','HW_PLAT']
product_types = {
    'android': {
        'PLATFORM':'android',
        'ARCH':'arm',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'ios': {
        'PLATFORM':'ios',
        'ARCH':'multi',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'linux': {
        'PLATFORM':'linux',
        'ARCH':'x86',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'linux_emb': {
        'PLATFORM':'linux_emb',
        'ARCH':'mips',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'linux_ol': {
        'PLATFORM':'linux',
        'ARCH':'x86',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'msvc': {
        'PLATFORM':'msvc',
        'ARCH':'multi',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'winrt': {
        'PLATFORM':'msvc',
        'ARCH':'multi',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'woa': {
        'PLATFORM':'msvc',
        'ARCH':'multi',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
    'cloudnode': {
        'PLATFORM':'cloudnode',
        'ARCH':'arm',
        'CONFIG_ES':'ul',
        'KVERS':'na',
        'HW_PLAT':'na'
    },
}
# End Product Type definitions

# Output make functions to manage variables derived from product type
alpha_products = [p for p in product_types]
alpha_products.sort()
print '## This file is generated by product_defs.py, DO NOT EDIT!'
print ''
print 'PRODUCT_VARS := %s' % (str.join(' ', params))
print ''
print '# Arguments: <product type> <param variable name prefix>'
print '# Calling this function causes the variables <prefix><param>, for each product parameter,'
print '#   to be defined with values corresponding to the product type.  E.g. after'
print '#   $(eval $(call setParamsFromProduct,linux,FOO_)) the variable FOO_PLATFORM is linux.'
print 'define setParamsFromProduct'
for pt in alpha_products:
    print 'ifeq ($(1),%s)' % (pt)
    for param in params:
        print '$(2)%s := %s' % (param, product_types[pt][param])
    print 'endif'
print 'ifndef $(2)%s' % (params[0])
print 'define ENDL'
print ''
print ''
print 'endef'
print '$$(error Invalid product type "$(1)".$$(ENDL)Please set environment variable "PRODUCT" to be one of:$$(ENDL)%s)' % \
    (str.join('', ['  ' + prod + '$$(ENDL)' for prod in alpha_products]))

print 'endif'
print 'endef'
