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

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

# Check if current architecture to be built for TA is supported on
# current target or not.
if not env.UserModePreferredArchitecture():
  print("Not building unneeded architecture: ", env["PROC"])
  Return()

# TA output binary will be called 'skeleton_cpp_ta32' or 'skeleton_cpp_ta64'
target = 'skeleton_cpp_ta' + ['32', '64'][env.Is64BitImage()]

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

sources = [
  'ta_main.cpp',
]

md = {
  'appName':      target,
  'privileges': [ 'default' ],
}

# Use the QTEE SDK Builder for TAs
app = env.SecureAppBuilder(
  sources   = sources,
  includes  = includes,
  metadata  = md,
  # 'image' is the name used for the output .so/mbn file
  image     = target,
)

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

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