• Drew's avatar
    Implement a substition engine for variable expansion · edafd8e4
    Drew authored
    For many reasons it is desireable to support custom variable expansion
    inside an atpkg file.  This commit does that.
    This feature is "opt-in", meaning an individual tool's field must opt in
    to varaible expansion.  This is because:
    * Variable substition is not appropriate for all fields and tools
    * The particular expansion I'm PRing here requires a complete parse in
      order to be well-defined.
    Here is the syntax:
    * `${VARIABLE}` means to substitite for the value `VARIABLE`
    * We require two tokens `${` to begin a substition.  This is because `$`
      alone is already in use, and we don't want to immediately break
      compatibility (and CI, etc.)  We reserve the right to deprecate
      unescaped `$` in a future release.
    * We support escape syntax `\${VARIABLE}`
    * We also support escape syntax `$?{VARIABLE}` (where `?` is a non-`{`
      character).  We reserve the right to deprecate unescaped `$` in a
      future release.
    We also implement the first expansion `${collect_sources:taskname}`.
    This expands to the "collected sources" of the specified task name,
    using the same definition as `atllbuild`.
    The intent here is to allow the creation of arbitrary tasks that accept
    source files as arguments.  `xcode-emit` is an obvious candidate, and
    would allow it to break its dependence on atpkg, which it only uses for
    this single feature.
    There are other obvious programs that we might want to call with "all
    sources" (e.g. preprocessors, etc.) and they may not want to take a
    dependency on atpkg either.
Substitutions.swift 3.08 KB