# 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 = [
  'ca_main.c',
  'CCallbackObjectExample.c',
  'smci_example_app.c',
]

# The name of the TA to load is defined as EXAMPLE_TA_NAME. We also need to define
# the name of our service TA here.

example_ta_name         = 'smcinvoke_example_ta' + ['32', '64'][env.Is64BitImage()]
example_service_ta_name = 'smcinvoke_example_svc_ta' + ['32', '64'][env.Is64BitImage()]

env.Append(CPPDEFINES='EXAMPLE_TA_NAME=\\"{}\\"'.format(example_ta_name))
env.Append(CPPDEFINES='EXAMPLE_SERVICE_TA_NAME=\\"{}\\"'.format(example_service_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_example_ca',
)

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

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

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