1# pylint:disable=I0011,W0401,W0614,C0103,E0602 2############################################################################ 3# Copyright 2017 Intel Corporation 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16############################################################################ 17"""Build configuration for tiny member library. 18""" 19Import('*') 20env.PartName('member') 21 22default_build_mode = 'static' 23 24include_files = Pattern(src_dir='.', includes=['*.h'], recursive=False).files() 25 26src_files = Pattern( 27 src_dir='tiny/src', includes=['*.c'], recursive=False).files() 28 29install_files = Pattern( 30 src_dir='tiny', 31 includes=[ 32 '*.h', '*.c', '*-test.cc', '*-testhelper.cc', '*-testhelper.h', 33 '*.parts', 'Makefile' 34 ], 35 excludes=['*/platform_specific*/'], 36 recursive=True) 37 38if 'install_package' in env['MODE']: 39 env.InstallTopLevel(install_files, sub_dir='epid/member/tiny') 40 41else: 42 env.Part(parts_file='tiny/stdlib/tiny_stdlib.parts') 43 env.Part(parts_file='tiny/math/math.parts') 44 env.DependsOn([ 45 Component('tinycommon', requires=REQ.HEADERS), 46 Component('member.tiny_stdlib'), Component('member.math') 47 ]) 48 49 env.Append(CPPPATH='#') 50 51 if 'use-sigrl-by-reference' in env['MODE']: 52 env.Append(CPPDEFINES=['USE_SIGRL_BY_REFERENCE']) 53 else: 54 max_sigrl_entries = ARGUMENTS.get('MAX_SIGRL_ENTRIES', 0) 55 n2_max = int(max_sigrl_entries) 56 if n2_max: 57 env.Append(CPPDEFINES=['MAX_SIGRL_ENTRIES={0}'.format(n2_max)]) 58 59 if 'static' in env['MODE'] and 'shared' in env['MODE']: 60 PrintError("both shared and static build mode specified for '{}'. " 61 .format(env.subst('$PART_SHORT_NAME'))) 62 if 'static' not in env['MODE'] and 'shared' not in env['MODE']: 63 PrintMessage( 64 "build mode not specified for '{}'. Defaulting to '{}'" 65 .format(env.subst('$PART_SHORT_NAME'), default_build_mode)) 66 env['MODE'].append(default_build_mode) 67 68 if 'shared' in env['MODE']: 69 env.Append(CPPDEFINES=['SHARED']) 70 env.ExportCPPDEFINES(['SHARED']) 71 outputs = env.SharedLibrary('${PART_SHORT_NAME}', src_files) 72 elif 'static' in env['MODE']: 73 outputs = env.Library('${PART_SHORT_NAME}', src_files) 74 else: 75 print env.subst('$PART_SHORT_NAME') 76 PrintError("build mode not specified for '{}'. {}".format( 77 env.subst('$PART_SHORT_NAME'), 78 "Specify either 'shared' or 'static'.")) 79 80 sdk_outs = env.Sdk(outputs) 81 env.SdkInclude(include_files, sub_dir='epid/${PART_SHORT_NAME}') 82 83 if 'shared' in env['MODE']: 84 env.InstallTarget(outputs) 85 86 if 'install_lib' in env['MODE']: 87 env.InstallInclude(include_files, sub_dir='epid/${PART_SHORT_NAME}') 88 if 'static' in env['MODE']: 89 env.InstallLib(outputs) 90 91 is_utest_build = False 92 for i in BUILD_TARGETS: 93 if "utest::" in str(i): 94 is_utest_build = True 95 if is_utest_build: 96 env.Part( 97 parts_file='tiny/unittests/utest.parts', 98 CONFIG=DefaultEnvironment().subst('$CONFIG')) 99