#######################################################
#	Build TCP adapter
#######################################################
import os

Import('connectivity_env')

print "Reading TCP adapter script"

target_os = connectivity_env.get('TARGET_OS')
src_dir = os.path.abspath(os.curdir)

# Source files to build common for all platforms
common_files = [os.path.join(src_dir, 'catcpadapter.c')]
if target_os in ['linux', 'tizen', 'android', 'ios', 'windows']:
    common_files.append(os.path.join(src_dir, 'catcpserver.c'))

connectivity_env.AppendUnique(CA_SRC = common_files)

# Get list of target-specific source file base names, i.e. no parent
# directories prepended to the path.
#
# Target-specific SConscript files are expected to return that list.

# Check for the existence of the platform-specific SConscript file
# relative to the top-level source directory, not the build (variant)
# directory, before calling that SConscript file to prevent a missing
# file warning platforms that don't provide one.
target_sconscript = target_os + '/SConscript'
if os.path.exists(target_sconscript):
    SConscript(target_sconscript, exports='connectivity_env')
