def std_file_props(): """Creates list of all standard source file properties.""" return _std_model_part_props() + [ Property("_filename", type=PathType(), default=[], readonly=True, inheritable=False, doc="Source file name."), Property("compile-commands", type=ListType(StringType()), default=[], inheritable=False, doc=""" Command or commands to run to compile this source file, i.e. to generate other file(s) from it. This can be used for generating some files or for compiling custom file types. Two placeholders can be used in the commands, ``%(in)`` and ``%(out)``. They are replaced with the name of the source file and ``outputs`` respectively. Both placeholders are optional. """), Property("compile-message", type=StringType(), default=expr.NullExpr(), inheritable=False, doc=""" Message shown to the user when running the command. The same placeholder as in *compiler-commands* can be used. """), Property("outputs", type=ListType(PathType()), default=lambda t: None if t["compile-commands"] else expr.NullExpr(), inheritable=False, doc=""" Output files created by the build step that compiles this file Only applicable if *compile-commands* is set. """), Property("dependencies", type=ListType(PathType()), default=[], inheritable=False, doc=""" List of additional files that the source file or or its commands depend on. List any files that must be created before the source file is compiled, such as generated header files. If *compile-commands* is set, list any other files referenced by the commands. """), ]
def std_setting_props(): """Creates list of all standard Setting properties.""" return _std_model_part_props() + [ Property("help", type=StringType(), default=expr.NullExpr(), inheritable=False, doc=""" Documentation for the setting. This will be used in the generated output to explain the setting to the user, if supported by the toolset. """), Property("default", type=TheAnyType, default=expr.NullExpr(), inheritable=False, doc="Default value of the setting, if any."), ]
def _normalize_impl(self, e): # Normalize the list: expand conditional expressions and references so # that the value is ListExpr with one item per one individual item in # the list. This makes implementing validate() straightforward. items = [] for cond, item in expr.enum_possible_values(e): norm = self.item_type.normalize(item) if cond is not None: norm = expr.IfExpr(cond, yes=norm, no=expr.NullExpr(pos=norm.pos), pos=norm.pos) items.append(norm) return expr.ListExpr(items, pos=e.pos)
def default_expr(self, for_obj, throw_if_required): """ Returns the value of :attr:`default` expression. Always returns an :class:`bkl.expr.Expr` instance, even if the default is of a different type. :param for_obj: The class:`bkl.model.ModelPart` object to return the default for. If the default value is defined, its expression is evaluated in the context of *for_obj*. :param throw_if_required: If False, returns NullExpr if the property is a required one (doesn't have a default value). If True, throws in that case. """ default = self._make_default_expr(self.default, for_obj) if default is None: if throw_if_required: raise error.UndefinedError( "required property \"%s\" on %s not set" % (self.name, for_obj), pos=for_obj.source_pos) else: return expr.NullExpr() return default