# Copyright (c) 2019-2020 Qualcomm Technologies, Inc.
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.

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

includes = [
  '../../common/idl',
  '../../common/inc',
  '../inc',
]

sources = [
  'smci_ca_main.cpp',
  'smci_skeleton.cpp'
]

# The name of the TA to load is defined as SMCI_SKELETON_TA_NAME
SMCI_SKELETON_TA_NAME = 'smcinvoke_skeleton_cpp_ta' + ['32', '64'][env.Is64BitImage()]
env.Append(CPPDEFINES='SMCI_SKELETON_TA_NAME=\\"{}\\"'.format(SMCI_SKELETON_TA_NAME))

# TA_INSTALL_PATH is added to the env in the calling SConstruct.
env.Append(CPPDEFINES='TA_PATH_DEFINE=\\"{}\\"'.format(env['TA_INSTALL_PATH']))

#Use the QTEE SDK Builder for offtarget CAs
app = env.OfftargetClientAppBuilder(
  includes = includes,
  sources = sources,
  # 'image' is the name used for the output .elf file
  image = 'smcinvoke_skeleton_cpp_ca',
)

# Add an alias so that the CA can be built by specifying 'smcinvoke_skeleton_cpp_ca' on the command line
env.Alias('smcinvoke_skeleton_cpp_ca', app)

# Declare which TAs the CA depends on
env.Depends(app, env.Alias('installed_ta'))

# Return the CA binary for higher level SConscripts to reference
Return('app')
