verbatim.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright 2010 Vladimir Prus
  2. # Distributed under the Boost Software License, Version 1.0.
  3. # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
  4. # This file is only used with Python port of Boost.Build
  5. # This file shows some of the primary customization mechanisms in Boost.Build V2
  6. # and should serve as a basic for your own customization.
  7. # Each part has a comment describing its purpose, and you can pick the parts
  8. # which are relevant to your case, remove everything else, and then change names
  9. # and actions to taste.
  10. # Declare a new target type. This allows Boost.Build to do something sensible
  11. # when targets with the .verbatim extension are found in sources.
  12. import b2.build.type as type
  13. type.register("VERBATIM", ["verbatim"])
  14. # Declare a dependency scanner for the new target type. The
  15. # 'inline-file.py' script does not handle includes, so this is
  16. # only for illustraction.
  17. import b2.build.scanner as scanner;
  18. # First, define a new class, derived from 'common-scanner',
  19. # that class has all the interesting logic, and we only need
  20. # to override the 'pattern' method which return regular
  21. # expression to use when scanning.
  22. class VerbatimScanner(scanner.CommonScanner):
  23. def pattern(self):
  24. return "//###include[ ]*\"([^\"]*)\""
  25. scanner.register(VerbatimScanner, ["include"])
  26. type.set_scanner("VERBATIM", VerbatimScanner)
  27. import b2.build.generators as generators
  28. generators.register_standard("verbatim.inline-file",
  29. ["VERBATIM"], ["CPP"])
  30. from b2.manager import get_manager
  31. get_manager().engine().register_action("verbatim.inline-file",
  32. """
  33. ./inline_file.py $(<) $(>)
  34. """)