XiangShan icon indicating copy to clipboard operation
XiangShan copied to clipboard

Format frontend

Open Yan-Muzi opened this issue 1 year ago • 8 comments

Format frontend according to the scalafmt file drafted in #3061.

Yan-Muzi avatar Aug 13 '24 06:08 Yan-Muzi

Wow 👀

eastonman avatar Aug 13 '24 06:08 eastonman

Merging #3061 and this PR into the master together will allow the CI format check to pass, which is kind of a relief as it eliminates the red cross.

Yan-Muzi avatar Aug 13 '24 07:08 Yan-Muzi

I don't think it's a good idea to limit includePaths in .scalafmt.conf, it's a project level configuration file and the IDE uses it too.

If you want CI to check only the files in the frontend directory, you can perform a replacement in CI.

This is not a good idea, because in this way make reformat would affect all the files.

Yan-Muzi avatar Aug 13 '24 07:08 Yan-Muzi

I don't think it's a good idea to limit includePaths in .scalafmt.conf, it's a project level configuration file and the IDE uses it too. If you want CI to check only the files in the frontend directory, you can perform a replacement in CI.

This is not a good idea, because in this way make reformat would affect all the files.

That's what it should do, same with make check-format, project level configuration should then be applied to the whole project, if you need make format to be restricted to some files as well, you should add some Makefile targets, e.g.:

reformat.%:
	sed -i 's!project\.includePaths.*!project.includePaths = ["glob:**/src/main/scala/xiangshan/$(subst .,/,$*)/**.scala"]!g' .scalafmt.conf
	mill xiangshan.reformat
	sed -i 's!project\.includePaths.*!project.includePaths = ["glob:**/src/main/scala/xiangshan/**.scala"]!g' .scalafmt.conf

Then we can use make reformat.frontend, make reformat.backend etc. to do it.

Idk if there is a better way than sed, but the general idea is this.

ngc7331 avatar Aug 13 '24 07:08 ngc7331

I don't think it's a good idea to limit includePaths in .scalafmt.conf, it's a project level configuration file and the IDE uses it too. If you want CI to check only the files in the frontend directory, you can perform a replacement in CI.

This is not a good idea, because in this way make reformat would affect all the files.

That's what it should do, same with make check-format, project level configuration should then be applied to the whole project, if you need make format to be restricted to some files as well, you should add some Makefile targets, e.g.:

reformat.%:
	sed -i 's!project\.includePaths.*!project.includePaths = ["glob:**/src/main/scala/xiangshan/$(subst .,/,$*)/**.scala"]!g' .scalafmt.conf
	mill xiangshan.reformat
	sed -i 's!project\.includePaths.*!project.includePaths = ["glob:**/src/main/scala/xiangshan/**.scala"]!g' .scalafmt.conf

Then we can use make reformat.frontend, make reformat.backend etc. to do it.

Idk if there is a better way than sed, but the general idea is this.

As a matter of fact, scalafmt is indeed now the project level configuration which is only applied to frontend. It would be strange if there is a project level configuration which most of the project files do not follow.

Yan-Muzi avatar Aug 13 '24 08:08 Yan-Muzi

[Generated by IPC robot] commit: 93bdebf8dc223b95ba07bfb6f95b07055d7d3858

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
93bdebf 1.831 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977

master branch:

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
afdeb38
88895b1 1.829 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
5f7c1a7 1.833 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
fb22914 1.829 0.458 1.992 1.181 2.835 2.483 2.365 0.957 1.405 1.424 3.361 2.510 2.425 2.977
9d9be65 1.798 0.457 1.987 1.199 2.838 2.483 2.361 0.957 1.409 1.379 3.353 2.494 2.422 2.972
ce34d21 1.823 0.457 1.987 1.199 2.838 2.483 2.358 0.957 1.409 1.379 3.353 2.494 2.422 2.972
c0beb49 1.823 0.457 1.987 1.199 2.838 2.483 2.358 0.957 1.409 1.379 3.353 2.494 2.422 2.972
ecb61d9 1.814 0.457 1.980 1.199 2.836 2.478 2.356 0.953 1.410 1.349 3.356 2.496 2.423 2.988
d286dd6 1.814 0.457 1.980 1.199 2.836 2.478 2.356 0.953 1.410 1.349 3.356 2.496 2.423 2.988
505c893 1.814 0.457 1.980 1.199 2.836 2.478 2.356 0.953 1.410 1.349 3.356 2.496 2.423 2.988

XiangShanRobot avatar Aug 13 '24 13:08 XiangShanRobot

[Generated by IPC robot] commit: 99b286c4c9187d60fc95730dbee8cb1a1d375c2a

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
99b286c 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977

master branch:

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
400391a 1.831 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
26f0fb0 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
f80535c 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
d9ed5e2 1.832 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
afdeb38 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.409 1.424 3.361 2.510 2.425 2.977
88895b1 1.829 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
5f7c1a7 1.833 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
fb22914 1.829 0.458 1.992 1.181 2.835 2.483 2.365 0.957 1.405 1.424 3.361 2.510 2.425 2.977
9d9be65 1.798 0.457 1.987 1.199 2.838 2.483 2.361 0.957 1.409 1.379 3.353 2.494 2.422 2.972
ce34d21 1.823 0.457 1.987 1.199 2.838 2.483 2.358 0.957 1.409 1.379 3.353 2.494 2.422 2.972

XiangShanRobot avatar Aug 14 '24 22:08 XiangShanRobot

[Generated by IPC robot] commit: bbfc833ec6998c84ba8f44617b52618ee3a3b1cb

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
bbfc833 1.833 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977

master branch:

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
11f2d1c 1.833 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
c7ffa89 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
689f6b8 0.458 1.992 1.181 2.382 0.957 1.405 3.361 2.510 2.977
400391a 1.831 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
26f0fb0 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
f80535c 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
d9ed5e2 1.832 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977
afdeb38 1.830 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.409 1.424 3.361 2.510 2.425 2.977
88895b1 1.829 0.458 1.992 1.181 2.835 2.483 2.382 0.957 1.405 1.424 3.361 2.510 2.425 2.977

XiangShanRobot avatar Aug 15 '24 20:08 XiangShanRobot

[Generated by IPC robot] commit: c1b4541d505426a5be315524ce9e60df6d5d75fc

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
c1b4541 1.917 0.450 2.699 1.195 2.823 2.460 2.395 0.913 1.373 1.611 3.418 2.742 2.420 3.263

master branch:

commit astar copy_and_run coremark gcc gromacs lbm linux mcf microbench milc namd povray wrf xalancbmk
b9dc808 2.699 1.191 2.460 0.913 1.373 1.611 3.418 3.263
ad74c6c 1.927 0.450 2.699 1.191 2.823 2.460 2.395 0.913 1.373 1.611 3.418 2.742 2.420 3.263
2d99134 1.928 0.450 2.699 1.200 2.823 2.460 2.395 0.913 1.373 1.611 3.418 2.742 2.420 3.263
0607615 1.928 0.450 2.699 1.200 2.823 2.460 2.395 0.913 1.373 1.611 3.418 2.742 2.420 3.263
a38d1ea 1.928 0.450 2.699 1.193 2.823 2.460 2.395 0.913 1.373 1.611 3.418 2.742 2.420 3.263
adf97c9 0.450 2.699 1.190 2.460 2.395 0.913 1.373 1.611 3.418 2.742 3.263
3e1dbb1 1.917 0.450 2.699 1.190 2.823 2.460 2.395 0.913 1.373 1.611 3.418 2.742 2.420 3.263
2196d1c 1.928 0.450 2.699 1.203 2.823 2.460 2.395 0.913 1.373 1.611 3.418 2.742 2.420 3.263
5c06072 1.926 0.451 2.705 1.192 2.824 2.464 2.401 0.920 1.394 1.616 3.413 2.734 2.417 3.275
7d53086 1.926 0.451 2.705 1.198 2.824 2.464 2.401 0.920 1.394 1.616 3.413 2.734 2.417 3.275

XiangShanRobot avatar Oct 25 '24 14:10 XiangShanRobot

Q: Is there any Jia Tan behaviour here?

eastonman avatar Oct 25 '24 14:10 eastonman

Q: Is there any Jia Tan behaviour here?

I've only used make reformat, so I guess we all rely on scalafmt is safe.🙏

Yan-Muzi avatar Oct 25 '24 14:10 Yan-Muzi

Q: Is there any Jia Tan behaviour here?

I've only used make reformat, so I guess we all rely on scalafmt is safe.🙏

Haha, just joking.

eastonman avatar Oct 25 '24 14:10 eastonman