libjpeg.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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("libjpeg/jpeglib.h", 'libjpeg')
  12. t.write("libjpeg/jerror.c", 'jpeg')
  13. t.write("Jamroot.jam", """
  14. path-constant here : . ;
  15. using libjpeg : : <source>$(here)/libjpeg ;
  16. alias libjpeg : /libjpeg//libjpeg : : <link>static <link>shared ;
  17. """)
  18. MockToolset.set_expected(t, '''
  19. source_file('jerror.c', 'jpeg')
  20. action('-c -x c -I./libjpeg -o $jerror.o $jerror.c')
  21. action('--dll $jerror.o -o $jpeg.so')
  22. action('--archive $jerror.o -o $jpeg.a')
  23. ''')
  24. t.run_build_system()
  25. t.expect_addition('bin/standalone/libjpeg/mock/debug/jpeg.dll')
  26. t.expect_addition('bin/standalone/libjpeg/mock/debug/link-static/jpeg.lib')
  27. t.rm('libjpeg')
  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('jpeg.h.cpp', '#include <stdio.h>\\n#include <jpeglib.h>\\n')
  33. action('-c -x c++ $main.cpp -o $main.o')
  34. '''
  35. t.write('test.cpp', 'test.cpp')
  36. t.write("Jamroot.jam", """
  37. path-constant here : . ;
  38. using libjpeg ;
  39. exe test : test.cpp /libjpeg//libjpeg ;
  40. """)
  41. # Default initialization - static library
  42. t.rm('bin')
  43. MockToolset.set_expected(t, common_stuff + '''
  44. action('$main.o --static-lib=jpeg -o $config.exe')
  45. action('-c -x c++ $jpeg.h.cpp -o $jpeg.h.o')
  46. action('-c -x c++ $test.cpp -o $test.o')
  47. action('$test.o --static-lib=jpeg -o $test')
  48. ''')
  49. t.run_build_system(["link=static"])
  50. t.expect_addition('bin/mock/debug/link-static/test.exe')
  51. # Default initialization - shared library
  52. t.rm('bin')
  53. t.write("Jamroot.jam", """
  54. path-constant here : . ;
  55. using libjpeg ;
  56. exe test : test.cpp /libjpeg//libjpeg ;
  57. """)
  58. MockToolset.set_expected(t, common_stuff + '''
  59. action('$main.o --shared-lib=jpeg -o $config.exe')
  60. action('-c -x c++ $jpeg.h.cpp -o $jpeg.h.o')
  61. action('-c -x c++ $test.cpp -o $test.o')
  62. action('$test.o --shared-lib=jpeg -o $test')
  63. ''')
  64. t.run_build_system(["link=shared"])
  65. t.expect_addition('bin/mock/debug/test.exe')
  66. # Initialization in explicit location - static library
  67. t.rm('bin')
  68. t.write("Jamroot.jam", """
  69. path-constant here : . ;
  70. using libjpeg : : <name>mylibjpeg <include>$(here)/libjpeg <search>$(here)/libjpeg ;
  71. exe test : test.cpp /libjpeg//libjpeg : : <link>static <link>shared ;
  72. """)
  73. t.write('libjpeg/jpeglib.h', 'libjpeg')
  74. MockToolset.set_expected(t, common_stuff + '''
  75. action('$main.o -L./libjpeg --static-lib=mylibjpeg -o $config.exe')
  76. action('-c -x c++ $test.cpp -I./libjpeg -o $test.o')
  77. action('$test.o -L./libjpeg --static-lib=mylibjpeg -o $test')
  78. ''')
  79. t.run_build_system()
  80. t.expect_addition('bin/mock/debug/test.exe')
  81. t.expect_addition('bin/mock/debug/link-static/test.exe')
  82. # Initialization in explicit location - shared library
  83. t.rm('bin')
  84. t.write("Jamroot.jam", """
  85. path-constant here : . ;
  86. using libjpeg : : <name>mylibjpeg <include>$(here)/libjpeg <search>$(here)/libjpeg ;
  87. exe test : test.cpp /libjpeg//libjpeg : : <link>static <link>shared ;
  88. """)
  89. MockToolset.set_expected(t, common_stuff + '''
  90. action('$main.o -L./libjpeg --shared-lib=mylibjpeg -o $config.exe')
  91. action('-c -x c++ $test.cpp -I./libjpeg -o $test.o')
  92. action('$test.o -L./libjpeg --shared-lib=mylibjpeg -o $test')
  93. ''')
  94. t.run_build_system()
  95. t.expect_addition('bin/mock/debug/test.exe')
  96. t.expect_addition('bin/mock/debug/link-static/test.exe')
  97. t.cleanup()