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