SConstruct 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. ############################################################################
  2. # Copyright 2016 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################
  16. """use scons -k to invoke all builds regardless of unit test failures
  17. """
  18. import string
  19. import sys
  20. import SCons.Script
  21. import os.path
  22. from parts import *
  23. print "**************** TOOLS ****************"
  24. print '* Python Version:', string.split(sys.version, " ", 1)[0]
  25. print '* SCons Version:', SCons.__version__
  26. print '* Parts Version:', PartsExtensionVersion()
  27. print "***************************************"
  28. def PrintCompilerVersion(env):
  29. """
  30. Function to print version of compilers used for build
  31. Args:
  32. env: Environment to get compilers version
  33. """
  34. res = ''
  35. if 'INTELC_VERSION' in env:
  36. res += 'ICC ' + env['INTELC_VERSION'] + ';'
  37. if 'MSVC_VERSION' in env:
  38. res += 'MS ' + env['MSVC_VERSION'] + ';'
  39. if 'GXX_VERSION' in env:
  40. res += 'GXX ' + env['GXX_VERSION'] + ';'
  41. if 'GCC_VERSION' in env:
  42. res += 'GCC ' + env['GCC_VERSION'] + ';'
  43. print 'Compiler Version: ', res
  44. def include_parts(part_list, **kwargs):
  45. for parts_file in part_list:
  46. if os.path.isfile(DefaultEnvironment().subst(parts_file)):
  47. Part(parts_file=parts_file, **kwargs)
  48. ######## Part groups ####################################################
  49. ipp_parts = ['ext/ipp/ippcp.parts',
  50. 'ext/ipp/ippcpepid.parts',
  51. 'ext/ipp/ippcommon.parts']
  52. utest_parts = ['ext/gtest/gtest.parts',
  53. 'epid/common-testhelper/common-testhelper.parts']
  54. common_parts = ['epid/common/common.parts']
  55. member_parts = ['epid/member/member.parts']
  56. verifier_parts = ['epid/verifier/verifier.parts']
  57. util_parts = ['example/util/util.parts']
  58. example_parts = ['example/verifysig/verifysig.parts',
  59. 'example/signmsg/signmsg.parts',
  60. 'example/data/data.parts']
  61. example_test_parts = ['test/testbot/testbot.parts',
  62. 'test/testbot/signmsg/signmsg_testbot.parts',
  63. 'test/testbot/verifysig/verifysig_testbot.parts',
  64. 'test/testbot/integration/integration_testbot.parts']
  65. package_parts = ['ext/gtest/gtest.parts',
  66. 'ext/ipp/ippcommon.parts',
  67. 'ext/ipp/ippcp.parts',
  68. 'ext/ipp/ippcpepid.parts',
  69. 'package.parts']
  70. internal_tools_parts = ['tools/ikgfwrapper/ikgfwrapper.parts',
  71. 'tools/revokegrp/revokegrp.parts',
  72. 'tools/revokekey/revokekey.parts',
  73. 'tools/revokesig/revokesig.parts',
  74. 'tools/extractkeys/extractkeys.parts',
  75. 'tools/extractgrps/extractgrps.parts']
  76. ######## End Part groups ###############################################
  77. ######## Commandline option setup #######################################
  78. product_variants = [
  79. 'production',
  80. 'internal-test',
  81. 'package-epid-sdk',
  82. 'internal-tools'
  83. ]
  84. default_variant = 'production'
  85. def is_production():
  86. return GetOption("product-variant") == 'production'
  87. def is_internal_test():
  88. return GetOption("product-variant") == 'internal-test'
  89. def is_internal_tools():
  90. return GetOption("product-variant") == 'internal-tools'
  91. def is_package():
  92. return GetOption("product-variant") == 'package-epid-sdk'
  93. def variant_dirname():
  94. s = GetOption("product-variant")
  95. if s == 'production':
  96. return 'epid-sdk'
  97. elif s == 'package-epid-sdk':
  98. return 'epid-sdk'
  99. else:
  100. return s
  101. AddOption("--product-variant", "--prod-var", nargs=1,
  102. help=("Select product variant to build. Possible "
  103. "options are: {0}. The default is {1} if no option "
  104. "is specified").format(", ".join(product_variants),
  105. default_variant),
  106. action='store', dest='product-variant', type='choice',
  107. choices=product_variants, default=default_variant)
  108. SetOptionDefault("PRODUCT_VARIANT", variant_dirname())
  109. ######## End Commandline option setup ###################################
  110. # fix for parts 0.10.8 until we get better logic to extract ${CC}
  111. SetOptionDefault('PARTS_USE_SHORT_TOOL_NAMES', 1)
  112. def set_default_production_options():
  113. SetOptionDefault('TARGET_PLATFORM', 'x86_64')
  114. SetOptionDefault('CONFIG', 'release')
  115. SetOptionDefault('TARGET_VARIANT', '${TARGET_OS}-${TARGET_ARCH}')
  116. SetOptionDefault('INSTALL_ROOT',
  117. '#_install/${PRODUCT_VARIANT}')
  118. SetOptionDefault('INSTALL_TOOLS_BIN',
  119. '$INSTALL_ROOT/tools')
  120. SetOptionDefault('INSTALL_SAMPLE_BIN',
  121. '$INSTALL_ROOT/example')
  122. SetOptionDefault('INSTALL_EPID_INCLUDE',
  123. '$INSTALL_ROOT/include/epid')
  124. SetOptionDefault('INSTALL_IPP_INCLUDE',
  125. '$INSTALL_ROOT/include/ext/ipp/include')
  126. SetOptionDefault('INSTALL_TEST_BIN',
  127. '$INSTALL_ROOT/test')
  128. SetOptionDefault('INSTALL_LIB',
  129. '$INSTALL_ROOT/lib/${TARGET_VARIANT}')
  130. SetOptionDefault('INSTALL_SAMPLE_DATA',
  131. '$INSTALL_ROOT/example')
  132. SetOptionDefault('PACKAGE_DIR',
  133. '#_package')
  134. SetOptionDefault('PACKAGE_ROOT',
  135. '#_package/${PRODUCT_VARIANT}')
  136. SetOptionDefault('ROOT',
  137. '#')
  138. SetOptionDefault('PACKAGE_NAME',
  139. '{PRODUCT_VARIANT}')
  140. if is_production():
  141. set_default_production_options()
  142. include_parts(ipp_parts, mode=['install_lib'],
  143. INSTALL_INCLUDE='${INSTALL_IPP_INCLUDE}')
  144. include_parts(utest_parts + common_parts +
  145. member_parts + verifier_parts,
  146. mode=['install_lib'],
  147. INSTALL_INCLUDE='${INSTALL_EPID_INCLUDE}')
  148. include_parts(util_parts + example_parts,
  149. INSTALL_INCLUDE='${INSTALL_EPID_INCLUDE}',
  150. INSTALL_BIN='${INSTALL_SAMPLE_BIN}',
  151. INSTALL_DATA='${INSTALL_SAMPLE_DATA}')
  152. PrintCompilerVersion(DefaultEnvironment())
  153. Default('all')
  154. Default('run_utest::')
  155. if is_internal_test():
  156. set_default_production_options()
  157. include_parts(ipp_parts)
  158. include_parts(utest_parts + common_parts +
  159. member_parts + verifier_parts)
  160. include_parts(util_parts + example_parts,
  161. INSTALL_BIN='${INSTALL_SAMPLE_BIN}',
  162. INSTALL_DATA='${INSTALL_SAMPLE_DATA}')
  163. include_parts(example_test_parts)
  164. Default('all')
  165. if is_internal_tools():
  166. set_default_production_options()
  167. include_parts(ipp_parts + utest_parts + common_parts + util_parts)
  168. include_parts(internal_tools_parts, INSTALL_BIN='${INSTALL_TOOLS_BIN}')
  169. Default('ikgfwrapper', 'revokegrp', 'revokekey', 'revokesig',
  170. 'extractkeys', 'extractgrps')
  171. if is_package():
  172. set_default_production_options()
  173. include_parts(package_parts,
  174. mode=['install_package'],
  175. INSTALL_TOP_LEVEL='${PACKAGE_ROOT}')
  176. Default('package')