aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShagun Agrawal <agrawalshagun07@gmail.com>2024-07-25 01:04:22 +0530
committerShagun Agrawal <agrawalshagun07@gmail.com>2024-07-25 01:04:22 +0530
commit264c71e3a7666bc234a5dd62b1bcc36c89d1949d (patch)
tree0a55558073d7f623f282a260da6cd6242955b533
parentb17a2610bd3d7293d1ae59c5531121e78859e7ea (diff)
update readme with build/run instructions
-rw-r--r--README.md98
-rw-r--r--bb.edn9
-rw-r--r--build.clj1
3 files changed, 44 insertions, 64 deletions
diff --git a/README.md b/README.md
index 6b9bee4..012f4a1 100644
--- a/README.md
+++ b/README.md
@@ -1,78 +1,56 @@
-# cljcc/cljcc
+# cljcc
-FIXME: my new application.
+A toy C Compiler implementation in Clojure.
-## Installation
+Follows the book [Writing a C Compiler by Nora Sandler](https://nostarch.com/writing-c-compiler).
-Download from https://github.com/cljcc/cljcc
+## Prerequisites
-## Usage
+* [Clojure](https://clojure.org)
+* [GraalVM](https://www.graalvm.org) for building native binary
+* [babashka](https://github.com/babashka/babashka#installation)
+
+Only Linux and Mac OS is supported. For Windows, run through WSL.
+
+## Tasks
-FIXME: explanation
+To see all available tasks in the project, run `bb tasks`:
-Run the project directly, via `:exec-fn`:
+``` sh
+bb tasks
+The following tasks are available:
- $ clojure -X:run-x
- Hello, Clojure!
+clean Removes target folder.
+run-main Run main
+build-uberjar Builds uberjar
+run-uberjar Run uberjar
+build-native Builds native image
-Run the project, overriding the name to be greeted:
+```
- $ clojure -X:run-x :name '"Someone"'
- Hello, Someone!
+## Build
-Run the project directly, via `:main-opts` (`-m cljcc.cljcc`):
+To build native image, run:
- $ clojure -M:run-m
- Hello, World!
+``` sh
+bb build-native
+```
-Run the project, overriding the name to be greeted:
+This produces a binary `cljcc` at `/target/cljcc`. Pass the path to the C file.
- $ clojure -M:run-m Via-Main
- Hello, Via-Main!
+``` sh
+./target/cljcc/cljcc "path/to/file.c"
+```
-Run the project's tests (they'll fail until you edit them):
+## Run
- $ clojure -T:build test
+``` sh
+bb run-main "path/to/file.c"
+```
-Run the project's CI pipeline and build an uberjar (this will fail until you edit the tests to pass):
+## References
- $ clojure -T:build ci
+Some talks / projects which helped in implementation.
-This will produce an updated `pom.xml` file with synchronized dependencies inside the `META-INF`
-directory inside `target/classes` and the uberjar in `target`. You can update the version (and SCM tag)
-information in generated `pom.xml` by updating `build.clj`.
-
-If you don't want the `pom.xml` file in your project, you can remove it. The `ci` task will
-still generate a minimal `pom.xml` as part of the `uber` task, unless you remove `version`
-from `build.clj`.
-
-Run that uberjar:
-
- $ java -jar target/net.clojars.cljcc/cljcc-0.1.0-SNAPSHOT.jar
-
-## Options
-
-FIXME: listing of options this app accepts.
-
-## Examples
-
-...
-
-### Bugs
-
-...
-
-### Any Other Sections
-### That You Think
-### Might be Useful
-
-## License
-
-Copyright © 2024 Shagunagrawal
-
-_EPLv1.0 is just the default for projects generated by `deps-new`: you are not_
-_required to open source this project, nor are you required to use EPLv1.0!_
-_Feel free to remove or change the `LICENSE` file and remove or update this_
-_section of the `README.md` file!_
-
-Distributed under the Eclipse Public License version 1.0.
+* [What's So Hard About Writing A Compiler, Anyway? Oh - Ramsey Nasser](https://www.youtube.com/watch?v=_7sncBhluXI)
+
diff --git a/bb.edn b/bb.edn
index c3da3be..5f08560 100644
--- a/bb.edn
+++ b/bb.edn
@@ -6,19 +6,22 @@
(do
(println "Cannot run on Windows !")
(System/exit 1))))
- clean (do
- (println "Removing target folder.")
- (fs/delete-tree "target"))
+
+ clean {:doc "Removes target folder."
+ :task (fs/delete-tree "target")}
run-main {:doc "Run main"
:task (apply clojure "-M -m cljcc.cljcc" *command-line-args*)}
+
build-uberjar {:doc "Builds uberjar"
:task (when (seq (fs/modified-since "target/cljcc"
["src" "build.clj" "deps.edn" "test" "resources"]))
(clojure "-T:build ci"))}
+
run-uberjar {:doc "Run uberjar"
:depends [build-uberjar]
:task (apply shell "java -jar target/cljcc/cljcc.jar" *command-line-args*)}
+
build-native {:doc "Builds native image"
:depends [build-uberjar]
:task
diff --git a/build.clj b/build.clj
index be2c688..8fdeaaf 100644
--- a/build.clj
+++ b/build.clj
@@ -3,7 +3,6 @@
(:require [clojure.tools.build.api :as b]))
(def lib 'net.clojars.cljcc/cljcc)
-(def version "0.1.0-SNAPSHOT")
(def main 'cljcc.cljcc)
(def class-dir "target/classes")