1#!/usr/bin/python 2 3# Copy-paste-modify from zlib.py 4# Copyright (C) 2013 Steven Watanabe 5# Distributed under the Boost Software License, Version 1.0. 6# (See accompanying file LICENSE_1_0.txt or copy at 7# http://www.boost.org/LICENSE_1_0.txt) 8 9import BoostBuild 10import MockToolset 11 12t = BoostBuild.Tester(arguments=['toolset=mock', '--ignore-site-config', '--user-config='], pass_toolset=0) 13 14MockToolset.create(t) 15 16# Generic definitions that aren't configuration specific 17common_stuff = ''' 18source_file('test.cpp', 'test.cpp') 19source_file('main.cpp', 'int main() {}') 20source_file('lzma.h.cpp', '#include <lzma.h>\\n') 21action('-c -x c++ $main.cpp -o $main.o') 22''' 23t.write('test.cpp', 'test.cpp') 24 25# Default initialization - static library 26t.rm('bin') 27t.write("Jamroot.jam", """ 28path-constant here : . ; 29using lzma ; 30exe test : test.cpp /lzma//lzma : : <link>static <link>shared ; 31""") 32 33MockToolset.set_expected(t, common_stuff + ''' 34action('$main.o --static-lib=lzma -o $config.exe') 35action('-c -x c++ $lzma.h.cpp -o $lzma.h.o') 36action('-c -x c++ $test.cpp -o $test.o') 37action('$test.o --static-lib=lzma -o $test') 38''') 39t.run_build_system() 40t.expect_addition('bin/mock/debug/test.exe') 41t.expect_addition('bin/mock/debug/link-static/test.exe') 42 43# Default initialization - shared library 44t.rm('bin') 45t.write("Jamroot.jam", """ 46path-constant here : . ; 47using lzma ; 48exe test : test.cpp /lzma//lzma : : <link>static <link>shared ; 49""") 50 51MockToolset.set_expected(t, common_stuff + ''' 52action('$main.o --shared-lib=lzma -o $config.exe') 53action('-c -x c++ $lzma.h.cpp -o $lzma.h.o') 54action('-c -x c++ $test.cpp -o $test.o') 55action('$test.o --shared-lib=lzma -o $test') 56''') 57t.run_build_system() 58t.expect_addition('bin/mock/debug/test.exe') 59t.expect_addition('bin/mock/debug/link-static/test.exe') 60 61# Initialization in explicit location - static library 62t.rm('bin') 63t.write("Jamroot.jam", """ 64path-constant here : . ; 65using lzma : : <name>mylzma <include>$(here)/lzma <search>$(here)/lzma ; 66exe test : test.cpp /lzma//lzma : : <link>static <link>shared ; 67""") 68 69t.write('lzma/lzma.h', 'lzma') 70 71MockToolset.set_expected(t, common_stuff + ''' 72action('$main.o -L./lzma --static-lib=mylzma -o $config.exe') 73action('-c -x c++ $test.cpp -I./lzma -o $test.o') 74action('$test.o -L./lzma --static-lib=mylzma -o $test') 75''') 76t.run_build_system() 77t.expect_addition('bin/mock/debug/test.exe') 78t.expect_addition('bin/mock/debug/link-static/test.exe') 79 80# Initialization in explicit location - shared library 81t.rm('bin') 82t.write("Jamroot.jam", """ 83path-constant here : . ; 84using lzma : : <name>mylzma <include>$(here)/lzma <search>$(here)/lzma ; 85exe test : test.cpp /lzma//lzma : : <link>static <link>shared ; 86""") 87 88MockToolset.set_expected(t, common_stuff + ''' 89action('$main.o -L./lzma --shared-lib=mylzma -o $config.exe') 90action('-c -x c++ $test.cpp -I./lzma -o $test.o') 91action('$test.o -L./lzma --shared-lib=mylzma -o $test') 92''') 93t.run_build_system() 94t.expect_addition('bin/mock/debug/test.exe') 95t.expect_addition('bin/mock/debug/link-static/test.exe') 96 97# Initialization in explicit location - both static and shared libraries 98t.rm('bin') 99t.write("Jamroot.jam", """ 100path-constant here : . ; 101using lzma : : <name>mylzma <include>$(here)/lzma <search>$(here)/lzma ; 102exe test : test.cpp /lzma//lzma 103 : <link>shared:<define>SHARED : <link>static <link>shared ; 104""") 105 106MockToolset.set_expected(t, common_stuff + ''' 107action('$main.o -L./lzma --static-lib=mylzma -o $config.exe') 108action('$main.o -L./lzma --shared-lib=mylzma -o $config.exe') 109action('-c -x c++ $test.cpp -I./lzma -o $test-static.o') 110action('-c -x c++ $test.cpp -I./lzma -DSHARED -o $test-shared.o') 111action('$test-static.o -L./lzma --static-lib=mylzma -o $test') 112action('$test-shared.o -L./lzma --shared-lib=mylzma -o $test') 113''') 114t.run_build_system() 115t.expect_addition('bin/mock/debug/test.exe') 116t.expect_addition('bin/mock/debug/link-static/test.exe') 117 118t.cleanup() 119