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

Build from clj #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Leiningen:

# Usage:

Use `lein javac` to AOT compile `clojure.tools.decompiler.RetrieveClasses` then you can use `lein repl` or `clj` to launch a repl
Use `lein javac` or `clojure -T:build compile` to AOT compile `clojure.tools.decompiler.RetrieveClasses` then you can use `lein repl` or `clj` to launch a repl.

Use `decompile-classfiles `to decompile AOT compiled classes:

Expand All @@ -21,15 +21,15 @@ user=> (d/decompile-classfiles {:input-path "path/to/root/classes/directory" :ou
[...]
```

You can use `decompile-classes` to decompile in memory classes, but to do so you must start the JVM using the java agent provided with `tools.decompiler` (use e.g. `lein jar` to build the jar):
You can use `decompile-classes` to decompile in memory classes, but to do so you must start the JVM using the java agent provided with `tools.decompiler` (use e.g. `lein jar` or `clojure -T:build jar` to build the jar):

```clojure
[~/src/tools.decompiler] clj -J-javaagent:tools.decompiler.jar
user=> (require '[clojure.tools.decompiler :as d])
nil
user=> (defn foo [a] a)
#'user/foo
user=> (decompile-classes {:classes #{"user$foo"}}) ;; optionally :output-path to decompile to disk
user=> (d/decompile-classes {:classes #{"user$foo"}}) ;; optionally :output-path to decompile to disk
Decompiling user$foo
(fn foo
([a] a)
Expand Down
17 changes: 17 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns build
(:refer-clojure :exclude [compile])
(:require [clojure.tools.build.api :as b]))

(defn compile
[_]
(b/javac {:src-dirs ["java"]
:class-dir "target/classes"}))

(defn jar
[_]
(b/copy-dir {:target-dir "target/classes"
:src-dirs ["src"]})
(compile {})
(b/jar {:class-dir "target/classes"
:jar-file "tools.decompiler.jar"
:manifest {"Premain-Class" "clojure.tools.decompiler.RetrieveClasses"}}))
13 changes: 9 additions & 4 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{:deps {org.clojure/clojure {:mvn/version "1.10.0"}
org.clojure/core.match {:mvn/version "0.3.0-alpha5"}
{:deps {org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/core.match {:mvn/version "1.0.0"}
org.apache.bcel/bcel {:mvn/version "6.1"}
fipp {:mvn/version "0.6.12"}}
:paths ["src" "target/classes"]}
fipp/fipp {:mvn/version "0.6.24"}}
:paths ["src" "target/classes"]
:aliases {:build {:deps {io.github.clojure/tools.build {:git/tag "v0.1.9" :git/sha "6736c83"}}
:ns-default build}}
:deps/prep-lib {:alias :build
:fn compile
:ensure "target/classes"}}