-
Notifications
You must be signed in to change notification settings - Fork 231
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
Support building native modules from other languages with jpm #709
Comments
I'm not sure i would classify other language support as hacks, it's more like some languages come with builtin 'make' rules and others don't. Since both rust and zig do their own fine grained dependency tracking, simply making jpm call out to those tools seems more reasonable than trying to reverse engineer how they build things. Perhaps jpm needs something like an 'externally built native' and the tool just needs to arrange for a .a and .so to be put in a specific place. It's a good thing to think about, these languages have lots of good libraries that janet can leverage. |
A side note -- perhaps it's well-understood, but IIUC there is C++ support (in addition to the aforementioned C). See: https://github.com/janet-lang/janet/blob/master/CHANGELOG.md#1155---2021-04-25 |
So jpm's general rules system is quite general and language agnostic, but yes all of the built in I can perhaps see the desire to mix languages in one A function like |
Another language that I could imagine being of interest for this kind of thing: Drew Devault's new not-yet-released (or even named?) systems language: https://drewdevault.com/2021/03/19/A-new-systems-language.html (more sample code here). |
I was thinking the same, implementing |
Could this be solved by the changes done/proposed in #1444 (bundle/* and related)? |
Yeah, for now closing this. The |
jpm is able to compile native modules for use in artifacts, but currently only supports those modules being written in one language: C. There are other languages, such as Zig or Rust, that people may also want to use, but integrating them into the jpm build system requires hacks. I propose we remove the assumptions that impose this restriction.
I see two ways this could be done:
declare-native :source
directly tocc
, first check the file extension, and pass to a user-definable command; so for instance.c
and.cpp
(or whatever alternative C++ extension the author uses) could be configured to route tocc -o {name}
,.zig
tozig build-lib -dynamic -o {name}
, and so on. This would require the least intervention from the author, but would be ambiguous in the case of multiple input files with different extensions.declare-native
::command
(or:compiler
,:build
, etc.), which takes a command string to pass to the shell, i.e.(declare-native :name "mymod" :command “zig build-lib -dynamic -o {name}” :source @["mymod.zig"])
. This is much more flexible and covers all cases, although the naïve implementation is more verbose. (This can be partially mitigated bydef
ining the command string earlier inproject.janet
.)The text was updated successfully, but these errors were encountered: