absolute_sources.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/python
  2. # Copyright 2003, 2004 Vladimir Prus
  3. # Distributed under the Boost Software License, Version 1.0.
  4. # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
  5. # Test that sources with absolute names are handled OK.
  6. import BoostBuild
  7. t = BoostBuild.Tester(use_test_config=False)
  8. t.write("jamroot.jam", "path-constant TOP : . ;")
  9. t.write("jamfile.jam", """\
  10. local pwd = [ PWD ] ;
  11. ECHO $(pwd) XXXXX ;
  12. exe hello : $(pwd)/hello.cpp $(TOP)/empty.cpp ;
  13. """)
  14. t.write("hello.cpp", "int main() {}\n")
  15. t.write("empty.cpp", "\n")
  16. t.run_build_system()
  17. t.expect_addition("bin/$toolset/debug*/hello.exe")
  18. t.rm(".")
  19. # Test a contrived case in which an absolute name is used in a standalone
  20. # project (not Jamfile). Moreover, the target with an absolute name is returned
  21. # via an 'alias' and used from another project.
  22. t.write("a.cpp", "int main() {}\n")
  23. t.write("jamfile.jam", "exe a : /standalone//a ;")
  24. t.write("jamroot.jam", "import standalone ;")
  25. t.write("standalone.jam", """\
  26. import project ;
  27. project.initialize $(__name__) ;
  28. project standalone ;
  29. local pwd = [ PWD ] ;
  30. alias a : $(pwd)/a.cpp ;
  31. """)
  32. t.write("standalone.py", """
  33. from b2.manager import get_manager
  34. # FIXME: this is ugly as death
  35. get_manager().projects().initialize(__name__)
  36. import os ;
  37. # This use of list as parameter is also ugly.
  38. project(['standalone'])
  39. pwd = os.getcwd()
  40. alias('a', [os.path.join(pwd, 'a.cpp')])
  41. """)
  42. t.run_build_system()
  43. t.expect_addition("bin/$toolset/debug*/a.exe")
  44. # Test absolute path in target ids.
  45. t.rm(".")
  46. t.write("d1/jamroot.jam", "")
  47. t.write("d1/jamfile.jam", "exe a : a.cpp ;")
  48. t.write("d1/a.cpp", "int main() {}\n")
  49. t.write("d2/jamroot.jam", "")
  50. t.write("d2/jamfile.jam", """\
  51. local pwd = [ PWD ] ;
  52. alias x : $(pwd)/../d1//a ;
  53. """)
  54. t.run_build_system(subdir="d2")
  55. t.expect_addition("d1/bin/$toolset/debug*/a.exe")
  56. t.cleanup()