I'm not sure how this will work yet, if jank will have a lein plugin or if something else is required. But jank will be adding support for require shortly, so we should be able to start hooking in deps, generating compilation artifacts, etc.
For now, blocked on #31.
[x] Add basic lein plugin which can run jank
[ ] Add support for a run-main command to jank
[ ] Bundle a jank library and publish it to clojars (verify lein is putting the jank source in the jar, too)
[ ] Pull that jank library down as a lein dependency, require the code, and verify it works (may be some bugs in the jar side of module loading, since it's been tested the least)
[ ] Add support for compiler flags in the project.clj which get passed to jank as command-line flags (see its currently supported flags and expose all of those)
NOTE: Keep in mind that jank will load .jank or .cljc files, but not .clj files. Just like ClojureScript.
Our run-main command will be very similar to the run command, but will load a module, rather than a file. We're using a new command, rather than a flag, since there's no point in loading a specific file from the lein project; we want to load a module, based on the class path we have.
We'll need a new transient string target_module option to go along with the command.
With out module loaded, we'll need to find the var for -main within that class and invoke it. The rt_ctx can be used to find the var. You can use dynamic_call on that to invoke it (don't forget to deref the var to get its root).
Passing in the command-line arguments will be more difficult, since we'll need to add CLI support for a -- flag, which then consumes everything after it. jank uses CL11 for flag handling, so you'll need to check out how to do -- there: https://github.com/CLIUtils/CLI11
The final command for lein jank run foo bar spam should look like this:
jank run-main my.program --class-path <...> -- foo bar spam
I'm not sure how this will work yet, if jank will have a lein plugin or if something else is required. But jank will be adding support for
require
shortly, so we should be able to start hooking in deps, generating compilation artifacts, etc.For now, blocked on #31.run-main
command to jankproject.clj
which get passed to jank as command-line flags (see its currently supported flags and expose all of those)NOTE: Keep in mind that jank will load
.jank
or.cljc
files, but not.clj
files. Just like ClojureScript.Adding a
run-main
commandThe jank CLI options are defined here: https://github.com/jank-lang/jank/blob/main/include/cpp/jank/util/cli.hpp The source to process them is here: https://github.com/jank-lang/jank/blob/main/src/cpp/jank/util/cli.cpp
Our
run-main
command will be very similar to therun
command, but will load a module, rather than a file. We're using a new command, rather than a flag, since there's no point in loading a specific file from the lein project; we want to load a module, based on the class path we have.I'd duplicate the
run
function we have into arun_main
and use thert_ctx
to load the module. https://github.com/jank-lang/jank/blob/main/src/cpp/main.cpp#L29We'll need a new transient string
target_module
option to go along with the command.With out module loaded, we'll need to find the var for
-main
within that class and invoke it. Thert_ctx
can be used to find the var. You can usedynamic_call
on that to invoke it (don't forget toderef
the var to get its root).Passing in the command-line arguments will be more difficult, since we'll need to add CLI support for a
--
flag, which then consumes everything after it. jank uses CL11 for flag handling, so you'll need to check out how to do--
there: https://github.com/CLIUtils/CLI11The final command for
lein jank run foo bar spam
should look like this: