krzema12 / kotlin-python

Python target for the Kotlin Programming Language. See https://github.com/krzema12/kotlin-python/tree/python-backend/python
https://discuss.kotlinlang.org/t/idea-python-backend/19852
47 stars 1 forks source link

[#73] Use Python's stdlib when manually calling the compiler #124

Closed krzema12 closed 2 years ago

krzema12 commented 2 years ago

Before this change, the Python-specific stdlib was used only in box tests. This change makes the stdlib present in dist directory and thus usable by e.g. end-to-end tests and GitHub workflows.

krzema12 commented 2 years ago

Reason of failure:

exception: java.lang.IllegalStateException: FATAL ERROR: Could not find "dist/kotlinc/lib/kotlin-stdlib-py-js.klib" in [/home/runner/work/kotlin-python/kotlin-python]

Weird, it worked fine locally. I have to dig deeper.

krzema12 commented 2 years ago

So far only learned that some JAR is created in Python's stdlib's build directory during dist, and the klib is created only when calling build task explicitly on the stdlib project. Simplest idea: we need to call a specific task from prepare/compiler/build.gradle.kts.

SerVB commented 2 years ago

~@krzema12, I've pushed a build task invocation here as you had suggested. Works now. However, it can be improved: we don't need the whole build but only the task that creates klib: it can save some time.~

UPD: never mind, changed build to assemble, should work more performant now. Waiting for tests anyway :)

krzema12 commented 2 years ago

@SerVB the idea with depending on whole build task was to get us unblocked. I found it pretty challenging to find a task which produces the file :sweat_smile: Hopefully assemble will work fine.

One more thing to check: if the produced KLIB really contains what it should. I'll change code of one of stdlib's function and see if it's reflected in the compiled output.

SerVB commented 2 years ago

Hopefully assemble will work fine.

AFAIU assemble is a standard Gradle task, like build, but without dependency on check:

grafik

Probably we can specify even more specific task instead of assemble, but indeed it requires some research which one is needed. On the other hand, using assemble instead of build already gives a good-enough boost, so I don't research it further.

One more thing to check: if the produced KLIB really contains what it should. I'll change code of one of stdlib's function and see if it's reflected in the compiled output.

Already checked in my local branch, seems working. Feel free to check too :)