-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix color emission to check for interactive terminal #3334
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's how I tested this (as a record for posterity). First show that it doesn't work on current main, with file //> using repository "sonatype-s01:snapshots"
//> using scala "2.13.10"
//> using lib "org.chipsalliance::chisel::6.0.0-M1+27-6e8eee88-SNAPSHOT"
//> using plugin "org.chipsalliance:::chisel-plugin::6.0.0-M1+27-6e8eee88-SNAPSHOT"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
import chisel3._
import circt.stage.ChiselStage
class Foo extends Module {
val in = IO(Input(Vec(4, UInt(8.W))))
val idx = IO(Input(UInt(3.W)))
val out = IO(Output(UInt(8.W)))
out := in(idx)
}
object Main extends App {
println(ChiselStage.emitCHIRRTL(new Foo))
} # Should see color
scala-cli main.scala
# Will see the color codes in the text file, this is bad
scala-cli main.scala > main.txt Now publish local ( //> using repository "sonatype-s01:snapshots"
//> using scala "2.13.10"
//> using lib "org.chipsalliance::chisel::6.0.0-M1+27-a832e2b0-SNAPSHOT"
//> using plugin "org.chipsalliance:::chisel-plugin::6.0.0-M1+27-a832e2b0-SNAPSHOT"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
import chisel3._
import circt.stage.ChiselStage
class Foo extends Module {
val in = IO(Input(Vec(4, UInt(8.W))))
val idx = IO(Input(UInt(3.W)))
val out = IO(Output(UInt(8.W)))
out := in(idx)
}
object Main extends App {
println(ChiselStage.emitCHIRRTL(new Foo))
} # Should see color
scala-cli fixed.scala
# Will NOT see color in the text file
scala-cli fixed.scala > fixed.txt
# Will NOT see color with no stdin (see release notes)
scala-cli fixed.scala </dev/null
# Can also test the environment variables
CHISEL_USE_COLOR=false scala-cli fixed.scala |
chick
approved these changes
Jun 7, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool. Looks good to me.
mergify bot
pushed a commit
that referenced
this pull request
Jun 7, 2023
(cherry picked from commit 308eb6a)
mergify bot
pushed a commit
that referenced
this pull request
Jun 7, 2023
(cherry picked from commit 308eb6a)
This was referenced Jun 7, 2023
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is really hard to test. See Release Notes below for user-facing API and limitations.
I would like to test this but it can't be done in ScalaTest nor really even with SBT, you need to publishLocal and then use scala-cli and then some way of processing the output for correctness.
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
CHISEL_USE_COLOR
. Set totrue
to force Chisel to use color andfalse
to disable it.TERM
to be set to something other thandumb
.Reviewer Checklist (only modified by reviewer)
3.5.x
or3.6.x
depending on impact, API modification or big change:5.0.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.