libtiff.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/python
  2. # Copyright (C) 2013 Steven Watanabe
  3. # Distributed under the Boost Software License, Version 1.0.
  4. # (See accompanying file LICENSE.txt or copy at
  5. # https://www.bfgroup.xyz/b2/LICENSE.txt)
  6. import BoostBuild
  7. import MockToolset
  8. t = BoostBuild.Tester(arguments=['toolset=mock', '--ignore-site-config', '--user-config='], pass_toolset=0)
  9. MockToolset.create(t)
  10. # Build from source
  11. t.write("libtiff/tiff.h", 'libtiff')
  12. t.write("libtiff/tif_aux.c", 'tif_aux')
  13. t.write("Jamroot.jam", """
  14. path-constant here : . ;
  15. using libtiff : : <source>$(here)/libtiff ;
  16. alias libtiff : /libtiff//libtiff : : <link>static <link>shared ;
  17. """)
  18. MockToolset.set_expected(t, '''
  19. source_file('tif_aux.c', 'tif_aux')
  20. action('-c -x c -I./libtiff -o $tif_aux.o $tif_aux.c')
  21. action('--dll $tif_aux.o -o $tiff.so')
  22. action('--archive $tif_aux.o -o $tiff.a')
  23. ''')
  24. t.run_build_system()
  25. t.expect_addition('bin/standalone/libtiff/mock/debug/tiff.dll')
  26. t.expect_addition('bin/standalone/libtiff/mock/debug/link-static/tiff.lib')
  27. t.rm('libtiff')
  28. # Generic definitions that aren't configuration specific
  29. common_stuff = '''
  30. source_file('test.cpp', 'test.cpp')
  31. source_file('main.cpp', 'int main() {}')
  32. source_file('tiff.h.cpp', '#include <tiff.h>\\n')
  33. action('-c -x c++ $main.cpp -o $main.o')
  34. '''
  35. t.write('test.cpp', 'test.cpp')
  36. # Default initialization - static library
  37. t.rm('bin')
  38. t.write("Jamroot.jam", """
  39. path-constant here : . ;
  40. using libtiff ;
  41. exe test : test.cpp /libtiff//libtiff : : <link>static <link>shared ;
  42. """)
  43. MockToolset.set_expected(t, common_stuff + '''
  44. action('$main.o --static-lib=tiff -o $config.exe')
  45. action('-c -x c++ $tiff.h.cpp -o $tiff.h.o')
  46. action('-c -x c++ $test.cpp -o $test.o')
  47. action('$test.o --static-lib=tiff -o $test')
  48. ''')
  49. t.run_build_system()
  50. t.expect_addition('bin/mock/debug/test.exe')
  51. t.expect_addition('bin/mock/debug/link-static/test.exe')
  52. # Default initialization - shared library
  53. t.rm('bin')
  54. t.write("Jamroot.jam", """
  55. path-constant here : . ;
  56. using libtiff ;
  57. exe test : test.cpp /libtiff//libtiff : : <link>static <link>shared ;
  58. """)
  59. MockToolset.set_expected(t, common_stuff + '''
  60. action('$main.o --shared-lib=tiff -o $config.exe')
  61. action('-c -x c++ $tiff.h.cpp -o $tiff.h.o')
  62. action('-c -x c++ $test.cpp -o $test.o')
  63. action('$test.o --shared-lib=tiff -o $test')
  64. ''')
  65. t.run_build_system()
  66. t.expect_addition('bin/mock/debug/test.exe')
  67. t.expect_addition('bin/mock/debug/link-static/test.exe')
  68. # Initialization in explicit location - static library
  69. t.rm('bin')
  70. t.write("Jamroot.jam", """
  71. path-constant here : . ;
  72. using libtiff : : <name>mylibtiff <include>$(here)/libtiff <search>$(here)/libtiff ;
  73. exe test : test.cpp /libtiff//libtiff : : <link>static <link>shared ;
  74. """)
  75. t.write('libtiff/tiff.h', 'libtiff')
  76. MockToolset.set_expected(t, common_stuff + '''
  77. action('$main.o -L./libtiff --static-lib=mylibtiff -o $config.exe')
  78. action('-c -x c++ $test.cpp -I./libtiff -o $test.o')
  79. action('$test.o -L./libtiff --static-lib=mylibtiff -o $test')
  80. ''')
  81. t.run_build_system()
  82. t.expect_addition('bin/mock/debug/test.exe')
  83. t.expect_addition('bin/mock/debug/link-static/test.exe')
  84. # Initialization in explicit location - shared library
  85. t.rm('bin')
  86. t.write("Jamroot.jam", """
  87. path-constant here : . ;
  88. using libtiff : : <name>mylibtiff <include>$(here)/libtiff <search>$(here)/libtiff ;
  89. exe test : test.cpp /libtiff//libtiff : : <link>static <link>shared ;
  90. """)
  91. MockToolset.set_expected(t, common_stuff + '''
  92. action('$main.o -L./libtiff --shared-lib=mylibtiff -o $config.exe')
  93. action('-c -x c++ $test.cpp -I./libtiff -o $test.o')
  94. action('$test.o -L./libtiff --shared-lib=mylibtiff -o $test')
  95. ''')
  96. t.run_build_system()
  97. t.expect_addition('bin/mock/debug/test.exe')
  98. t.expect_addition('bin/mock/debug/link-static/test.exe')
  99. t.cleanup()