2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-17 01:32:12 +00:00

make dump-test work nicely for subincluded Jamfiles

[SVN r16777]
This commit is contained in:
Dave Abrahams
2003-01-06 23:32:46 +00:00
parent 4047a1395c
commit 779c7acf4f
4 changed files with 152 additions and 42 deletions

View File

@@ -1363,6 +1363,33 @@ rule top-relative-tokens
return [ simplify-path-tokens $(SUBDIR_TOKENS) [ split-path $(<) ] ] ;
}
.project-root-tokens = [ split-path $(.boost-build-file:D) ] ;
# try to make a potentially absolute path relative to the project
# root. Only works for paths below the project root right now; others
# will remain absolute.
rule relative-path ( path )
{
local path-tokens = [ split-path $(path) ] ;
# try to strip the project root
local r = $(.project-root-tokens) ;
local p = $(path-tokens) ;
while $(r) && ( $(r[1]) = $(p[1]) )
{
p = $(p[2-]) ;
r = $(r[2-]) ;
}
# if successful, use the stripped project root
if ! $(r)
{
path-tokens = $(p) ;
}
return [ tokens-to-simple-path $(path-tokens) ] ;
}
# dependent-include target-path...
#
# For each target-path, ensure that the appropriate Jamfile has been

View File

@@ -48,28 +48,8 @@ rule boost-test ( sources + : target-type : requirements * : test-name ? : defau
if ( --dump-tests in $(ARGV) )
{
local srcs = [ on $(result) get-var-value source-files ] ;
local source-files ;
for local s in $(srcs)
{
source-files += [
SEARCH_FOR_TARGET $(s:G=)
: [ on $(s) get-var-value LOCATE SEARCH ]
] ;
}
# Extract values of the <test-info> feature
local dump-test-info = [ get-values <test-info> : $(requirements) ] ;
# Format them into a single string of quoted strings
dump-test-info = \"$(dump-test-info:J=\"\ \")\" ;
ECHO boost-test($(target-type)) \"$(test-name)\"
[$(dump-test-info)]
":" \"$(source-files)\"
;
dump-test ;
}
}
Clean clean : $(result) ;
@@ -88,6 +68,54 @@ rule boost-test ( sources + : target-type : requirements * : test-name ? : defau
}
}
# Helper for boost-test above. Uses dynamic scoping to access
# boost-test's locals.
local rule dump-test ( )
{
local srcs = [ on $(result) get-var-value source-files ] ;
# locate each source file
local source-files ;
for local s in $(srcs)
{
# find out where to look for the file
local paths = [ on $(s) get-var-value LOCATE SEARCH ] ;
s = $(s:G=) ; # strip grist
# build all the potential full paths of the file
local full-paths = $(s:R=$(paths)) ;
# look there
local files = [ GLOB $(full-paths:D) : $(s:D=) ] ;
if $(files)
{
# make relative to the project root instead of "."
local file = $(files[1]:R=$(SUBDIR_TOKENS:J=/) ;
# try to undo absolute paths
source-files += [ relative-path $(file)) ] ;
}
}
# Extract values of the <test-info> feature
local dump-test-info = [ get-values <test-info> : $(requirements) ] ;
# Format them into a single string of quoted strings
dump-test-info = \"$(dump-test-info:J=\"\ \")\" ;
ECHO boost-test($(target-type)) \"$(test-name)\"
[$(dump-test-info)]
":" \"$(source-files)\"
;
}
#######
BOOST_TEST_SUFFIX ?= .test ;

View File

@@ -1363,6 +1363,33 @@ rule top-relative-tokens
return [ simplify-path-tokens $(SUBDIR_TOKENS) [ split-path $(<) ] ] ;
}
.project-root-tokens = [ split-path $(.boost-build-file:D) ] ;
# try to make a potentially absolute path relative to the project
# root. Only works for paths below the project root right now; others
# will remain absolute.
rule relative-path ( path )
{
local path-tokens = [ split-path $(path) ] ;
# try to strip the project root
local r = $(.project-root-tokens) ;
local p = $(path-tokens) ;
while $(r) && ( $(r[1]) = $(p[1]) )
{
p = $(p[2-]) ;
r = $(r[2-]) ;
}
# if successful, use the stripped project root
if ! $(r)
{
path-tokens = $(p) ;
}
return [ tokens-to-simple-path $(path-tokens) ] ;
}
# dependent-include target-path...
#
# For each target-path, ensure that the appropriate Jamfile has been

View File

@@ -48,28 +48,8 @@ rule boost-test ( sources + : target-type : requirements * : test-name ? : defau
if ( --dump-tests in $(ARGV) )
{
local srcs = [ on $(result) get-var-value source-files ] ;
local source-files ;
for local s in $(srcs)
{
source-files += [
SEARCH_FOR_TARGET $(s:G=)
: [ on $(s) get-var-value LOCATE SEARCH ]
] ;
}
# Extract values of the <test-info> feature
local dump-test-info = [ get-values <test-info> : $(requirements) ] ;
# Format them into a single string of quoted strings
dump-test-info = \"$(dump-test-info:J=\"\ \")\" ;
ECHO boost-test($(target-type)) \"$(test-name)\"
[$(dump-test-info)]
":" \"$(source-files)\"
;
dump-test ;
}
}
Clean clean : $(result) ;
@@ -88,6 +68,54 @@ rule boost-test ( sources + : target-type : requirements * : test-name ? : defau
}
}
# Helper for boost-test above. Uses dynamic scoping to access
# boost-test's locals.
local rule dump-test ( )
{
local srcs = [ on $(result) get-var-value source-files ] ;
# locate each source file
local source-files ;
for local s in $(srcs)
{
# find out where to look for the file
local paths = [ on $(s) get-var-value LOCATE SEARCH ] ;
s = $(s:G=) ; # strip grist
# build all the potential full paths of the file
local full-paths = $(s:R=$(paths)) ;
# look there
local files = [ GLOB $(full-paths:D) : $(s:D=) ] ;
if $(files)
{
# make relative to the project root instead of "."
local file = $(files[1]:R=$(SUBDIR_TOKENS:J=/) ;
# try to undo absolute paths
source-files += [ relative-path $(file)) ] ;
}
}
# Extract values of the <test-info> feature
local dump-test-info = [ get-values <test-info> : $(requirements) ] ;
# Format them into a single string of quoted strings
dump-test-info = \"$(dump-test-info:J=\"\ \")\" ;
ECHO boost-test($(target-type)) \"$(test-name)\"
[$(dump-test-info)]
":" \"$(source-files)\"
;
}
#######
BOOST_TEST_SUFFIX ?= .test ;