-
-
Notifications
You must be signed in to change notification settings - Fork 338
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 Examples #3657
base: main
Are you sure you want to change the base?
Conversation
Hi @lihaoyi something like this or I have to use scalatags and mainargs? |
Let's use the same scalatags/mainargs example as we did in You can get rid of most of the docs that are already part of |
Alright, it's noted |
//build.mill
package build
import mill._, scalalib._, scalanativelib._
object `package` extends RootModule with ScalaNativeModule {
def scalaVersion = "2.13.11"
def scalaNativeVersion = "0.5.5"
def nativeLinkingOptions = pathToWhereTheTargetWasSaved
object test extends ScalaNativeTests {
def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.8.4")
def testFramework = "utest.runner.Framework"
}
} #makefile
all :
gcc -m64 -shared -c native-src/HelloWorld.c -o target/libstub.so @lihaoyi good day, I've some few questions to ask Is it possible for me to run the commands in When I replace the That's why I asked whether it's possible to run the comments in Lastly, is this what you want for the |
Sure,
Make an upstream task generate the SO file and return a
Yes the |
Okay. For this my draft PR, @lihaoyi what do you think? |
I did a review pass. Please make sure you read through the original ticket and earlier comments, it doesn't make sense for me to keep repeating things I've already written |
Alright @lihaoyi I did the changes to the draft PR About
I have a question to ask also, if I want to make use of a file or directory path of a module in another module how to go about it in mill |
You can read things from other modules' folders by declaring them as For the scala-native thing, I have no idea. Try the scala-native discord channel? |
#1 [info] Linking native code (immix gc, none lto) (185 ms) | ||
#1 [info] Postprocessing (0 ms) | ||
#1 [info] Total (24202 ms) | ||
[90/1] run | ||
<h1>hello</h1> |
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.
The syntax here looks wrong; are the example tests actually being run?
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.
You might need to register this folder in the example/package.mill. Please follow the existing code that's already there, and follow instructions in the readme for how to run them, and verify thst you can run the tests and that they pass
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.
Okay
I needed to know so I can direct the location of the header file foo depend on, no writing to it |
// | ||
// This example is pretty minimal, but it demonstrates the core principles, and | ||
// can be extended if necessary to more elaborate use cases. The `native*` tasks | ||
// can also be extracted out into a `trait1 for re-use if you have multiple |
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.
`trait
?
object bar extends MyModule { | ||
|
||
// Compile C | ||
def nativeCompiled = T { |
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.
You should be using the Task {}
and Task.dest
syntax in main
|
||
os.proc( | ||
"gcc", "-m64", "-shared", "-fPIC", | ||
"-I", "/workspaces/milling-two/sunday-work/mill/example/scalalib/native/3-multi/bar/native-src", |
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.
Hardcoded paths are wrong
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.
Yes, I know. I can now replace it with what you informed me of how to use paths from one module in another one
def nativeCompiled = T { | ||
os.makeDir.all(millSourcePath / "target") | ||
|
||
os.proc( |
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 os.proc
call should be moved into MyModule
This is a draft to close issue #3647