WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 3dfdbc4

Browse files
committed
Remove babashka for regular clj
1 parent e42b1f8 commit 3dfdbc4

File tree

15 files changed

+126
-107
lines changed

15 files changed

+126
-107
lines changed

compiled_starters/clojure/.codecrafters/compile.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
# Learn more: https://codecrafters.io/program-interface
88

99
set -e # Exit on failure
10+
11+
clj -T:build

compiled_starters/clojure/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
bb -m sqlite.core "$@"
11+
exec java -jar /tmp/codecrafters-build-sqlite-clojure/target.jar "$@"

compiled_starters/clojure/build.clj

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
(:gen-class)
33
(:require [clojure.tools.build.api :as b]))
44

5-
(def lib 'io.codecrafters.http-server)
6-
(def class-dir "/tmp/codecrafters-build-http-server-clojure/classes")
5+
(def lib 'io.codecrafters.sqlite)
6+
(def class-dir "/tmp/codecrafters-build-sqlite-clojure/classes")
77
(def basis (b/create-basis {:project "deps.edn"}))
8-
(def uber-file "/tmp/codecrafters-build-http-server-clojure/target.jar")
8+
(def uber-file "/tmp/codecrafters-build-sqlite-clojure/target.jar")
99

10-
(defn clean
11-
[_]
12-
(b/delete {:path "/tmp/codecrafters-build-http-server-clojure"}))
10+
(defn clean [_] (b/delete {:path "/tmp/codecrafters-build-sqlite-clojure"}))
1311

1412
(defn uber
1513
[_]
1614
(clean nil)
1715
(b/copy-dir {:src-dirs ["src"], :target-dir class-dir})
1816
(b/compile-clj
19-
{:basis basis, :ns-compile '[http-server.core], :class-dir class-dir})
17+
{:basis basis, :ns-compile '[sqlite.core], :class-dir class-dir})
2018
(b/uber {:class-dir class-dir,
2119
:uber-file uber-file,
2220
:basis basis,
23-
:main 'http-server.core}))
21+
:main 'sqlite.core}))
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
(ns sqlite.core
22
(:gen-class)
3-
(:require
4-
[clojure.java.io :as io]))
3+
(:require [clojure.java.io :as io]))
54

65
(defn lazy-byte-seq [filepath]
76
(let [is (io/input-stream filepath)
87
step (fn step [input-stream]
9-
(lazy-seq
10-
(let [byte-val (.read input-stream)]
11-
(when (not= byte-val -1)
12-
(cons byte-val (step input-stream))))))]
8+
(lazy-seq (let [byte-val (.read input-stream)]
9+
(when (not= byte-val -1)
10+
(cons byte-val (step input-stream))))))]
1311
(step is)))
1412

1513
(defn bytes-to-int [bytes]
16-
(reduce (fn [acc b] (+ (* acc 256) b)) 0 bytes))
14+
(reduce (fn [acc b] (+ (* acc 256) b))
15+
0
16+
bytes))
1717

1818
(defn -main [& args]
19-
;; You can use print statements as follows for debugging, they'll be visible when running tests.
19+
;; You can use print statements as follows for debugging, they'll be
20+
;; visible when running tests.
2021
(println "Logs from your program will appear here!")
21-
22-
;; Uncomment this block to pass the first stage
23-
;; (let [command (second args)]
24-
;; (case command
25-
;; ".dbinfo"
26-
;; (let [db-file-path (first args)
27-
;; contents (lazy-byte-seq db-file-path)
28-
;; page-size (bytes-to-int (take 2 (drop 16 contents)))]
29-
;; (println (str "database page size: " page-size)))))
30-
)
22+
;; Uncomment this block to pass the first stage
23+
;; (let [command (second args)]
24+
;; (case command
25+
;; ".dbinfo"
26+
;; (let [db-file-path (first args)
27+
;; contents (lazy-byte-seq db-file-path)
28+
;; page-size (bytes-to-int (take 2 (drop 16 contents)))]
29+
;; (println (str "database page size: " page-size)))))
30+
)

compiled_starters/clojure/your_program.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@
88

99
set -e # Exit early if any commands fail
1010

11+
# Copied from .codecrafters/compile.sh
12+
#
13+
# - Edit this to change how your program compiles locally
14+
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
15+
(
16+
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
17+
clj -T:build
18+
)
19+
1120
# Copied from .codecrafters/run.sh
1221
#
1322
# - Edit this to change how your program runs locally
1423
# - Edit .codecrafters/run.sh to change how your program runs remotely
15-
bb -m sqlite.core "$@"
24+
exec java -jar /tmp/codecrafters-build-sqlite-clojure/target.jar "$@"

solutions/clojure/01-dr6/code/.codecrafters/compile.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
# Learn more: https://codecrafters.io/program-interface
88

99
set -e # Exit on failure
10+
11+
clj -T:build

solutions/clojure/01-dr6/code/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
bb -m sqlite.core "$@"
11+
exec java -jar /tmp/codecrafters-build-sqlite-clojure/target.jar "$@"

solutions/clojure/01-dr6/code/build.clj

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
(:gen-class)
33
(:require [clojure.tools.build.api :as b]))
44

5-
(def lib 'io.codecrafters.http-server)
6-
(def class-dir "/tmp/codecrafters-build-http-server-clojure/classes")
5+
(def lib 'io.codecrafters.sqlite)
6+
(def class-dir "/tmp/codecrafters-build-sqlite-clojure/classes")
77
(def basis (b/create-basis {:project "deps.edn"}))
8-
(def uber-file "/tmp/codecrafters-build-http-server-clojure/target.jar")
8+
(def uber-file "/tmp/codecrafters-build-sqlite-clojure/target.jar")
99

10-
(defn clean
11-
[_]
12-
(b/delete {:path "/tmp/codecrafters-build-http-server-clojure"}))
10+
(defn clean [_] (b/delete {:path "/tmp/codecrafters-build-sqlite-clojure"}))
1311

1412
(defn uber
1513
[_]
1614
(clean nil)
1715
(b/copy-dir {:src-dirs ["src"], :target-dir class-dir})
1816
(b/compile-clj
19-
{:basis basis, :ns-compile '[http-server.core], :class-dir class-dir})
17+
{:basis basis, :ns-compile '[sqlite.core], :class-dir class-dir})
2018
(b/uber {:class-dir class-dir,
2119
:uber-file uber-file,
2220
:basis basis,
23-
:main 'http-server.core}))
21+
:main 'sqlite.core}))
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
(ns sqlite.core
22
(:gen-class)
3-
(:require
4-
[clojure.java.io :as io]))
3+
(:require [clojure.java.io :as io]))
54

65
(defn lazy-byte-seq [filepath]
76
(let [is (io/input-stream filepath)
87
step (fn step [input-stream]
9-
(lazy-seq
10-
(let [byte-val (.read input-stream)]
11-
(when (not= byte-val -1)
12-
(cons byte-val (step input-stream))))))]
8+
(lazy-seq (let [byte-val (.read input-stream)]
9+
(when (not= byte-val -1)
10+
(cons byte-val (step input-stream))))))]
1311
(step is)))
1412

1513
(defn bytes-to-int [bytes]
16-
(reduce (fn [acc b] (+ (* acc 256) b)) 0 bytes))
14+
(reduce (fn [acc b] (+ (* acc 256) b))
15+
0
16+
bytes))
1717

1818
(defn -main [& args]
19-
(let [command (second args)]
20-
(case command
21-
".dbinfo"
22-
(let [db-file-path (first args)
23-
contents (lazy-byte-seq db-file-path)
24-
page-size (bytes-to-int (take 2 (drop 16 contents)))]
25-
(println (str "database page size: " page-size)))))
26-
)
19+
(println "Logs from your program will appear here!")
20+
(let [command (second args)]
21+
(case command
22+
".dbinfo"
23+
(let [db-file-path (first args)
24+
contents (lazy-byte-seq db-file-path)
25+
page-size (bytes-to-int (take 2 (drop 16 contents)))]
26+
(println (str "database page size: " page-size)))))
27+
)

solutions/clojure/01-dr6/code/your_program.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@
88

99
set -e # Exit early if any commands fail
1010

11+
# Copied from .codecrafters/compile.sh
12+
#
13+
# - Edit this to change how your program compiles locally
14+
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
15+
(
16+
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
17+
clj -T:build
18+
)
19+
1120
# Copied from .codecrafters/run.sh
1221
#
1322
# - Edit this to change how your program runs locally
1423
# - Edit .codecrafters/run.sh to change how your program runs remotely
15-
bb -m sqlite.core "$@"
24+
exec java -jar /tmp/codecrafters-build-sqlite-clojure/target.jar "$@"

0 commit comments

Comments
 (0)