2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-20 14:42:14 +00:00
Files
build/new/build-system.jam
2002-04-07 17:35:42 +00:00

127 lines
4.3 KiB
Plaintext

# (C) Copyright David Abrahams 2001. 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.
import modules ;
import os.path ;
# this rule will be used to generate build instructions for the
# given module (Jamfile) once its declarations have been read.
rule construct ( module-name )
{
}
# Default patterns to search for the Jamfiles to use for build
# declarations.
#
JAMFILE = [ modules.peek : JAMFILE ] ;
JAMFILE ?= [Jj]amfile [Jj]amfile.jam ;
# Load a Jamfile at the given directory. Will attempt to load
# the file as indicated by the JAMFILE patterns. Also the project-root.jam
# corresponding to the Jamfile is also loaded. We return the
# name of the Jamfile we loaded, which is the module for the Jamfile.
#
rule load-jamfile ( dir )
{
# See if the Jamfile is where it should be.
#
local jamfile-to-load = [ GLOB $(dir) : $(JAMFILE) ] ;
# Could not find it, error.
#
if ! $(jamfile-to-load)
{
EXIT
"Unable to load Jamfile. Could not find a Jamfile in"
"this directory:" $(dir)"." "Attempted to find it with"
"this pattern:" $(JAMFILE)"."
"Please consult the documentation at 'http://www.boost.org'." ;
}
# Multiple Jamfiles found in the same place. Warn about this.
# And ensure we use only one of them.
#
if $(jamfile-to-load[2-])
{
ECHO
"WARNING: Found multiple Jamfiles at this '"$(dir)"' location!"
"Loading the first one: '"$(jamfile-to-load[1]:D=)"'." ;
}
jamfile-to-load = $(jamfile-to-load[1]) ;
if ! [ os.path.is_rooted $(jamfile-to-load) ]
{
local root-path =
[ os.path.parent [ os.path.make [ modules.binding [ CALLER_MODULE ] ] ] ] ;
jamfile-to-load =
[ os.path.native [ os.path.root_relative_path $(jamfile-to-load) $(root-path) ] ] ;
}
# Load the project-root, and find out what the project root is
# for this Jamfile so we can correctly scope it.
#
local project-root-module = [ load-project-root $(jamfile-to-load:D) ] ;
# Setup variable and rule for access to project-root location in
# Jamfile.
#
modules.poke $(jamfile-module)
: project-root-module : $(project-root-module) ;
IMPORT build-system : project-root
: $(jamfile-module) : project-root : LOCALIZE ;
# Now load the Jamfile in the project-root module context.
#
local jamfile-module = Jamfile<$(jamfile-to-load:D)> ;
modules.load $(jamfile-module)
: $(jamfile-to-load:D=) : $(jamfile-to-load:D) ;
# Return the Jamfile's filename/module.
#
return $(jamfile-module) ;
}
# 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 location.
#
rule load-project-root ( dir )
{
# 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'." ;
}
# Load it within a module specifically for the project root.
# The module system handles checking for multiple includes.
#
local project-root-module = project-root<$(project-root-to-load:D)> ;
modules.load $(project-root-module)
: $(project-root-to-load:D=) : $(project-root-to-load:D) ;
# Return the module for the project.
#
return $(project-root-module) ;
}
# Returns the project-root for the calling context. This hides the
# internals of maintenance of project-root values. This is imported
# into all project-root modules to ease use.
#
rule project-root ( )
{
local project-root-binding = [ modules.binding $(project-root-module) ] ;
return $(project-root-binding:D) ;
}