mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 00:12:11 +00:00
* os.path.jam (basename, pwd, glob): New rules. Changed naming convention
for many other rules.
* project-root.jam: Use os.path everywhere.
* project.jam: Don't convert project paths to absolute paths. Use os.path.
* build-system.jam: Don't use absolute name when loading jamfile.
[SVN r13634]
188 lines
5.3 KiB
Plaintext
188 lines
5.3 KiB
Plaintext
# Copyright (C) Rene Rivera 2002. 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.
|
|
|
|
# Represents the projet-root of a collection of projects. This maintains
|
|
# information about the root, and pointers to the project defined within
|
|
# the root. Each project-root gets it's own module to put things into. For
|
|
# instance declared constants which also get interned into each loaded project.
|
|
|
|
import modules ;
|
|
|
|
# Load the project-root file for the given directory. The directory can
|
|
# be either the project-root itself, or any subdirectory. Fails if it can't
|
|
# find the project-root. We return the project-root module.
|
|
#
|
|
rule load (
|
|
dir # The directory of the project-root.jam to load.
|
|
)
|
|
{
|
|
# Find the project-root.jam corresponding to this directory.
|
|
#
|
|
local project-root-to-load = [ find-to-root $(dir) : project-root.jam ] ;
|
|
|
|
# No project-root file found.
|
|
#
|
|
if ! $(project-root-to-load)
|
|
{
|
|
EXIT
|
|
"Failed to find the project root for:" $(dir)"." "Did not"
|
|
"find a project-root.jam file there or in any of its parent"
|
|
"directories."
|
|
"Please consult the documentation at 'http://www.boost.org'." ;
|
|
}
|
|
|
|
local project-root-location = [ os.path.make $(project-root-to-load) ] ;
|
|
local project-root-dir = [ os.path.parent $(project-root-location) ] ;
|
|
local project-root-module = project-root<$(project-root-dir)> ;
|
|
|
|
# Only bother with the rest if the project-root isn't loaded yet.
|
|
#
|
|
if ! [ modules.binding $(project-root-module) ]
|
|
{
|
|
# Give the new module all the rules from project-root-context
|
|
modules.clone-rules project-root-context $(project-root-module) ;
|
|
|
|
# Remember the project-root, and some info about it.
|
|
#
|
|
.project-root += $(project-root-module) ;
|
|
modules.poke $(project-root-module) : .module : $(project-root-module) ;
|
|
modules.poke $(project-root-module) : .location : $(project-root-dir) ;
|
|
|
|
# Load it within a module specifically for the project root.
|
|
# The module system handles checking for multiple includes.
|
|
#
|
|
modules.load $(project-root-module)
|
|
: [ os.path.basename $(project-root-location) ]
|
|
: $(project-root-dir) ;
|
|
}
|
|
|
|
# Return the module for the project.
|
|
#
|
|
return $(project-root-module) ;
|
|
}
|
|
|
|
# Print out all the project-roots.
|
|
#
|
|
rule print ( )
|
|
{
|
|
import sequence ;
|
|
import print ;
|
|
|
|
print.section "Project Roots" ;
|
|
local project-roots = [ sequence.insertion-sort $(.project-root) ] ;
|
|
for local project-root in $(projects-roots)
|
|
{
|
|
$(project-root).print ;
|
|
}
|
|
}
|
|
|
|
module project-root-context
|
|
{
|
|
|
|
# Module context for each project-root loaded.
|
|
|
|
# The module name of the project-root.
|
|
.module = ;
|
|
|
|
# The location of the project-root, as a path.
|
|
.location = ;
|
|
|
|
# The set of projects registered in this project-root.
|
|
.projects = ;
|
|
|
|
# The set of interned constants for this project-root.
|
|
.constants = ;
|
|
|
|
# Accessor to .module.
|
|
#
|
|
rule module-name ( )
|
|
{
|
|
return $(.module) ;
|
|
}
|
|
|
|
# Accessor to .location.
|
|
#
|
|
rule location ( )
|
|
{
|
|
return $(.location) ;
|
|
}
|
|
|
|
# Register a project under this project-root. This does any setup
|
|
# in the module of the project, including interning the project-root
|
|
# constants. Multiple calls on the same project are allowed and will
|
|
# not disturb the previous calls.
|
|
#
|
|
rule register-project (
|
|
project-module # The module of the project to register.
|
|
)
|
|
{
|
|
if ! $(project-module) in $(.projects)
|
|
{
|
|
.projects += $(project-module) ;
|
|
intern-constants $(project-module) ;
|
|
}
|
|
modules.poke $(project-module) : .project-root-module : $(.module) ;
|
|
}
|
|
|
|
# Declare and set a project global constant. Project global constants are
|
|
# normal variables but should not be changed. They are applied to each
|
|
# Jamfile that is loaded under it's corresponding project-root.
|
|
#
|
|
rule constant (
|
|
name # Variable name of the constant.
|
|
: value # Value of the constant.
|
|
)
|
|
{
|
|
$(name) = $(value) ;
|
|
.constants += $(name) ;
|
|
}
|
|
|
|
# Intern the constants from this project-root into the calling context.
|
|
#
|
|
rule intern-constants (
|
|
context ? # The module to intern into the current module.
|
|
)
|
|
{
|
|
local intern-module = $(context) ;
|
|
intern-module ?= [ CALLER_MODULE ] ;
|
|
for local c in $(*constants)
|
|
{
|
|
modules.poke $(intern-module) : $(c) : $($(c)) ;
|
|
}
|
|
}
|
|
|
|
# Print out info about this project root. Calls print on the
|
|
# individual projects in this project-root.
|
|
#
|
|
rule print ( )
|
|
{
|
|
import sequence ;
|
|
import print ;
|
|
|
|
print.section "'"$(.location)"'" Module for project-root is "'"$(.module)"'" ;
|
|
if $(.constants)
|
|
{
|
|
print.section Constants ;
|
|
print.list-start ;
|
|
local constants = [ sequence.insertion-sort $(.constants) ] ;
|
|
for local c in $(constants)
|
|
{
|
|
print.list-item $(c) "=" $($(c)) ;
|
|
}
|
|
print.list-end ;
|
|
}
|
|
if $(.projects)
|
|
{
|
|
print.section Projects ;
|
|
local projects = [ sequence.insertion-sort $(.projects) ] ;
|
|
for local p in $(projects)
|
|
{
|
|
$(p).print ;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|