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

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

includes = [
  '../../TA/inc', #skeleton_cppapp.h
]

sources = [
  'ca_main.cpp',
]

# The name of the TA to load is defined as SKELETON_TA_NAME
skeleton_ta_name = 'skeleton_cpp_ta' + ['32', '64'][env.Is64BitImage()]
env.Append(CPPDEFINES='SKELETON_TA_NAME=\\"{}\\"'.format(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 = 'skeleton_cpp_ca',
)

# Add an alias so that the CA can be built by specifying 'skeleton_ca' on the command line
env.Alias('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')
