2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 13:02:11 +00:00

Allow "bjam some_directory" to work even if there's no Jamfile in ".".

[SVN r29588]
This commit is contained in:
Vladimir Prus
2005-06-15 13:26:37 +00:00
parent c921b04cfb
commit d7bdc38c6c
4 changed files with 106 additions and 3 deletions

View File

@@ -122,7 +122,10 @@ if --version in [ modules.peek : ARGV ]
# We always load project in "." so that 'use-project' directives has
# any chance of been seen. Otherwise, we won't be able to refer to
# subprojects using target ids.
current-project = [ project.target [ project.load "." ] ] ;
if [ project.find "." : "." ]
{
current-project = [ project.target [ project.load "." ] ] ;
}
if ! [ feature.values <toolset> ]
{
@@ -162,6 +165,50 @@ if "--clean" in [ modules.peek : ARGV ]
local bjam-targets ;
# Given a target it, try to find and return corresponding target.
# This is only invoked when there's no Jamfile in "."
# This code somewhat duplicates code in project-target.find but we can't reuse
# that code without project-targets instance.
rule find-target ( target-id )
{
local split = [ MATCH (.*)//(.*) : $(target-id) ] ;
local pm ;
if $(split)
{
pm = [ project.find $(split[1]) : "." ] ;
}
else
{
pm = [ project.find $(target-id) : "." ] ;
}
local result ;
if $(pm)
{
result = [ project.target $(pm) ] ;
}
if $(split)
{
result = [ $(result).find $(split[2]) ] ;
}
return $(result) ;
}
if ! $(current-project)
{
if ! $(target-ids)
{
ECHO "error: no Jamfile in current directory found, and no target references specified." ;
EXIT ;
}
}
for local id in $(target-ids)
{
if $(id) = clean
@@ -170,7 +217,16 @@ for local id in $(target-ids)
}
else
{
local t = [ $(current-project).find $(id) : no-error ] ;
local t ;
if $(current-project)
{
t = [ $(current-project).find $(id) : no-error ] ;
}
else
{
t = [ find-target $(id) ] ;
}
if ! $(t)
{
ECHO "notice: could not find main target " $(id) ;

View File

@@ -159,7 +159,7 @@ rule find ( name : current-location )
project-module = [ module-name $(location) ] ;
if ! $(project-module) in $(.jamfile-modules)
{
if [ find-jamfile $(location) : no-error ]
if [ path.glob $(location) : $(JAMROOT) $(JAMFILE) ]
{
project-module = [ load $(location) ] ;
}

46
v2/test/out_of_tree.py Normal file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/python
# Copyright (C) FILL SOMETHING HERE 2005.
# 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 that we can build a project when the current directory is outside of
# that project tree, that is:
# bjam some_dir
# works.
from BoostBuild import Tester, List
# Create a temporary working directory
t = Tester()
# Create the needed files
t.write("p1/Jamroot", """
exe hello : hello.cpp ;
""")
t.write("p1/hello.cpp", """
int main()
{
return 0;
}
""")
t.write("p2/Jamroot", """
exe hello2 : hello.cpp ;
exe hello3 : hello.cpp ;
""")
t.write("p2/hello.cpp", """
int main()
{
return 0;
}
""")
t.run_build_system("p1 p2//hello3")
t.expect_addition("p1/bin/$toolset/debug/hello.exe")
t.expect_addition("p2/bin/$toolset/debug/hello3.exe")
t.cleanup()

View File

@@ -129,6 +129,7 @@ tests = [ "rebuilds",
"wrong_project",
"using",
"source_locations",
"out_of_tree",
]
if os.name == 'posix':