Ejemplo n.º 1
0
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 ;
""")
t.write("a.cpp", """
int main() { return 0; }
""")

t.rm("bin")
t.run_build_system()
t.expect_addition(["bin/$toolset/debug/a.o", "bin/$toolset/debug/main-target-b/a.o"])


t.cleanup()
Ejemplo n.º 2
0
exe a : [ glob ../*.cpp ] ;
""")
t.write("d3/a.cpp", """
int main()
{
    return 0;
}
""")

t.run_build_system(subdir="d1")
t.expect_addition("d1/bin/$toolset/debug/a.exe")

t.run_build_system(subdir="d3/d")
t.expect_addition("d3/d/bin/$toolset/debug/a.exe")

t.rm("d2/d/bin")
t.run_build_system(subdir="d2/d")
t.expect_addition("d2/d/bin/$toolset/debug/l.dll")

# Test that when 'source-location' is explicitly-specified
# glob works relatively to source location
t.rm("d1")

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

""")

t.write(
    "d1/Jamfile", """
project : source-location src ;
Ejemplo n.º 3
0
void 
#if defined(_WIN32)
__declspec(dllexport)
#endif
foo() { geek(); }

""")

t.write("b/Jamfile", """ 
lib b : b.cpp ../a//a ; 
""")

t.run_build_system(stderr=None)
t.expect_addition("bin/$toolset/debug/main.exe")
t.rm(["bin", "a/bin", "b/bin"])

t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/main.exe")
t.rm(["bin", "a/bin", "b/bin"])

# Check that <library> works for static linking.

t.write("b/Jamfile", """ 
lib b : b.cpp : <library>../a//a ; 
""")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/main.exe")

t.rm(["bin", "a/bin", "b/bin"])
t.write("b/Jamfile", """ 
Ejemplo n.º 4
0
t.write("Jamfile", "build-project d ;")

t.write(
    "d/Jamfile",
"""
exe a : a.cpp ;
stage dist : a : <location>$(DIST) ;
""")

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

t.run_build_system()
t.expect_addition("dist/a.exe")

t.rm("dist")
# Workaround a BIG BUG: the response file is not deleted,
# even if application *is* deleted. We'll try to use the
# same response file when building from subdir, with very
# bad results.
t.rm("d/bin")
t.run_build_system(subdir="d")
t.expect_addition("dist/a.exe")


# Check that 'stage' does not incorrectly reset target suffixes.
t.write("a.cpp", """ 
int main() {} 
""")

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()
Ejemplo n.º 6
0
t.write("standalone.jam", """ 
import project ;

project.initialize $(__name__) ;
project standalone ;

local pwd = [ PWD ] ;

alias a : $(pwd)/a.cpp ;

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

# Test absolute path in target ids
t.rm(".")
t.write("d1/project-root.jam", "")
t.write("d1/Jamfile", """
exe a : a.cpp ;
""")
t.write("d1/a.cpp", """
int main() { return 0; }
""")
t.write("d2/project-root.jam", "")
t.write("d2/Jamfile", """
local pwd = [ PWD ] ;
alias x : $(pwd)/../d1//a ;
""")

t.run_build_system(subdir="d2")
t.expect_addition("d1/bin/$toolset/debug/a.exe")
Ejemplo n.º 7
0
t.write("project-root.jam", "")
t.write("Jamfile", """ 
alias everything : [ exe a : a.cpp ] ; 
""")

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

""")

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

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

t.rm("bin")

# Now check that inline targets with the same name but
# present in different places are not confused between
# each other, and with top-level targets.
t.write(
    "Jamfile", """
exe a : a.cpp ;
alias everything : [ exe a : a.cpp ] ;
alias everything2 : [ exe a : a.cpp ] ; 
""")
Ejemplo n.º 8
0
exe a : [ glob ../*.cpp ] ;
""")
t.write("d3/a.cpp", """
int main()
{
    return 0;
}
""")

t.run_build_system(subdir="d1")
t.expect_addition("d1/bin/$toolset/debug/a.exe")

t.run_build_system(subdir="d3/d")
t.expect_addition("d3/d/bin/$toolset/debug/a.exe")

t.rm("d2/d/bin")
t.run_build_system(subdir="d2/d")
t.expect_addition("d2/d/bin/$toolset/debug/l.dll")

# Test that when 'source-location' is explicitly-specified
# glob works relatively to source location
t.rm("d1")

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

""")

t.write("d1/Jamfile", """
project : source-location src ;
exe a : [ glob *.cpp ] ../d2/d//l ; 
Ejemplo n.º 9
0
    "d2/d/l.cpp", """ 
#if defined(_WIN32)
__declspec(dllexport)
void force_import_lib_creation() {}
#endif
""")

t.write("d2/d/Jamfile", """ 
lib l : [ glob *.cpp ] ; 
""")

t.run_build_system(subdir="d1")

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

t.rm("d2/d/bin")
t.run_build_system(subdir="d2/d")
t.expect_addition("d2/d/bin/$toolset/debug/l.dll")

# Test that when 'source-location' is explicitly-specified
# glob works relatively to source location
t.rm("d1")

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

""")

t.write(
    "d1/Jamfile", """
project : source-location src ;
Ejemplo n.º 10
0
{
    return 0;
}

""",
)

t.run_build_system()
t.ignore("*.tds")
t.expect_addition(List("bin/$toolset/debug/hello") * [".exe", ".obj"])
t.expect_nothing_more()

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

t.rm(".")


# Test that 'explicit' used in a helper rule applies to the current project,
# and not to the Jamfile where the helper rule is defined.
t.write(
    "Jamroot",
    """ 
rule myinstall ( name : target )
{
    install $(name)-bin : $(target) ;
    explicit $(name)-bin ;
    alias $(name) : $(name)-bin ;
} 
""",
)
Ejemplo n.º 11
0
#endif
""",
)

t.write(
    "d2/d/Jamfile",
    """ 
lib l : [ glob *.cpp ] ; 
""",
)

t.run_build_system(subdir="d1")

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

t.rm("d2/d/bin")
t.run_build_system(subdir="d2/d")
t.expect_addition("d2/d/bin/$toolset/debug/l.dll")

# Test that when 'source-location' is explicitly-specified
# glob works relatively to source location
t.rm("d1")

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

""",
)
Ejemplo n.º 12
0
""")

t.write("hello.cpp", """ #include <pch.hpp>

int main()
{
  TestClass c(1, 2);    
  return 0;
}

""")

t.run_build_system()

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

# Now make the header unusable, without changing timestamp.
# If everything is OK, Boost.Build won't recreate PCH, and
# compiler will happily use pre-compiled header, not noticing
# that the real header is bad.

t.copy_preserving_timestamp("pch.hpp.bad", "pch.hpp")

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

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

t.cleanup()

Ejemplo n.º 13
0
int main()
{
    return 0;
}

""")

t.run_build_system()
t.ignore("*.tds")
t.expect_addition(List("bin/$toolset/debug/hello") * [".exe", ".obj"])
t.expect_nothing_more()

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

t.rm(".")

# Test that 'explicit' used in a helper rule applies to the current project,
# and not to the Jamfile where the helper rule is defined.
t.write(
    "Jamroot", """ 
rule myinstall ( name : target )
{
    install $(name)-bin : $(target) ;
    explicit $(name)-bin ;
    alias $(name) : $(name)-bin ;
} 
""")

t.write("sub/a.cpp", """ 
""")
Ejemplo n.º 14
0
# 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
t.write("Jamfile",
        "lib a : a.cpp : <include>. : : <variant>debug:<include>. ;")
t.write("d/b.cpp", """
#include <a.h>
void foo();
int main() { foo(); }
""")
t.rm("d/bin")
t.run_build_system(subdir="d")

# Test that absolute paths inside requirements are ok. The problem
# appear only when building targets in subprojects.
Ejemplo n.º 15
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.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(".")
Ejemplo n.º 16
0
t.run_build_system(pass_toolset=0)
t.expect_addition("bin/$toolset/debug/a.exe")

# Test that only properties which are in build request
# matters when selection alternative. IOW, alternative
# with <variant>release is better than one with
# <variant>debug when building release version.
t.write(
    "Jamfile", """

exe a : a_empty.cpp : <variant>debug ;
exe a : a.cpp : <variant>release ;
""")

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

# Test that free properties do not matter. We really don't
# want <cxxflags> property in build request to affect
# alternative selection.
t.write(
    "Jamfile", """
exe a : a_empty.cpp : <variant>debug <define>FOO <include>BAR ;
exe a : a.cpp : <variant>release ;
""")

t.rm("bin/$toolset/release/a.exe")
t.run_build_system("release define=FOO")
t.expect_addition("bin/$toolset/release/a.exe")
Ejemplo n.º 17
0
build-project src ;
""")           

t.write("src/Jamfile", """
project
    : build-dir build 
    ;
exe b : b.cpp ;    
""")

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

# Now test the '--build-dir' option.
t.rm(".")
t.write("Jamroot", "")

# Test that we get an error when no project id is specified.
t.run_build_system("--build-dir=foo")
t.fail_test(string.find(t.stdout(),
                   "warning: the --build-dir option will be ignored") == -1)

t.write("Jamroot", """
project foo ;
exe a : a.cpp ;
build-project sub ;
""")
t.write("a.cpp", "int main() { return 0; }\n")
t.write("sub/Jamfile", "exe b : b.cpp ;\n")
t.write("sub/b.cpp", "int main() { return 0; }\n")
Ejemplo n.º 18
0
void 
#if defined(_WIN32)
__declspec(dllexport)
#endif
foo() { geek(); }

""")

t.write("b/Jamfile", """ 
lib b : b.cpp ../a//a ; 
""")

t.run_build_system(stderr=None)
t.expect_addition("bin/$toolset/debug/main.exe")
t.rm(["bin", "a/bin", "b/bin"])

t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/main.exe")
t.rm(["bin", "a/bin", "b/bin"])

# Check that <library> works for static linking.

t.write("b/Jamfile", """ 
lib b : b.cpp : <library>../a//a ; 
""")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/main.exe")

t.rm(["bin", "a/bin", "b/bin"])
t.write("b/Jamfile", """ 
Ejemplo n.º 19
0
t.write("project-root.jam", "")
t.write("Jamfile", """ 
alias everything : [ exe a : a.cpp ] ; 
""")

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

""")

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

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

t.rm("bin")

# Now check that inline targets with the same name but
# present in different places are not confused between
# each other, and with top-level targets.
t.write("Jamfile", """
exe a : a.cpp ;
alias everything : [ exe a : a.cpp ] ;
alias everything2 : [ exe a : a.cpp ] ; 
""")
Ejemplo n.º 20
0
t.write("main.cpp", """
void helper();
int main() { helper(); return 0; }
""")
t.write("helper.cpp", """
void foo();

void
#if defined(_WIN32)
__declspec(dllexport)
#endif
helper() { foo(); }
""")
t.run_build_system(stderr=None) # gcc warns about libraries which are not in -rpath.
t.expect_addition("bin/$toolset/debug/main.exe")
t.rm("bin/$toolset/debug/main.exe")

# Now try using searched lib from static lib. Request shared version
# of searched lib, since we don't have static one handy.
t.write('Jamfile', """
exe main : main.cpp helper ;
lib helper : helper.cpp test_lib/<link>shared : <link>static ;
lib test_lib : : <name>test_lib <search>lib ;
""")
t.run_build_system(stderr=None)
t.expect_addition("bin/$toolset/debug/main.exe")
t.expect_addition("bin/$toolset/debug/link-static/helper.lib")
t.rm("bin/$toolset/debug/main.exe")

# A regression test: <library>property referring to
# searched-lib was mishandled. As the result, we were
Ejemplo n.º 21
0
""")

t.write(
    "hello.cpp", """ #include <pch.hpp>

int main()
{
  TestClass c(1, 2);    
  return 0;
}

""")

t.run_build_system()

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

# Now make the header unusable, without changing timestamp.
# If everything is OK, Boost.Build won't recreate PCH, and
# compiler will happily use pre-compiled header, not noticing
# that the real header is bad.

t.copy_preserving_timestamp("pch.hpp.bad", "pch.hpp")

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

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

t.cleanup()
Ejemplo n.º 22
0
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")

# Regression test for a bug found by Ali Azarbayejani.
# Conditionals inside usage requirement were not evaluated.
# This breaks

t.write(
    "Jamfile", """
lib l : l.cpp : : : <link>static:<define>STATIC ;
exe a : a.cpp l ;
""")
t.write("l.cpp", "")
t.write("l.cpp", """
int i;
Ejemplo n.º 23
0
t.expect_addition("bin/$toolset/release/a.exe")

# Test that alternative selection works for ordinary
# properties, in particular user-defined.
t.write("project-root.jam", " ")
t.write("Jamfile", """

import feature ;
feature.feature X : off on : propagated ;

exe a : b.cpp ;
exe a : a.cpp : <X>on ;
""")
t.write("b.cpp", "int main() { return 0; }\n")

t.rm("bin")

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

t.run_build_system("X=on")
t.expect_addition("bin/$toolset/debug/X-on/a.obj")

t.rm("bin")

# Test that everything works ok even with default
# build.

t.write("Jamfile", """

exe a : a_empty.cpp : <variant>release ;
Ejemplo n.º 24
0
# 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
t.write("Jamfile", "lib a : a.cpp : <include>. : : <variant>debug:<include>. ;")
t.write("d/b.cpp", """
#include <a.h>
void foo();
int main() { foo(); }
""")
t.rm("d/bin")
t.run_build_system(subdir="d")

# Test that absolute paths inside requirements are ok. The problem
# appear only when building targets in subprojects.
t.write("project-root.jam", "")
Ejemplo n.º 25
0
int main()
{
    return 0;
}

""")

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

t.run_build_system()
t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib")
t.rm("bin/$toolset/debug/link-static/a__helper.lib")

t.run_build_system("a__helper")
t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib")

t.rm("bin")

# Now check that inline targets with the same name but
# present in different places are not confused between
# each other, and with top-level targets.
t.write(
    "Jamroot", """
project : requirements <link>static ;
exe a : a.cpp [ lib helper : helper.cpp ] ;
exe a2 : a.cpp [ lib helper : helper.cpp ] ; 
""")
Ejemplo n.º 26
0
build-project src ;
""")

t.write("src/Jamfile", """
project
    : build-dir build 
    ;
exe b : b.cpp ;    
""")

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

# Now test the '--build-dir' option.
t.rm(".")
t.write("Jamroot", "")

# Test that we get an error when no project id is specified.
t.run_build_system("--build-dir=foo")
t.fail_test(
    string.find(t.stdout(), "warning: the --build-dir option will be ignored")
    == -1)

t.write("Jamroot", """
project foo ;
exe a : a.cpp ;
build-project sub ;
""")
t.write("a.cpp", "int main() { return 0; }\n")
t.write("sub/Jamfile", "exe b : b.cpp ;\n")
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.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'
Ejemplo n.º 28
0
int main()
{
    return 0;
}

""")

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

t.run_build_system()
t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib")
t.rm("bin/$toolset/debug/link-static/a__helper.lib")

t.run_build_system("a__helper")
t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib")

t.rm("bin")

# Now check that inline targets with the same name but
# present in different places are not confused between
# each other, and with top-level targets.
t.write("Jamroot", """
project : requirements <link>static ;
exe a : a.cpp [ lib helper : helper.cpp ] ;
exe a2 : a.cpp [ lib helper : helper.cpp ] ; 
""")
Ejemplo n.º 29
0
t.write(
    "src/Jamfile",
    """
project
    : build-dir build 
    ;
exe b : b.cpp ;    
""",
)

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

# Now test the '--build-dir' option.
t.rm(".")
t.write("Jamroot", "")

# Test that we get an error when no project id is specified.
t.run_build_system("--build-dir=foo")
t.fail_test(string.find(t.stdout(), "warning: the --build-dir option will be ignored") == -1)

t.write(
    "Jamroot",
    """
project foo ;
exe a : a.cpp ;
build-project sub ;
""",
)
t.write("a.cpp", "int main() { return 0; }\n")