Jamfile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # Copyright (c) 2018 Stefan Seefeld
  2. # All rights reserved.
  3. #
  4. # Distributed under the Boost Software License, Version 1.0.
  5. # (See accompanying file LICENSE_1_0.txt or copy at
  6. # http://www.boost.org/LICENSE_1_0.txt)
  7. import option ;
  8. import regex ;
  9. import python ;
  10. #
  11. # The `version-suffix` rule really belongs into python.jam, and
  12. # should be moved there. `split-version` is only duplicated here
  13. # as a prerequisite. (See https://github.com/boostorg/build/pull/290)
  14. #
  15. # Validate the version string and extract the major/minor part we care about.
  16. #
  17. local rule split-version ( version )
  18. {
  19. local major-minor = [ MATCH "^([0-9]+)\.([0-9]+)(.*)$" : $(version) : 1 2 3 ] ;
  20. if ! $(major-minor[2]) || $(major-minor[3])
  21. {
  22. ECHO "Warning: \"using python\" expects a two part (major, minor) version number; got" $(version) instead ;
  23. # Add a zero to account for the missing digit if necessary.
  24. major-minor += 0 ;
  25. }
  26. return $(major-minor[1]) $(major-minor[2]) ;
  27. }
  28. # Define a version suffix for libraries depending on Python.
  29. # For example, Boost.Python built for Python 2.7 uses the suffix "27"
  30. rule version-suffix ( version )
  31. {
  32. local major-minor = [ split-version $(version) ] ;
  33. local suffix = $(major-minor:J="") ;
  34. return $(suffix) ;
  35. }
  36. # Python build id (for Python libraries only).
  37. python-id = [ option.get "python-buildid" ] ;
  38. if $(python-id)
  39. {
  40. PYTHON_ID = [ regex.replace $(python-id) "[*\\/:.\"\']" _ ] ;
  41. }
  42. rule python-tag ( name : type ? : property-set )
  43. {
  44. local result = $(name) ;
  45. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  46. {
  47. local version = [ $(property-set).get <python> ] ;
  48. local lib-suffix = [ version-suffix $(version) ] ;
  49. result = $(result)$(lib-suffix) ;
  50. }
  51. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB && $(PYTHON_ID)
  52. {
  53. result = $(result)-$(PYTHON_ID) ;
  54. }
  55. # forward to the boost tagging rule
  56. return [ tag $(result) : $(type) : $(property-set) ] ;
  57. }