Skip to content

Commit 422f0a5

Browse files
committed
added subproject for profiling compilation
1 parent fa36d90 commit 422f0a5

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

build.sbt

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ val commonSettings = Seq(
5151
"-Xfatal-warnings",
5252
s"-Xlint:-missing-interpolator,-adapted-args,${if (scalaBinaryVersion.value == "2.12") "-unused," else ""}_",
5353
),
54+
scalacOptions ++= {
55+
if (scalaBinaryVersion.value == "2.12") Seq(
56+
"-Ycache-plugin-class-loader:last-modified",
57+
"-Ycache-macro-class-loader:last-modified",
58+
) else Seq.empty
59+
},
5460
// some Java 8 related tests use Java interface static methods, Scala 2.11.12 requires JDK8 target for that
55-
scalacOptions in Test ++= (if (scalaBinaryVersion.value == "2.11") Seq("-target:jvm-1.8") else Seq()),
61+
scalacOptions in Test ++= (if (scalaBinaryVersion.value == "2.11") Seq("-target:jvm-1.8") else Nil),
5662
apiURL := Some(url("http://avsystem.github.io/scala-commons/api")),
5763
autoAPIMappings := true,
5864

@@ -131,19 +137,20 @@ val CompileAndTest = "compile->compile;test->test"
131137
lazy val commons = project.in(file("."))
132138
.enablePlugins(ScalaUnidocPlugin)
133139
.aggregate(
140+
`commons-analyzer`,
141+
`commons-macros`,
134142
`commons-annotations`,
135143
`commons-annotations-js`,
136-
`commons-macros`,
137144
`commons-core`,
138145
`commons-core-js`,
139-
`commons-analyzer`,
140146
`commons-jetty`,
141-
`commons-benchmark`,
142147
`commons-mongo`,
143148
`commons-spring`,
144149
`commons-redis`,
145150
`commons-akka`,
146151
`commons-kafka`,
152+
`commons-benchmark`,
153+
`commons-benchmark-js`,
147154
)
148155
.settings(
149156
commonSettings,
@@ -159,6 +166,7 @@ lazy val commons = project.in(file("."))
159166
`commons-core-js`,
160167
`commons-benchmark`,
161168
`commons-benchmark-js`,
169+
`commons-comprof`,
162170
),
163171
)
164172

@@ -344,3 +352,30 @@ lazy val `commons-akka` = project
344352
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test,
345353
),
346354
)
355+
356+
lazy val `commons-comprof` = project
357+
.dependsOn(`commons-core`)
358+
.settings(
359+
jvmCommonSettings,
360+
noPublishSettings,
361+
ideSkipProject := true,
362+
addCompilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "1.0.0"),
363+
scalacOptions ++= Seq(
364+
s"-P:scalac-profiling:sourceroot:${baseDirectory.value}",
365+
"-P:scalac-profiling:generate-macro-flamegraph",
366+
"-P:scalac-profiling:no-profiledb",
367+
"-Ystatistics",
368+
),
369+
sourceGenerators in Compile += Def.task {
370+
val originalSrc = (sourceDirectory in `commons-core`).value /
371+
"main/scala/com/avsystem/commons/rest/openapi/OpenApi.scala"
372+
val originalContent = IO.read(originalSrc)
373+
(0 until 10).map { i =>
374+
val pkg = f"oa$i%02d"
375+
val newContent = originalContent.replaceAllLiterally("package rest.openapi", s"package rest.$pkg")
376+
val newFile = (sourceManaged in Compile).value / pkg / "OpenApi.scala"
377+
IO.write(newFile, newContent)
378+
newFile
379+
}
380+
}.taskValue
381+
)

commons-macros/src/main/scala/com/avsystem/commons/macros/MacroCommons.scala

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -967,22 +967,17 @@ trait MacroCommons { bundle =>
967967
Some(ApplyUnapply(constructor, NoSymbol, paramsWithDefaults(constructor.typeSignatureIn(dtpe))))
968968
} else {
969969
val applicableResults = applyUnapplyPairs.flatMap {
970+
case (apply, unapply) if caseClass && apply.isSynthetic && unapply.isSynthetic =>
971+
val constructor = primaryConstructorOf(dtpe)
972+
Some(ApplyUnapply(constructor, unapply, paramsWithDefaults(constructor.typeSignatureIn(dtpe))))
970973
case (apply, unapply) if typeParamsMatch(apply, unapply) =>
971-
val constructor =
972-
if (caseClass && apply.isSynthetic && unapply.isSynthetic)
973-
primaryConstructorOf(dtpe)
974-
else NoSymbol
975-
976974
val applySig =
977-
if (constructor != NoSymbol) constructor.typeSignatureIn(dtpe)
978-
else setTypeArgs(apply.typeSignatureIn(typedCompanion.tpe))
975+
setTypeArgs(apply.typeSignatureIn(typedCompanion.tpe))
979976
val unapplySig =
980977
setTypeArgs(unapply.typeSignatureIn(typedCompanion.tpe))
981-
982978
if (matchingApplyUnapply(dtpe, applySig, unapplySig))
983-
Some(ApplyUnapply(constructor orElse apply, unapply, paramsWithDefaults(applySig)))
979+
Some(ApplyUnapply(apply, unapply, paramsWithDefaults(applySig)))
984980
else None
985-
986981
case _ => None
987982
}
988983

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1")
1515
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
1616
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M7")
1717
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4")
18+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.0.0")

0 commit comments

Comments
 (0)