tinymember.parts 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. """
  19. Import('*')
  20. env.PartName('member')
  21. default_build_mode = 'static'
  22. include_files = Pattern(src_dir='.', includes=['*.h'], recursive=False).files()
  23. src_files = Pattern(
  24. src_dir='tiny/src', includes=['*.c'], recursive=False).files()
  25. install_files = Pattern(
  26. src_dir='tiny',
  27. includes=[
  28. '*.h', '*.c', '*-test.cc', '*-testhelper.cc', '*-testhelper.h',
  29. '*.parts', 'Makefile'
  30. ],
  31. excludes=['*/platform_specific*/'],
  32. recursive=True)
  33. if 'install_package' in env['MODE']:
  34. env.InstallTopLevel(install_files, sub_dir='epid/member/tiny')
  35. else:
  36. env.Part(parts_file='tiny/stdlib/tiny_stdlib.parts')
  37. env.Part(parts_file='tiny/math/math.parts')
  38. env.DependsOn([
  39. Component('tinycommon', requires=REQ.HEADERS),
  40. Component('member.tiny_stdlib'), Component('member.math')
  41. ])
  42. env.Append(CPPPATH='#')
  43. if 'use-sigrl-by-reference' in env['MODE']:
  44. env.Append(CPPDEFINES=['USE_SIGRL_BY_REFERENCE'])
  45. else:
  46. max_sigrl_entries = ARGUMENTS.get('MAX_SIGRL_ENTRIES', 0)
  47. n2_max = int(max_sigrl_entries)
  48. if n2_max:
  49. env.Append(CPPDEFINES=['MAX_SIGRL_ENTRIES={0}'.format(n2_max)])
  50. if 'static' in env['MODE'] and 'shared' in env['MODE']:
  51. PrintError("both shared and static build mode specified for '{}'. "
  52. .format(env.subst('$PART_SHORT_NAME')))
  53. if 'static' not in env['MODE'] and 'shared' not in env['MODE']:
  54. PrintMessage(
  55. "build mode not specified for '{}'. Defaulting to '{}'"
  56. .format(env.subst('$PART_SHORT_NAME'), default_build_mode))
  57. env['MODE'].append(default_build_mode)
  58. if 'shared' in env['MODE']:
  59. env.Append(CPPDEFINES=['SHARED'])
  60. env.ExportCPPDEFINES(['SHARED'])
  61. outputs = env.SharedLibrary('${PART_SHORT_NAME}', src_files)
  62. elif 'static' in env['MODE']:
  63. outputs = env.Library('${PART_SHORT_NAME}', src_files)
  64. else:
  65. print env.subst('$PART_SHORT_NAME')
  66. PrintError("build mode not specified for '{}'. {}".format(
  67. env.subst('$PART_SHORT_NAME'),
  68. "Specify either 'shared' or 'static'."))
  69. sdk_outs = env.Sdk(outputs)
  70. env.SdkInclude(include_files, sub_dir='epid/${PART_SHORT_NAME}')
  71. if 'shared' in env['MODE']:
  72. env.InstallTarget(outputs)
  73. if 'install_lib' in env['MODE']:
  74. env.InstallInclude(include_files, sub_dir='epid/${PART_SHORT_NAME}')
  75. if 'static' in env['MODE']:
  76. env.InstallLib(outputs)
  77. is_utest_build = False
  78. for i in BUILD_TARGETS:
  79. if "utest::" in str(i):
  80. is_utest_build = True
  81. if is_utest_build:
  82. env.Part(
  83. parts_file='tiny/unittests/utest.parts',
  84. CONFIG=DefaultEnvironment().subst('$CONFIG'))