"""
int 
#if defined(_WIN32) && defined(SHARED_C)
__declspec(dllexport)
#endif
must_export_something;
""")

t.write(
    "lib2/Jamfile", 
"""
    lib b : b.cpp : <link>shared:<define>SHARED_B
    : : <define>FOO <link>shared:<define>SHARED_B ;
""")

t.copy("b.cpp", "lib2/b.cpp")

t.run_build_system()

# Test that dependency feature in use requirements are built
# with the correct properties
t.rm(".")

t.write(
    "Jamfile", 
""" 
lib main : main.cpp : <use>libs//lib1 : : <library>libs//lib1 ; 
exe hello : hello.cpp main : ;
""")

t.write(
Exemple #2
0
__declspec(dllexport)
#endif
void foo() {}\n
""")
t.write(
    "src/Jamfile", """
project
    : requirements <library>../lib//lib1
    ;
    
exe a : a.cpp ;
exe b : b.cpp ;    
""")
t.write(
    "src/a.cpp", """
#ifdef _WIN32
__declspec(dllimport)
#endif
void foo();
int main() { foo(); return 0; }
""")
t.copy("src/a.cpp", "src/b.cpp")

t.run_build_system()

# Test that there's no "main-target-a" part.
# t.expect_addition("src/bin/$toolset/debug/a.exe")
# t.expect_addition("src/bin/$toolset/debug/b.exe")

t.cleanup()
Exemple #3
0
# Test that we can use already built sources

from BoostBuild import Tester
t = Tester()

t.set_tree('prebuilt')

t.expand_toolset("ext/project-root.jam")
t.expand_toolset("project-root.jam")
# First, build the external project
t.run_build_system("debug release", subdir="ext")

# Then pretend that we don't have the sources for the external project,
# and can only use compiled binaries
t.copy("ext/Jamfile2", "ext/Jamfile")
t.expand_toolset("ext/Jamfile")

# Now check that we can build the main project, and that
# correct prebuilt file is picked, depending of variant.
# This also checks that correct includes for prebuilt
# libraries are used.

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

t.rm("bin")
# Now test that prebuilt file specified by absolute name 
# works too.
t.copy("ext/Jamfile3", "ext/Jamfile")
t.set_tree("direct-request-test")
t.run_build_system(extra_args="define=MACROS")

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

# When building debug version, the 'define' still applies
t.rm("bin")
t.run_build_system(extra_args="debug define=MACROS")
t.expect_addition("bin/$toolset/debug/" 
                  * (List("a.obj b.obj b.dll a.exe")))

# When building release version, the 'define' should not
# apply: we'll have direct build request 'release <define>MACROS'
# and real build properties 'debug'.
t.copy("Jamfile2", "Jamfile")
t.copy("b_inverse.cpp", "b.cpp")
t.rm("bin")
t.run_build_system(extra_args="release define=MACROS")


# 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")
Exemple #5
0
t.write("lib/project-root.jam", "")
t.write("lib/Jamfile", "lib test_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/test_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/test_lib.implib", "lib/test_lib.implib")
    t.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/test_lib.dll")
else:
    t.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/test_lib.dll")


# Test that the simplest usage of searched library works.
t.write('project-root.jam', '')
t.write('Jamfile', """

import path ;
import project ;

local here = [ project.attribute $(__name__) location ] ;
here = [ path.root $(here) [ path.pwd ] ] ;
Exemple #6
0
t.write("lib/Jamfile", "lib test_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/test_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/test_lib.implib", "lib/test_lib.implib")
    t.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/test_lib.dll")
else:
    t.copy("lib/bin/$toolset/debug/test_lib.dll", "lib/test_lib.dll")

# Test that the simplest usage of searched library works.
t.write('project-root.jam', '')
t.write(
    'Jamfile', """

import path ;
import project ;

local here = [ project.attribute $(__name__) location ] ;
here = [ path.root $(here) [ path.pwd ] ] ;
)

t.expect_addition("lib/bin/$toolset/debug/optimization-speed/b.obj")
t.expect_content(
    "lib/bin/$toolset/debug/optimization-speed/b.obj",
    """$toolset/debug/include-everything/optimization-speed
lib/b.cpp
""")

t.expect_addition("bin/$toolset/debug/b.exe")
t.expect_content(
    "bin/$toolset/debug/b.exe",
    "$toolset/debug/define-MACROS/include-everything\n" +
    "bin/$toolset/debug/a.obj\n")

t.copy("lib/Jamfile3", "lib/Jamfile")

# Link-compatibility check for rtti is disabled...
#t.run_build_system(status=None)
#t.fail_test(find(t.stdout(),
#"""warning: targets produced from b.obj are link incompatible
#warning: with main target a.exe""") !=-0)

# Test that if we specified composite property in target reference,
# everything works OK.

t.copy("lib/Jamfile1", "lib/Jamfile")
t.copy("Jamfile5", "Jamfile")

t.run_build_system()
# 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 ;')
t.write("main.cpp", """
int main() { return 0; }
t.write(
    "lib1/c.cpp", """
int 
#if defined(_WIN32) && defined(SHARED_C)
__declspec(dllexport)
#endif
must_export_something;
""")

t.write(
    "lib2/Jamfile", """
    lib b : b.cpp : <link>shared:<define>SHARED_B
    : : <define>FOO <link>shared:<define>SHARED_B ;
""")

t.copy("b.cpp", "lib2/b.cpp")

t.run_build_system()

# Test that dependency feature in use requirements are built
# with the correct properties
t.rm(".")

t.write(
    "Jamfile", """ 
lib main : main.cpp : <use>libs//lib1 : : <library>libs//lib1 ; 
exe hello : hello.cpp main : ;
""")

t.write(
    "main.cpp", """ 
Exemple #10
0
)

t.expect_addition("lib/bin/$toolset/debug/optimization-speed/b.obj")
t.expect_content(
    "lib/bin/$toolset/debug/optimization-speed/b.obj",
    """$toolset/debug/include-everything/optimization-speed
lib/b.cpp
""")

t.expect_addition("bin/$toolset/debug/main-target-b.exe/b.exe")
t.expect_content(
    "bin/$toolset/debug/main-target-b.exe/b.exe",
    "$toolset/debug/define-MACROS/include-everything\n" +
    "bin/$toolset/debug/a.obj\n")

t.copy("lib/Jamfile2", "lib/Jamfile")

expected = """error: Requirements for project at 'lib' conflict with parent's.
Explanation:  link-incompatible properties <threading>single and <threading>multi

"""
t.run_build_system("--no-error-backtrace", stdout=expected, status=None)

t.copy("lib/Jamfile3", "lib/Jamfile")

t.run_build_system(status=None)
t.fail_test(find(t.stdout(), "warning: skipped build of lib/b.obj with properties") \
            != 0)

# Check that project can be skipped as well
t.copy("Jamfile4", "Jamfile")
Exemple #11
0
# 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.obj b.obj b.dll a.exe")))

# When building debug version, the 'define' still applies
t.rm("bin")
t.run_build_system(extra_args="debug define=MACROS")
t.expect_addition("bin/$toolset/debug/" * (List("a.obj b.obj b.dll a.exe")))

# When building release version, the 'define' should not
# apply: we'll have direct build request 'release <define>MACROS'
# and real build properties 'debug'.
t.copy("Jamfile2", "Jamfile")
t.copy("b_inverse.cpp", "b.cpp")
t.rm("bin")
t.run_build_system(extra_args="release define=MACROS")

# 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.expect_addition("lib/bin/$toolset/debug/optimization-speed/b.obj")
t.expect_content("lib/bin/$toolset/debug/optimization-speed/b.obj",
"""$toolset/debug/include-everything/optimization-speed
lib/b.cpp
""")

t.expect_addition("bin/$toolset/debug/b.exe")
t.expect_content("bin/$toolset/debug/b.exe",
"$toolset/debug/define-MACROS/include-everything\n" +
"bin/$toolset/debug/a.obj\n"
)


t.copy("lib/Jamfile3", "lib/Jamfile")

# Link-compatibility check for rtti is disabled...
#t.run_build_system(status=None)
#t.fail_test(find(t.stdout(),
#"""warning: targets produced from b.obj are link incompatible
#warning: with main target a.exe""") !=-0)

# Test that if we specified composite property in target reference,
# everything works OK.

t.copy("lib/Jamfile1", "lib/Jamfile")
t.copy("Jamfile5", "Jamfile")

t.run_build_system()
Exemple #13
0
#!/usr/bin/python

# Test that we can use already built sources

from BoostBuild import Tester
t = Tester()

t.set_tree('prebuilt')

# First, build the external project
t.run_build_system("debug release", subdir="ext")

# Then pretend that we don't have the sources for the external project,
# and can only use compiled binaries
t.copy("ext/Jamfile2", "ext/Jamfile")

# Now check that we can build the main project, and that
# correct prebuilt file is picked, depending of variant.
# This also checks that correct includes for prebuilt
# libraries are used.

t.run_build_system("debug release")
t.expect_addition("bin/$toolset/debug/main-target-hello/hello.exe")
t.expect_addition("bin/$toolset/release/main-target-hello/hello.exe")

t.cleanup()
Exemple #14
0
# 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 ;')
t.write("main.cpp", """
from BoostBuild import Tester, List

t = Tester()

t.write("project-root.jam", "import gcc ;")
t.write("Jamfile", "build-project src ;")
t.write("lib/Jamfile", "lib lib1 : lib1.cpp ;")
t.write("lib/lib1.cpp", "void foo() {}\n")
t.write("src/Jamfile", """
project
    : requirements <library>../lib/lib1
    ;
    
exe a : a.cpp ;
exe b : b.cpp ;    
""")
t.write("src/a.cpp", """
void foo();
int main() { foo(); return 0; }
""")
t.copy("src/a.cpp", "src/b.cpp")

t.run_build_system()

# Test that there's no "main-target-a" part.
t.expect_addition("src/bin/$toolset/debug/" * List("a.exe b.exe"))


t.cleanup()
Exemple #16
0
t.write("Jamfile", """ 
lib l : l.cpp ;
exe a : a.cpp l ;
stage dist : a : <install-dependencies>on <install-type>EXE <install-type>LIB ; 
""")

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

t.rm("dist")
t.run_build_system()
t.expect_addition("dist/a.exe")
t.expect_addition("dist/l.dll")

# Check that <use> properties are ignored the traversing
# target for staging.
t.copy("l.cpp", "l2.cpp")
t.copy("l.cpp", "l3.cpp")
t.write("Jamfile", """
lib l2 : l2.cpp ;
lib l3 : l3.cpp ;
lib l : l.cpp : <use>l2 <dependency>l3 ;
exe a : a.cpp l ;
stage dist : a : <install-dependencies>on <install-type>EXE <install-type>LIB ; 
""")

t.rm("dist")
t.run_build_system()
t.expect_addition("dist/l3.dll")
t.expect_nothing("dist/l2.dll")

# Check if <dependency> on 'stage' works.
Exemple #17
0
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")
t.expect_addition(List("bin/$toolset/debug/") * "a.exe a.obj")
t.expect_nothing_more()

# Try again with "bin2"
t.run_build_system("bin2")
t.ignore("*.tds")
t.expect_addition(List("bin/$toolset/debug/") * "b.exe b.obj")
Exemple #18
0
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")
t.expect_addition(List("bin/$toolset/debug/") * "a.exe a.obj")
t.expect_nothing_more()

# Try again with "bin2"
t.run_build_system("bin2")
t.ignore("*.tds")
t.expect_addition(List("bin/$toolset/debug/") * "b.exe b.obj")
Exemple #19
0
t.expect_addition("lib/bin/$toolset/debug/optimization-speed/b.obj")
t.expect_content(
    "lib/bin/$toolset/debug/optimization-speed/b.obj",
    """$toolset/debug/include-everything/optimization-speed
lib/b.cpp
""",
)

t.expect_addition("bin/$toolset/debug/main-target-b.exe/b.exe")
t.expect_content(
    "bin/$toolset/debug/main-target-b.exe/b.exe",
    "$toolset/debug/define-MACROS/include-everything\n" + "bin/$toolset/debug/a.obj\n",
)


t.copy("lib/Jamfile2", "lib/Jamfile")

expected = """error: Requirements for project at 'lib' conflict with parent's.
Explanation:  link-incompatible properties <threading>single and <threading>multi

"""
t.run_build_system("--no-error-backtrace", stdout=expected, status=None)

t.copy("lib/Jamfile3", "lib/Jamfile")

t.run_build_system(status=None)
t.fail_test(find(t.stdout(), "warning: skipped build of lib/b.obj with properties") != 0)

# Check that project can be skipped as well
t.copy("Jamfile4", "Jamfile")