]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright (C) 2013 Steven Watanabe | |
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 | ||
8 | import BoostBuild | |
9 | import MockToolset | |
10 | ||
11 | t = BoostBuild.Tester(arguments=['toolset=mock', '--ignore-site-config', '--user-config='], pass_toolset=0) | |
12 | ||
13 | MockToolset.create(t) | |
14 | ||
15 | # Build from source | |
11fdf7f2 TL |
16 | t.write("libjpeg/jpeglib.h", 'libjpeg') |
17 | t.write("libjpeg/jerror.c", 'jpeg') | |
7c673cae FG |
18 | |
19 | t.write("Jamroot.jam", """ | |
20 | path-constant here : . ; | |
21 | using libjpeg : : <source>$(here)/libjpeg ; | |
22 | alias libjpeg : /libjpeg//libjpeg : : <link>static <link>shared ; | |
23 | """) | |
24 | ||
25 | MockToolset.set_expected(t, ''' | |
92f5a8d4 TL |
26 | source_file('jerror.c', 'jpeg') |
27 | action('-c -x c -I./libjpeg -o $jerror.o $jerror.c') | |
28 | action('--dll $jerror.o -o $jpeg.so') | |
29 | action('--archive $jerror.o -o $jpeg.a') | |
7c673cae FG |
30 | ''') |
31 | ||
32 | t.run_build_system() | |
33 | t.expect_addition('bin/standalone/libjpeg/mock/debug/jpeg.dll') | |
34 | t.expect_addition('bin/standalone/libjpeg/mock/debug/link-static/jpeg.lib') | |
35 | ||
36 | t.rm('libjpeg') | |
37 | ||
38 | # Generic definitions that aren't configuration specific | |
39 | common_stuff = ''' | |
40 | source_file('test.cpp', 'test.cpp') | |
41 | source_file('main.cpp', 'int main() {}') | |
11fdf7f2 | 42 | source_file('jpeg.h.cpp', '#include <stdio.h>\\n#include <jpeglib.h>\\n') |
7c673cae FG |
43 | action('-c -x c++ $main.cpp -o $main.o') |
44 | ''' | |
45 | t.write('test.cpp', 'test.cpp') | |
46 | ||
47 | # Default initialization - static library | |
48 | t.rm('bin') | |
49 | t.write("Jamroot.jam", """ | |
50 | path-constant here : . ; | |
51 | using libjpeg ; | |
52 | exe test : test.cpp /libjpeg//libjpeg : : <link>static <link>shared ; | |
53 | """) | |
54 | ||
55 | MockToolset.set_expected(t, common_stuff + ''' | |
56 | action('$main.o --static-lib=jpeg -o $config.exe') | |
57 | action('-c -x c++ $jpeg.h.cpp -o $jpeg.h.o') | |
58 | action('-c -x c++ $test.cpp -o $test.o') | |
59 | action('$test.o --static-lib=jpeg -o $test') | |
60 | ''') | |
61 | t.run_build_system() | |
62 | t.expect_addition('bin/mock/debug/test.exe') | |
63 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
64 | ||
65 | # Default initialization - shared library | |
66 | t.rm('bin') | |
67 | t.write("Jamroot.jam", """ | |
68 | path-constant here : . ; | |
69 | using libjpeg ; | |
70 | exe test : test.cpp /libjpeg//libjpeg : : <link>static <link>shared ; | |
71 | """) | |
72 | ||
73 | MockToolset.set_expected(t, common_stuff + ''' | |
74 | action('$main.o --shared-lib=jpeg -o $config.exe') | |
75 | action('-c -x c++ $jpeg.h.cpp -o $jpeg.h.o') | |
76 | action('-c -x c++ $test.cpp -o $test.o') | |
77 | action('$test.o --shared-lib=jpeg -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 | ||
83 | # Initialization in explicit location - static library | |
84 | t.rm('bin') | |
85 | t.write("Jamroot.jam", """ | |
86 | path-constant here : . ; | |
87 | using libjpeg : : <name>mylibjpeg <include>$(here)/libjpeg <search>$(here)/libjpeg ; | |
88 | exe test : test.cpp /libjpeg//libjpeg : : <link>static <link>shared ; | |
89 | """) | |
90 | ||
11fdf7f2 | 91 | t.write('libjpeg/jpeglib.h', 'libjpeg') |
7c673cae FG |
92 | |
93 | MockToolset.set_expected(t, common_stuff + ''' | |
94 | action('$main.o -L./libjpeg --static-lib=mylibjpeg -o $config.exe') | |
95 | action('-c -x c++ $test.cpp -I./libjpeg -o $test.o') | |
96 | action('$test.o -L./libjpeg --static-lib=mylibjpeg -o $test') | |
97 | ''') | |
98 | t.run_build_system() | |
99 | t.expect_addition('bin/mock/debug/test.exe') | |
100 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
101 | ||
102 | # Initialization in explicit location - shared library | |
103 | t.rm('bin') | |
104 | t.write("Jamroot.jam", """ | |
105 | path-constant here : . ; | |
106 | using libjpeg : : <name>mylibjpeg <include>$(here)/libjpeg <search>$(here)/libjpeg ; | |
107 | exe test : test.cpp /libjpeg//libjpeg : : <link>static <link>shared ; | |
108 | """) | |
109 | ||
110 | MockToolset.set_expected(t, common_stuff + ''' | |
111 | action('$main.o -L./libjpeg --shared-lib=mylibjpeg -o $config.exe') | |
112 | action('-c -x c++ $test.cpp -I./libjpeg -o $test.o') | |
113 | action('$test.o -L./libjpeg --shared-lib=mylibjpeg -o $test') | |
114 | ''') | |
115 | t.run_build_system() | |
116 | t.expect_addition('bin/mock/debug/test.exe') | |
117 | t.expect_addition('bin/mock/debug/link-static/test.exe') | |
118 | ||
119 | t.cleanup() |