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

Hook jank into leiningen #29

Open
1 of 5 tasks
jeaye opened this issue Apr 15, 2023 · 1 comment
Open
1 of 5 tasks

Hook jank into leiningen #29

jeaye opened this issue Apr 15, 2023 · 1 comment

Comments

@jeaye
Copy link
Collaborator

jeaye commented Apr 15, 2023

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.

  • 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.

Adding a run-main command

The 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 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.

I'd duplicate the run function we have into a run_main and use the rt_ctx to load the module. https://github.com/jank-lang/jank/blob/main/src/cpp/main.cpp#L29

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
@Samy-33
Copy link
Contributor

Samy-33 commented Jan 12, 2024

@jeaye, please assign this to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants