SConstruct 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 = ['ext/dropt/dropt.parts',
  59. 'example/verifysig/verifysig.parts',
  60. 'example/signmsg/signmsg.parts',
  61. 'example/data/data.parts',
  62. 'example/compressed_data/compressed_data.parts']
  63. tools_parts = ['tools/revokegrp/revokegrp.parts',
  64. 'tools/revokekey/revokekey.parts',
  65. 'tools/revokesig/revokesig.parts',
  66. 'tools/extractkeys/extractkeys.parts',
  67. 'tools/extractgrps/extractgrps.parts']
  68. testbot_test_parts = ['test/testbot/testbot.parts',
  69. 'test/testbot/signmsg/signmsg_testbot.parts',
  70. 'test/testbot/verifysig/verifysig_testbot.parts',
  71. 'test/testbot/integration/integration_testbot.parts',
  72. 'test/testbot/ssh_remote/ssh_remote_testbot.parts',
  73. 'test/testbot/revokegrp/revokegrp_testbot.parts',
  74. 'test/testbot/revokekey/revokekey_testbot.parts',
  75. 'test/testbot/revokesig/revokesig_testbot.parts',
  76. 'test/testbot/extractkeys/extractkeys_testbot.parts',
  77. 'test/testbot/extractgrps/extractgrps_testbot.parts']
  78. package_parts = ['ext/gtest/gtest.parts',
  79. 'ext/ipp/ippcommon.parts',
  80. 'ext/ipp/ippcp.parts',
  81. 'ext/ipp/ippcpepid.parts',
  82. 'package.parts']
  83. internal_tools_parts = ['ext/dropt/dropt.parts',
  84. 'tools/ikgfwrapper/ikgfwrapper.parts']
  85. ######## End Part groups ###############################################
  86. ######## Commandline option setup #######################################
  87. product_variants = [
  88. 'production',
  89. 'internal-test',
  90. 'package-epid-sdk',
  91. 'internal-tools'
  92. ]
  93. default_variant = 'production'
  94. def is_production():
  95. return GetOption("product-variant") == 'production'
  96. def is_internal_test():
  97. return GetOption("product-variant") == 'internal-test'
  98. def is_internal_tools():
  99. return GetOption("product-variant") == 'internal-tools'
  100. def is_package():
  101. return GetOption("product-variant") == 'package-epid-sdk'
  102. def use_commercial_ipp():
  103. return GetOption("use-commercial-ipp")
  104. def variant_dirname():
  105. s = GetOption("product-variant")
  106. if s == 'production':
  107. return 'epid-sdk'
  108. elif s == 'package-epid-sdk':
  109. return 'epid-sdk'
  110. else:
  111. return s
  112. AddOption("--product-variant", "--prod-var", nargs=1,
  113. help=("Select product variant to build. Possible "
  114. "options are: {0}. The default is {1} if no option "
  115. "is specified").format(", ".join(product_variants),
  116. default_variant),
  117. action='store', dest='product-variant', type='choice',
  118. choices=product_variants, default=default_variant)
  119. AddOption("--use-commercial-ipp",
  120. help=("Link with commercial IPP. The IPPROOT environment variable "
  121. "must be set."),
  122. action='store_true', dest='use-commercial-ipp',
  123. default=False)
  124. SetOptionDefault("PRODUCT_VARIANT", variant_dirname())
  125. ######## End Commandline option setup ###################################
  126. # fix for parts 0.10.8 until we get better logic to extract ${CC}
  127. SetOptionDefault('PARTS_USE_SHORT_TOOL_NAMES', 1)
  128. def set_default_production_options():
  129. SetOptionDefault('TARGET_PLATFORM', 'x86_64')
  130. SetOptionDefault('CONFIG', 'release')
  131. SetOptionDefault('TARGET_VARIANT', '${TARGET_OS}-${TARGET_ARCH}')
  132. SetOptionDefault('INSTALL_ROOT',
  133. '#_install/${PRODUCT_VARIANT}')
  134. SetOptionDefault('INSTALL_TOOLS_BIN',
  135. '$INSTALL_ROOT/tools')
  136. SetOptionDefault('INSTALL_SAMPLE_BIN',
  137. '$INSTALL_ROOT/example')
  138. SetOptionDefault('INSTALL_EPID_INCLUDE',
  139. '$INSTALL_ROOT/include/epid')
  140. SetOptionDefault('INSTALL_IPP_INCLUDE',
  141. '$INSTALL_ROOT/include/ext/ipp/include')
  142. SetOptionDefault('INSTALL_TEST_BIN',
  143. '$INSTALL_ROOT/test')
  144. SetOptionDefault('INSTALL_LIB',
  145. '$INSTALL_ROOT/lib/${TARGET_VARIANT}')
  146. SetOptionDefault('INSTALL_SAMPLE_DATA',
  147. '$INSTALL_ROOT/example')
  148. SetOptionDefault('INSTALL_TOOLS_DATA',
  149. '$INSTALL_ROOT/tools')
  150. SetOptionDefault('PACKAGE_DIR',
  151. '#_package')
  152. SetOptionDefault('PACKAGE_ROOT',
  153. '#_package/${PRODUCT_VARIANT}')
  154. SetOptionDefault('ROOT',
  155. '#')
  156. SetOptionDefault('PACKAGE_NAME',
  157. '{PRODUCT_VARIANT}')
  158. if is_production():
  159. set_default_production_options()
  160. ipp_mode = ['install_lib']
  161. if use_commercial_ipp():
  162. ipp_mode.append('use_commercial_ipp')
  163. include_parts(ipp_parts, mode=ipp_mode,
  164. INSTALL_INCLUDE='${INSTALL_IPP_INCLUDE}')
  165. include_parts(utest_parts + common_parts +
  166. member_parts + verifier_parts,
  167. mode=['install_lib'],
  168. INSTALL_INCLUDE='${INSTALL_EPID_INCLUDE}')
  169. include_parts(util_parts + example_parts,
  170. INSTALL_INCLUDE='${INSTALL_EPID_INCLUDE}',
  171. INSTALL_BIN='${INSTALL_SAMPLE_BIN}',
  172. INSTALL_DATA='${INSTALL_SAMPLE_DATA}')
  173. include_parts(tools_parts,
  174. INSTALL_BIN='${INSTALL_TOOLS_BIN}',
  175. INSTALL_DATA='${INSTALL_TOOLS_DATA}')
  176. PrintCompilerVersion(DefaultEnvironment())
  177. Default('all')
  178. Default('run_utest::')
  179. if is_internal_test():
  180. set_default_production_options()
  181. include_parts(ipp_parts)
  182. include_parts(utest_parts + common_parts +
  183. member_parts + verifier_parts)
  184. include_parts(util_parts + example_parts,
  185. INSTALL_BIN='${INSTALL_SAMPLE_BIN}',
  186. INSTALL_DATA='${INSTALL_SAMPLE_DATA}')
  187. include_parts(tools_parts, INSTALL_BIN='${INSTALL_TOOLS_BIN}')
  188. include_parts(testbot_test_parts)
  189. Default('all')
  190. if is_internal_tools():
  191. set_default_production_options()
  192. include_parts(ipp_parts + utest_parts + common_parts + util_parts)
  193. include_parts(internal_tools_parts, INSTALL_BIN='${INSTALL_TOOLS_BIN}')
  194. Default('ikgfwrapper')
  195. if is_package():
  196. set_default_production_options()
  197. include_parts(package_parts,
  198. mode=['install_package'],
  199. INSTALL_TOP_LEVEL='${PACKAGE_ROOT}')
  200. Default('package')