#===============================================================================
#
# SMD Libs
#
# GENERAL DESCRIPTION
#    build script
#
# Copyright (c) 2009-2010 by QUALCOMM, Incorporated.
# All Rights Reserved.
# QUALCOMM Proprietary/GTDR
#
#-------------------------------------------------------------------------------
#
#  $Header: //source/qcom/qct/core/mproc/smd/rel/2h09/build/SConscript#3 $
#  $DateTime: 2010/10/27 12:17:41 $
#  $Author: rsalas $
#  $Change: 1495307 $
#                      EDIT HISTORY FOR FILE
#
#  This section contains comments describing changes made to the module.
#  Notice that changes are listed in reverse chronological order.
#
# when       who     what, where, why
# --------   ---     ---------------------------------------------------------
# 10/13/10   rs      Removed SMD Port Manager API
# 10/04/10   ih/esh  Added LDM8/STM8 memcpy optimizations
#                    Cleaned up make targets
# 02/10/10   rs      Added smd_bridge_target.c
# 05/06/09   wd      Create
#
#===============================================================================
from copy import deepcopy

Import('env')
env = env.Clone()

#-------------------------------------------------------------------------------
# Source PATH
#-------------------------------------------------------------------------------
SRCPATH = "${BUILD_ROOT}/core/mproc/smd"

env.VariantDir('${BUILDPATH}', SRCPATH, duplicate=0)

#-------------------------------------------------------------------------------
# External depends within CoreBSP
#-------------------------------------------------------------------------------
env.RequireExternalApi([
   'CS',
   'DSM',
   'MODEM_DATA',
   'MODEM_HDR',
   'MODEM_PMIC',
   'MODEM_RF',
   'MODEM_SERVICES',
])

#-------------------------------------------------------------------------------
# Internal depends within CoreBSP
#-------------------------------------------------------------------------------
CBSP_API = [
   'BOOT',
   'DEBUGTOOLS',
   'HAL',
   'DAL',
   'HWENGINES',
   'MPROC',
   'POWER',
   'SERVICES',
   'SYSTEMDRIVERS',
   'WIREDCONNECTIVITY',

   # needs to be last also contains wrong comdef.h
   'KERNEL',   
]

env.RequirePublicApi(CBSP_API)
env.RequireRestrictedApi(CBSP_API)

#-------------------------------------------------------------------------------
# Sources, libraries
#-------------------------------------------------------------------------------
SMD_CORE = [
   '${BUILDPATH}/smd.c',
   '${BUILDPATH}/smd_bridge_target.c',
   '${BUILDPATH}/smd_bridge_client.c',
   '${BUILDPATH}/smd_bridge_server.c',
   '${BUILDPATH}/smd_internal.c',
   '${BUILDPATH}/smd_main.c',
   '${BUILDPATH}/smd_sio.c',
   '${BUILDPATH}/smd_rex.c',
   '${BUILDPATH}/smd_dsm.c',
   '${BUILDPATH}/smd_block.c',
   '${BUILDPATH}/smd_target.c'
]

SMD_MEMCPY = [
   '${BUILDPATH}/smd_dsm_memcpy.c',
   '${BUILDPATH}/smd_memcpy.c',
   '${BUILDPATH}/smd_dmov_stubs.c',
   '${BUILDPATH}/smd_packet_memcpy.c',
]

SMD_MEMCPY_MODEM = deepcopy(SMD_MEMCPY)
if env['MSM_ID'] == '7x30':
    SMD_MEMCPY_MODEM += [ '${BUILDPATH}/smd_memcpy_arm.c',
                    '${BUILDPATH}/smd_memcpy_arm_asm.s',
    ]

SMD_DM = [
   '${BUILDPATH}/smd_dsm_dm.c',
   '${BUILDPATH}/smd_dmov.c',
   '${BUILDPATH}/smd_memcpy_stubs.c'
]

SMD_SOURCES = [
   '${BUILDPATH}/smd_dsm_dm.c',
   '${BUILDPATH}/smd_dmov.c',
   '${BUILDPATH}/smd_dsm_memcpy.c',
   '${BUILDPATH}/smd_memcpy.c'
]

SMD_BLOCK_TEST_SOURCES = [
   '${BUILDPATH}/smd_block_test.c'
]

#-------------------------------------------------------------------------------
# Build or pull pre-build smd_memcpy library depending on STRIP / ODM
#-------------------------------------------------------------------------------
if env.has_key('USES_NO_STRIP_NO_ODM'):
   smd_memcpy = env.Library('${BUILDPATH}/smd_memcpy', SMD_MEMCPY)
else:
   smd_memcpy = File(env.subst("${BUILDPATH}/smd_memcpy${LIBSUFFIX}"))

if env.has_key('USES_NO_STRIP_NO_ODM'):
   smd_memcpy_modem = env.Library('${BUILDPATH}/smd_memcpy_modem', SMD_MEMCPY_MODEM)
else:
   smd_memcpy_modem = File(env.subst("${BUILDPATH}/smd_memcpy_modem${LIBSUFFIX}"))

#-------------------------------------------------------------------------------
# Build or pull pre-build smd_core library depending on STRIP / ODM
#-------------------------------------------------------------------------------
if env.has_key('USES_NO_STRIP_NO_ODM'):
   smd_core = env.Library('${BUILDPATH}/smd_core', SMD_CORE)
else:
   smd_core = File(env.subst("${BUILDPATH}/smd_core${LIBSUFFIX}"))

#-------------------------------------------------------------------------------
# Build or pull pre-build smd_dm library depending on STRIP / ODM
#-------------------------------------------------------------------------------
if env.has_key('USES_NO_STRIP_NO_ODM'):
   smd_dm = env.Library('${BUILDPATH}/smd_dm', SMD_DM)
else:
   smd_dm = File(env.subst("${BUILDPATH}/smd_dm${LIBSUFFIX}"))

#-------------------------------------------------------------------------------
# Build or pull pre-build smd library depending on STRIP / ODM
#-------------------------------------------------------------------------------
if env.has_key('USES_NO_STRIP_NO_ODM'):
   smd = env.Library('${BUILDPATH}/smd', SMD_SOURCES)
else:
   smd = File(env.subst("${BUILDPATH}/smd${LIBSUFFIX}"))


#-------------------------------------------------------------------------------
# Add Libraries to image
#-------------------------------------------------------------------------------

env.AddLibsToImage(['APPS_IMAGE', 'CBSP_APPS_IMAGE'], [smd_core, smd_memcpy])
env.AddLibsToImage(['MODEM_IMAGE', 'CBSP_MODEM_IMAGE'], [smd_core, 
    smd_memcpy_modem])   
   