github.com/tiagovtristao/plz@v13.4.0+incompatible/src/parse/rules/builtins.build_defs (about)

     1  # Contains declarations of built-in functions & objects
     2  
     3  
     4  # Do not change the order of arguments to this function unless you feel like
     5  # updating all of targets.go to match it.
     6  def build_rule(name:str, cmd:str|dict='', test_cmd:str|dict='', srcs:list|dict=None, data:list=None, outs:list|dict=None,
     7                 deps:list=None, exported_deps:list=None, secrets:list=None, tools:list|dict=None, labels:list=None,
     8                 visibility:list=CONFIG.DEFAULT_VISIBILITY, hashes:list=None, binary:bool=False, test:bool=False,
     9                 test_only:bool=CONFIG.DEFAULT_TESTONLY, building_description:str=None, needs_transitive_deps:bool=False,
    10                 output_is_complete:bool=False, container:bool|dict=False, sandbox:bool=CONFIG.BUILD_SANDBOX,
    11                 test_sandbox:bool=CONFIG.TEST_SANDBOX, no_test_output:bool=False, flaky:bool|int=0, build_timeout:int=0,
    12                 test_timeout:int=0, pre_build:function=None, post_build:function=None, requires:list=None, provides:dict=None,
    13                 licences:list=CONFIG.DEFAULT_LICENCES, test_outputs:list=None, system_srcs:list=None, stamp:bool=False,
    14                 tag:str='', optional_outs:list=None, progress:bool=False, _urls:list=None):
    15      pass
    16  
    17  
    18  def len(obj) -> int:
    19      pass
    20  def enumerate(seq:list):
    21      pass
    22  def zip(args):
    23      pass
    24  
    25  def join(self:str, seq:list) -> str:
    26      pass
    27  def split(self:str, on:str=' ') -> list:
    28      pass
    29  def replace(self:str, old:str, new:str):
    30      pass
    31  def partition(self:str, sep:str) -> list:
    32      pass
    33  def rpartition(self:str, sep:str) -> list:
    34      pass
    35  def startswith(self:str, s:str) -> bool:
    36      pass
    37  def endswith(self:str, s:str) -> bool:
    38      pass
    39  def format(self:str) -> str:
    40      pass
    41  def lstrip(self:str, cutset:str=' \n') -> str:
    42      pass
    43  def rstrip(self:str, cutset:str=' \n') -> str:
    44      pass
    45  def strip(self:str, cutset:str=' \n') -> str:
    46      pass
    47  def find(self:str, needle:str) -> int:
    48      pass
    49  def rfind(self:str, needle:str) -> int:
    50      pass
    51  def count(self:str, needle:str) -> int:
    52      pass
    53  def upper(self:str) -> str:
    54      pass
    55  def lower(self:str) -> str:
    56      pass
    57  
    58  def fail(msg:str):
    59      pass
    60  
    61  def subinclude(target:str, hash:str=None):
    62      pass
    63  def load(target:str, names:str=None):
    64      pass
    65  def subrepo(name:str, dep:str='', path:str=None, config:str=None, bazel_compat:bool=False):
    66      pass
    67  
    68  
    69  def isinstance(obj, types:function|list) -> bool:
    70      pass
    71  
    72  
    73  def range(start:int, stop:int=None, step:int=1) -> str:
    74      pass
    75  def any(seq:list) -> bool:
    76      for x in seq:
    77          if x:
    78              return True
    79      return False
    80  def all(seq:list) -> bool:
    81      for x in seq:
    82          if not x:
    83              return False
    84      return True
    85  
    86  
    87  def bool(b) -> bool:
    88      pass
    89  def int(s:str) -> int:
    90      pass
    91  def str(s) -> str:
    92      pass
    93  def list(l):
    94      raise 'list is not callable'
    95  def dict(d):
    96      raise 'dict is not callable'
    97  
    98  
    99  def glob(include:list, exclude:list&excludes=[], hidden:bool=False) -> list:
   100      pass
   101  
   102  
   103  def package():
   104      pass
   105  
   106  
   107  def sorted(seq:list) -> list:
   108      pass
   109  
   110  
   111  def get(self:dict, key:str, default=None):
   112      pass
   113  def setdefault(self:config, key:str, default=None) -> config:
   114      if key in self:
   115          return self[key]
   116      self[key] = default
   117      return default
   118  def config_get(self:config, key:str, default=None) -> config:
   119      pass
   120  
   121  
   122  def get_base_path() -> str:
   123      pass
   124  def package_name() -> str:
   125      pass
   126  
   127  def canonicalise(label:str) -> str:
   128      """Converts the given build label to its full form.
   129  
   130      For example:
   131        //package:target -> //package:target
   132        //package -> //package:package
   133        :target -> //current_package:target
   134      """
   135      pass
   136  
   137  
   138  def keys(self:dict) -> list:
   139      pass
   140  def values(self:dict) -> list:
   141      pass
   142  def items(self:dict) -> list:
   143      pass
   144  def copy(self:dict) -> dict:
   145      pass
   146  
   147  
   148  def git_branch(short:bool=True) -> str:
   149      raise 'Disabled in config'
   150  def git_commit() -> str:
   151      raise 'Disabled in config'
   152  def git_show(fmt:str) -> str:
   153      raise 'Disabled in config'
   154  def git_state(clean_label:str="clean", dirty_label:str="dirty") -> str:
   155      raise 'Disabled in config'
   156  
   157  def debug(args):
   158      pass
   159  def info(args):
   160      pass
   161  def notice(args):
   162      pass
   163  def warning(args):
   164      pass
   165  def error(args):
   166      pass
   167  def fatal(args):
   168      pass
   169  
   170  log = {
   171      'debug': debug,
   172      'info': info,
   173      'notice': notice,
   174      'warning': warning,
   175      'error': error,
   176      'fatal': fatal,
   177  }
   178  
   179  
   180  def join_path(paths:str) -> str:
   181      pass  # Has to be implemented natively since it's varargs.
   182  
   183  
   184  def split_path(p:str) -> list:
   185      before, _, after = p.rpartition('/')
   186      return before, after
   187  
   188  
   189  def splitext(p:str) -> list:
   190      before, dot, after = p.rpartition('.')
   191      return (before, dot + after) if before else (after, '')
   192  
   193  
   194  def basename(p:str) -> str:
   195      """Returns the final component of a pathname"""
   196      _, _, after = p.rpartition('/')
   197      return after
   198  
   199  
   200  def dirname(p:str) -> str:
   201      """Returns the directory component of a pathname"""
   202      before, _, after = p.rpartition('/')
   203      return before
   204  
   205  
   206  # Exception types.
   207  # There is no actual Exception, but str() is similar enough here.
   208  ParseError = str
   209  ConfigError = str
   210  ValueError = str
   211  
   212  
   213  # Post-build callback functions.
   214  def get_labels(name:str, prefix:str) -> list:
   215      pass
   216  def has_label(name:str, prefix:str) -> bool:
   217      return len(get_labels(name, prefix)) > 0
   218  def add_dep(target:str, dep:str, exported:bool=False):
   219      pass
   220  def add_exported_dep(target:str, dep:str):
   221      add_dep(target, dep, True)
   222  def add_out(target:str, name:str, out:str=''):
   223      pass
   224  def add_licence(target:str, licence:str):
   225      pass
   226  def get_command(target:str, config:str='') -> str:
   227      pass
   228  def set_command(target:str, config:str, command:str=''):
   229      pass
   230  
   231  
   232  # N.B. This should really be limited so it's only visible when Bazel compat is on,
   233  #      but we currently don't alter the builtins for that scenario.
   234  def licenses(licences):
   235      """Sets the default licences for the package."""
   236      assert CONFIG.BAZEL_COMPATIBILITY, 'licenses() can only be called in Bazel compat mode'
   237      package(default_licences = licences)