aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/options/package.scala
blob: 7e82603921f50e3b6136f625dd4d3ec4e17f9f6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-License-Identifier: Apache-2.0

package firrtl

package object options {

  implicit object StageOptionsView extends OptionsView[StageOptions] {
    def view(options: AnnotationSeq): StageOptions = options.collect { case a: StageOption => a }
      .foldLeft(new StageOptions())((c, x) =>
        x match {
          case TargetDirAnnotation(a) => c.copy(targetDir = a)
          /* Insert input files at the head of the Seq for speed and because order shouldn't matter */
          case InputAnnotationFileAnnotation(a)  => c.copy(annotationFilesIn = a +: c.annotationFilesIn)
          case OutputAnnotationFileAnnotation(a) => c.copy(annotationFileOut = Some(a))
          /* Do NOT reorder program args. The order may matter. */
          case ProgramArgsAnnotation(a) => c.copy(programArgs = c.programArgs :+ a)
          case WriteDeletedAnnotation   => c.copy(writeDeleted = true)
        }
      )
  }

}