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

Support module.sc files in subfolders #3213

Merged
merged 73 commits into from
Aug 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
e93dfea
.
lihaoyi Jun 13, 2024
9297f37
wip
lihaoyi Jun 16, 2024
3f9425c
compiles
lihaoyi Jun 16, 2024
e0a71c4
compiles
lihaoyi Jun 16, 2024
edac3e9
things compile with multiple root modules
lihaoyi Jun 17, 2024
d5af69e
compile passes kinda
lihaoyi Jun 17, 2024
327e88c
combined sub-folder build.sc resolution works
lihaoyi Jun 17, 2024
338196c
CLI handling of nested rootmodules works
lihaoyi Jun 17, 2024
d9096e3
merge
lihaoyi Jun 17, 2024
c2fd1ed
add test for commands
lihaoyi Jun 18, 2024
8229ed4
wip try to derive segments from nested build.sc
lihaoyi Jun 18, 2024
be77e65
pass Segments to all root modules (now RootModule.Base) and properly …
lihaoyi Jun 18, 2024
db85faf
relativize packages
lihaoyi Jun 18, 2024
56e9af6
add doubly nested build.sc to example
lihaoyi Jun 18, 2024
11b3f51
fix compile errors
lihaoyi Jun 25, 2024
a637e58
merge
lihaoyi Jun 25, 2024
5f8d58d
mill.integration.local.ForeignBuildsTest.checkProjectPaths passes
lihaoyi Jun 25, 2024
41b8bd1
almost all of ForeignBuildsTest passes, one remaining
lihaoyi Jun 25, 2024
279e5ab
all of ForeignBuildsTest passes
lihaoyi Jun 25, 2024
2f07454
avoid walking mill-build folder
lihaoyi Jun 25, 2024
aa336e9
fix
lihaoyi Jun 26, 2024
48e023a
re-enable relative up imports
lihaoyi Jun 26, 2024
2e16b48
fix failure tests
lihaoyi Jun 26, 2024
113f019
.
lihaoyi Jun 26, 2024
c065dfe
.
lihaoyi Jun 27, 2024
2301413
.
lihaoyi Jun 28, 2024
3d2358c
fix
lihaoyi Jun 28, 2024
6046085
.
lihaoyi Jun 28, 2024
7715603
.
lihaoyi Jun 28, 2024
f23bf98
.
lihaoyi Jun 28, 2024
e6f573b
.
lihaoyi Jun 28, 2024
f36f315
.
lihaoyi Jun 28, 2024
eb31770
rename millbuild package to build
lihaoyi Jun 30, 2024
5bca32e
improve package object discovery
lihaoyi Jun 30, 2024
dd0dbcd
remove hardcoded filters from module.sc discovery logic
lihaoyi Jun 30, 2024
e03be05
import nested package objects into scope for enclosing package objects
lihaoyi Jun 30, 2024
be5a5a3
.
lihaoyi Jul 1, 2024
67b1ed4
.
lihaoyi Jul 1, 2024
4810e15
.
lihaoyi Jul 1, 2024
69e254b
.
lihaoyi Jul 1, 2024
de50a36
skip folders without module.sc files
lihaoyi Jul 2, 2024
0e2c0e5
.
lihaoyi Jul 2, 2024
3019b15
update foreign modules tests
lihaoyi Jul 2, 2024
3d9b969
wip
lihaoyi Jul 2, 2024
72650a9
.
lihaoyi Jul 2, 2024
a060b93
.
lihaoyi Jul 2, 2024
a97d988
wip trying to do multi main module resolution
lihaoyi Jul 6, 2024
85806a1
augment resolution logic with nested module.sc files
lihaoyi Jul 6, 2024
34a452a
.
lihaoyi Jul 6, 2024
0cf3f9e
.
lihaoyi Jul 6, 2024
90cc28d
no mainmodule methods in module.sc
lihaoyi Jul 6, 2024
aff816f
reformat
lihaoyi Jul 6, 2024
ab7b9a5
.
lihaoyi Jul 6, 2024
451e409
.
lihaoyi Jul 6, 2024
4f6fc22
.
lihaoyi Jul 7, 2024
5805f98
.
lihaoyi Jul 7, 2024
e6f5aae
introduce BaseModuleTree
lihaoyi Jul 7, 2024
db64a64
pre-computed BaseModuleTree
lihaoyi Jul 7, 2024
61b7656
consolidate rootModule into BaseModuleTree
lihaoyi Jul 7, 2024
3e85f94
.
lihaoyi Jul 7, 2024
b80b9bc
.
lihaoyi Jul 18, 2024
9e7a6b4
.
lihaoyi Jul 18, 2024
f67ba73
.
lihaoyi Jul 18, 2024
949cc97
.
lihaoyi Jul 18, 2024
9789515
.
lihaoyi Jul 18, 2024
ab2a09b
.
lihaoyi Jul 18, 2024
c3f14d6
.
lihaoyi Aug 5, 2024
38e1fa5
.
lihaoyi Aug 5, 2024
6f43b70
.
lihaoyi Aug 5, 2024
422164e
.
lihaoyi Aug 6, 2024
b59e986
cleanup
lihaoyi Aug 6, 2024
d34c2d0
Merge branch 'main' into multi-build-file
lihaoyi Aug 6, 2024
4ebb2f2
.
lihaoyi Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mill.integration.local.ForeignBuildsTest.checkProjectPaths passes
lihaoyi committed Jun 25, 2024
commit 5f8d58dd5dec369a6f047da64f15606a76e643f9
2 changes: 1 addition & 1 deletion integration/feature/foreign/repo/conflict/build.sc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $file.inner.{build => innerBuild}
import millbuild.conflict.inner
import mill._

// In this build, we have a local module targeting
2 changes: 1 addition & 1 deletion integration/feature/foreign/repo/outer/build.sc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $file.inner.build

import mill._

trait PathAware extends mill.Module {
48 changes: 23 additions & 25 deletions integration/feature/foreign/repo/project/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import $file.^.outer.build
import $file.inner.build
import $file.other

import mill._
@@ -15,7 +13,7 @@ object sub extends PathAware with DestAware {

object sub extends PathAware with DestAware

object sub2 extends ^.outer.build.PathAware with ^.outer.build.DestAware
object sub2 extends millbuild.outer.PathAware with millbuild.outer.DestAware

}

@@ -29,39 +27,39 @@ def checkProjectPaths = T {

def checkInnerPaths = T {
val thisPath: os.Path = millSourcePath
assertPathsEqual(inner.build.millSourcePath, thisPath / "inner")
assertPathsEqual(inner.build.sub.selfPath(), thisPath / "inner" / "sub")
assertPathsEqual(inner.build.sub.sub.selfPath(), thisPath / "inner" / "sub" / "sub")
assertPathsEqual(millbuild.inner.millSourcePath, thisPath / "inner")
assertPathsEqual(millbuild.inner.sub.selfPath(), thisPath / "inner" / "sub")
assertPathsEqual(millbuild.inner.sub.sub.selfPath(), thisPath / "inner" / "sub" / "sub")
}

def checkOuterPaths = T {
val thisPath: os.Path = millSourcePath
assertPathsEqual(^.outer.build.millSourcePath, thisPath / os.up / "outer")
assertPathsEqual(^.outer.build.sub.selfPath(), thisPath / os.up / "outer" / "sub")
assertPathsEqual(^.outer.build.sub.sub.selfPath(), thisPath / os.up / "outer" / "sub" / "sub")
assertPathsEqual(millbuild.outer.millSourcePath, thisPath / os.up / "outer")
assertPathsEqual(millbuild.outer.sub.selfPath(), thisPath / os.up / "outer" / "sub")
assertPathsEqual(millbuild.outer.sub.sub.selfPath(), thisPath / os.up / "outer" / "sub" / "sub")

// covers the case where millSourcePath is modified in a submodule
assertPathsNotEqual(
^.outer.build.sourcepathmod.jvm.selfDest(),
^.outer.build.sourcepathmod.js.selfDest()
millbuild.outer.sourcepathmod.jvm.selfDest(),
millbuild.outer.sourcepathmod.js.selfDest()
)
}

def checkOuterInnerPaths = T {
val thisPath: os.Path = millSourcePath
assertPathsEqual(^.outer.inner.build.millSourcePath, thisPath / os.up / "outer" / "inner")
assertPathsEqual(^.outer.inner.build.sub.selfPath(), thisPath / os.up / "outer" / "inner" / "sub")
assertPathsEqual(millbuild.outer.inner.millSourcePath, thisPath / os.up / "outer" / "inner")
assertPathsEqual(millbuild.outer.inner.sub.selfPath(), thisPath / os.up / "outer" / "inner" / "sub")
assertPathsEqual(
^.outer.inner.build.sub.sub.selfPath(),
millbuild.outer.inner.sub.sub.selfPath(),
thisPath / os.up / "outer" / "inner" / "sub" / "sub"
)
}

def checkOtherPaths = T {
val thisPath: os.Path = millSourcePath
assertPathsEqual(other.millSourcePath, thisPath)
assertPathsEqual(other.sub.selfPath(), thisPath / "sub")
assertPathsEqual(other.sub.sub.selfPath(), thisPath / "sub" / "sub")
assertPathsEqual(millbuild.other.millSourcePath, thisPath)
assertPathsEqual(millbuild.other.sub.selfPath(), thisPath / "sub")
assertPathsEqual(millbuild.other.sub.sub.selfPath(), thisPath / "sub" / "sub")
}

def checkProjectDests = T {
@@ -73,35 +71,35 @@ def checkProjectDests = T {

def checkInnerDests = T {
val foreignOut: os.Path = millSourcePath / "out" / "foreign-modules"
assertPathsEqual(inner.build.sub.selfDest(), foreignOut / "inner" / "build" / "sub")
assertPathsEqual(inner.build.sub.sub.selfDest(), foreignOut / "inner" / "build" / "sub" / "sub")
assertPathsEqual(millbuild.inner.sub.selfDest(), foreignOut / "inner" / "build" / "sub")
assertPathsEqual(millbuild.inner.sub.sub.selfDest(), foreignOut / "inner" / "build" / "sub" / "sub")
}

def checkOuterDests = T {
val foreignOut: os.Path = millSourcePath / "out" / "foreign-modules"
assertPathsEqual(^.outer.build.sub.selfDest(), foreignOut / "up-1" / "outer" / "build" / "sub")
assertPathsEqual(millbuild.outer.sub.selfDest(), foreignOut / "up-1" / "outer" / "build" / "sub")
assertPathsEqual(
^.outer.build.sub.sub.selfDest(),
millbuild.outer.sub.sub.selfDest(),
foreignOut / "up-1" / "outer" / "build" / "sub" / "sub"
)
}

def checkOuterInnerDests = T {
val foreignOut: os.Path = millSourcePath / "out" / "foreign-modules"
assertPathsEqual(
^.outer.inner.build.sub.selfDest(),
millbuild.outer.inner.sub.selfDest(),
foreignOut / "up-1" / "outer" / "inner" / "build" / "sub"
)
assertPathsEqual(
^.outer.inner.build.sub.sub.selfDest(),
millbuild.outer.inner.sub.sub.selfDest(),
foreignOut / "up-1" / "outer" / "inner" / "build" / "sub" / "sub"
)
}

def checkOtherDests = T {
val foreignOut: os.Path = millSourcePath / "out" / "foreign-modules"
assertPathsEqual(other.sub.selfDest(), foreignOut / "other" / "sub")
assertPathsEqual(other.sub.sub.selfDest(), foreignOut / "other" / "sub" / "sub")
assertPathsEqual(millbuild.other.sub.selfDest(), foreignOut / "other" / "sub")
assertPathsEqual(millbuild.other.sub.sub.selfDest(), foreignOut / "other" / "sub" / "sub")
}

trait PathAware extends mill.Module {
6 changes: 5 additions & 1 deletion integration/src/mill/integration/IntegrationTestSuite.scala
Original file line number Diff line number Diff line change
@@ -109,7 +109,11 @@ abstract class IntegrationTestSuite extends TestSuite {
// wrapper-folder inside the zip file, so copy the wrapper folder to the
// destination instead of the folder containing the wrapper.

os.copy(scriptSourcePath, workspacePath)

// somehow os.copy does not properly preserve symlinks
// os.copy(scriptSourcePath, workspacePath)
os.proc("cp", "-R", scriptSourcePath, workspacePath).call()

os.remove.all(workspacePath / "out")
workspacePath
}
16 changes: 16 additions & 0 deletions main/src/mill/main/RootModule.scala
Original file line number Diff line number Diff line change
@@ -44,4 +44,20 @@ object RootModule {
baseModuleInfo.discover.asInstanceOf[Discover[this.type]]
}
case class Info(millSourcePath0: os.Path, discover: Discover[_])


abstract class Foreign(foreign0: Option[Segments])(implicit
baseModuleInfo: RootModule.Info,
millModuleEnclosing0: sourcecode.Enclosing,
millModuleLine0: sourcecode.Line,
millFile0: sourcecode.File
) extends mill.define.BaseModule(baseModuleInfo.millSourcePath0, foreign0 = foreign0)(
millModuleEnclosing0,
millModuleLine0,
millFile0,
Caller(null)
) with mill.main.MainModule {

override implicit lazy val millDiscover: Discover[this.type] = Discover[this.type]
}
}
2 changes: 1 addition & 1 deletion runner/src/mill/runner/FileImportGraph.scala
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ object FileImportGraph {

val useDummy = !os.exists(projectRoot / "build.sc")
walkScripts(projectRoot / "build.sc", useDummy)
os.walk(projectRoot)
os.walk(projectRoot, followLinks = true)
.filter{p =>
val rel = p.relativeTo(projectRoot)
rel.last == "build.sc" &&