http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/6da3961b/ext/kenlm/jam-files/boost-build/build/type.jam ---------------------------------------------------------------------- diff --git a/ext/kenlm b/ext/kenlm new file mode 160000 index 0000000..56fdb5c --- /dev/null +++ b/ext/kenlm @@ -0,0 +1 @@ +Subproject commit 56fdb5c44fca34d5a2e07d96139c28fb163983c5 diff --git a/ext/kenlm/jam-files/boost-build/build/type.jam b/ext/kenlm/jam-files/boost-build/build/type.jam deleted file mode 100644 index e8cc44e..0000000 --- a/ext/kenlm/jam-files/boost-build/build/type.jam +++ /dev/null @@ -1,401 +0,0 @@ -# Copyright 2002, 2003 Dave Abrahams -# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - -# Deals with target type declaration and defines target class which supports -# typed targets. - -import "class" : new ; -import feature ; -import generators : * ; -import os ; -import project ; -import property ; -import scanner ; - -# The following import would create a circular dependency: -# project -> project-root -> builtin -> type -> targets -> project -# import targets ; - -# The feature is optional so it would never get added implicitly. It is used -# only for internal purposes and in all cases we want to use it explicitly. -feature.feature target-type : : composite optional ; - -feature.feature main-target-type : : optional incidental ; -feature.feature base-target-type : : composite optional free ; - - -# Registers a target type, possible derived from a 'base-type'. Providing a list -# of 'suffixes' here is a shortcut for separately calling the register-suffixes -# rule with the given suffixes and the set-generated-target-suffix rule with the -# first given suffix. -# -rule register ( type : suffixes * : base-type ? ) -{ - # Type names cannot contain hyphens, because when used as feature-values - # they would be interpreted as composite features which need to be - # decomposed. - switch $(type) - { - case *-* : - import errors ; - errors.error "type name \"$(type)\" contains a hyphen" ; - } - - if $(type) in $(.types) - { - import errors ; - errors.error "Type $(type) is already registered." ; - } - - { - .types += $(type) ; - .base.$(type) = $(base-type) ; - .derived.$(base-type) += $(type) ; - .bases.$(type) = $(type) $(.bases.$(base-type)) ; - - # Store suffixes for generated targets. - .suffixes.$(type) = [ new property-map ] ; - - # Store prefixes for generated targets (e.g. "lib" for library). - .prefixes.$(type) = [ new property-map ] ; - - if $(suffixes)-is-defined - { - # Specify mapping from suffixes to type. - register-suffixes $(suffixes) : $(type) ; - # By default generated targets of 'type' will use the first of - #'suffixes'. This may be overriden. - set-generated-target-suffix $(type) : : $(suffixes[1]) ; - } - - feature.extend target-type : $(type) ; - feature.extend main-target-type : $(type) ; - feature.extend base-target-type : $(type) ; - - feature.compose <target-type>$(type) : $(base-type:G=<base-target-type>) ; - feature.compose <base-target-type>$(type) : <base-target-type>$(base-type) ; - - # We used to declare the main target rule only when a 'main' parameter - # has been specified. However, it is hard to decide that a type will - # *never* need a main target rule and so from time to time we needed to - # make yet another type 'main'. So now a main target rule is defined for - # each type. - main-rule-name = [ type-to-rule-name $(type) ] ; - .main-target-type.$(main-rule-name) = $(type) ; - IMPORT $(__name__) : main-target-rule : : $(main-rule-name) ; - - # Adding a new derived type affects generator selection so we need to - # make the generator selection module update any of its cached - # information related to a new derived type being defined. - generators.update-cached-information-with-a-new-type $(type) ; - } -} - - -# Given a type, returns the name of the main target rule which creates targets -# of that type. -# -rule type-to-rule-name ( type ) -{ - # Lowercase everything. Convert underscores to dashes. - import regex ; - local n = [ regex.split $(type:L) "_" ] ; - return $(n:J=-) ; -} - - -# Given a main target rule name, returns the type for which it creates targets. -# -rule type-from-rule-name ( rule-name ) -{ - return $(.main-target-type.$(rule-name)) ; -} - - -# Specifies that files with suffix from 'suffixes' be recognized as targets of -# type 'type'. Issues an error if a different type is already specified for any -# of the suffixes. -# -rule register-suffixes ( suffixes + : type ) -{ - for local s in $(suffixes) - { - if ! $(.type.$(s)) - { - .type.$(s) = $(type) ; - } - else if $(.type.$(s)) != $(type) - { - import errors ; - errors.error Attempting to specify multiple types for suffix - \"$(s)\" : "Old type $(.type.$(s)), New type $(type)" ; - } - } -} - - -# Returns true iff type has been registered. -# -rule registered ( type ) -{ - if $(type) in $(.types) - { - return true ; - } -} - - -# Issues an error if 'type' is unknown. -# -rule validate ( type ) -{ - if ! [ registered $(type) ] - { - import errors ; - errors.error "Unknown target type $(type)" ; - } -} - - -# Sets a scanner class that will be used for this 'type'. -# -rule set-scanner ( type : scanner ) -{ - validate $(type) ; - .scanner.$(type) = $(scanner) ; -} - - -# Returns a scanner instance appropriate to 'type' and 'properties'. -# -rule get-scanner ( type : property-set ) -{ - if $(.scanner.$(type)) - { - return [ scanner.get $(.scanner.$(type)) : $(property-set) ] ; - } -} - - -# Returns a base type for the given type or nothing in case the given type is -# not derived. -# -rule base ( type ) -{ - return $(.base.$(type)) ; -} - - -# Returns the given type and all of its base types in order of their distance -# from type. -# -rule all-bases ( type ) -{ - return $(.bases.$(type)) ; -} - - -# Returns the given type and all of its derived types in order of their distance -# from type. -# -rule all-derived ( type ) -{ - local result = $(type) ; - for local d in $(.derived.$(type)) - { - result += [ all-derived $(d) ] ; - } - return $(result) ; -} - - -# Returns true if 'type' is equal to 'base' or has 'base' as its direct or -# indirect base. -# -rule is-derived ( type base ) -{ - if $(base) in $(.bases.$(type)) - { - return true ; - } -} - -# Returns true if 'type' is either derived from or is equal to 'base'. -# -# TODO: It might be that is-derived and is-subtype were meant to be different -# rules - one returning true for type = base and one not, but as currently -# implemented they are actually the same. Clean this up. -# -rule is-subtype ( type base ) -{ - return [ is-derived $(type) $(base) ] ; -} - - - - -# Sets a file suffix to be used when generating a target of 'type' with the -# specified properties. Can be called with no properties if no suffix has -# already been specified for the 'type'. The 'suffix' parameter can be an empty -# string ("") to indicate that no suffix should be used. -# -# Note that this does not cause files with 'suffix' to be automatically -# recognized as being of 'type'. Two different types can use the same suffix for -# their generated files but only one type can be auto-detected for a file with -# that suffix. User should explicitly specify which one using the -# register-suffixes rule. -# -rule set-generated-target-suffix ( type : properties * : suffix ) -{ - set-generated-target-ps suffix : $(type) : $(properties) : $(suffix) ; -} - - -# Change the suffix previously registered for this type/properties combination. -# If suffix is not yet specified, sets it. -# -rule change-generated-target-suffix ( type : properties * : suffix ) -{ - change-generated-target-ps suffix : $(type) : $(properties) : $(suffix) ; -} - - -# Returns the suffix used when generating a file of 'type' with the given -# properties. -# -rule generated-target-suffix ( type : property-set ) -{ - return [ generated-target-ps suffix : $(type) : $(property-set) ] ; -} - - -# Sets a target prefix that should be used when generating targets of 'type' -# with the specified properties. Can be called with empty properties if no -# prefix for 'type' has been specified yet. -# -# The 'prefix' parameter can be empty string ("") to indicate that no prefix -# should be used. -# -# Usage example: library names use the "lib" prefix on unix. -# -rule set-generated-target-prefix ( type : properties * : prefix ) -{ - set-generated-target-ps prefix : $(type) : $(properties) : $(prefix) ; -} - - -# Change the prefix previously registered for this type/properties combination. -# If prefix is not yet specified, sets it. -# -rule change-generated-target-prefix ( type : properties * : prefix ) -{ - change-generated-target-ps prefix : $(type) : $(properties) : $(prefix) ; -} - - -rule generated-target-prefix ( type : property-set ) -{ - return [ generated-target-ps prefix : $(type) : $(property-set) ] ; -} - - -# Common rules for prefix/suffix provisioning follow. - -local rule set-generated-target-ps ( ps : type : properties * : psval ) -{ - $(.$(ps)es.$(type)).insert $(properties) : $(psval) ; -} - - -local rule change-generated-target-ps ( ps : type : properties * : psval ) -{ - local prev = [ $(.$(ps)es.$(type)).find-replace $(properties) : $(psval) ] ; - if ! $(prev) - { - set-generated-target-ps $(ps) : $(type) : $(properties) : $(psval) ; - } -} - - -# Returns either prefix or suffix (as indicated by 'ps') that should be used -# when generating a target of 'type' with the specified properties. Parameter -# 'ps' can be either "prefix" or "suffix". If no prefix/suffix is specified for -# 'type', returns prefix/suffix for base type, if any. -# -local rule generated-target-ps ( ps : type : property-set ) -{ - local result ; - local found ; - while $(type) && ! $(found) - { - result = [ $(.$(ps)es.$(type)).find $(property-set) ] ; - # If the prefix/suffix is explicitly set to an empty string, we consider - # prefix/suffix to be found. If we were not to compare with "", there - # would be no way to specify an empty prefix/suffix. - if $(result)-is-defined - { - found = true ; - } - type = $(.base.$(type)) ; - } - if $(result) = "" - { - result = ; - } - return $(result) ; -} - - -# Returns file type given its name. If there are several dots in filename, tries -# each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and "so" will -# be tried. -# -rule type ( filename ) -{ - if [ os.name ] in NT CYGWIN - { - filename = $(filename:L) ; - } - local type ; - while ! $(type) && $(filename:S) - { - local suffix = $(filename:S) ; - type = $(.type$(suffix)) ; - filename = $(filename:S=) ; - } - return $(type) ; -} - - -# Rule used to construct all main targets. Note that this rule gets imported -# into the global namespace under different alias names and the exact target -# type to construct is selected based on the alias used to actually invoke this -# rule. -# -rule main-target-rule ( name : sources * : requirements * : default-build * : - usage-requirements * ) -{ - # First discover the required target type based on the exact alias used to - # invoke this rule. - local bt = [ BACKTRACE 1 ] ; - local rulename = $(bt[4]) ; - local target-type = [ type-from-rule-name $(rulename) ] ; - - # This is a circular module dependency and so must be imported here. - import targets ; - - return [ targets.create-typed-target $(target-type) : [ project.current ] : - $(name) : $(sources) : $(requirements) : $(default-build) : - $(usage-requirements) ] ; -} - - -rule __test__ ( ) -{ - import assert ; - - # TODO: Add tests for all the is-derived, is-base & related type relation - # checking rules. -}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/6da3961b/ext/kenlm/jam-files/boost-build/build/version.jam ---------------------------------------------------------------------- diff --git a/ext/kenlm b/ext/kenlm new file mode 160000 index 0000000..56fdb5c --- /dev/null +++ b/ext/kenlm @@ -0,0 +1 @@ +Subproject commit 56fdb5c44fca34d5a2e07d96139c28fb163983c5 diff --git a/ext/kenlm/jam-files/boost-build/build/version.jam b/ext/kenlm/jam-files/boost-build/build/version.jam deleted file mode 100644 index d4b787d..0000000 --- a/ext/kenlm/jam-files/boost-build/build/version.jam +++ /dev/null @@ -1,165 +0,0 @@ -# Copyright 2002, 2003, 2004, 2006 Vladimir Prus -# Copyright 2008, 2012 Jurko Gospodnetic -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - -import numbers ; - - -.major = "2011" ; -.minor = "12" ; - - -rule boost-build ( ) -{ - return "$(.major).$(.minor)-svn" ; -} - - -rule print ( ) -{ - if [ verify-engine-version ] - { - ECHO "Boost.Build" [ boost-build ] ; - } -} - - -rule verify-engine-version ( ) -{ - local v = [ modules.peek : JAM_VERSION ] ; - - if $(v[1]) != $(.major) || $(v[2]) != $(.minor) - { - local argv = [ modules.peek : ARGV ] ; - local e = $(argv[1]) ; - local l = [ modules.binding version ] ; - l = $(l:D) ; - l = $(l:D) ; - ECHO "warning: mismatched versions of Boost.Build engine and core" ; - ECHO "warning: Boost.Build engine ($(e)) is $(v:J=.)" ; - ECHO "warning: Boost.Build core (at $(l)) is" [ boost-build ] ; - } - else - { - return true ; - } -} - - -# Utility rule for testing whether all elements in a sequence are equal to 0. -# -local rule is-all-zeroes ( sequence * ) -{ - local result = "true" ; - for local e in $(sequence) - { - if $(e) != "0" - { - result = "" ; - } - } - return $(result) ; -} - - -# Returns "true" if the first version is less than the second one. -# -rule version-less ( lhs + : rhs + ) -{ - numbers.check $(lhs) ; - numbers.check $(rhs) ; - - local done ; - local result ; - - while ! $(done) && $(lhs) && $(rhs) - { - if [ numbers.less $(lhs[1]) $(rhs[1]) ] - { - done = "true" ; - result = "true" ; - } - else if [ numbers.less $(rhs[1]) $(lhs[1]) ] - { - done = "true" ; - } - else - { - lhs = $(lhs[2-]) ; - rhs = $(rhs[2-]) ; - } - } - if ( ! $(done) && ! $(lhs) && ! [ is-all-zeroes $(rhs) ] ) - { - result = "true" ; - } - - return $(result) ; -} - - -# Returns "true" if the current JAM version version is at least the given -# version. -# -rule check-jam-version ( version + ) -{ - local version-tag = $(version:J=.) ; - if ! $(version-tag) - { - import errors ; - errors.error Invalid version specifier: : $(version:E="(undefined)") ; - } - - if ! $(.jam-version-check.$(version-tag))-is-defined - { - local jam-version = [ modules.peek : JAM_VERSION ] ; - if ! $(jam-version) - { - import errors ; - errors.error "Unable to deduce Boost Jam version. Your Boost Jam" - "installation is most likely terribly outdated." ; - } - .jam-version-check.$(version-tag) = "true" ; - if [ version-less [ modules.peek : JAM_VERSION ] : $(version) ] - { - .jam-version-check.$(version-tag) = "" ; - } - } - return $(.jam-version-check.$(version-tag)) ; -} - - -rule __test__ ( ) -{ - import assert ; - - local jam-version = [ modules.peek : JAM_VERSION ] ; - local future-version = $(jam-version) ; - future-version += "1" ; - - assert.true check-jam-version $(jam-version) ; - assert.false check-jam-version $(future-version) ; - - assert.true version-less 0 : 1 ; - assert.false version-less 0 : 0 ; - assert.true version-less 1 : 2 ; - assert.false version-less 1 : 1 ; - assert.false version-less 2 : 1 ; - assert.true version-less 3 1 20 : 3 4 10 ; - assert.false version-less 3 1 10 : 3 1 10 ; - assert.false version-less 3 4 10 : 3 1 20 ; - assert.true version-less 3 1 20 5 1 : 3 4 10 ; - assert.false version-less 3 1 10 5 1 : 3 1 10 ; - assert.false version-less 3 4 10 5 1 : 3 1 20 ; - assert.true version-less 3 1 20 : 3 4 10 5 1 ; - assert.true version-less 3 1 10 : 3 1 10 5 1 ; - assert.false version-less 3 4 10 : 3 1 20 5 1 ; - assert.false version-less 3 1 10 : 3 1 10 0 0 ; - assert.false version-less 3 1 10 0 0 : 3 1 10 ; - assert.false version-less 3 1 10 0 : 3 1 10 0 0 ; - assert.false version-less 3 1 10 0 : 03 1 10 0 0 ; - assert.false version-less 03 1 10 0 : 3 1 10 0 0 ; - - # TODO: Add tests for invalid input data being sent to version-less. -} http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/6da3961b/ext/kenlm/jam-files/boost-build/build/virtual-target.jam ---------------------------------------------------------------------- diff --git a/ext/kenlm b/ext/kenlm new file mode 160000 index 0000000..56fdb5c --- /dev/null +++ b/ext/kenlm @@ -0,0 +1 @@ +Subproject commit 56fdb5c44fca34d5a2e07d96139c28fb163983c5 diff --git a/ext/kenlm/jam-files/boost-build/build/virtual-target.jam b/ext/kenlm/jam-files/boost-build/build/virtual-target.jam deleted file mode 100644 index f62eadb..0000000 --- a/ext/kenlm/jam-files/boost-build/build/virtual-target.jam +++ /dev/null @@ -1,1339 +0,0 @@ -# Copyright 2003 Dave Abrahams -# Copyright 2005, 2006 Rene Rivera -# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus -# 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) - -# Implements virtual targets, which correspond to actual files created during a -# build, but are not yet targets in Jam sense. They are needed, for example, -# when searching for possible transformation sequences, when it is not yet known -# whether a particular target should be created at all. -# -# +--------------------------+ -# | virtual-target | -# +==========================+ -# | actualize | -# +--------------------------+ -# | actualize-action() = 0 | -# | actualize-location() = 0 | -# +----------------+---------+ -# | -# ^ -# / \ -# +-+-+ -# | -# +---------------------+ +-------+--------------+ -# | action | | abstract-file-target | -# +=====================| * +======================+ -# | action-name | +--+ action | -# | properties | | +----------------------+ -# +---------------------+--+ | actualize-action() | -# | actualize() |0..1 +-----------+----------+ -# | path() | | -# | adjust-properties() | sources | -# | actualize-sources() | targets | -# +------+--------------+ ^ -# | / \ -# ^ +-+-+ -# / \ | -# +-+-+ +-------------+-------------+ -# | | | -# | +------+---------------+ +--------+-------------+ -# | | file-target | | searched-lib-target | -# | +======================+ +======================+ -# | | actualize-location() | | actualize-location() | -# | +----------------------+ +----------------------+ -# | -# +-+------------------------------+ -# | | -# +----+----------------+ +---------+-----------+ -# | compile-action | | link-action | -# +=====================+ +=====================+ -# | adjust-properties() | | adjust-properties() | -# +---------------------+ | actualize-sources() | -# +---------------------+ -# -# The 'compile-action' and 'link-action' classes are not defined here but in -# builtin.jam modules. They are shown in the diagram to give the big picture. - -import "class" : new ; -import path ; -import sequence ; -import set ; -import type ; -import utility ; - - -# Models a potential target. It can be converted into a Jam target and used in -# building, if needed. However, it can be also dropped, which allows us to -# search for different transformations and select only one. -# -class virtual-target -{ - import scanner ; - import sequence ; - import utility ; - import virtual-target ; - - rule __init__ ( - name # Target/project name. - : project # Project to which this target belongs. - ) - { - self.name = $(name) ; - self.project = $(project) ; - self.dependencies = ; - } - - # Name of this target. - # - rule name ( ) - { - return $(self.name) ; - } - - # Project of this target. - # - rule project ( ) - { - return $(self.project) ; - } - - # Adds additional 'virtual-target' instances this one depends on. - # - rule depends ( d + ) - { - self.dependencies = [ sequence.merge $(self.dependencies) : - [ sequence.insertion-sort $(d) ] ] ; - } - - rule dependencies ( ) - { - return $(self.dependencies) ; - } - - rule always ( ) - { - .always = 1 ; - } - - # Generates all the actual targets and sets up build actions for this - # target. - # - # If 'scanner' is specified, creates an additional target with the same - # location as the actual target, which will depend on the actual target and - # be associated with a 'scanner'. That additional target is returned. See - # the docs (#dependency_scanning) for rationale. Target must correspond to a - # file if 'scanner' is specified. - # - # If scanner is not specified then the actual target is returned. - # - rule actualize ( scanner ? ) - { - local actual-name = [ actualize-no-scanner ] ; - - if $(.always) - { - ALWAYS $(actual-name) ; - } - - if ! $(scanner) - { - return $(actual-name) ; - } - else - { - # Add the scanner instance to the grist for name. - local g = [ sequence.join [ utility.ungrist $(actual-name:G) ] - $(scanner) : - ] ; - local name = $(actual-name:G=$(g)) ; - - if ! $(self.made.$(scanner)) - { - self.made.$(scanner) = true ; - actualize-location $(name) ; - scanner.install $(scanner) : $(name) ; - } - return $(name) ; - } - } - -# private: (overridables) - - # Sets up build actions for 'target'. Should call appropriate rules and set - # target variables. - # - rule actualize-action ( target ) - { - import errors : error : errors.error ; - errors.error "method should be defined in derived classes" ; - } - - # Sets up variables on 'target' which specify its location. - # - rule actualize-location ( target ) - { - import errors : error : errors.error ; - errors.error "method should be defined in derived classes" ; - } - - # If the target is a generated one, returns the path where it will be - # generated. Otherwise, returns an empty list. - # - rule path ( ) - { - import errors : error : errors.error ; - errors.error "method should be defined in derived classes" ; - } - - # Returns the actual target name to be used in case when no scanner is - # involved. - # - rule actual-name ( ) - { - import errors : error : errors.error ; - errors.error "method should be defined in derived classes" ; - } - -# implementation - rule actualize-no-scanner ( ) - { - # In fact, we just need to merge virtual-target with - # abstract-file-target as the latter is the only class derived from the - # former. But that has been left for later. - - import errors : error : errors.error ; - errors.error "method should be defined in derived classes" ; - } -} - - -# Target corresponding to a file. The exact mapping for file is not yet -# specified in this class. (TODO: Actually, the class name could be better...) -# -# May be a source file (when no action is specified) or a derived file -# (otherwise). -# -# The target's grist is a concatenation of its project's location, action -# properties (for derived targets) and, optionally, value identifying the main -# target. -# -class abstract-file-target : virtual-target -{ - import project ; - import regex ; - import sequence ; - import path ; - import type ; - import property-set ; - import indirect ; - - rule __init__ ( - name # Target's name. - exact ? # If non-empty, the name is exactly the name created file - # should have. Otherwise, the '__init__' method will add a - # suffix obtained from 'type' by calling - # 'type.generated-target-suffix'. - : type ? # Target's type. - : project - : action ? - ) - { - virtual-target.__init__ $(name) : $(project) ; - - self.type = $(type) ; - self.action = $(action) ; - if $(action) - { - $(action).add-targets $(__name__) ; - - if $(self.type) && ! $(exact) - { - _adjust-name $(name) ; - } - } - } - - rule type ( ) - { - return $(self.type) ; - } - - # Sets the path. When generating target name, it will override any path - # computation from properties. - # - rule set-path ( path ) - { - self.path = [ path.native $(path) ] ; - } - - # Returns the currently set action. - # - rule action ( ) - { - return $(self.action) ; - } - - # Sets/gets the 'root' flag. Target is root if it directly corresponds to - # some variant of a main target. - # - rule root ( set ? ) - { - if $(set) - { - self.root = true ; - } - return $(self.root) ; - } - - # Gets or sets the subvariant which created this target. Subvariant is set - # when target is brought into existance and is never changed after that. In - # particular, if a target is shared by multiple subvariants, only the first - # one is stored. - # - rule creating-subvariant ( s ? # If specified, specifies the value to set, - # which should be a 'subvariant' class - # instance. - ) - { - if $(s) && ! $(self.creating-subvariant) - { - self.creating-subvariant = $(s) ; - } - return $(self.creating-subvariant) ; - } - - rule actualize-action ( target ) - { - if $(self.action) - { - $(self.action).actualize ; - } - } - - # Return a human-readable representation of this target. If this target has - # an action, that is: - # - # { <action-name>-<self.name>.<self.type> <action-sources>... } - # - # otherwise, it is: - # - # { <self.name>.<self.type> } - # - rule str ( ) - { - local action = [ action ] ; - local name-dot-type = [ sequence.join $(self.name) "." $(self.type) ] ; - - if $(action) - { - local sources = [ $(action).sources ] ; - local action-name = [ $(action).action-name ] ; - - local ss ; - for local s in $(sources) - { - ss += [ $(s).str ] ; - } - - return "{" $(action-name)-$(name-dot-type) $(ss) "}" ; - } - else - { - return "{" $(name-dot-type) "}" ; - } - } - - rule less ( a ) - { - if [ str ] < [ $(a).str ] - { - return true ; - } - } - - rule equal ( a ) - { - if [ str ] = [ $(a).str ] - { - return true ; - } - } - -# private: - rule actual-name ( ) - { - if ! $(self.actual-name) - { - local grist = [ grist ] ; - local basename = [ path.native $(self.name) ] ; - self.actual-name = <$(grist)>$(basename) ; - } - return $(self.actual-name) ; - } - - # Helper to 'actual-name', above. Computes a unique prefix used to - # distinguish this target from other targets with the same name creating - # different files. - # - rule grist ( ) - { - # Depending on target, there may be different approaches to generating - # unique prefixes. We generate prefixes in the form: - # <one letter approach code> <the actual prefix> - local path = [ path ] ; - if $(path) - { - # The target will be generated to a known path. Just use the path - # for identification, since path is as unique as it can get. - return p$(path) ; - } - else - { - # File is either source, which will be searched for, or is not a - # file at all. Use the location of project for distinguishing. - local project-location = [ $(self.project).get location ] ; - local location-grist = [ sequence.join [ regex.split - $(project-location) "/" ] : "!" ] ; - - if $(self.action) - { - local ps = [ $(self.action).properties ] ; - local property-grist = [ $(ps).as-path ] ; - # 'property-grist' can be empty when 'ps' is an empty property - # set. - if $(property-grist) - { - location-grist = $(location-grist)/$(property-grist) ; - } - } - - return l$(location-grist) ; - } - } - - # Given the target name specified in constructor, returns the name which - # should be really used, by looking at the <tag> properties. Tag properties - # need to be specified as <tag>@rule-name. This makes Boost Build call the - # specified rule with the target name, type and properties to get the new - # name. If no <tag> property is specified or the rule specified by <tag> - # returns nothing, returns the result of calling - # virtual-target.add-prefix-and-suffix. - # - rule _adjust-name ( specified-name ) - { - local ps ; - if $(self.action) - { - ps = [ $(self.action).properties ] ; - } - else - { - ps = [ property-set.empty ] ; - } - - local tag = [ $(ps).get <tag> ] ; - - if $(tag) - { - local rule-name = [ MATCH ^@(.*) : $(tag) ] ; - if $(rule-name) - { - if $(tag[2]) - { - import errors : error : errors.error ; - errors.error <tag>@rulename is present but is not the only - <tag> feature. ; - } - - self.name = [ indirect.call $(rule-name) $(specified-name) - : $(self.type) : $(ps) ] ; - } - else - { - import errors : error : errors.error ; - errors.error <tag> property value must be '@rule-name'. ; - } - } - - # If there is no tag or the tag rule returned nothing. - if ! $(tag) || ! $(self.name) - { - self.name = [ virtual-target.add-prefix-and-suffix $(specified-name) - : $(self.type) : $(ps) ] ; - } - } - - rule actualize-no-scanner ( ) - { - local name = [ actual-name ] ; - - # Do anything only on the first invocation. - if ! $(self.made-no-scanner) - { - self.made-no-scanner = true ; - - if $(self.action) - { - # For non-derived target, we do not care if there are several - # virtual targets that refer to the same name. One case when - # this is unavoidable is when the file name is main.cpp and two - # targets have types CPP (for compiling) and MOCCABLE_CPP (for - # conversion to H via Qt tools). - virtual-target.register-actual-name $(name) : $(__name__) ; - } - - for local i in $(self.dependencies) - { - DEPENDS $(name) : [ $(i).actualize ] ; - } - - actualize-location $(name) ; - actualize-action $(name) ; - } - return $(name) ; - } -} - - -# Appends the suffix appropriate to 'type/property-set' combination to the -# specified name and returns the result. -# -rule add-prefix-and-suffix ( specified-name : type ? : property-set ) -{ - local suffix = [ type.generated-target-suffix $(type) : $(property-set) ] ; - - # Handle suffixes for which no leading dot is desired. Those are specified - # by enclosing them in <...>. Needed by python so it can create "_d.so" - # extensions, for example. - if $(suffix:G) - { - suffix = [ utility.ungrist $(suffix) ] ; - } - else - { - suffix = .$(suffix) ; - } - - local prefix = [ type.generated-target-prefix $(type) : $(property-set) ] ; - - if [ MATCH ^($(prefix)) : $(specified-name) ] - { - prefix = ; - } - return $(prefix:E="")$(specified-name)$(suffix:E="") ; -} - - -# File targets with explicitly known location. -# -# The file path is determined as -# * Value passed to the 'set-path' method, if any. -# * For derived files, project's build dir, joined with components that -# describe action properties. If free properties are not equal to the -# project's reference properties an element with the name of the main -# target is added. -# * For source files, project's source dir. -# -# The file suffix is determined as: -# * The value passed to the 'suffix' method, if any. -# * The suffix corresponding to the target's type. -# -class file-target : abstract-file-target -{ - import "class" : new ; - import common ; - - rule __init__ ( - name exact ? - : type ? # Optional type for this target. - : project - : action ? - : path ? - ) - { - abstract-file-target.__init__ $(name) $(exact) : $(type) : $(project) : - $(action) ; - - self.path = $(path) ; - } - - rule clone-with-different-type ( new-type ) - { - return [ new file-target $(self.name) exact : $(new-type) : - $(self.project) : $(self.action) : $(self.path) ] ; - } - - rule actualize-location ( target ) - { - # Scanner targets are always bound to already existing files in already - # existing folder. They need to be marked as depending on their base - # target (i.e. the target being scanned) but, unlike regular - # dependencies set up by the DEPENDS rule, they must not depend on any - # targets already marked as included by the base target. Otherwise such - # an included file being newer than the file being scanned would cause - # the scanner target to be updated, further causing any target depending - # on that scanner target to be rebuilt. This is the exact relationship - # as set up by Boost Jam's SEARCH binding method (needed to support - # searching for generated targets) so we want to bind scanner targets - # using this method instead of explicitly specifying their location - # using LOCATE. - # - # FIXME: We recognize scanner targets by their given name being - # different from this target's actual name. This is a hack and should be - # cleaned up by reorganizing who knows about scanners in the - # virtual-target/abstract-file-target/file-target/notfile-target/ - # searched-lib-target/... class hierarchy. - local is-scanner-target ; - if $(target) != [ actual-name ] - { - is-scanner-target = true ; - } - - if $(self.action) && ! $(is-scanner-target) - { - # This is a derived file. - local path = [ path ] ; - LOCATE on $(target) = $(path) ; - - # Make sure the path exists. - DEPENDS $(target) : $(path) ; - common.MkDir $(path) ; - - # It is possible that the target name includes a directory too, for - # example when installing headers. Create that directory. - if $(target:D) - { - local d = $(target:D) ; - d = $(d:R=$(path)) ; - DEPENDS $(target) : $(d) ; - common.MkDir $(d) ; - } - - # For a real file target, we create a fake target depending on the - # real target. This allows us to run - # - # b2 hello.o - # - # without trying to guess the name of the real target. Note that the - # target has no directory name and uses a special <e> grist. - # - # First, that means that "b2 hello.o" will build all known hello.o - # targets. Second, the <e> grist makes sure this target will not be - # confused with other targets, for example, if we have subdir 'test' - # with target 'test' in it that includes a 'test.o' file, then the - # target for directory will be just 'test' the target for test.o - # will be <ptest/bin/gcc/debug>test.o and the target we create below - # will be <e>test.o - DEPENDS $(target:G=e) : $(target) ; - # Allow b2 <path-to-file>/<file> to work. This will not catch all - # possible ways to refer to the path (relative/absolute, extra ".", - # various "..", but should help in obvious cases. - DEPENDS $(target:G=e:R=$(path)) : $(target) ; - } - else - { - SEARCH on $(target) = [ path.native $(self.path) ] ; - } - } - - # Returns the directory for this target. - # - rule path ( ) - { - if ! $(self.path) - { - if $(self.action) - { - local p = [ $(self.action).properties ] ; - local path,relative-to-build-dir = [ $(p).target-path ] ; - local path = $(path,relative-to-build-dir[1]) ; - local relative-to-build-dir = $(path,relative-to-build-dir[2]) ; - - if $(relative-to-build-dir) - { - path = [ path.join [ $(self.project).build-dir ] $(path) ] ; - } - - self.path = [ path.native $(path) ] ; - } - } - return $(self.path) ; - } -} - - -class notfile-target : abstract-file-target -{ - rule __init__ ( name : project : action ? ) - { - abstract-file-target.__init__ $(name) : : $(project) : $(action) ; - } - - # Returns nothing to indicate that the target's path is not known. - # - rule path ( ) - { - return ; - } - - rule actualize-location ( target ) - { - NOTFILE $(target) ; - ALWAYS $(target) ; - # TEMPORARY $(target) ; - NOUPDATE $(target) ; - } -} - - -# Class representing an action. Both 'targets' and 'sources' should list -# instances of 'virtual-target'. Action name should name a rule with this -# prototype: -# rule action-name ( targets + : sources * : properties * ) -# Targets and sources are passed as actual Jam targets. The rule may not -# establish additional dependency relationships. -# -class action -{ - import "class" ; - import indirect ; - import path ; - import property-set ; - import set : difference ; - import toolset ; - import type ; - - rule __init__ ( sources * : action-name + : property-set ? ) - { - self.sources = $(sources) ; - - self.action-name = [ indirect.make-qualified $(action-name) ] ; - - if ! $(property-set) - { - property-set = [ property-set.empty ] ; - } - - if ! [ class.is-instance $(property-set) ] - { - import errors : error : errors.error ; - errors.error "Property set instance required" ; - } - - self.properties = $(property-set) ; - } - - rule add-targets ( targets * ) - { - self.targets += $(targets) ; - } - - rule replace-targets ( old-targets * : new-targets * ) - { - self.targets = [ set.difference $(self.targets) : $(old-targets) ] ; - self.targets += $(new-targets) ; - } - - rule targets ( ) - { - return $(self.targets) ; - } - - rule sources ( ) - { - return $(self.sources) ; - } - - rule action-name ( ) - { - return $(self.action-name) ; - } - - rule properties ( ) - { - return $(self.properties) ; - } - - # Generates actual build instructions. - # - rule actualize ( ) - { - if ! $(self.actualized) - { - self.actualized = true ; - - local ps = [ properties ] ; - local properties = [ adjust-properties $(ps) ] ; - - local actual-targets ; - for local i in [ targets ] - { - actual-targets += [ $(i).actualize ] ; - } - - actualize-sources [ sources ] : $(properties) ; - - DEPENDS $(actual-targets) : $(self.actual-sources) - $(self.dependency-only-sources) ; - - # Action name can include additional rule arguments, which should - # not be passed to 'set-target-variables'. - toolset.set-target-variables - [ indirect.get-rule $(self.action-name[1]) ] $(actual-targets) - : $(properties) ; - - # Reflect ourselves in a variable for the target. This allows - # looking up additional info for the action given the raw target. - # For example to debug or output action information from action - # rules. - .action on $(actual-targets) = $(__name__) ; - - indirect.call $(self.action-name) $(actual-targets) - : $(self.actual-sources) : [ $(properties).raw ] ; - - # Since we set up the creating action here, we set up the action for - # cleaning up as well. - common.Clean clean-all : $(actual-targets) ; - } - } - - # Helper for 'actualize-sources'. For each passed source, actualizes it with - # the appropriate scanner. Returns the actualized virtual targets. - # - rule actualize-source-type ( sources * : property-set ) - { - local result = ; - for local i in $(sources) - { - local scanner ; - if [ $(i).type ] - { - scanner = [ type.get-scanner [ $(i).type ] : $(property-set) ] ; - } - result += [ $(i).actualize $(scanner) ] ; - } - return $(result) ; - } - - # Creates actual Jam targets for sources. Initializes the following member - # variables: - # 'self.actual-sources' -- sources passed to the updating action. - # 'self.dependency-only-sources' -- sources marked as dependencies, but - # are not used otherwise. - # - # New values will be *appended* to the variables. They may be non-empty if - # caller wants it. - # - rule actualize-sources ( sources * : property-set ) - { - local dependencies = [ $(self.properties).get <dependency> ] ; - - self.dependency-only-sources += - [ actualize-source-type $(dependencies) : $(property-set) ] ; - self.actual-sources += - [ actualize-source-type $(sources) : $(property-set) ] ; - - # This is used to help b2 find dependencies in generated headers and - # other main targets, e.g. in: - # - # make a.h : ....... ; - # exe hello : hello.cpp : <implicit-dependency>a.h ; - # - # For b2 to find the dependency the generated target must be - # actualized (i.e. have its Jam target constructed). In the above case, - # if we are building just hello ("b2 hello"), 'a.h' will not be - # actualized unless we do it here. - local implicit = [ $(self.properties).get <implicit-dependency> ] ; - for local i in $(implicit) - { - $(i:G=).actualize ; - } - } - - # Determines real properties when trying to build with 'properties'. This is - # the last chance to fix properties, for example to adjust includes to get - # generated headers correctly. Default implementation simply returns its - # argument. - # - rule adjust-properties ( property-set ) - { - return $(property-set) ; - } -} - - -# Action class which does nothing --- it produces the targets with specific -# properties out of nowhere. It is needed to distinguish virtual targets with -# different properties that are known to exist and have no actions which create -# them. -# -class null-action : action -{ - rule __init__ ( property-set ? ) - { - action.__init__ : .no-action : $(property-set) ; - } - - rule actualize ( ) - { - if ! $(self.actualized) - { - self.actualized = true ; - for local i in [ targets ] - { - $(i).actualize ; - } - } - } -} - - -# Class which acts exactly like 'action', except that its sources are not -# scanned for dependencies. -# -class non-scanning-action : action -{ - rule __init__ ( sources * : action-name + : property-set ? ) - { - action.__init__ $(sources) : $(action-name) : $(property-set) ; - } - - rule actualize-source-type ( sources * : property-set ) - { - local result ; - for local i in $(sources) - { - result += [ $(i).actualize ] ; - } - return $(result) ; - } -} - - -# Creates a virtual target with an appropriate name and type from 'file'. If a -# target with that name in that project already exists, returns that already -# created target. -# -# FIXME: a more correct way would be to compute the path to the file, based on -# name and source location for the project, and use that path to determine if -# the target has already been created. This logic should be shared with how we -# usually find targets identified by a specific target id. It should also be -# updated to work correctly when the file is specified using both relative and -# absolute paths. -# -# TODO: passing a project with all virtual targets is starting to be annoying. -# -rule from-file ( file : file-loc : project ) -{ - import type ; # Had to do this here to break a circular dependency. - - # Check whether we already created a target corresponding to this file. - local path = [ path.root [ path.root $(file) $(file-loc) ] [ path.pwd ] ] ; - - if $(.files.$(path)) - { - return $(.files.$(path)) ; - } - else - { - local name = [ path.make $(file) ] ; - local type = [ type.type $(file) ] ; - local result ; - - result = [ new file-target $(file) : $(type) : $(project) : : - $(file-loc) ] ; - - .files.$(path) = $(result) ; - return $(result) ; - } -} - - -# Registers a new virtual target. Checks if there is already a registered target -# with the same name, type, project and subvariant properties as well as the -# same sources and equal action. If such target is found it is returned and a -# new 'target' is not registered. Otherwise, 'target' is registered and -# returned. -# -rule register ( target ) -{ - local signature = [ sequence.join [ $(target).path ] [ $(target).name ] : - - ] ; - - local result ; - for local t in $(.cache.$(signature)) - { - local a1 = [ $(t).action ] ; - local a2 = [ $(target).action ] ; - - if ! $(result) - { - if ! $(a1) && ! $(a2) - { - result = $(t) ; - } - else if $(a1) && $(a2) && - ( [ $(a1).action-name ] = [ $(a2).action-name ] ) && - ( [ $(a1).sources ] = [ $(a2).sources ] ) - { - local ps1 = [ $(a1).properties ] ; - local ps2 = [ $(a2).properties ] ; - local p1 = [ $(ps1).base ] [ $(ps1).free ] [ set.difference - [ $(ps1).dependency ] : [ $(ps1).incidental ] ] ; - local p2 = [ $(ps2).base ] [ $(ps2).free ] [ set.difference - [ $(ps2).dependency ] : [ $(ps2).incidental ] ] ; - if $(p1) = $(p2) - { - result = $(t) ; - } - } - } - } - - if ! $(result) - { - .cache.$(signature) += $(target) ; - result = $(target) ; - } - - .recent-targets += $(result) ; - .all-targets += $(result) ; - - return $(result) ; -} - - -# Each target returned by 'register' is added to the .recent-targets list, -# returned by this function. This allows us to find all virtual targets created -# when building a specific main target, even those constructed only as -# intermediate targets. -# -rule recent-targets ( ) -{ - return $(.recent-targets) ; -} - - -rule clear-recent-targets ( ) -{ - .recent-targets = ; -} - - -# Returns all virtual targets ever created. -# -rule all-targets ( ) -{ - return $(.all-targets) ; -} - - -# Returns all targets from 'targets' with types equal to 'type' or derived from -# it. -# -rule select-by-type ( type : targets * ) -{ - local result ; - for local t in $(targets) - { - if [ type.is-subtype [ $(t).type ] $(type) ] - { - result += $(t) ; - } - } - return $(result) ; -} - - -rule register-actual-name ( actual-name : virtual-target ) -{ - if $(.actual.$(actual-name)) - { - local cs1 = [ $(.actual.$(actual-name)).creating-subvariant ] ; - local cmt1-name ; - if $(cs1)-is-defined - { - local cmt1 = [ $(cs1).main-target ] ; - cmt1-name = [ $(cmt1).full-name ] ; - } - local cs2 = [ $(virtual-target).creating-subvariant ] ; - local cmt2-name ; - if $(cs2)-is-defined - { - local cmt2 = [ $(cs2).main-target ] ; - cmt2-name = [ $(cmt2).full-name ] ; - } - local extra-error-information ; - if ! $(cs1)-is-defined || ! $(cs2)-is-defined - { - extra-error-information = Encountered a virtual-target without a - creating subvariant. It could be the virtual target has not been - registered via the virtual-target.register rule. ; - } - - local action1 = [ $(.actual.$(actual-name)).action ] ; - local action2 = [ $(virtual-target).action ] ; - local properties-added ; - local properties-removed ; - if $(action1) && $(action2) - { - local p1 = [ $(action1).properties ] ; - p1 = [ $(p1).raw ] ; - local p2 = [ $(action2).properties ] ; - p2 = [ $(p2).raw ] ; - properties-removed = [ set.difference $(p1) : $(p2) ] ; - properties-removed ?= "none" ; - properties-added = [ set.difference $(p2) : $(p1) ] ; - properties-added ?= "none" ; - } - import errors : error : errors.error ; - errors.error "Duplicate name of actual target:" $(actual-name) - : "previous virtual target" [ $(.actual.$(actual-name)).str ] - : "created from" $(cmt1-name) - : "another virtual target" [ $(virtual-target).str ] - : "created from" $(cmt2-name) - : "added properties:" $(properties-added) - : "removed properties:" $(properties-removed) - : $(extra-error-information) ; - } - else - { - .actual.$(actual-name) = $(virtual-target) ; - } -} - - -# Traverses the dependency graph of 'target' and return all targets that will be -# created before this one is created. If the root of some dependency graph is -# found during traversal, it is either included or not, depending on the -# 'include-roots' value. In either case traversal stops at root targets, i.e. -# root target sources are not traversed. -# -rule traverse ( target : include-roots ? : include-sources ? ) -{ - local result ; - if [ $(target).action ] - { - local action = [ $(target).action ] ; - # This includes the 'target' as well. - result += [ $(action).targets ] ; - - for local t in [ $(action).sources ] - { - if ! [ $(t).root ] - { - result += [ traverse $(t) : $(include-roots) : - $(include-sources) ] ; - } - else if $(include-roots) - { - result += $(t) ; - } - } - } - else if $(include-sources) - { - result = $(target) ; - } - return $(result) ; -} - - -# Takes an 'action' instance and creates a new instance of it and all targets -# produced by the action. The rule-name and properties are set to -# 'new-rule-name' and 'new-properties', if those are specified. Returns the -# cloned action. -# -rule clone-action ( action : new-project : new-action-name ? : new-properties ? - ) -{ - if ! $(new-action-name) - { - new-action-name = [ $(action).action-name ] ; - } - if ! $(new-properties) - { - new-properties = [ $(action).properties ] ; - } - - local action-class = [ modules.peek $(action) : __class__ ] ; - local cloned-action = [ class.new $(action-class) - [ $(action).sources ] : $(new-action-name) : $(new-properties) ] ; - - local cloned-targets ; - for local target in [ $(action).targets ] - { - local n = [ $(target).name ] ; - # Do not modify produced target names. - local cloned-target = [ class.new file-target $(n) exact : - [ $(target).type ] : $(new-project) : $(cloned-action) ] ; - local d = [ $(target).dependencies ] ; - if $(d) - { - $(cloned-target).depends $(d) ; - } - $(cloned-target).root [ $(target).root ] ; - $(cloned-target).creating-subvariant [ $(target).creating-subvariant ] ; - - cloned-targets += $(cloned-target) ; - } - - return $(cloned-action) ; -} - - -class subvariant -{ - import sequence ; - import type ; - - rule __init__ ( main-target # The instance of main-target class. - : property-set # Properties requested for this target. - : sources * - : build-properties # Actually used properties. - : sources-usage-requirements # Properties propagated from sources. - : created-targets * ) # Top-level created targets. - { - self.main-target = $(main-target) ; - self.properties = $(property-set) ; - self.sources = $(sources) ; - self.build-properties = $(build-properties) ; - self.sources-usage-requirements = $(sources-usage-requirements) ; - self.created-targets = $(created-targets) ; - - # Pre-compose a list of other dependency graphs this one depends on. - local deps = [ $(build-properties).get <implicit-dependency> ] ; - for local d in $(deps) - { - self.other-dg += [ $(d:G=).creating-subvariant ] ; - } - - self.other-dg = [ sequence.unique $(self.other-dg) ] ; - } - - rule main-target ( ) - { - return $(self.main-target) ; - } - - rule created-targets ( ) - { - return $(self.created-targets) ; - } - - rule requested-properties ( ) - { - return $(self.properties) ; - } - - rule build-properties ( ) - { - return $(self.build-properties) ; - } - - rule sources-usage-requirements ( ) - { - return $(self.sources-usage-requirements) ; - } - - rule set-usage-requirements ( usage-requirements ) - { - self.usage-requirements = $(usage-requirements) ; - } - - rule usage-requirements ( ) - { - return $(self.usage-requirements) ; - } - - # Returns all targets referenced by this subvariant, either directly or - # indirectly, and either as sources, or as dependency properties. Targets - # referred to using the dependency property are returned as properties, not - # targets. - # - rule all-referenced-targets ( theset ) - { - # Find directly referenced targets. - local deps = [ $(self.build-properties).dependency ] ; - local all-targets = $(self.sources) $(deps) ; - - # Find other subvariants. - local r ; - for local t in $(all-targets) - { - if ! [ $(theset).contains $(t) ] - { - $(theset).add $(t) ; - r += [ $(t:G=).creating-subvariant ] ; - } - } - r = [ sequence.unique $(r) ] ; - for local s in $(r) - { - if $(s) != $(__name__) - { - $(s).all-referenced-targets $(theset) ; - } - } - } - - # Returns the properties specifying implicit include paths to generated - # headers. This traverses all targets in this subvariant and subvariants - # referred by <implicit-dependecy> properties. For all targets of type - # 'target-type' (or for all targets, if 'target-type' is not specified), the - # result will contain <$(feature)>path-to-that-target. - # - rule implicit-includes ( feature : target-type ? ) - { - local key = ii$(feature)-$(target-type:E="") ; - if ! $($(key))-is-not-empty - { - local target-paths = [ all-target-directories $(target-type) ] ; - target-paths = [ sequence.unique $(target-paths) ] ; - local result = $(target-paths:G=$(feature)) ; - if ! $(result) - { - result = "" ; - } - $(key) = $(result) ; - } - if $($(key)) = "" - { - return ; - } - else - { - return $($(key)) ; - } - } - - rule all-target-directories ( target-type ? ) - { - if ! $(self.target-directories) - { - compute-target-directories $(target-type) ; - } - return $(self.target-directories) ; - } - - rule compute-target-directories ( target-type ? ) - { - local result ; - for local t in $(self.created-targets) - { - # Skip targets of the wrong type. - if ! $(target-type) || - [ type.is-derived [ $(t).type ] $(target-type) ] - { - result = [ sequence.merge $(result) : [ $(t).path ] ] ; - } - } - for local d in $(self.other-dg) - { - result += [ $(d).all-target-directories $(target-type) ] ; - } - self.target-directories = $(result) ; - } -} http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/6da3961b/ext/kenlm/jam-files/boost-build/kernel/boost-build.jam ---------------------------------------------------------------------- diff --git a/ext/kenlm b/ext/kenlm new file mode 160000 index 0000000..56fdb5c --- /dev/null +++ b/ext/kenlm @@ -0,0 +1 @@ +Subproject commit 56fdb5c44fca34d5a2e07d96139c28fb163983c5 diff --git a/ext/kenlm/jam-files/boost-build/kernel/boost-build.jam b/ext/kenlm/jam-files/boost-build/kernel/boost-build.jam deleted file mode 100644 index 377f6ec..0000000 --- a/ext/kenlm/jam-files/boost-build/kernel/boost-build.jam +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright 2003 Dave Abrahams -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - -boost-build . ; http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/6da3961b/ext/kenlm/jam-files/boost-build/kernel/bootstrap.jam ---------------------------------------------------------------------- diff --git a/ext/kenlm b/ext/kenlm new file mode 160000 index 0000000..56fdb5c --- /dev/null +++ b/ext/kenlm @@ -0,0 +1 @@ +Subproject commit 56fdb5c44fca34d5a2e07d96139c28fb163983c5 diff --git a/ext/kenlm/jam-files/boost-build/kernel/bootstrap.jam b/ext/kenlm/jam-files/boost-build/kernel/bootstrap.jam deleted file mode 100644 index c4320dc..0000000 --- a/ext/kenlm/jam-files/boost-build/kernel/bootstrap.jam +++ /dev/null @@ -1,266 +0,0 @@ -# Copyright 2003 Dave Abrahams -# Copyright 2003, 2005, 2006 Rene Rivera -# Copyright 2003, 2005, 2006 Vladimir Prus -# 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) - -# First of all, check the jam version. -if $(JAM_VERSION:J="") < 030112 -{ - ECHO "error: Boost.Jam version 3.1.12 or later required" ; - EXIT ; -} - -local required-rules = GLOB-RECURSIVELY HAS_NATIVE_RULE ; -for local r in $(required-rules) -{ - if ! $(r) in [ RULENAMES ] - { - ECHO "error: builtin rule '$(r)' is not present" ; - ECHO "error: your version of bjam is likely out of date" ; - ECHO "error: please get a fresh version from SVN." ; - EXIT ; - } -} - -local native = regex transform 2 ; -while $(native) -{ - if ! [ HAS_NATIVE_RULE $(native[1]) : $(native[2]) : $(native[3]) ] - { - ECHO "error: missing native rule '$(native[1]).$(native[2])'" ; - ECHO "error: or interface version of that rule is too low" ; - ECHO "error: your version of bjam is likely out of date" ; - ECHO "error: please get a fresh version from SVN." ; - EXIT ; - } - native = $(native[4-]) ; -} - - -# Check that the builtin .ENVIRON module is present. We do not have a builtin to -# check that a module is present, so we assume that the PATH environment -# variable is always set and verify that the .ENVIRON module has a non-empty -# value of that variable. -module .ENVIRON -{ - local p = $(PATH) $(Path) $(path) ; - if ! $(p) - { - ECHO "error: no builtin module .ENVIRON is found" ; - ECHO "error: your version of bjam is likely out of date" ; - ECHO "error: please get a fresh version from SVN." ; - EXIT ; - } -} - -# Check that @() functionality is present. Similarly to modules, we do not have -# a way to test this directly. Instead we check that $(TMPNAME) functionality is -# present which was added at roughly the same time (more precisely, it was added -# just before). -{ - if ! $(TMPNAME) - { - ECHO "error: no @() functionality found" ; - ECHO "error: your version of b2 is likely out of date" ; - ECHO "error: please get a fresh version from SVN." ; - EXIT ; - } -} - -# Make sure that \n escape is avaiable. -if "\n" = "n" -{ - if $(OS) = CYGWIN - { - ECHO "warning: escape sequences are not supported" ; - ECHO "warning: this will cause major misbehaviour on cygwin" ; - ECHO "warning: your version of b2 is likely out of date" ; - ECHO "warning: please get a fresh version from SVN." ; - } -} - - -# Bootstrap the module system. Then bring the import rule into the global module. -# -SEARCH on <module@>modules.jam = $(.bootstrap-file:D) ; -module modules { include <module@>modules.jam ; } -IMPORT modules : import : : import ; - -{ - # Add module subdirectories to the BOOST_BUILD_PATH, which allows us to make - # incremental refactoring steps by moving modules to appropriate - # subdirectories, thereby achieving some physical separation of different - # layers without changing all of our code to specify subdirectories in - # import statements or use an extra level of qualification on imported - # names. - - local subdirs = - kernel # only the most-intrinsic modules: modules, errors - util # low-level substrate: string/number handling, etc. - build # essential elements of the build system architecture - tools # toolsets for handling specific build jobs and targets. - contrib # user contributed (unreviewed) modules - . # build-system.jam lives here - ; - local whereami = [ NORMALIZE_PATH $(.bootstrap-file:DT) ] ; - BOOST_BUILD_PATH += $(whereami:D)/$(subdirs) ; - - modules.poke .ENVIRON : BOOST_BUILD_PATH : $(BOOST_BUILD_PATH) ; - - modules.poke : EXTRA_PYTHONPATH : $(whereami) ; -} - -# Reload the modules, to clean up things. The modules module can tolerate being -# imported twice. -# -import modules ; - -# Process option plugins first to allow them to prevent loading the rest of the -# build system. -# -import option ; -local dont-build = [ option.process ] ; - -# Should we skip building, i.e. loading the build system, according to the -# options processed? -# -if ! $(dont-build) -{ - if ! --python in $(ARGV) - { - # Allow users to override the build system file from the command-line - # (mostly for testing). - local build-system = [ MATCH --build-system=(.*) : $(ARGV) ] ; - build-system ?= build-system ; - - # Use last element in case of multiple command-line options. - import $(build-system[-1]) ; - } - else - { - ECHO "Boost.Build V2 Python port (experimental)" ; - - # Define additional interface exposed to Python code. Python code will - # also have access to select bjam builtins in the 'bjam' module, but - # some things are easier to define outside C. - module python_interface - { - rule load ( module-name : location ) - { - USER_MODULE $(module-name) ; - # Make all rules in the loaded module available in the global - # namespace, so that we do not have to bother specifying the - # "correct" module when calling from Python. - module $(module-name) - { - __name__ = $(1) ; - include $(2) ; - local rules = [ RULENAMES $(1) ] ; - IMPORT $(1) : $(rules) : $(1) : $(1).$(rules) ; - } - } - - rule peek ( module-name ? : variables + ) - { - module $(<) - { - return $($(>)) ; - } - } - - rule set-variable ( module-name : name : value * ) - { - module $(<) - { - $(>) = $(3) ; - } - } - - rule set-top-level-targets ( targets * ) - { - DEPENDS all : $(targets) ; - } - - rule call-in-module ( m : rulename : * ) - { - module $(m) - { - return [ $(2) $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) - : $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : $(16) - : $(17) : $(18) : $(19) ] ; - } - } - - - rule set-update-action ( action : targets * : sources * : - properties * ) - { - $(action) $(targets) : $(sources) : $(properties) ; - } - - rule set-update-action-in-module ( m : action : targets * : - sources * : properties * ) - { - module $(m) - { - $(2) $(3) : $(4) : $(5) ; - } - } - - rule set-target-variable ( targets + : variable : value * : append ? - ) - { - if $(append) - { - $(variable) on $(targets) += $(value) ; - } - else - { - $(variable) on $(targets) = $(value) ; - } - } - - rule get-target-variable ( targets + : variable ) - { - return [ on $(targets) return $($(variable)) ] ; - } - - rule import-rules-from-parent ( parent-module : this-module : - user-rules * ) - { - IMPORT $(parent-module) : $(user-rules) : $(this-module) : - $(user-rules) ; - EXPORT $(this-module) : $(user-rules) ; - } - - rule mark-included ( targets * : includes * ) - { - NOCARE $(includes) ; - INCLUDES $(targets) : $(includes) ; - ISFILE $(includes) ; - } - } - - PYTHON_IMPORT_RULE bootstrap : bootstrap : PyBB : bootstrap ; - modules.poke PyBB : root : [ NORMALIZE_PATH $(.bootstrap-file:DT)/.. ] ; - - module PyBB - { - local ok = [ bootstrap $(root) ] ; - if ! $(ok) - { - EXIT ; - } - } - - - #PYTHON_IMPORT_RULE boost.build.build_system : main : PyBB : main ; - - #module PyBB - #{ - # main ; - #} - } -} http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/6da3961b/ext/kenlm/jam-files/boost-build/kernel/class.jam ---------------------------------------------------------------------- diff --git a/ext/kenlm b/ext/kenlm new file mode 160000 index 0000000..56fdb5c --- /dev/null +++ b/ext/kenlm @@ -0,0 +1 @@ +Subproject commit 56fdb5c44fca34d5a2e07d96139c28fb163983c5 diff --git a/ext/kenlm/jam-files/boost-build/kernel/class.jam b/ext/kenlm/jam-files/boost-build/kernel/class.jam deleted file mode 100644 index e48ab6d..0000000 --- a/ext/kenlm/jam-files/boost-build/kernel/class.jam +++ /dev/null @@ -1,420 +0,0 @@ -# Copyright 2001, 2002, 2003 Dave Abrahams -# Copyright 2002, 2005 Rene Rivera -# Copyright 2002, 2003 Vladimir Prus -# 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) - -# Polymorphic class system built on top of core Jam facilities. -# -# Classes are defined by 'class' keywords: -# -# class myclass -# { -# rule __init__ ( arg1 ) # constructor -# { -# self.attribute = $(arg1) ; -# } -# -# rule method1 ( ) # method -# { -# return [ method2 ] ; -# } -# -# rule method2 ( ) # method -# { -# return $(self.attribute) ; -# } -# } -# -# The __init__ rule is the constructor, and sets member variables. -# -# New instances are created by invoking [ new <class> <args...> ]: -# -# local x = [ new myclass foo ] ; # x is a new myclass object -# assert.result foo : [ $(x).method1 ] ; # $(x).method1 returns "foo" -# -# Derived class are created by mentioning base classes in the declaration:: -# -# class derived : myclass -# { -# rule __init__ ( arg ) -# { -# myclass.__init__ $(arg) ; # call base __init__ -# -# } -# -# rule method2 ( ) # method override -# { -# return $(self.attribute)XXX ; -# } -# } -# -# All methods operate virtually, replacing behavior in the base classes. For -# example:: -# -# local y = [ new derived foo ] ; # y is a new derived object -# assert.result fooXXX : [ $(y).method1 ] ; # $(y).method1 returns "foo" -# -# Each class instance is its own core Jam module. All instance attributes and -# methods are accessible without additional qualification from within the class -# instance. All rules imported in class declaration, or visible in base classses -# are also visible. Base methods are available in qualified form: -# base-name.method-name. By convention, attribute names are prefixed with -# "self.". - -import modules ; -import numbers ; - - -rule xinit ( instance : class ) -{ - module $(instance) - { - __class__ = $(2) ; - __name__ = $(1) ; - } -} - - -rule new ( class args * : * ) -{ - .next-instance ?= 1 ; - local id = object($(class))@$(.next-instance) ; - - INSTANCE $(id) : class@$(class) ; - xinit $(id) : $(class) ; - IMPORT_MODULE $(id) ; - $(id).__init__ $(args) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : - $(9) : $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : - $(18) : $(19) ; - - # Bump the next unique object name. - .next-instance = [ numbers.increment $(.next-instance) ] ; - - # Return the name of the new instance. - return $(id) ; -} - - -rule bases ( class ) -{ - module class@$(class) - { - return $(__bases__) ; - } -} - - -rule is-derived ( class : bases + ) -{ - local stack = $(class) ; - local visited found ; - while ! $(found) && $(stack) - { - local top = $(stack[1]) ; - stack = $(stack[2-]) ; - if ! ( $(top) in $(visited) ) - { - visited += $(top) ; - stack += [ bases $(top) ] ; - - if $(bases) in $(visited) - { - found = true ; - } - } - } - return $(found) ; -} - - -# Returns true if the 'value' is a class instance. -# -rule is-instance ( value ) -{ - return [ MATCH "^(object\\()[^@]+\\)@.*" : $(value) ] ; -} - - -# Check if the given value is of the given type. -# -rule is-a ( - instance # The value to check. - : type # The type to test for. -) -{ - if [ is-instance $(instance) ] - { - return [ class.is-derived [ modules.peek $(instance) : __class__ ] : $(type) ] ; - } -} - - -local rule typecheck ( x ) -{ - local class-name = [ MATCH "^\\[(.*)\\]$" : [ BACKTRACE 1 ] ] ; - if ! [ is-a $(x) : $(class-name) ] - { - return "Expected an instance of "$(class-name)" but got \""$(x)"\" for argument" ; - } -} - - -rule __test__ ( ) -{ - import assert ; - import "class" : new ; - import errors : try catch ; - - # This will be the construction function for a class called 'myclass'. - # - class myclass - { - import assert ; - - rule __init__ ( x_ * : y_ * ) - { - # Set some instance variables. - x = $(x_) ; - y = $(y_) ; - foo += 10 ; - } - - rule set-x ( newx * ) - { - x = $(newx) ; - } - - rule get-x ( ) - { - return $(x) ; - } - - rule set-y ( newy * ) - { - y = $(newy) ; - } - - rule get-y ( ) - { - return $(y) ; - } - - rule f ( ) - { - return [ g $(x) ] ; - } - - rule g ( args * ) - { - if $(x) in $(y) - { - return $(x) ; - } - else if $(y) in $(x) - { - return $(y) ; - } - else - { - return ; - } - } - - rule get-class ( ) - { - return $(__class__) ; - } - - rule get-instance ( ) - { - return $(__name__) ; - } - - rule invariant ( ) - { - assert.equal 1 : 1 ; - } - - rule get-foo ( ) - { - return $(foo) ; - } - } # class myclass ; - - class derived1 : myclass - { - rule __init__ ( z_ ) - { - myclass.__init__ $(z_) : X ; - z = $(z_) ; - } - - # Override g. - # - rule g ( args * ) - { - return derived1.g ; - } - - rule h ( ) - { - return derived1.h ; - } - - rule get-z ( ) - { - return $(z) ; - } - - # Check that 'assert.equal' visible in base class is visible here. - # - rule invariant2 ( ) - { - assert.equal 2 : 2 ; - } - - # Check that 'assert.variable-not-empty' visible in base class is - # visible here. - # - rule invariant3 ( ) - { - local v = 10 ; - assert.variable-not-empty v ; - } - } # class derived1 : myclass ; - - class derived2 : myclass - { - rule __init__ ( ) - { - myclass.__init__ 1 : 2 ; - } - - # Override g. - # - rule g ( args * ) - { - return derived2.g ; - } - - # Test the ability to call base class functions with qualification. - # - rule get-x ( ) - { - return [ myclass.get-x ] ; - } - } # class derived2 : myclass ; - - class derived2a : derived2 - { - rule __init__ - { - derived2.__init__ ; - } - } # class derived2a : derived2 ; - - local rule expect_derived2 ( [derived2] x ) { } - - local a = [ new myclass 3 4 5 : 4 5 ] ; - local b = [ new derived1 4 ] ; - local b2 = [ new derived1 4 ] ; - local c = [ new derived2 ] ; - local d = [ new derived2 ] ; - local e = [ new derived2a ] ; - - expect_derived2 $(d) ; - expect_derived2 $(e) ; - - # Argument checking is set up to call exit(1) directly on failure, and we - # can not hijack that with try, so we should better not do this test by - # default. We could fix this by having errors look up and invoke the EXIT - # rule instead; EXIT can be hijacked (;-) - if --fail-typecheck in [ modules.peek : ARGV ] - { - try ; - { - expect_derived2 $(a) ; - } - catch - "Expected an instance of derived2 but got" instead - ; - } - - #try ; - #{ - # new bad_subclass ; - #} - #catch - # bad_subclass.bad_subclass failed to call base class constructor - # myclass.__init__ - # ; - - #try ; - #{ - # class bad_subclass ; - #} - #catch bad_subclass has already been declared ; - - assert.result 3 4 5 : $(a).get-x ; - assert.result 4 5 : $(a).get-y ; - assert.result 4 : $(b).get-x ; - assert.result X : $(b).get-y ; - assert.result 4 : $(b).get-z ; - assert.result 1 : $(c).get-x ; - assert.result 2 : $(c).get-y ; - assert.result 4 5 : $(a).f ; - assert.result derived1.g : $(b).f ; - assert.result derived2.g : $(c).f ; - assert.result derived2.g : $(d).f ; - - assert.result 10 : $(b).get-foo ; - - $(a).invariant ; - $(b).invariant2 ; - $(b).invariant3 ; - - # Check that the __class__ attribute is getting properly set. - assert.result myclass : $(a).get-class ; - assert.result derived1 : $(b).get-class ; - assert.result $(a) : $(a).get-instance ; - - $(a).set-x a.x ; - $(b).set-x b.x ; - $(c).set-x c.x ; - $(d).set-x d.x ; - assert.result a.x : $(a).get-x ; - assert.result b.x : $(b).get-x ; - assert.result c.x : $(c).get-x ; - assert.result d.x : $(d).get-x ; - - class derived3 : derived1 derived2 - { - rule __init__ ( ) - { - } - } - - assert.result : bases myclass ; - assert.result myclass : bases derived1 ; - assert.result myclass : bases derived2 ; - assert.result derived1 derived2 : bases derived3 ; - - assert.true is-derived derived1 : myclass ; - assert.true is-derived derived2 : myclass ; - assert.true is-derived derived3 : derived1 ; - assert.true is-derived derived3 : derived2 ; - assert.true is-derived derived3 : derived1 derived2 myclass ; - assert.true is-derived derived3 : myclass ; - - assert.false is-derived myclass : derived1 ; - - assert.true is-instance $(a) ; - assert.false is-instance bar ; - - assert.true is-a $(a) : myclass ; - assert.true is-a $(c) : derived2 ; - assert.true is-a $(d) : myclass ; - assert.false is-a literal : myclass ; -}
