Skip to content

Commit 7c757ef

Browse files
committed
Make jpm configurable for environments like MinGW.
1 parent 2db7945 commit 7c757ef

File tree

6 files changed

+84
-14
lines changed

6 files changed

+84
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ All notable changes to this project will be documented in this file.
1010
- Remove the `tarray` module. The functionality of typed arrays will be moved to an external module
1111
that can be installed via `jpm`.
1212
- Add `from-pairs` to core.
13+
- Add `JPM_OS_WHICH` environment variable to jpm to allow changing auto-detection behavior.
14+
- The flychecker will consider any top-level calls of functions that start with `define-` to
15+
be safe to execute and execute them. This allows certain patterns (like spork/path) to be
16+
better processed by the flychecker.
1317

1418
## 1.15.5 - 2021-04-25
1519
- Add `declare-headers` to jpm.

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ See the examples directory for some example janet code.
234234
## Discussion
235235

236236
Feel free to ask questions and join the discussion on the [Janet Gitter Channel](https://gitter.im/janet-language/community).
237-
Alternatively, check out [the #janet channel on Freenode](https://webchat.freenode.net/)
237+
Gitter provides Matrix and irc bridges as well.
238238

239239
## FAQ
240240

@@ -246,8 +246,35 @@ will not. If your terminal does not support ANSI escape codes, run the REPL with
246246
the `-n` flag, which disables color output. You can also try the `-s` if further issues
247247
ensue.
248248

249-
## Why Janet
249+
### Where is (favorite feature from other language)?
250250

251-
Janet is named after the almost omniscient and friendly artificial being in [The Good Place](https://en.wikipedia.org/wiki/The_Good_Place).
251+
It may exist, it may not. If you want to propose major language features, go ahead and open an issue, but
252+
they will likely by closed as "will not implement". Often, such features make one usecase simpler at the expense
253+
of 5 others by making the language more complicated.
254+
255+
### Where is the example code?
256+
257+
In the examples directory.
258+
259+
### Is this a Clojure port?
260+
261+
No. It's similar to Clojure superficially because I like Lisps and I like the asthetics.
262+
Internally, Janet is not at all like Clojure.
263+
264+
### Are the immutable data structures (tuples and structs) implemented as hash tries?
252265

253-
<img src="https://raw.githubusercontent.com/janet-lang/janet/master/assets/janet-the-good-place.gif" alt="Janet logo" width="115px" align="left">
266+
No. They are immutable arrays and hash tables. Don't try and use them like Clojure's vectors
267+
and maps, instead they work well as table keys or other identifiers.
268+
269+
### Why can't we add (feature from Clojure) into the core?
270+
271+
Usually, one of a few reasons:
272+
- Often, it already exists in a different form and the Clojure port would be redundant.
273+
- Clojure programs often generate a lot of garbage and rely on the JVM to clean it up.
274+
Janet does not run on the JVM. We admittedly have a much more primitive GC.
275+
- We want to keep the Janet core small. With Lisps, usually a feature can be added as a library
276+
without feeling "bolted on", especially when compared to ALGOL like languages.
277+
278+
## Why is it called "Janet"?
279+
280+
Janet is named after the almost omniscient and friendly artificial being in [The Good Place](https://en.wikipedia.org/wiki/The_Good_Place).

assets/janet-the-good-place.gif

-109 KB
Binary file not shown.

jpm

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66
# Basic Path Settings
77
#
88

9-
# Windows is the OS outlier
10-
(def- is-win (= (os/which) :windows))
11-
(def- is-mac (= (os/which) :macos))
12-
(def- sep (if is-win "\\" "/"))
13-
(def- objext (if is-win ".obj" ".o"))
14-
(def- modext (if is-win ".dll" ".so"))
15-
(def- statext (if is-win ".static.lib" ".a"))
16-
(def- absprefix (if is-win "C:\\" "/"))
9+
# Allow changing the behavior via an environment variable
10+
(def- host-os (keyword (string/ascii-lower (os/getenv "JPM_OS_WHICH" (os/which)))))
11+
(defn- define-utils
12+
[]
13+
(def is-win (= host-os :windows))
14+
(defglobal 'is-win is-win)
15+
(defglobal 'is-mac (= host-os :macos))
16+
(def sep (if is-win "\\" "/"))
17+
(defglobal 'sep sep)
18+
(defglobal 'objext (if is-win ".obj" ".o"))
19+
(defglobal 'modext (if is-win ".dll" ".so"))
20+
(defglobal 'statext (if is-win ".static.lib" ".a"))
21+
(defglobal 'absprefix (if is-win "C:\\" "/")))
22+
23+
(define-utils)
1724

1825
#
1926
# Defaults
@@ -58,6 +65,9 @@
5865

5966
###END###
6067

68+
# Redefine utils in case the above section is overriden on some installs.
69+
(define-utils)
70+
6171
(compwhen (not (dyn 'extra-lflags))
6272
(def- extra-lflags []))
6373

@@ -370,7 +380,7 @@
370380
# flags needed for the janet binary and compiling standalone
371381
# executables.
372382
(def janet-lflags
373-
(case (os/which)
383+
(case host-os
374384
:macos ["-ldl" "-lm" ;thread-flags ;extra-lflags]
375385
:windows [;thread-flags ;extra-lflags]
376386
:linux ["-lm" "-ldl" "-lrt" ;thread-flags ;extra-lflags]

jpm.1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,30 @@ An optional path to a git executable to use to clone git dependencies. By defaul
269269
if you have a normal install of git.
270270
.RE
271271

272+
.B JPM_OS_WHICH
273+
.RS
274+
Use this option to override the C compiler and build system auto-detection for the host operating system. For example, set this
275+
environment variable to "posix" to make sure that on platforms like MinGW, you will use GCC instead of MSVC. On most platforms, users will not need to
276+
set this environment variable. Set this to one of the following
277+
strings:
278+
.IP
279+
\- windows
280+
.IP
281+
\- macos
282+
.IP
283+
\- linux
284+
.IP
285+
\- freebsd
286+
.IP
287+
\- openbsd
288+
.IP
289+
\- netbsd
290+
.IP
291+
\- bsd
292+
.IP
293+
\- posix
294+
.RE
295+
296+
272297
.SH AUTHOR
273298
Written by Calvin Rose <[email protected]>

src/boot/boot.janet

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3315,7 +3315,11 @@
33153315
[thunk source env where]
33163316
(when (tuple? source)
33173317
(def head (source 0))
3318-
(def safe-check (safe-forms head))
3318+
(def safe-check
3319+
(or
3320+
(safe-forms head)
3321+
(if (symbol? head)
3322+
(if (string/has-prefix? "define-" head) is-safe-def))))
33193323
(cond
33203324
# Sometimes safe form
33213325
(function? safe-check)

0 commit comments

Comments
 (0)