SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
"""Extension to SCons providing advanced static library dependency tracking.
|
|
|
|
|
|
|
|
These modifications to a build environment, which can be attached to
|
|
|
|
StaticLibrary and Program builders via a call to setup_environment(env),
|
|
|
|
cause the build system to track library dependencies through static libraries,
|
|
|
|
and to add them to the link command executed when building programs.
|
|
|
|
|
|
|
|
For example, consider a program 'try' that depends on a lib 'tc', which in
|
|
|
|
turn uses a symbol from a lib 'tb' which in turn uses a library from 'ta'.
|
|
|
|
Without this package, the Program declaration for "try" looks like this:
|
|
|
|
|
|
|
|
Program('try', ['try.c', 'path/to/${LIBPREFIX}tc${LIBSUFFIX}',
|
|
|
|
'path/to/${LIBPREFIX}tc${LIBSUFFIX}',
|
|
|
|
'path/to/${LIBPREFIX}tc${LIBSUFFIX}',])
|
|
|
|
|
|
|
|
With this library, we can instead write the following
|
|
|
|
|
|
|
|
Program('try', ['try.c'], LIBDEPS=['path/to/tc'])
|
|
|
|
StaticLibrary('tc', ['c.c'], LIBDEPS=['path/to/tb'])
|
|
|
|
StaticLibrary('tb', ['b.c'], LIBDEPS=['path/to/ta'])
|
|
|
|
StaticLibrary('ta', ['a.c'])
|
|
|
|
|
|
|
|
And the build system will figure out that it needs to link libta.a and libtb.a
|
|
|
|
when building 'try'.
|
2013-07-08 23:44:05 +02:00
|
|
|
|
|
|
|
A StaticLibrary S may also declare programs or libraries, [L1, ...] to be dependent
|
|
|
|
upon S by setting LIBDEPS_DEPENDENTS=[L1, ...], using the same syntax as is used
|
|
|
|
for LIBDEPS, except that the libraries and programs will not have LIBPREFIX/LIBSUFFIX
|
|
|
|
automatically added when missing.
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
# Copyright (c) 2010, Corensic Inc., All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
# a copy of this software and associated documentation files (the
|
|
|
|
# "Software"), to deal in the Software without restriction, including
|
|
|
|
# without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
# permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
# the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included
|
|
|
|
# in all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
|
|
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
import SCons.Errors
|
|
|
|
import SCons.Scanner
|
|
|
|
import SCons.Util
|
|
|
|
|
2012-10-18 21:57:19 +02:00
|
|
|
libdeps_env_var = 'LIBDEPS'
|
|
|
|
syslibdeps_env_var = 'SYSLIBDEPS'
|
|
|
|
|
2012-03-30 19:20:40 +02:00
|
|
|
def sorted_by_str(iterable):
|
|
|
|
"""Shorthand for sorting an iterable according to its string representation.
|
|
|
|
|
|
|
|
We use this instead of sorted(), below, because SCons.Node objects are
|
|
|
|
compared on object identity, rather than value, so sorts aren't stable
|
|
|
|
across invocations of SCons. Since dependency order changes force rebuilds,
|
|
|
|
we use this sort to create stable dependency orders.
|
|
|
|
"""
|
|
|
|
return sorted(iterable, cmp=lambda lhs, rhs: cmp(str(lhs), str(rhs)))
|
|
|
|
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
class DependencyCycleError(SCons.Errors.UserError):
|
|
|
|
"""Exception representing a cycle discovered in library dependencies."""
|
|
|
|
|
|
|
|
def __init__(self, first_node ):
|
|
|
|
super(DependencyCycleError, self).__init__()
|
|
|
|
self.cycle_nodes = [first_node]
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return " => ".join(str(n) for n in self.cycle_nodes)
|
|
|
|
|
2012-10-18 21:57:19 +02:00
|
|
|
def __get_libdeps(node):
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
"""Given a SCons Node, return its library dependencies.
|
|
|
|
|
|
|
|
Computes the dependencies if they're not already cached.
|
|
|
|
"""
|
|
|
|
|
2012-10-18 21:57:19 +02:00
|
|
|
cached_var_name = libdeps_env_var + '_cached'
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
|
|
|
|
if not hasattr(node.attributes, cached_var_name):
|
2012-10-18 21:57:19 +02:00
|
|
|
setattr(node.attributes, cached_var_name, __compute_libdeps(node))
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
return getattr(node.attributes, cached_var_name)
|
|
|
|
|
2012-10-18 21:57:19 +02:00
|
|
|
def __compute_libdeps(node):
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
"""Recursively identify all library dependencies for a node."""
|
|
|
|
|
|
|
|
if getattr(node.attributes, 'libdeps_exploring', False):
|
|
|
|
raise DependencyCycleError(node)
|
|
|
|
|
|
|
|
env = node.get_env()
|
|
|
|
deps = set()
|
|
|
|
node.attributes.libdeps_exploring = True
|
|
|
|
try:
|
|
|
|
try:
|
2013-07-08 23:44:05 +02:00
|
|
|
for child in env.Flatten(getattr(node.attributes, 'libdeps_direct', [])):
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
if not child:
|
|
|
|
continue
|
|
|
|
deps.add(child)
|
2012-10-18 21:57:19 +02:00
|
|
|
deps.update(__get_libdeps(child))
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
|
|
|
|
except DependencyCycleError, e:
|
|
|
|
if len(e.cycle_nodes) == 1 or e.cycle_nodes[0] != e.cycle_nodes[-1]:
|
|
|
|
e.cycle_nodes.append(node)
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
node.attributes.libdeps_exploring = False
|
|
|
|
|
|
|
|
return deps
|
|
|
|
|
2012-10-18 21:57:19 +02:00
|
|
|
def __get_syslibdeps(node):
|
|
|
|
""" Given a SCons Node, return its system library dependencies.
|
|
|
|
|
|
|
|
These are the depencencies listed with SYSLIBDEPS, and are linked using -l.
|
|
|
|
"""
|
|
|
|
cached_var_name = syslibdeps_env_var + '_cached'
|
|
|
|
if not hasattr(node.attributes, cached_var_name):
|
|
|
|
syslibdeps = []
|
|
|
|
for lib in __get_libdeps(node):
|
2013-06-06 21:05:15 +02:00
|
|
|
for syslib in node.get_env().Flatten(lib.get_env().get(syslibdeps_env_var, [])):
|
|
|
|
if syslib:
|
|
|
|
syslibdeps.append(syslib)
|
2013-01-04 00:22:39 +01:00
|
|
|
setattr(node.attributes, cached_var_name, syslibdeps)
|
2012-10-18 21:57:19 +02:00
|
|
|
return getattr(node.attributes, cached_var_name)
|
|
|
|
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
def update_scanner(builder):
|
|
|
|
"""Update the scanner for "builder" to also scan library dependencies."""
|
|
|
|
|
|
|
|
old_scanner = builder.target_scanner
|
|
|
|
|
|
|
|
if old_scanner:
|
|
|
|
path_function = old_scanner.path_function
|
|
|
|
def new_scanner(node, env, path=()):
|
|
|
|
result = set(old_scanner.function(node, env, path))
|
2012-10-18 21:57:19 +02:00
|
|
|
result.update(__get_libdeps(node))
|
2012-03-30 19:20:40 +02:00
|
|
|
return sorted_by_str(result)
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
else:
|
|
|
|
path_function = None
|
|
|
|
def new_scanner(node, env, path=()):
|
2012-10-18 21:57:19 +02:00
|
|
|
result = set(__get_libdeps(node))
|
2012-03-30 19:20:40 +02:00
|
|
|
return sorted_by_str(result)
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
|
|
|
|
builder.target_scanner = SCons.Scanner.Scanner(function=new_scanner,
|
|
|
|
path_function=path_function)
|
|
|
|
|
|
|
|
def get_libdeps(source, target, env, for_signature):
|
|
|
|
"""Implementation of the special _LIBDEPS environment variable.
|
|
|
|
|
|
|
|
Expands to the library dependencies for a target.
|
|
|
|
"""
|
|
|
|
|
2012-01-18 02:01:15 +01:00
|
|
|
target = env.Flatten([target])
|
2012-10-18 21:57:19 +02:00
|
|
|
return sorted_by_str(__get_libdeps(target[0]))
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
|
2012-01-21 04:34:13 +01:00
|
|
|
def get_libdeps_objs(source, target, env, for_signature):
|
|
|
|
objs = set()
|
|
|
|
for lib in get_libdeps(source, target, env, for_signature):
|
|
|
|
objs.update(lib.sources_set)
|
2012-09-07 19:16:24 +02:00
|
|
|
return sorted_by_str(objs)
|
2012-01-21 04:34:13 +01:00
|
|
|
|
2012-01-30 22:12:24 +01:00
|
|
|
def get_libdeps_special_sun(source, target, env, for_signature):
|
|
|
|
x = get_libdeps(source, target, env, for_signature )
|
|
|
|
return x + x + x
|
|
|
|
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
def get_syslibdeps(source, target, env, for_signature):
|
2012-10-18 21:57:19 +02:00
|
|
|
deps = __get_syslibdeps(target[0])
|
|
|
|
lib_link_prefix = env.subst('$LIBLINKPREFIX')
|
|
|
|
lib_link_suffix = env.subst('$LIBLINKSUFFIX')
|
2013-01-04 00:22:39 +01:00
|
|
|
result = []
|
|
|
|
for d in deps:
|
|
|
|
# Elements of syslibdeps are either strings (str or unicode), or they're File objects.
|
|
|
|
# If they're File objects, they can be passed straight through. If they're strings,
|
|
|
|
# they're believed to represent library short names, that should be prefixed with -l
|
|
|
|
# or the compiler-specific equivalent. I.e., 'm' becomes '-lm', but 'File("m.a") is passed
|
|
|
|
# through whole cloth.
|
|
|
|
if type(d) in (str, unicode):
|
|
|
|
result.append('%s%s%s' % (lib_link_prefix, d, lib_link_suffix))
|
|
|
|
else:
|
|
|
|
result.append(d)
|
2012-10-18 21:57:19 +02:00
|
|
|
return result
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
|
2013-07-08 23:44:05 +02:00
|
|
|
def __append_direct_libdeps(node, prereq_nodes):
|
|
|
|
if getattr(node.attributes, 'libdeps_direct', None) is None:
|
|
|
|
node.attributes.libdeps_direct = []
|
|
|
|
node.attributes.libdeps_direct.extend(prereq_nodes)
|
|
|
|
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
def libdeps_emitter(target, source, env):
|
|
|
|
"""SCons emitter that takes values from the LIBDEPS environment variable and
|
|
|
|
converts them to File node objects, binding correct path information into
|
|
|
|
those File objects.
|
|
|
|
|
|
|
|
Emitters run on a particular "target" node during the initial execution of
|
|
|
|
the SConscript file, rather than during the later build phase. When they
|
|
|
|
run, the "env" environment's working directory information is what you
|
|
|
|
expect it to be -- that is, the working directory is considered to be the
|
|
|
|
one that contains the SConscript file. This allows specification of
|
|
|
|
relative paths to LIBDEPS elements.
|
|
|
|
|
|
|
|
This emitter also adds LIBSUFFIX and LIBPREFIX appropriately.
|
2013-07-08 23:44:05 +02:00
|
|
|
|
|
|
|
NOTE: For purposes of LIBDEPS_DEPENDENTS propagation, only the first member
|
|
|
|
of the "target" list is made a prerequisite of the elements of LIBDEPS_DEPENDENTS.
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
libdep_files = []
|
|
|
|
lib_suffix = env.subst('$LIBSUFFIX', target=target, source=source)
|
|
|
|
lib_prefix = env.subst('$LIBPREFIX', target=target, source=source)
|
2013-07-08 23:44:05 +02:00
|
|
|
for prereq in env.Flatten([env.get(libdeps_env_var, [])]):
|
|
|
|
full_path = env.subst(str(prereq), target=target, source=source)
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
dir_name = os.path.dirname(full_path)
|
|
|
|
file_name = os.path.basename(full_path)
|
|
|
|
if not file_name.startswith(lib_prefix):
|
|
|
|
file_name = '${LIBPREFIX}' + file_name
|
|
|
|
if not file_name.endswith(lib_suffix):
|
|
|
|
file_name += '${LIBSUFFIX}'
|
|
|
|
libdep_files.append(env.File(os.path.join(dir_name, file_name)))
|
|
|
|
|
2013-07-08 23:44:05 +02:00
|
|
|
for t in target:
|
|
|
|
__append_direct_libdeps(t, libdep_files)
|
|
|
|
|
|
|
|
for dependent in env.Flatten([env.get('LIBDEPS_DEPENDENTS', [])]):
|
|
|
|
__append_direct_libdeps(env.File(dependent), [target[0]])
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
|
|
|
|
return target, source
|
|
|
|
|
|
|
|
def setup_environment(env):
|
|
|
|
"""Set up the given build environment to do LIBDEPS tracking."""
|
|
|
|
|
2012-01-21 04:34:13 +01:00
|
|
|
try:
|
|
|
|
env['_LIBDEPS']
|
|
|
|
except KeyError:
|
|
|
|
env['_LIBDEPS'] = '$_LIBDEPS_LIBS'
|
|
|
|
|
2012-01-30 21:43:45 +01:00
|
|
|
# TODO: remove this
|
|
|
|
# this is a horrible horrible hack for
|
|
|
|
# for 32-bit solaris
|
2012-01-30 21:59:39 +01:00
|
|
|
if "uname" in dir(os) and os.uname()[1] == "sun32b":
|
2012-01-30 22:12:24 +01:00
|
|
|
env['_LIBDEPS_LIBS'] = get_libdeps_special_sun
|
2012-01-30 21:43:45 +01:00
|
|
|
else:
|
|
|
|
env['_LIBDEPS_LIBS'] = get_libdeps
|
|
|
|
|
2012-01-21 04:34:13 +01:00
|
|
|
env['_LIBDEPS_OBJS'] = get_libdeps_objs
|
2012-10-18 21:57:19 +02:00
|
|
|
env['_SYSLIBDEPS'] = get_syslibdeps
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
env['_SHLIBDEPS'] = '$SHLIBDEP_GROUP_START ${_concat(SHLIBDEPPREFIX, __env__.subst(_LIBDEPS, target=TARGET, source=SOURCE), SHLIBDEPSUFFIX, __env__, target=TARGET, source=SOURCE)} $SHLIBDEP_GROUP_END'
|
|
|
|
|
2012-10-18 21:57:19 +02:00
|
|
|
env[libdeps_env_var] = SCons.Util.CLVar()
|
|
|
|
env[syslibdeps_env_var] = SCons.Util.CLVar()
|
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly
closer in line with standard SCons organization.
In particular, the SConstruct file sets up the various "build environment"
objects, by examining the local system and command line parameters. Then, it
delegates to some SConscript files, which describe build rules, like how to
compile "mongod" from source.
Typically, you would create several SConscript files for a project this large,
after breaking the project into logical sub projects, such as "platform
abstraction", "data manager", "query optimizer", etc. That will be future work.
For now, we only separate out the special rules for executing smoke tests into
SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript.
"tools" are placed in site_scons/site_tools.
This patch also includes better support for building and tracking dependencies
among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor
restructuring.
This patch introduces a "warning" message from SCons about framework.o having
two rules that generate it. It is harmless, for now, and will be removed in
future work.
Future work also includes eliminating use of the SCons "Glob" utility, and
restructuring the source code into sensible components.
2012-01-04 20:30:29 +01:00
|
|
|
env.Append(LIBEMITTER=libdeps_emitter,
|
|
|
|
PROGEMITTER=libdeps_emitter,
|
|
|
|
SHLIBEMITTER=libdeps_emitter)
|
|
|
|
env.Prepend(_LIBFLAGS=' $LINK_LIBGROUP_START $_LIBDEPS $LINK_LIBGROUP_END $_SYSLIBDEPS ')
|
|
|
|
for builder_name in ('Program', 'SharedLibrary', 'LoadableModule'):
|
|
|
|
try:
|
|
|
|
update_scanner(env['BUILDERS'][builder_name])
|
|
|
|
except KeyError:
|
|
|
|
pass
|