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

Add Scala Native as a supported platform #238

Merged
merged 1 commit into from
May 17, 2017

Conversation

shadaj
Copy link
Contributor

@shadaj shadaj commented May 14, 2017

This adds cross-compilation of Squants to Scala Native (for Scala 2.11 only). There is a small hack in toString for Quantity to work around string formatting being unimplemented in Scala Native. This also updates publishing instructions to handle Scala Native only supporting Scala 2.11.

@shadaj shadaj force-pushed the scala-native-support branch 3 times, most recently from 3e3c4f6 to e6cab6f Compare May 14, 2017 23:58
@cquiroz
Copy link
Collaborator

cquiroz commented May 15, 2017

Wow this is great. I'm not too familiar with scala-native tooling. Can you run tests there?

@shadaj
Copy link
Contributor Author

shadaj commented May 15, 2017

Not at the moment; Scala Native doesn't have support for running tests from SBT, and ScalaTest and ScalaCheck are not available there yet. So the support is very experimental.

@@ -125,5 +125,16 @@ package object squants {
* @param d Double number to be formatted
* @return
*/
private[squants] def crossFormat(d: Double): String = if (d.toLong == d) { "%.1f".format(d) } else { d.toString }
private[squants] def crossFormat(d: Double): String = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

On scala.js we can put different implementations of a class for each platform under the js and jvm folders. Can we do the same and put the native specific code is a separate location?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a Platform object that contains platform-specific implementations of crossFormat

@@ -9,6 +9,7 @@
package squants.thermal

import squants._
import squants.Platform.crossFormat
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting, is this really the only place this is being used? Regardless I like this solution

@cquiroz
Copy link
Collaborator

cquiroz commented May 15, 2017

This is looking good and I'm all for including this new capability it but I'll wait a while for other members to chime in

@derekmorr
Copy link
Collaborator

This looks fine to me, and I'm glad can isolate scala native code in its own directory.

```
sbt +publishSigned
sbt +squantsJVM/publishSigned
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to break these out into three commands now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a good point, breaking it will probably slow down travis a bit while warming up sbt

@cquiroz
Copy link
Collaborator

cquiroz commented May 17, 2017

@paxelord Let us know if you can change the travis task split and if you want you can add yourself to the contributors list on the README

If you don't want to change those we can merge and change it later

Thanks a lot for this, I'll start adding scala-native support to my own projects

@derekmorr
Copy link
Collaborator

He should already be in the contributor list. I added him in #237 , but I forgot to run tut to rebuild the main README.md. I believe that's fixed in #239 .

@cquiroz cquiroz merged commit eb4612e into typelevel:master May 17, 2017
@shadaj
Copy link
Contributor Author

shadaj commented May 17, 2017

I split up the Travis task because Scala Native only supports Scala 2.11, so we cannot run the cross-version commands for native compilation. As soon as support is added in Scala Native for 2.10 and 2.12 the change can be reverted run cross-version commands for all platforms.

Also, just a little confusion, @paxelord is another member on the same robotics team as me (@Team846). But I pinged him to let him know about the contributors list since he contributed additional angular units in a previous PR.

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.

3 participants