boost_contract_no.jam-gen.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. print '''
  2. # Generated file `python boost_contract_no.jam-gen.py > boost_contract_no.jam`.
  3. # Copyright (C) 2008-2018 Lorenzo Caminiti
  4. # Distributed under the Boost Software License, Version 1.0 (see accompanying
  5. # file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  6. # See: https://lcaminiti.github.io/boost-contract
  7. '''
  8. import collections
  9. import itertools
  10. defs = collections.OrderedDict([
  11. # Short keys (1-2 chars) as MSVC gives linker errors on long file names.
  12. ('y', 'BOOST_CONTRACT_NO_ENTRY_INVARIANTS'),
  13. ('r', 'BOOST_CONTRACT_NO_PRECONDITIONS'),
  14. ('x', 'BOOST_CONTRACT_NO_EXIT_INVARIANTS'),
  15. ('s', 'BOOST_CONTRACT_NO_POSTCONDITIONS'),
  16. ('e', 'BOOST_CONTRACT_NO_EXCEPTS'),
  17. ('k', 'BOOST_CONTRACT_NO_CHECKS')
  18. # Add more macros here.
  19. ])
  20. separator = '' # Might want to set to '_' if keys longer than 1 char.
  21. print 'module boost_contract_no {\n'
  22. s = ''
  23. exit
  24. for r in range(len(defs.keys())):
  25. for comb in itertools.combinations(defs.keys(), r + 1):
  26. c = ''
  27. d = ''
  28. sep = ''
  29. for cond in comb:
  30. c += sep + cond
  31. sep = separator
  32. d += " <define>" + defs[cond]
  33. s += ' ' + c
  34. print 'rule defs_{0} {{ return {1} ; }}\n'.format(c, d[1:])
  35. print '''rule combinations {{ return {0} ; }}
  36. }} # module
  37. # All combinations: {1}
  38. '''.format(s[1:], s.replace(" ", ",")[1:])