Skip to content

Commit

Permalink
Discover - break overridesRoutes into fixed size chunks (#509)
Browse files Browse the repository at this point in the history
* Discover - break overridesRoutes into fixed size chunks

* Discover - simplify lambda creation

* add LargeProjectTests

* LargeProjectTests: remove Ydelambdafy
  • Loading branch information
kongo2002 authored and lihaoyi committed Dec 15, 2018
1 parent 2935287 commit 9cbcfa9
Show file tree
Hide file tree
Showing 6 changed files with 325 additions and 3 deletions.
293 changes: 293 additions & 0 deletions integration/test/resources/large-project/build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
import mill._, scalalib._

trait TModule extends SbtModule {
def scalaVersion = "2.12.7"
}

object foo extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq(foo.common.one)
}
object three extends TModule {
def moduleDeps = Seq(foo.common.two)
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq(foo.common.one)
}
object two extends TModule {
def moduleDeps = Seq(foo.domain.one)
}
object three extends TModule {
def moduleDeps = Seq(foo.domain.two)
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq(foo.domain.three)
}
object two extends TModule {
def moduleDeps = Seq(foo.server.one)
}
object three extends TModule {
def moduleDeps = Seq(foo.server.two)
}
}
}

object bar extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq(foo.common.three)
}
object two extends TModule {
def moduleDeps = Seq(bar.common.one)
}
object three extends TModule {
def moduleDeps = Seq(bar.common.two)
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq(foo.domain.three)
}
object two extends TModule {
def moduleDeps = Seq(bar.domain.one)
}
object three extends TModule {
def moduleDeps = Seq(bar.domain.two)
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq(foo.server.one)
}
object two extends TModule {
def moduleDeps = Seq(bar.server.one)
}
object three extends TModule {
def moduleDeps = Seq(bar.server.two)
}
}
}

object ham extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq(bar.common.one)
}
object two extends TModule {
def moduleDeps = Seq(bar.common.two)
}
object three extends TModule {
def moduleDeps = Seq(bar.common.three)
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq(bar.domain.three)
}
object two extends TModule {
def moduleDeps = Seq(bar.domain.two, ham.common.three)
}
object three extends TModule {
def moduleDeps = Seq(bar.domain.two)
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
}

object eggs extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
}

object salt extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
}

object pepper extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
}

object oregano extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
}

object rosmarin extends Module {
object common extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object domain extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
object server extends Module {
object one extends TModule {
def moduleDeps = Seq()
}
object two extends TModule {
def moduleDeps = Seq()
}
object three extends TModule {
def moduleDeps = Seq()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package foo.common.one

object Main extends App {
println("large-project")
}
19 changes: 19 additions & 0 deletions integration/test/src/LargeProjectTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package mill.integration

import mill.util.ScriptTestSuite
import utest._

class LargeProjectTests(fork: Boolean)
extends ScriptTestSuite(fork) {
def workspaceSlug: String = "large-project"
def scriptSourcePath: os.Path = os.pwd / 'integration / 'test / 'resources / workspaceSlug

val tests = Tests{
initWorkspace()
'test - {

assert(eval("foo.common.one.compile"))
}

}
}
1 change: 1 addition & 0 deletions integration/test/src/forked/Tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mill.integration.forked
object AcyclicTests extends mill.integration.AcyclicTests(fork = true)
object AmmoniteTests extends mill.integration.AmmoniteTests(fork = true)
object BetterFilesTests extends mill.integration.BetterFilesTests(fork = true)
object LargeProjectTests extends mill.integration.LargeProjectTests(fork = true)
object JawnTests extends mill.integration.JawnTests(fork = true)
object UpickleTests extends mill.integration.UpickleTests(fork = true)
object PlayJsonTests extends mill.integration.PlayJsonTests(fork = true)
Expand Down
3 changes: 2 additions & 1 deletion integration/test/src/local/Tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package mill.integration.local
object AcyclicTests extends mill.integration.AcyclicTests(fork = false)
object AmmoniteTests extends mill.integration.AmmoniteTests(fork = false)
object BetterFilesTests extends mill.integration.BetterFilesTests(fork = false)
object LargeProjectTests extends mill.integration.LargeProjectTests(fork = false)
object JawnTests extends mill.integration.JawnTests(fork = false)
object UpickleTests extends mill.integration.UpickleTests(fork = false)
object PlayJsonTests extends mill.integration.PlayJsonTests(fork = false)
object CaffeineTests extends mill.integration.CaffeineTests(fork = false)
object DocAnnotationsTests extends mill.integration.DocAnnotationsTests(fork = false)
object DocAnnotationsTests extends mill.integration.DocAnnotationsTests(fork = false)
7 changes: 5 additions & 2 deletions main/core/src/define/Discover.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ object Discover {
}
if overridesRoutes.nonEmpty
} yield {
// by wrapping the `overridesRoutes` in a lambda function we kind of work around
// the problem of generating a *huge* macro method body that finally exceeds the
// JVM's maximum allowed method size
val overridesLambda = q"(() => $overridesRoutes)()"
val lhs = q"classOf[${discoveredModuleType.typeSymbol.asClass}]"
val rhs = q"scala.Seq[(Int, mill.util.Router.EntryPoint[_])](..$overridesRoutes)"
q"$lhs -> $rhs"
q"$lhs -> $overridesLambda"
}

c.Expr[Discover[T]](q"mill.define.Discover(scala.collection.immutable.Map(..$mapping))")
Expand Down

0 comments on commit 9cbcfa9

Please sign in to comment.