📄 project.jam
字号:
rule mark-as-user ( module-name ){ if USER_MODULE in [ RULENAMES ] { USER_MODULE $(module-name) ; }}rule load-aux ( module-name : file ){ mark-as-user $(module-name) ; module $(module-name) { include $(2) ; local rules = [ RULENAMES $(1) ] ; IMPORT $(1) : $(rules) : $(1) : $(1).$(rules) ; }}.global-build-dir = [ MATCH --build-dir=(.*) : [ modules.peek : ARGV ] ] ;if $(.global-build-dir){ # If the option is specified several times, take the last value. .global-build-dir = [ path.make $(.global-build-dir[-1]) ] ;}# Initialize the module for a project.#rule initialize ( module-name # The name of the project module. : location ? # The location (directory) of the project to initialize. If # not specified, a standalone project will be initialized. : basename ? ){ if --debug-loading in [ modules.peek : ARGV ] { ECHO "Initializing project '$(module-name)'" ; } # TODO: need to consider if standalone projects can do anything but define # prebuilt targets. If so, we need to give it a more sensible "location", so # that source paths are correct. location ?= "" ; # Create the module for the Jamfile first. module $(module-name) { } $(module-name).attributes = [ new project-attributes $(location) $(module-name) ] ; local attributes = $($(module-name).attributes) ; if $(location) { $(attributes).set source-location : [ path.make $(location) ] : exact ; } else { $(attributes).set source-location : "" : exact ; } $(attributes).set requirements : [ property-set.empty ] : exact ; $(attributes).set usage-requirements : [ property-set.empty ] : exact ; # Import rules common to all project modules from project-rules module, # defined at the end of this file. modules.clone-rules project-rules $(module-name) ; local jamroot ; local parent-module ; if $(module-name) = test-config { # No parent. } else if $(module-name) = site-config { parent-module = test-config ; } else if $(module-name) = user-config { parent-module = site-config ; } else { # We search for parent/project-root only if Jamfile was specified, i.e. # if the project is not standalone. if $(location) && ! [ MATCH ($(JAMROOT)) : $(basename) ] { parent-module = [ load-parent $(location) ] ; } else { # It's either jamroot or standalone project. If it's jamroot, # inherit from user-config. if $(location) { parent-module = user-config ; jamroot = true ; } } } if $(parent-module) { inherit-attributes $(module-name) : $(parent-module) ; $(attributes).set parent-module : $(parent-module) : exact ; } if $(jamroot) { $(attributes).set project-root : $(location) : exact ; } local parent ; if $(parent-module) { parent = [ target $(parent-module) ] ; } if ! $(.target.$(module-name)) { .target.$(module-name) = [ new project-target $(module-name) : $(module-name) $(parent) : [ attribute $(module-name) requirements ] ] ; if --debug-loading in [ modules.peek : ARGV ] { ECHO "Assigned project target" $(.target.$(module-name)) "to '$(module-name)'" ; } } .current-project = [ target $(module-name) ] ;}# Make 'project-module' inherit attributes of project root and parent module.#rule inherit-attributes ( project-module : parent-module ){ local attributes = $($(project-module).attributes) ; local pattributes = [ attributes $(parent-module) ] ; # Parent module might be locationless configuration module. if [ modules.binding $(parent-module) ] { $(attributes).set parent : [ path.parent [ path.make [ modules.binding $(parent-module) ] ] ] ; } local v = [ $(pattributes).get project-root ] ; $(attributes).set project-root : $(v) : exact ; $(attributes).set default-build : [ $(pattributes).get default-build ] ; $(attributes).set requirements : [ $(pattributes).get requirements ] : exact ; $(attributes).set usage-requirements : [ $(pattributes).get usage-requirements ] : exact ; local parent-build-dir = [ $(pattributes).get build-dir ] ; if $(parent-build-dir) { # Have to compute relative path from parent dir to our dir. Convert both # paths to absolute, since we cannot find relative path from ".." to # ".". local location = [ attribute $(project-module) location ] ; local parent-location = [ attribute $(parent-module) location ] ; local pwd = [ path.pwd ] ; local parent-dir = [ path.root $(parent-location) $(pwd) ] ; local our-dir = [ path.root $(location) $(pwd) ] ; $(attributes).set build-dir : [ path.join $(parent-build-dir) [ path.relative $(our-dir) $(parent-dir) ] ] : exact ; }}# Associate the given id with the given project module.#rule register-id ( id : module ){ $(id).jamfile-module = $(module) ;}# Class keeping all the attributes of a project.## The standard attributes are "id", "location", "project-root", "parent"# "requirements", "default-build", "source-location" and "projects-to-build".#class project-attributes{ import property ; import property-set ; import errors ; import path ; import print ; import sequence ; import project ; rule __init__ ( location project-module ) { self.location = $(location) ; self.project-module = $(project-module) ; } # Set the named attribute from the specification given by the user. The # value actually set may be different. # rule set ( attribute : specification * : exact ? # Sets value from 'specification' without any processing. ) { if $(exact) { self.$(attribute) = $(specification) ; } else if $(attribute) = "requirements" { local result = [ property-set.refine-from-user-input $(self.requirements) : $(specification) : $(self.project-module) : $(self.location) ] ; if $(result[1]) = "@error" { errors.error Requirements for project at '$(self.location)' conflict with parent's. : Explanation: $(result[2-]) ; } else { self.requirements = $(result) ; } } else if $(attribute) = "usage-requirements" { local unconditional ; for local p in $(specification) { local split = [ property.split-conditional $(p) ] ; split ?= nothing $(p) ; unconditional += $(split[2]) ; } local non-free = [ property.remove free : $(unconditional) ] ; if $(non-free) { errors.error usage-requirements $(specification) have non-free properties $(non-free) ; } local t = [ property.translate-paths $(specification) : $(self.location) ] ; if $(self.usage-requirements) { self.usage-requirements = [ property-set.create [ $(self.usage-requirements).raw ] $(t) ] ; } else { self.usage-requirements = [ property-set.create $(t) ] ; } } else if $(attribute) = "default-build" { self.default-build = [ property.make $(specification) ] ; } else if $(attribute) = "source-location" { self.source-location = ; for local src-path in $(specification) { self.source-location += [ path.root [ path.make $(src-path) ] $(self.location) ] ; } } else if $(attribute) = "build-dir" { self.build-dir = [ path.root [ path.make $(specification) ] $(self.location) ] ; } else if $(attribute) = "id" { id = [ path.root $(specification) / ] ; project.register-id $(id) : $(self.project-module) ; self.id = $(id) ; } else if ! $(attribute) in "default-build" "location" "parent" "projects-to-build" "project-root" "source-location" { errors.error Invalid project attribute '$(attribute)' specified for project at '$(self.location)' ; } else { self.$(attribute) = $(specification) ; } } # Returns the value of the given attribute. # rule get ( attribute ) { return $(self.$(attribute)) ; } # Prints the project attributes. # rule print ( ) { local id = $(self.id) ; id ?= (none) ; local parent = $(self.parent) ; parent ?= (none) ; print.section "'"$(id)"'" ; print.list-start ; print.list-item "Parent project:" $(parent) ; print.list-item "Requirements:" [ $(self.requirements).raw ] ; print.list-item "Default build:" $(self.default-build) ; print.list-item "Source location:" $(self.source-location) ; print.list-item "Projects to build:" [ sequence.insertion-sort $(self.projects-to-build) ] ; print.list-end ; }}# Returns the project which is currently being loaded.#rule current ( ){ return $(.current-project) ;}# Temporarily changes the current project to 'project'. Should be followed by# 'pop-current'.#rule push-current ( project ){ .saved-current-project += $(.current-project) ; .current-project = $(project) ;}rule pop-current ( )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -