Beispiel #1
0
#!/usr/bin/python

# Test the 'symlink' rule

from BoostBuild import Tester, List
import os

t = Tester()

if os.name != "posix":
    print "The symlink tests can be run on posix only"
    sys.exit(1)

t.write("project-root.jam", "import gcc ;")
t.write(
    "Jamfile",
    """
exe hello : hello.cpp ;
symlink hello_release : hello/<variant>release ; 
symlink hello_debug : hello/<variant>debug ;
symlink links/hello_release : hello/<variant>release ; 
""",
)
t.write(
    "hello.cpp",
    """
int main()
{
    return 0;
}
""",
Beispiel #2
0
#!/usr/bin/python

# Test that default build clause actually has any effect.

from BoostBuild import Tester, List

t = Tester()

t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", "exe a : a.cpp : : debug release ;")
t.write("a.cpp", "int main() { return 0; }\n")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/a.exe")
t.expect_addition("bin/$toolset/release/a.exe")

# Check that explictly-specified build variant supresses
# default-build
t.rm("bin")
t.run_build_system("release")
t.expect_addition(List("bin/$toolset/release/") * "a.exe a.obj")
t.expect_nothing_more()

# Now check that we can specify explicit build request and
# default-build will be combined with it
t.run_build_system("optimization=space")
t.expect_addition("bin/$toolset/debug/optimization-space/a.exe")
t.expect_addition("bin/$toolset/release/optimization-space/a.exe")

# Test that default-build must be identical in all alternatives. Error case.
t.write(
Beispiel #3
0
t.write(
    "Jamroot", """ 
exe a1 : a1.cpp : <conditional>@a1-rule ;

rule a1-rule ( properties * )
{
    if <variant>debug in $(properties)
    {
	    return <define>OK ;
    }
}

exe a2 : a2.cpp : <conditional>@$(__name__).a2-rule <variant>debug:<optimization>speed ;

rule a2-rule ( properties * )
{
    if <optimization>speed in $(properties)
    {
        return <define>OK ;
    }
}

exe a3 : a3.cpp : <conditional>@$(__name__).a3-rule-1 <conditional>@$(__name__).a3-rule-2 ;

rule a3-rule-1 ( properties * )
{
    if <optimization>speed in $(properties)
    {
        return <define>OK ;
    }
}

rule a3-rule-2 ( properties * )
{
    if <variant>debug in $(properties)
    {
        return <optimization>speed ;
    }
}

""")
Beispiel #4
0
#!/usr/bin/python

# This tests a bug where files were places to a directory corresponding to a main
# target that was using its main target.

from BoostBuild import Tester
t = Tester()

# In order to correctly link this app, 'b.cpp', created by 'make'
# rule, should be compiled.
t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", """
lib b : b.cpp : <define>BAR ;
exe a : a.cpp b ;
""")
t.write("a.cpp", """
void foo();
int main() { foo(); }
""")
t.write("b.cpp", "void foo() {}\n")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/main-target-b/b.o")

# This tests another bug: when source file was used by two main targets,
# one without any requirements and another with free requirements, it 
# was compiled twice with to the same locaiton. 

t.write("Jamfile", """
exe a : a.cpp ;
exe b : a.cpp : <define>FOO ;
#!/usr/bin/python

# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

#  Test that conditional properties work, even if property is free, and
#  value includes colon.
from BoostBuild import Tester, List

t = Tester()

# Create the needed files
t.write("project-root.jam", "")
t.write(
    "Jamfile", """
exe hello : hello.cpp : <variant>debug:<define>CLASS=Foo::Bar ;
""")
t.write(
    "hello.cpp", """
namespace Foo { class Bar { } ; }
int main()
{
    CLASS c;
    return 0;
}

""")

# Don't check stderr, which can include warning about unused 'c'.
t.run_build_system(stdout=None, stderr=None)
#!/usr/bin/python

# Test the 'make' rule

from BoostBuild import Tester
from string import find

t = Tester(pass_toolset=0)

t.write("project-root.jam", "")
t.write(
    "Jamfile", """

rule creator ( string targets * : sources * : * )
{
    STRING on $(targets) = $(string) ;
    creator2 $(targets) : $(sources) ;
}

actions creator2
{
    echo $(STRING) > $(<)
}

make foo.bar : : creator foobar ;
""")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/foo.bar")
t.fail_test(find(t.read("bin/$toolset/debug/foo.bar"), "foobar") == -1)
Beispiel #7
0
#!/usr/bin/python

# Copyright 2002 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

# Test that we cannot specify targets of unknown type as sources.
# This is based on the fact that Unix 'ar' will happily consume
# just about anything.

from BoostBuild import Tester
t = Tester()

t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", """
static-lib a : a.foo ;
""")
t.write("a.foo", "")

t.run_build_system(status=1)

t.cleanup()
Beispiel #8
0
#!/usr/bin/python

# Copyright 2003 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

#  Test that composite properties are handled correctly.
from BoostBuild import Tester, List

t = Tester()

t.write("project-root.jam", "")
t.write("Jamfile", """
exe hello : hello.cpp : <variant>release ;
""")
t.write("hello.cpp", """
int main()
{
    return 0;
}

""")

t.run_build_system()

t.expect_addition("bin/$toolset/release/hello.exe")


t.cleanup()
Beispiel #9
0
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

#  This file is template for Boost.Build tests. It creates a simple
#  project that builds one exe from one source, and checks that the exe
#  is really created.
from BoostBuild import Tester, List


t = Tester()

t.write("a.cpp", """ 
#ifdef CF_IS_OFF
int main() { return 0; }
#endif

""")

t.write("b.cpp", """ 
#ifdef CF_1
int main() { return 0; }
#endif

""")

t.write("c.cpp", """
#ifdef FOO
int main() { return 0; }
#endif
#!/usr/bin/python

# Test that default build clause actually has any effect.

from BoostBuild import Tester, List
t = Tester()

t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", "exe a : a.cpp : : debug release ;")
t.write("a.cpp", "int main() { return 0; }\n")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/a.exe")
t.expect_addition("bin/$toolset/release/a.exe")

# Check that explictly-specified build variant supresses
# default-build
t.rm("bin")
t.run_build_system("release")
t.expect_addition(List("bin/$toolset/release/") * "a.exe a.obj")
t.expect_nothing_more()

# Now check that we can specify explicit build request and
# default-build will be combined with it
t.run_build_system("optimization=space")
t.expect_addition("bin/$toolset/debug/optimization-space/a.exe")
t.expect_addition("bin/$toolset/release/optimization-space/a.exe")

# Test that default-build must be identical in all alternatives. Error case.
t.write("Jamfile", """
exe a : a.cpp : : debug ;
Beispiel #11
0
#!/usr/bin/python

# Test the 'make' rule

from BoostBuild import Tester
from string import find

t = Tester(pass_toolset=1)

t.write("project-root.jam", "")
t.write("Jamfile", """

rule creator ( string targets * : sources * : * )
{
    STRING on $(targets) = $(string) ;
    creator2 $(targets) : $(sources) ;
}

actions creator2
{
    echo $(STRING) > $(<)
}

make foo.bar : : creator foobar ;
""")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/foo.bar")
t.fail_test(find(t.read("bin/$toolset/debug/foo.bar"), "foobar") == -1)

# Regression test. Make sure that if main target requested two times,
#  Copyright (C) Vladimir Prus 2006.
#  Distributed under the Boost Software License, Version 1.0. (See
#  accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)

#  Regression test: if a library had no explicit sources, but
#  only <source> properties, it was built as it it were searched
#  library, and the specified sources were not compiled.
from BoostBuild import Tester, List

# Create a temporary working directory
t = Tester()

# Create the needed files
t.write("Jamroot", """
lib a : : <source>a.cpp ;
""")
t.write("a.cpp", """
#ifdef _WIN32
__declspec(dllexport)
#endif
void foo() {}

""")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/a.obj")

t.rm("bin")

# Now try with <conditional>
Beispiel #13
0
#  Previously, it affected all targets, so
#
#     project : requirements <library>foo ;
#     exe a : a.cpp helper ;
#     obj helper : helper.cpp : <optimization>off ;
#
#  caused 'foo' to be built with and without optimization.
from BoostBuild import Tester, List

# Create a temporary working directory
t = Tester()

t.write(
    "Jamfile", """ 
project
   : requirements <library>lib//x
   ;
exe a : a.cpp foo ;
obj foo : foo.cpp : <variant>release ; 
""")

t.write("a.cpp", """
void aux();
int main() { aux(); }
""")

t.write("foo.cpp", """
void gee();
void aux() { gee(); }
""")

t.write("project-root.jam", """ 
#!/usr/bin/python

from BoostBuild import Tester, List
import os
from string import strip

t = Tester()

# First check some startup
t.set_tree("direct-request-test")
t.run_build_system(extra_args="define=MACROS")

t.expect_addition("bin/$toolset/debug/" * (List("a.o b.o b.dll a.exe")))

# Regression test: direct build request was not working
# when there's more than one level of 'build-project'

t.rm(".")
t.write('project-root.jam', '')
t.write('Jamfile', 'build-project a ;')
t.write('a/Jamfile', 'build-project b ;')
t.write('a/b/Jamfile', '')

t.run_build_system("release")

t.cleanup()
#!/usr/bin/python

#  Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

#  Test that conditional properties work, even if property is free, and
#  value includes colon.
from BoostBuild import Tester, List


t = Tester()

# Create the needed files
t.write("project-root.jam", "")
t.write("Jamfile", """
exe hello : hello.cpp : <variant>debug:<define>CLASS=Foo::Bar ;
""")
t.write("hello.cpp", """
namespace Foo { class Bar { } ; }
int main()
{
    CLASS c;
    return 0;
}

""")

# Don't check stderr, which can include warning about unused 'c'.
t.run_build_system(stdout=None, stderr=None)
Beispiel #16
0
<optimization>space <rtti>on <runtime-link>dynamic <toolset>yfc <variant>debug
b.cpp
""")

# Check that we have vanilla target names available in subdirs

t.touch("auxillary/b.cpp")
t.run_build_system("-sTOOLSET b.obj", subdir="auxillary")
t.expect_touch("auxillary/bin/b.obj/yfc/debug/runtime-link-dynamic/optimization-space/b.obj")
t.expect_no_modification("bin/a.obj/yfc/debug/runtime-link-dynamic/a.obj")
t.expect_no_modification("bin/a/yfc/debug/runtime-link-dynamic/a")


# Check that we cannot request link-incompatible property for source target

t.write('Jamfile', t.read('Jamfile2'))
stdout="""Error: subvariant of target ./a with properties
    <optimization>off <rtti>on <runtime-link>dynamic <toolset>yfc <variant>debug
requests link-incompatible property
    <rtti>off
for source @auxillary/b.obj
"""
t.run_build_system("-sTOOLSET=yfc", stdout=stdout)

# Check that if we request link-compatible property then requirement for
# the source target will override it, with warning. This is similar to
# the way build requests are satisfied (see the first test)
# CONSIDER: should be print the main target which requests this one
# (and modifies requiremenets)?

t.write('Jamfile3', t.read('Jamfile3'))
Beispiel #17
0
# Test that unused sources are at least reported.

from BoostBuild import Tester
from string import find
t = Tester()

t.set_tree("unused")

t.run_build_system()
# The second invocation should do nothing, and produce
# no warning. The previous invocation might have printed
# executed actions and other things, so it's not easy
# to check if warning was issued or not.
t.run_build_system()
t.fail_test(find(t.stdout(), "warning: Unused source { b.X } in main target ./a") == -1)

t.run_build_system("-sGENERATE_ONLY_UNUSABLE=1")
t.fail_test(find(t.stdout(), "warning: Unused source { b.X } in main target ./a") == -1)

# Now check that even if main target generates nothing, its
# usage requirements are still propagated to dependents.
t.write("a.cpp","""
#ifdef FOO
int main() {}
#endif
""")
t.run_build_system("-sGENERATE_NOTHING=1")

t.cleanup()

Beispiel #18
0
#!/usr/bin/python

from BoostBuild import Tester, List
import os
from string import strip

t = Tester()

# First check some startup
t.set_tree("direct-request-test")
t.run_build_system(extra_args="define=MACROS")

t.expect_addition("bin/$toolset/debug/" 
                  * (List("a.o b.o b.dll a.exe")))
		  
# Regression test: direct build request was not working
# when there's more than one level of 'build-project'

t.rm(".")
t.write('project-root.jam', '')
t.write('Jamfile', 'build-project a ;')
t.write('a/Jamfile', 'build-project b ;')
t.write('a/b/Jamfile', '')

t.run_build_system("release")		  


t.cleanup()
Beispiel #19
0
#!/usr/bin/python

#  Copyright (C) Pedro Ferreira 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

from BoostBuild import Tester, List
import string

t = Tester()

t.write("project-root.jam", "")
t.write("Jamfile", """ 
import virtual-target ;
rule tag ( name : type ? : property-set )
{
    local tags ;
    local v = [ $(property-set).get <variant> ] ;
    if $(v) = debug
    {
        tags += d ;
    }
    else if $(v) = release
    {
        tags += r ;
    }
    
    local l = [ $(property-set).get <link> ] ;
    if $(l) = shared
    {
#!/usr/bin/python

# Test usage of searched-libs: one which are found via -l
# switch to the linker/compiler. 

from BoostBuild import Tester, get_toolset
import string
import os
t = Tester()

# To start with, we have to prepate a library to link with
t.write("lib/project-root.jam", "")
t.write("lib/Jamfile", "lib libtest_lib : test_lib.cpp ;")
t.write("lib/test_lib.cpp", """
#ifdef _WIN32
__declspec(dllexport)
#endif
void foo() {}
""");

t.run_build_system(subdir="lib")
t.expect_addition("lib/bin/$toolset/debug/libtest_lib.dll")

# Auto adjusting of suffixes does not work, since we need to
# change dll to lib.
# 
if (os.name == 'nt' or os.uname()[0].lower().startswith('cygwin')) and get_toolset() != 'gcc':
    t.copy("lib/bin/$toolset/debug/libtest_lib.lib", "lib/test_lib.lib")
else:
    t.copy("lib/bin/$toolset/debug/libtest_lib.dll", "lib/libtest_lib.dll")
Beispiel #21
0
#!/usr/bin/python

#  Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

#  Test that V2 does not fail gracelessy when any target is skipped.
from BoostBuild import Tester, List

# Create a temporary working directory
t = Tester()
t.write("a.cpp", """ 
int main() {} 
""")

t.write("b.cpp", """ 
int main() {} 
""")

t.write("c.cpp", """ 
int main() {} 
""")

t.write("Jamfile", """ 
import feature : feature ;

feature foo : 1 2 : link-incompatible ;

exe a : a.cpp : <foo>1 ;
exe b : b.cpp : <foo>2 ;
#!/usr/bin/python

#  Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

#  Test that we can access project-root attributes from Jamfiles.
from BoostBuild import Tester, List

# Create a temporary working directory
t = Tester()

t.write("Jamfile", """
local l = [ project-root get-location ] ;
ECHO XXX $(l) ;
""")

t.write("project-root.jam", "")
        
t.run_build_system(stdout="XXX .\n")

t.cleanup()
Beispiel #23
0
#!/usr/bin/python

from BoostBuild import Tester, List
t = Tester()

# Test that top-level project can affect build dir
t.write("project-root.jam", "")
t.write(
    "Jamfile", """

exe a : a.cpp ;
exe b : b.cpp ;
exe c : c.cpp ;

alias bin1 : a ;
alias bin2 : a b ;

alias src : s.cpp ;
exe hello : hello.cpp src ;

""")
t.write("a.cpp", "int main() { return 0; }\n")
t.copy("a.cpp", "b.cpp")
t.copy("a.cpp", "c.cpp")
t.copy("a.cpp", "hello.cpp")
t.write("s.cpp", "")

# Check that targets to which "bin1" refers are updated,
# and only those.
t.run_build_system("bin1")
t.ignore("*.tds")
Beispiel #24
0
# Copyright 2004 Vladimir Prus.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

#  Test that we load parent projects before loading children.
from BoostBuild import Tester, List
from string import find

t = Tester()

t.write("Jamfile", """ 
use-project /child : child ;

ECHO "Setting parent requirements" ;
project
    : requirements <define>PASS_THE_TEST
    ; 
    
alias x : child//main ;    
""")

t.write("project-root.jam", """ 
""")

t.write("child/Jamfile", """ 
ECHO "Setting child requirements" ;
project /child ;

exe main : main.cpp ; 
""")
Beispiel #25
0
#!/usr/bin/python

# Test staging

from BoostBuild import Tester

t = Tester()

t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", """
lib a : a.cpp ;
stage dist : a a.h auxilliary/1 ;
""")
t.write("a.cpp", "")
t.write("a.h", "")
t.write("auxilliary/1", "")

t.run_build_system()
t.expect_addition(["dist/a.dll", "dist/a.h", "dist/1"])

# Test the <location> property
t.write(
    "Jamfile", """
lib a : a.cpp ;
stage dist : a 
    : <variant>debug:<location>ds <variant>release:<location>rs
    ;
""")

t.run_build_system()
t.expect_addition("ds/a.dll")
Beispiel #26
0
#!/usr/bin/python

# Test that we can change build directory using
# the 'build-dir' project attribute.

from BoostBuild import Tester
t = Tester()

# Test that top-level project can affect build dir
t.write("project-root.jam", "import gcc ; ")
t.write(
    "Jamfile", """
project
    : build-dir build
    ;
    
exe a : a.cpp ;
build-project src ;    
""")
t.write("a.cpp", "int main() { return 0; }\n")

t.write("src/Jamfile", "exe b : b.cpp ; ")
t.write("src/b.cpp", "int main() { return 0; }\n")

t.run_build_system()

t.expect_addition(
    ["build/bin/$toolset/debug/a.exe", "build/src/bin/$toolset/debug/b.exe"])

# Test that building from child projects work
t.run_build_system(subdir='src')
Beispiel #27
0
#!/usr/bin/python

# Test usage of searched-libs: one which are found via -l
# switch to the linker/compiler. 

from BoostBuild import Tester
import string
t = Tester()

# To start with, we have to prepate a library to link with
t.write("lib/project-root.jam", "import gcc ; ")
t.write("lib/Jamfile", "lib test_lib : test_lib.cpp ;")
t.write("lib/test_lib.cpp", "void foo() {}\n");

t.run_build_system(subdir="lib")
t.expect_addition("lib/bin/$toolset/debug/test_lib.dll")

t.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/libtest_lib.dll")


# A regression test: <library>property referring to
# searched-lib was mishandled. As the result, we were
# putting target name to the command line!
# Note that 
#    g++ ...... <.>z
# works nicely in some cases, sending output from compiler
# to file 'z'.
# This problem shows up when searched libs are in usage
# requirements.

t.write('project-root.jam', 'import gcc ;')
Beispiel #28
0
#!/usr/bin/python

# Copyright 2003, 2004 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

# Test that sources with absolute names are handled OK.

from BoostBuild import Tester
t = Tester()

t.write("project-root.jam", """
path-constant TOP : . ;
""")
t.write("Jamfile", """
local pwd = [ PWD ] ;
ECHO $(pwd) XXXXX ;
exe hello : $(pwd)/hello.cpp $(TOP)/empty.cpp ;
""")
t.write("hello.cpp", "int main() { return 0; }\n")
t.write("empty.cpp", "\n")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/hello.exe")

# Test a contrived case. There, absolute name is used in
# standalone project (not Jamfile). Moreover, the target with
# absolute name is returned by 'alias' and used from other project.
t.write("a.cpp", """ 
int main()
{
Beispiel #29
0
#!/usr/bin/python

# Copyright 2003 Dave Abrahams 
# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

# Test staging

from BoostBuild import Tester
t = Tester()

t.write("project-root.jam", "import gcc ;")

t.write(
    "Jamfile", 
"""
lib a : a.cpp ;
stage dist : a a.h auxilliary/1 ;
""")

t.write(
    "a.cpp",
"""
int
#ifdef _WIN32
__declspec(dllexport)
#endif
must_export_something;
""")
Beispiel #30
0
#  accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)

# Test that projects with multiple source-location directories are handled OK.

from BoostBuild import Tester
t = Tester()

t.write("Jamroot", """
path-constant SRC1  : "./src1" ;
path-constant SRC2  : "./src2" ;
path-constant SRC3  : "./src3" ;
path-constant BUILD : "build" ;

project
        : requirements
                <include>$(SRC1)/include
                <threading>multi
        : build-dir $(BUILD)
        ;

build-project project1 ;

""")
t.write("project1/Jamfile", """
project project1
        : source-location $(SRC1)
          $(SRC2)
          $(SRC3)
        ;

SRCS =  s1.cpp
Beispiel #31
0
#  Copyright (C) Vladimir Prus 2006.
#  Distributed under the Boost Software License, Version 1.0. (See
#  accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)

#  Tests for the target id resolution process.
from BoostBuild import Tester, List

# Create a temporary working directory
t = Tester()

# Create the needed files
t.write("Jamroot", """
exe hello : hello.cpp ;
# This should use the 'hello' target, even if there's
# 'hello' file in current dir.
install s : hello : <location>. ;
""")
t.write("hello.cpp", """
int main()
{
    return 0;
}
""")

t.run_build_system()

t.expect_addition("bin/$toolset/debug/hello.obj")

t.touch("hello.cpp")
t.run_build_system("s")
Beispiel #32
0
# Copyright 2002, 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

# This tests that
# 1) the 'make' correctly assigns types to produced targets
# 2) than if 'make' create targets of type CPP, they are
# correctly used (there was a bug with it).

from BoostBuild import Tester

t = Tester()

# In order to correctly link this app, 'b.cpp', created by 'make'
# rule, should be compiled.
t.write("project-root.jam", "import gcc ;")
t.write(
    "Jamfile", r'''
rule create ( dst : src * : properties * )
{
    # hack to echo a space under NT
    setup on $(dst) = "set x=int main(){ return 0; }" ;
}

import modules ;
if [ modules.peek : NT ]
{
    actions create 
    {
        $(setup)
        echo %x% > $(<)
from BoostBuild import Tester
import os, string

t = Tester(
      executable="jam"
    , workdir = os.getcwd()
    , pass_toolset=0
    )

jamfile="""
actions print_pwd { pwd ; }
print_pwd pwd ;
Always pwd ;
"""

t.write("Jamfile", jamfile)
t.write("project-root.jam", " ")

t.run_build_system(status=0, extra_args = "pwd")

if 'TMP' in os.environ:
  tmp_dir =os.environ.get('TMP')
else:
  tmp_dir ="/tmp"

if string.rfind(t.stdout(), tmp_dir) != -1:
    t.fail_test(1)

if string.rfind(t.stdout(), 'build/v2/test') == -1:
    t.fail_test(1)
Beispiel #34
0
#!/usr/bin/python

# Test conditional properties

from BoostBuild import Tester, List
import os
from string import strip

t = Tester()

# Arrange a project which will build only if
# 'a.cpp' is compiled with "STATIC" define.
t.write("project-root.jam", "import gcc ;")
t.write("a.cpp", """
#ifdef STATIC
int main() {  return 0; }
#endif
""")
t.write("Jamfile", "exe a : a.cpp : <link>static:<define>STATIC ;")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/a.exe")

t.write(
    "Jamfile", """
project : requirements <link>static:<define>STATIC ;
exe a : a.cpp ;
""")
t.rm("bin")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/a.exe")
Beispiel #35
0
#  Distributed under the Boost Software License, Version 1.0. (See
#  accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)

#  Test that it's possible to add a suffix to a main target name to
#  disambiguate that main target from another, and that this does not
#  affect the names of the generated targets.
from BoostBuild import Tester, List

# Create a temporary working directory
t = Tester()

# Create the needed files
t.write("Jamroot", """
exe hello.exe : hello.obj ;
obj hello.obj : hello.cpp : <variant>debug ;
obj hello.obj2 : hello.cpp : <variant>release ;
""")
t.write("hello.cpp", """
int main()
{
    return 0;
}

""")

t.run_build_system()

t.expect_addition("bin/$toolset/debug/hello.exe")
t.expect_addition("bin/$toolset/debug/hello.obj")
t.expect_addition("bin/$toolset/release/hello.obj")
# Niklaus Giger, 2005-03-15
# Testing whether we may run a test in a absolute directories
# There are no tests for temporary directories as this is implictly tested in a lot of other cases

from BoostBuild import Tester
import os, string

t = Tester(executable="jam", workdir=os.getcwd(), pass_toolset=0)

jamfile = """
actions print_pwd { pwd ; }
print_pwd pwd ;
Always pwd ;
"""

t.write("Jamfile", jamfile)
t.write("project-root.jam", " ")

t.run_build_system(status=0, extra_args="pwd")

if 'TMP' in os.environ:
    tmp_dir = os.environ.get('TMP')
else:
    tmp_dir = "/tmp"

if string.rfind(t.stdout(), tmp_dir) != -1:
    t.fail_test(1)

if string.rfind(t.stdout(), 'build/v2/test') == -1:
    t.fail_test(1)
#!/usr/bin/python

# Test usage of searched-libs: one which are found via -l
# switch to the linker/compiler.

from BoostBuild import Tester
import string
t = Tester()

# To start with, we have to prepate a library to link with
t.write("lib/project-root.jam", "import gcc ; ")
t.write("lib/Jamfile", "lib test_lib : test_lib.cpp ;")
t.write("lib/test_lib.cpp", "void foo() {}\n")

t.run_build_system(subdir="lib")
t.expect_addition("lib/bin/$toolset/debug/test_lib.dll")

t.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/libtest_lib.dll")

# A regression test: <library>property referring to
# searched-lib was mishandled. As the result, we were
# putting target name to the command line!
# Note that
#    g++ ...... <.>z
# works nicely in some cases, sending output from compiler
# to file 'z'.
# This problem shows up when searched libs are in usage
# requirements.

t.write('project-root.jam', 'import gcc ;')
t.write('Jamfile', 'exe main : main.cpp d/d2/a ;')
Beispiel #38
0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)

# Regression test. When Jamfile contained "using whatever ; " and the
# 'whatever' module declared a project, then all targets in Jamfile were
# considered to be declared in the project associated with 'whatever',
# not with the Jamfile.

from BoostBuild import Tester, List

t = Tester()
# Remove temporary directories

t.write("a.cpp", """ 
int main() { return 0; }

""")

t.write("Jamroot", """ 
using some_tool ;
exe a : a.cpp ; 
""")

t.write(
    "some_tool.jam", """ 
import project ;
project.initialize $(__name__) ;

rule init ( )
{
}
#  Basic tests for the 'notfile' rule.

from BoostBuild import Tester, List
import string
import os

t = Tester()

t.write("Jamroot", """ 
import notfile ;

notfile say : "echo hi" ;

exe hello : hello.cpp ;
notfile hello_valgrind : @valgrind : hello ;

actions valgrind
{
   valgrind $(>) 
}

""")

t.write("hello.cpp", """

#include <iostream>

int main()
{
    std::cout << "Hello!\\n";
    return 1;
Beispiel #40
0
# Copyright 2002, 2003, 2004 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

# Test that we can specify a dependency property
# in project requirements, and that it won't
# cause every main target in the project to
# be generated in it's own subdirectory.

# The whole test is somewhat moot now.

from BoostBuild import Tester, List

t = Tester()

t.write("Jamroot", "build-project src ;")
t.write("lib/Jamfile", "lib lib1 : lib1.cpp ;")
t.write("lib/lib1.cpp", """
#ifdef _WIN32
__declspec(dllexport)
#endif
void foo() {}\n
""")
t.write(
    "src/Jamfile", """
project
    : requirements <library>../lib//lib1
    ;
    
exe a : a.cpp ;
exe b : b.cpp ;    
Beispiel #41
0
# Copyright 2003 Dave Abrahams
# Copyright 2002, 2003, 2005 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

# Test that we can change build directory using
# the 'build-dir' project attribute.

from BoostBuild import Tester
import string
import os

t = Tester()

# Test that top-level project can affect build dir
t.write("project-root.jam", "import gcc ; ")
t.write(
    "Jamfile", """
project
    : build-dir build
    ;
    
exe a : a.cpp ;
build-project src ;    
""")
t.write("a.cpp", "int main() { return 0; }\n")

t.write("src/Jamfile", "exe b : b.cpp ; ")
t.write("src/b.cpp", "int main() { return 0; }\n")

t.run_build_system()
Beispiel #42
0
#!/usr/bin/python

# Copyright 2003 Dave Abrahams
# Copyright 2002, 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

# Test that we can specify sources using relative names.

from BoostBuild import Tester

t = Tester()

t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", "exe a : src/a.cpp ;")
t.write("src/a.cpp", "int main() { return 0; }\n")

t.run_build_system()

t.cleanup()
#!/usr/bin/python

#  Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

from BoostBuild import Tester, List
import string

t = Tester()

#  Regression test for double loading of the same Jamfile.
t.write("Jamfile", """ 
build-project subdir ; 
""")

t.write("project-root.jam", """ 
""")

t.write("subdir/Jamfile", """ 
ECHO "Loaded subdir" ; 
""")

t.run_build_system(subdir="subdir")
t.fail_test(string.count(t.stdout(), "Loaded subdir") != 1)

#  Regression test for a more contrived case. The top-level
#  jamfile refers to subdir via use-project, while subdir's
#  Jamfile is being loaded. The motivation why use-project
#  referring to subprojects are usefull can be found at
Beispiel #44
0
# Copyright 2003, 2004, 2005, 2006 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

#  Test that a chain of libraries work ok, not matter if we use static or
#  shared linking.
from BoostBuild import Tester, List, get_toolset
import string
import os

t = Tester()

t.write("Jamfile", """
# Stage the binary, so that it will be relinked
# without hardcode-dll-paths. That will chech that
# we pass correct -rpath-link, even if not passing
# -rpath.
stage dist : main ;
exe main : main.cpp b ; 
""")

t.write("main.cpp", """ 
void foo();

int main() { foo(); return 0; }

""")

t.write("project-root.jam", """ 
""")

t.write("a/a.cpp", """
Beispiel #45
0
#!/usr/bin/python

#  Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

#  Test that we can access project-root attributes from Jamfiles.
from BoostBuild import Tester, List

# Create a temporary working directory
t = Tester()

t.write("Jamfile", """
local l = [ project-root get-location ] ;
ECHO XXX $(l) ;
""")

t.write("project-root.jam", "")

t.run_build_system(stdout="XXX .\n")

t.cleanup()
Beispiel #46
0
#!/usr/bin/python

# Test that sources with absolute names are handled OK.

from BoostBuild import Tester
t = Tester()

t.write("project-root.jam", """
path-constant TOP : . ;
""")
t.write(
    "Jamfile", """
local pwd = [ PWD ] ;
ECHO $(pwd) XXXXX ;
exe hello : $(pwd)/hello.cpp $(TOP)/empty.cpp ;
""")
t.write("hello.cpp", "int main() { return 0; }\n")
t.write("empty.cpp", "\n")

t.run_build_system()
t.expect_addition("bin/$toolset/debug/hello.exe")

# Test a contrived case. There, absolute name is used in
# standalone project (not Jamfile). Moreover, the target with
# absolute name is returned by 'alias' and used from other project.
t.write("a.cpp", """ 
int main()
{
    return 0;
}
Beispiel #47
0
#!/usr/bin/python

#  Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

from BoostBuild import Tester, List
from string import find

t = Tester()


t.write("project-root.jam", "")
t.write("Jamfile", """ 

lib main : main.cpp l ;
lib l : l.cpp main ; 
""")

t.write("main.cpp", "")
t.write("l.cpp", "")

t.run_build_system("--no-error-backtrace", status=1)
t.fail_test(find(t.stdout(), "error: Recursion in main target references") == -1)
t.fail_test(find(t.stdout(), "./main ./l ./main") == -1)

t.cleanup()
Beispiel #48
0
#!/usr/bin/python

from BoostBuild import Tester
t = Tester()

t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", "lib a : a.cpp : <include>. ;")
t.write("a.cpp", """
#include <a.h>
void
# ifdef _WIN32
__declspec(dllexport)
# endif 
foo() {}
""")
t.write("a.h", "//empty file\n")

t.write("d/Jamfile", "exe b : b.cpp ..//a ; ")
t.write("d/b.cpp", """
    void foo();
    int main() { foo(); }
""")

t.run_build_system(subdir="d")

# Now test the path features with condition work as well
t.write("Jamfile", "lib a : a.cpp : <variant>debug:<include>.  ;")
t.rm("bin")
t.run_build_system(subdir="d")

# Test path features with condtion in usage requirements
Beispiel #49
0
#!/usr/bin/python

# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

#  Test that composite properties are handled correctly.
from BoostBuild import Tester, List

t = Tester()

t.write("project-root.jam", "")
t.write("Jamfile", """
exe hello : hello.cpp : <variant>release ;
""")
t.write("hello.cpp", """
int main()
{
    return 0;
}

""")

t.run_build_system()

t.expect_addition("bin/$toolset/release/hello.exe")

t.cleanup()
Beispiel #50
0
# Copyright 2002, 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

# This tests that
# 1) the 'make' correctly assigns types to produced targets
# 2) than if 'make' create targets of type CPP, they are
# correctly used (there was a bug with it).

from BoostBuild import Tester

t = Tester()

# In order to correctly link this app, 'b.cpp', created by 'make'
# rule, should be compiled.
t.write("project-root.jam", "import gcc ;")
t.write(
    "Jamfile",
    r"""
rule create ( dst : src * : properties * )
{
    # hack to echo a space under NT
    setup on $(dst) = "set x=int main(){ return 0; }" ;
}

import modules ;
if [ modules.peek : NT ]
{
    actions create 
    {
        $(setup)
Beispiel #51
0
#!/usr/bin/python

# Copyright 2003, 2006 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

from BoostBuild import Tester, List

t = Tester()

t.write("Jamroot", """
project : requirements <link>static ;
exe a : a.cpp [ lib helper : helper.cpp ] ; 
""")

t.write("a.cpp", """
extern void helper();
int main()
{
    return 0;
}

""")

t.write("helper.cpp", """
void helper()
{
}
""")

t.run_build_system()
Beispiel #52
0
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

#  Test that a chain of libraries work ok, not matter if we use static or
#  shared linking.
from BoostBuild import Tester, List, get_toolset
import string
import os

t = Tester()

t.write(
    "Jamfile", """
# Stage the binary, so that it will be relinked
# without hardcode-dll-paths. That will chech that
# we pass correct -rpath-link, even if not passing
# -rpath.
stage dist : main ;
exe main : main.cpp b ; 
""")

t.write("main.cpp", """ 
void foo();

int main() { foo(); return 0; }

""")

t.write("project-root.jam", """ 
""")