Skip to content

Commit 19a3221

Browse files
committed
log loaded ini files
1 parent 2275d7f commit 19a3221

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/defold/focus.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
(:require
33
[babashka.fs :as fs]
44
[defold.constants :refer [base-class-name]]
5-
[defold.mini :as mini]
6-
[defold.utils :refer [command-exists? determine-os project-id run-shell]]
5+
[defold.utils :refer [command-exists? determine-os load-ini project-id
6+
run-shell]]
77
[taoensso.timbre :as log]))
88

99
(defn switch-focus [type name]
@@ -97,7 +97,7 @@
9797
(assert (some? root-dir))
9898
(let [game-project (fs/path root-dir "game.project")
9999
_ (assert (fs/exists? game-project))
100-
config (mini/parse-string (slurp (str game-project)))
100+
config (load-ini game-project)
101101
title (get-in config ["project" "title"])
102102
_ (assert (some? title))]
103103
(case (determine-os)

src/defold/mini.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@
137137
(let [k value
138138
tokens (expect-token (rest tokens) :equal)
139139
[v tokens] (case (peek-token tokens)
140-
:ident (consume-token tokens)
141-
:string (consume-token tokens)
142-
(parser-error (format "Unexpected token: %s" (ffirst tokens)) (last (first tokens))))
140+
:ident (consume-token tokens)
141+
:string (consume-token tokens)
142+
:newline [nil tokens]
143+
(parser-error (format "Unexpected token (line): %s" (ffirst tokens)) (last (first tokens))))
143144
tokens (expect-token tokens [:newline :eof])]
144145
(if current-section
145146
(recur tokens (assoc-in result (concat current-section [k]) v) current-section nil)

src/defold/project.clj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
(:require
33
[babashka.fs :as fs]
44
[clojure.string :as string]
5-
[defold.mini :as mini]
65
[defold.script-api-compiler :as script-api-compiler]
7-
[defold.utils :as utils]
6+
[defold.utils :as utils :refer [load-ini]]
87
[taoensso.timbre :as log])
98
(:import
109
[java.nio.charset StandardCharsets]
@@ -55,7 +54,7 @@
5554
(let [game-projects (find-game-project-files in-dir)]
5655
(flatten (map (fn [game-project]
5756
(let [project-dir (fs/parent game-project)
58-
config (mini/parse-string (slurp (str game-project)))
57+
config (load-ini game-project)
5958
libs (get-in config ["library" "include_dirs"])]
6059
(map #(str (fs/path project-dir %)) (string/split libs #","))))
6160
game-projects))))
@@ -87,7 +86,7 @@
8786
(fs/delete-tree deps-dir)
8887
(fs/delete-tree cache-dir))
8988
(let [ident (make-ident game-project-file)
90-
ini (mini/parse-string (slurp game-project-file))
89+
ini (load-ini game-project-file)
9190
deps (get-dependencies ini)
9291
deps-dir (deps-dir ident)
9392
cache-dir (cache-dir ident)]

src/defold/utils.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[babashka.process :refer [shell]]
66
[clojure.java.io :as io]
77
[clojure.string :as string]
8+
[defold.mini :as mini]
89
[taoensso.timbre :as log]))
910

1011
(defn command-exists? [cmd]
@@ -129,3 +130,7 @@
129130

130131
(defn project-id [project-root]
131132
(subs (sha3 project-root) 0 8))
133+
134+
(defn load-ini [path]
135+
(log/debug "Loading .ini file" (str path))
136+
(mini/parse-string (slurp (str path))))

0 commit comments

Comments
 (0)