verbatim.jam 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright 2003, 2004 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 shows some of the primary customization mechanisms in B2 V2
  5. # and should serve as a basic for your own customization.
  6. # Each part has a comment describing its purpose, and you can pick the parts
  7. # which are relevant to your case, remove everything else, and then change names
  8. # and actions to taste.
  9. import os ;
  10. # Declare a new target type. This allows B2 to do something sensible
  11. # when targets with the .verbatim extension are found in sources.
  12. import 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 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 verbatim-scanner : common-scanner
  23. {
  24. rule pattern ( )
  25. {
  26. return "//###include[ ]*\"([^\"]*)\"" ;
  27. }
  28. }
  29. # Register the scanner class. The 'include' is
  30. # the property which specifies the search path
  31. # for includes.
  32. scanner.register verbatim-scanner : include ;
  33. # Assign the scanner class to the target type.
  34. # Now, all .verbatim sources will be scanned.
  35. # To test this, build the project, touch the
  36. # t2.verbatim file and build again.
  37. type.set-scanner VERBATIM : verbatim-scanner ;
  38. import generators ;
  39. generators.register-standard verbatim.inline-file : VERBATIM : CPP ;
  40. # Note: To use Cygwin Python on Windows change the following line
  41. # to "python inline_file.py $(<) $(>)"
  42. # Also, make sure that "python" in in PATH.
  43. actions inline-file
  44. {
  45. "./inline_file.py" $(<) $(>)
  46. }
  47. if [ os.name ] = VMS
  48. {
  49. actions inline-file
  50. {
  51. python inline_file.py $(<:W) $(>:W)
  52. }
  53. }