Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove java.io in FileUtils #2256

Merged
merged 3 commits into from
Jun 7, 2021

Conversation

sinofp
Copy link
Contributor

@sinofp sinofp commented Jun 4, 2021

  1. Add getPath to turn a String to os.Path.
  2. Replace java.io.File methods with os-lib functions.

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you update the FIRRTL spec to include every new feature/behavior?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • code refactoring
  • new feature/API
  • deprecation

API Impact

Backend Code Generation Impact

Desired Merge Strategy

  • Rebase: You will rebase the PR onto master and it will be merged with a merge commit.

Release Notes

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (1.2.x, 1.3.0, 1.4.0) ?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you mark as Please Merge?

Copy link
Member

@sequencer sequencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGMT, just need deprecation annotations.

src/main/scala/firrtl/FileUtils.scala Outdated Show resolved Hide resolved
src/main/scala/firrtl/FileUtils.scala Outdated Show resolved Hide resolved
src/main/scala/firrtl/FileUtils.scala Outdated Show resolved Hide resolved
src/main/scala/firrtl/FileUtils.scala Outdated Show resolved Hide resolved
@sequencer
Copy link
Member

LGTM, this is the first step to remove complex Java.IO.

@sequencer sequencer merged commit eec65c8 into chipsalliance:master Jun 7, 2021
@sequencer
Copy link
Member

See you in your next PR @sinofp 👍

Comment on lines +188 to +195
/** Get os.Path from String
* @param pathName an absolute or relative path string
*/
def getPath(pathName: String): os.Path = os.FilePath(pathName) match {
case path: os.Path => path
case sub: os.SubPath => os.pwd / sub
case rel: os.RelPath => os.pwd / rel
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit late here, but it seems this is enshrining use of absolute paths which I understand is convenient but is actually generally not a great thing to do since it makes runs not relocatable (eg. if I emit files with absolute paths in them, then the one in my workspace is different than the one in your work space).

To be fair, I'm not sure if the existing APIs are already very "absolutely path centric" but it's generally something we should move away from rather than encouraging.

@mwachs5
Copy link
Contributor

mwachs5 commented Sep 1, 2021

@sinofp , @sequencer what do I need to upgrade to get this os. variable? Bumping from 3.4 branch to master I am getting a bunch of FileUtils.scala: not found: value os... is this assuming a certain Scala version? I'm on 2.12.13

@sequencer
Copy link
Member

@sinofp , @sequencer what do I need to upgrade to get this os. variable? Bumping from 3.4 branch to master I am getting a bunch of FileUtils.scala: not found: value os... is this assuming a certain Scala version? I'm on 2.12.13

Form these lines:

"com.lihaoyi" %% "os-lib" % "0.7.8",

ivy"com.lihaoyi::os-lib:0.7.8",

I think os-lib is available in the latest SNAPSHOT(master), can you DM me your build flow?

@mwachs5
Copy link
Contributor

mwachs5 commented Sep 1, 2021

I got past that by adding the com:lihayi library to my build, thanks! On to the next thing...

@sequencer
Copy link
Member

I got past that by adding the com:lihayi library to my build, thanks! On to the next thing...

haha, I guess it blames to ivydependencies.json ;p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants