Skip to content

[WIP] Add support for Scala native#1929

Closed
adampauls wants to merge 4 commits intocirce:mainfrom
adampauls:main
Closed

[WIP] Add support for Scala native#1929
adampauls wants to merge 4 commits intocirce:mainfrom
adampauls:main

Conversation

@adampauls
Copy link

@adampauls adampauls commented Mar 21, 2022

Starts to address #1077, which was closed years ago but I would re-open if I could.

I thought I would put this up as proof that there isn't too much to do. The outstanding issues are:

  • Fix issue in testingNative where io.circe.Spaces2PrinterSuite cannot read modules/tests/shared/src/test/resources/io/circe/spaces2-example.json (but testingJVM can)
  • See if "scodec-bits" dependency can support native.
  • See if "eu.timepit" %%% "refined" can support native.
  • Implement CopyOnWriteArrayList properly or find a workaround.

I would love to see this done but don't know the project well enough to solve all these problems quickly. I thought I would put this draft PR up for discussion. Hope that's alright!

@armanbilge
Copy link
Contributor

Nice! I've been interested in this as well as @lolgab. Now that Native supports Scala 3 I'm hoping that more of the ecosystem will adopt, including scodec. All of that is basically blocked from here:

@adampauls
Copy link
Author

adampauls commented Mar 21, 2022

Is it reasonable to publish a native version without support for refined and scodec (temporarily)?

@armanbilge
Copy link
Contributor

It is reasonable. It is also reasonable to publish without Scala 3. But, we are so close! Let's do it right, and put our energy into driving this from the bottom up. For example, I just added support for shared source folder e.g. js-native so that you don't have to copy files like you did here.

@adampauls
Copy link
Author

Sure thing, whatever you think is best!

BTW I just pushed a fix and sbt validateNative seems to work now, so I think there aren't many unknowns left.

@adampauls
Copy link
Author

It looks like the upstream efforts are stalled. Do you think it's worth pushing something out without scodec-bits, Scala 3, or refined?

@armanbilge
Copy link
Contributor

Depends what you mean by pushing something out :) I'd say upstreams and circe are moving at roughly the same pace e.g. see #1933.

@adampauls
Copy link
Author

Heh, good question. I think what I meant was to submit a PR like this one if I can figure out a way to simply exclude the non-native-ready parts of the code from the native build. I know it's not great practice to have the native build support less functionality than the JVM/JS builds, but it's also better than nothing.

@fiatjaf
Copy link

fiatjaf commented May 20, 2022

Good morning, just adding here that scodec-bits Scala Native support has been merged: scodec/scodec-bits#373

adampauls added 3 commits May 21, 2022 20:38
# Conflicts:
#	build.sbt
#	project/plugins.sbt
@armanbilge
Copy link
Contributor

Cats is now published for Native on Scala 2.12, 2.13, 3. So Circe should be able to do the same.

https://github.com/typelevel/cats/releases/tag/v2.8.0

Note that my build changes in #1968 will make configuring the build for Native very easy.

@armanbilge
Copy link
Contributor

armanbilge commented Jul 11, 2022

@adampauls were you ever actually able to run the tests? I started looking into this myself and it seems that Native is missing CopyOnWriteArrayList. This should be ported to Scala Native from Scala.js before we can move ahead. Would be fantastic if you (or any motivated on-lookers) can take that on. It should be a very easy PR, just copy the sources and the tests from Scala.js to Scala Native. Thank you!

https://github.com/scala-js/scala-js/blob/33ed7588ad80eaff5802aaf3b6f620b408a200cd/javalib/src/main/scala/java/util/concurrent/CopyOnWriteArrayList.scala

@adampauls
Copy link
Author

I am on vacation at the moment but can try to do it soon!

@armanbilge
Copy link
Contributor

armanbilge commented Jul 15, 2022

I already opened scala-native/scala-native#2725. I'm sorry, I missed the fact that it was on your checklist you made in March. Fixing this should have been # 1 priority since it affects the Circe Core module and requires a change in Scala Native itself. We will be blocked until the next Scala Native release unfortunately.

@armanbilge
Copy link
Contributor

For anyone who wants to play around I've published a bootleg snapshot of Circe Native.
https://s01.oss.sonatype.org/content/repositories/snapshots/com/armanbilge/circe-core_native0.4_3/0.14.2-87-a48d472-SNAPSHOT/

@armanbilge armanbilge mentioned this pull request Sep 1, 2022
@armanbilge
Copy link
Contributor

I now have a PR up at #2017.

@zarthross
Copy link
Member

Superseded by 2017

@zarthross zarthross closed this Sep 6, 2022
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.

4 participants