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

[WIP] Compile ank #491

Closed
wants to merge 9 commits into from
Closed

[WIP] Compile ank #491

wants to merge 9 commits into from

Conversation

nomisRev
Copy link
Member

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

@@ -6,6 +6,7 @@ import java.io.File

const val AnkBlock = ":ank"
const val AnkSilentBlock = ":ank:silent"
const val AnkCompileBlock = ":ank:compile"
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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)
Copy link
Member

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 ?

Copy link
Member Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@raulraja
Copy link
Member

Added some concerns but overall this looks awesome!

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"))
Copy link
Member Author

@nomisRev nomisRev Dec 4, 2017

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?

Copy link
Member

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"))
Copy link
Member

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.

@raulraja
Copy link
Member

@nomisRev is this still relevant?, if so it needs to get updated to the latest arrow structure in master

@raulraja
Copy link
Member

raulraja commented Feb 5, 2018

@nomisRev, closing this since Ank is no longer hosted in this repo

@raulraja raulraja closed this Feb 5, 2018
@pakoito pakoito deleted the simon-compile-ank branch April 6, 2018 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide support to bypass the ScriptEngine and just compile with kotlin:ank:compile
3 participants