mirror of
https://github.com/janet-lang/janet
synced 2025-08-06 14:05:32 +00:00
Add :native-deps option to jpm
.
Use is like: ``` (declare-native :name "my-nuermical-library" :source @["numerical_lib.c"] :native-deps ["tarray"]) ``` Where `tarray` is a native generated by o ne of the project dependencies. This will lets us move more C functionality out of the core of Janet while still allowing it's use from natives.
This commit is contained in:
parent
1baab5eb61
commit
60c6a0d334
@ -2,6 +2,8 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## ??? - Unreleased
|
## ??? - Unreleased
|
||||||
|
- Add `native-deps` option to `decalre-native` in `jpm`. This lets native libraries link to other
|
||||||
|
native libraries when building with jpm.
|
||||||
- Remove the `tarray` module. The functionality of typed arrays will be moved to an external module
|
- Remove the `tarray` module. The functionality of typed arrays will be moved to an external module
|
||||||
that can be installed via `jpm`.
|
that can be installed via `jpm`.
|
||||||
- Add `from-pairs` to core.
|
- Add `from-pairs` to core.
|
||||||
|
33
jpm
33
jpm
@ -523,29 +523,18 @@
|
|||||||
(string hpath `\\janet.lib`))
|
(string hpath `\\janet.lib`))
|
||||||
|
|
||||||
(defn- link-c
|
(defn- link-c
|
||||||
"Link C object files together to make a native module."
|
"Link C or C++ object files together to make a native module."
|
||||||
[opts target & objects]
|
[has-cpp opts target & objects]
|
||||||
(def linker (opt opts (if is-win :linker :compiler) default-linker))
|
(def linker
|
||||||
(def cflags (getcflags opts))
|
(if has-cpp
|
||||||
|
(opt opts (if is-win :cpp-linker :cpp-compiler) default-cpp-linker)
|
||||||
|
(opt opts (if is-win :linker :compiler) default-linker)))
|
||||||
|
(def cflags ((if has-cpp getcppflags getcflags) opts))
|
||||||
(def lflags [;(opt opts :lflags default-lflags)
|
(def lflags [;(opt opts :lflags default-lflags)
|
||||||
;(if (opts :static) [] dynamic-lflags)])
|
;(if (opts :static) [] dynamic-lflags)])
|
||||||
(def ldflags [;(opt opts :ldflags [])])
|
(def deplibs (get opts :native-deps []))
|
||||||
(rule target objects
|
(def dep-ldflags (seq [x :in deplibs] (string (dyn :modpath JANET_MODPATH) sep x modext)))
|
||||||
(check-cc)
|
(def ldflags [;(opt opts :ldflags []) ;dep-ldflags])
|
||||||
(print "linking " target "...")
|
|
||||||
(create-dirs target)
|
|
||||||
(if is-win
|
|
||||||
(shell linker ;ldflags (string "/OUT:" target) ;objects (win-import-library) ;lflags)
|
|
||||||
(shell linker ;cflags ;ldflags `-o` target ;objects ;lflags))))
|
|
||||||
|
|
||||||
(defn- link-cpp
|
|
||||||
"Link C++ object files together to make a native module."
|
|
||||||
[opts target & objects]
|
|
||||||
(def linker (opt opts (if is-win :cpp-linker :cpp-compiler) default-cpp-linker))
|
|
||||||
(def cflags (getcppflags opts))
|
|
||||||
(def lflags [;(opt opts :lflags default-lflags)
|
|
||||||
;(if (opts :static) [] dynamic-lflags)])
|
|
||||||
(def ldflags [;(opt opts :ldflags [])])
|
|
||||||
(rule target objects
|
(rule target objects
|
||||||
(check-cc)
|
(check-cc)
|
||||||
(print "linking " target "...")
|
(print "linking " target "...")
|
||||||
@ -990,7 +979,7 @@ int main(int argc, const char **argv) {
|
|||||||
(array/push objects o-src)
|
(array/push objects o-src)
|
||||||
(create-buffer-c src c-src (embed-name src))
|
(create-buffer-c src c-src (embed-name src))
|
||||||
(compile-c opts c-src o-src)))
|
(compile-c opts c-src o-src)))
|
||||||
((if has-cpp link-cpp link-c) opts lname ;objects)
|
(link-c has-cpp opts lname ;objects)
|
||||||
(add-dep "build" lname)
|
(add-dep "build" lname)
|
||||||
(install-rule lname path)
|
(install-rule lname path)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user