-
Notifications
You must be signed in to change notification settings - Fork 449
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
[WIP] Compile ank #491
[WIP] Compile ank #491
Conversation
@@ -6,6 +6,7 @@ import java.io.File | |||
|
|||
const val AnkBlock = ":ank" | |||
const val AnkSilentBlock = ":ank:silent" | |||
const val AnkCompileBlock = ":ank:compile" |
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 can reuse ank:silent
or remove it in favor of ank:compile
since essentially both produce the same output which is guaranteeing compilation and being added to the scope of the page scripts but not actually evaluating anything.
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.
silent
gets evaluated by ScriptEngine
which means you can reference it in a regular ank
blocks. Whatever is defined in compile
cannot be referenced from a regular ank
block.
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.
makes sense, let's keep them separate then.
val args = listOf("-Xcoroutines=enable", "-cp", classPath, "-d", file.parentFile.absolutePath, tmpFile.absolutePath).toTypedArray() | ||
|
||
//If compilation fails compiler shuts down VM. However correct output is shown in Gradle. | ||
K2JVMCompiler.main(args) |
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.
what happens if the code snippet is java:ank:compile
?
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.
Need to check!
@@ -199,7 +199,7 @@ eitherTVal.value() | |||
|
|||
So how would our function look if we implemented it with the EitherT monad transformer? | |||
|
|||
```kotlin | |||
```kotlin:ank:compile |
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.
👏
Added some concerns but overall this looks awesome! |
… simon-compile-ank
codeBlocks.filter { it.lang != "kotlin" } | ||
.find { it.compile } | ||
?.let { | ||
throw CompilationException(file, it, IllegalStateException("```${it.lang}:ank:compile is not supported. Use ```${it.lang}:ank or ```${it.lang}:ank:silent")) |
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.
I throw a CompilationException
here but Gradle seems to get stuck instead of terminating. Any ideas?
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 because you are within an async boundary not blocking. If you block the result of async
it will blow up in the gradle thread.
codeBlocks.filter { it.lang != "kotlin" } | ||
.find { it.compile } | ||
?.let { | ||
throw CompilationException(file, it, IllegalStateException("```${it.lang}:ank:compile is not supported. Use ```${it.lang}:ank or ```${it.lang}:ank:silent")) |
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 because you are within an async boundary not blocking. If you block the result of async
it will blow up in the gradle thread.
@nomisRev is this still relevant?, if so it needs to get updated to the latest arrow structure in master |
@nomisRev, closing this since Ank is no longer hosted in this repo |
I enabled compilation of the
EitherT
documentation and it compiles. 🎉Currently all snippets get combined into one
kts
file and it gets compiled if one snippet has the compile flag present.This closes #472