-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Make builds able to depend on external projects #291
Make builds able to depend on external projects #291
Conversation
@Baccata since this deals with |
661fb6b
to
d0fa222
Compare
@lihaoyi, say I depend on an outer build under I think I know how to implement either ways, it's just a matter of making the decision ^^ |
@Baccata one thing that isn't clear to me is what you mean by Would It's a bit unclear to me whether a shared top-level/enclosing Apart from re-wiring up |
My bad, should have been more descriptive. I don't have a definitive answer to that question. My usecase started from the former :
It actually does, with the current changes ! However, whilst writing tests, I realised that with the current modifications,
Roll a dice ? 😸 If you don't have a clear preference, I think I'll have a go at implementing the former (bazel style). The only benefit I see from the latter (sbt style) is that it'd save some time when moving from one dir to another as things might already have been cached. Not sure it's worth it
With the current changes, |
I suppose the main use case of SBT-style per-subproject This can also be accomplished by having the sub projects "discover" what the outer-most Maybe we can just punt on the problem for now and accept the a bit of unnecessary re-building when you w.r.t. filesystem-collisions, there are a few approaches we could take:
|
Agreed
I think I'll roll with this. Adding another magic import that is not fully orthogonal with $file does not feel right to me, and disambiguating looks easy enough. Thanks for the answers ! |
Builds are now able to load external projects and depend on them as if they were local submodules. `import $file.external.path.build`
* Calling modules loaded from external directories "Foreign" to avoid conflicting with the already existing concept of "ExternalModule". * Amended the way `dest` is computed for foreign modules * Added tests to check that the source paths and dest are as expected * Added a test to show that local modules do not conflict with foreign modules when they are named the same
b4f041d
to
60d1cdc
Compare
core/src/mill/eval/Evaluator.scala
Outdated
@@ -30,7 +30,6 @@ case class Labelled[T](task: NamedTask[T], | |||
} | |||
case class Evaluator[T](home: Path, | |||
outPath: Path, | |||
externalOutPath: Path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this parameter was always equal to outPath
(except in one test), so I took the liberty to remove. I think I could add a external-modules
segment in out in the new destSegments
conditioned by the module/task being "external". Thoughts ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We re-used externalOutPaths in tests to speed up the test suite; otherwise re-initializing the Zinc incremental compiler made them take forever. Do you have a good reason to believe this is no longer the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ! Fair enough, reverted there 1607f78
@@ -191,6 +191,27 @@ case class Evaluator[T](home: Path, | |||
} | |||
} | |||
} | |||
|
|||
def destSegments(labelledTask : Labelled[_]) : Segments = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core of the PR I guess. This makes sure that "foreign" modules do not conflict with local modules
@@ -0,0 +1,82 @@ | |||
import $file.^.outer.build | |||
import $file.inner.build | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the main test, it checks the consistency of sourcePaths and dest
assertPaths(^.outer.build.sub.sub.selfPath(), thisPath / up / 'outer / 'sub / 'sub) | ||
} | ||
|
||
def checkOuterInnerPaths = T { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking that importing a foreign build which imports a foreign build works as expected
@@ -8,28 +8,29 @@ import utest._ | |||
abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to tweak this a bit to accommodate the new tests. Changes are not breaking
fileName: String){ | ||
} | ||
|
||
object Ctx{ | ||
case class External(value: Boolean) | ||
case class Foreign(value : Boolean) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to choose a name for the concept "builds that originate from other directories", and External was already taken. Obviously I'm not a native English speaker, so perhaps there's a term that would suit the concept better.
b49d657
to
6d2b1f3
Compare
.appveyor.yml
Outdated
@@ -46,6 +46,7 @@ build_script: | |||
C:\%CYGWIN_DIR%\bin\bash -lc "curl -Lo /usr/local/bin/mill %MILL_URL%" && | |||
C:\%CYGWIN_DIR%\bin\bash -lc 'sed -i '"'"'0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}; 0,/-cp "\$0"/{s/-cp "\$0"/-cp `cygpath -w "\$0"`/}'"'"' /usr/local/bin/mill' && | |||
C:\%CYGWIN_DIR%\bin\bash -lc 'chmod +x /usr/local/bin/mill' && | |||
C:\%CYGWIN_DIR%\bin\bash -lc "cd /cygdrive/c/mill && mill -i all main.test scalajslib.test") | |||
C:\%CYGWIN_DIR%\bin\bash -lc "cd /cygdrive/c/mill && mill -i all __.publishLocal release" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cygwin job was not bootstrapping before testing, leading the tests to fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this is necessary? I don't see any reason the changes I've reviewed would cause bootstrapping issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I momentarily switched output stream to System.out in failing test to understand what was happening.
As far as I understand, without bootstrapping the foreign0 param was not defined in the version of mill used to compile this wrapping code
This started happened locally as well after I rebased the changes against the master (I had been out of sync for ~10 days I think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the unit tests via mill all main.test
should use the freshly-compiled version of Mill; the fact that it's including foreign0
in the code wrapper is evidence of this. Thus I do not see why that freshly-compiled Mill would not be able to handle foreign0
during compilation.
Furthermore, the Travis build ran the foreign module tests also without bootstrapping, but successfully.
Can you dig into this a bit deeper? We should figure out what is going on here rather than just working around the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
@lihaoyi, I think I've reached a satisfying state for this. If you're happy with it, I'll proceed and add some documentation |
Apart from one comment looks ok i guess |
* Add documentation for foreign-modules
3945ce4
to
1607f78
Compare
@lihaoyi, regarding the failed appveyor build when using the cygwin environment, here's what I found so far :
I'm happy to investigate further, but this shows the PR is not at cause. I'd like to make the CI green again, which I can make by either re-adding the bootstrapping line in the cygwin env, or disabling the tests like in
|
@Baccata we wanted to run our test suite with a mix of bootstrapped and non-bootstraped runs, to make sure it works on both. I don't remember the reason for disabling I think your options are to either figure out what's causing the non-bootstrapped test to fail, or disabling it in java 9. I don't think turning on bootstrapping temporarily to get them working is viable: that just pushes the problem down the line to when it fails some time in future. If you disable it in java9, open an issue to write down what you know about the problem. |
Looks good to me |
Following com-lihaoyi/Ammonite#792
Builds are now able to load external projects (also built with mill), and depend on them as if they were local submodules, using simple ammonite imports :
import $file.outer.path.build
Without this patch, external builds are compiled using pwd to create
millSourcePath
, disregarding the original location of the outer projects, and their sources are looked up in the current directory rather than the external one.