Skip to content

Commit d0eea00

Browse files
committed
Page 0.24.1
- NPScript has been renamed to "Page" - All documentation for builtins has been moved into docstrings - The build system now uses NimScript - 'import' now uses `/` intead of `.` as a path separator - The project dependancies are now stored locally
1 parent c3bee61 commit d0eea00

36 files changed

Lines changed: 798 additions & 684 deletions

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[*.{nim,nims,nps,c,cc,h,hh}]
1+
[*.{nim,nims,nps,pg,c,cc,h,hh}]
22
indent_style = space
33
indent_size = 2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ npscript
55
commsg.txt
66
build/
77
out/
8+
bin/
89
dist/
910
nimbledeps/

build.nims

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#! /usr/bin/env nim
2+
3+
import std/[
4+
os,
5+
strformat,
6+
macros,
7+
strutils
8+
]
9+
10+
const
11+
appname = "page"
12+
bindir = "bin"
13+
distdir = "dist"
14+
nimc = "nim c"
15+
16+
17+
proc cmd(str: string) =
18+
echo "Running `", str, "`"
19+
exec str
20+
21+
proc getPack(targetpair: string): (string, proc()) =
22+
let outpath = bindir / targetpair
23+
24+
return (
25+
outpath / (if "windows" in targetpair: appname & ".exe" else: appname),
26+
proc() =
27+
cmd fmt"cp -R {outpath} ."
28+
29+
cmd fmt"zip -r {targetpair} {targetpair}"
30+
31+
cmd fmt"mv {targetpair}.zip {distdir}"
32+
33+
cmd fmt"rm -rf {targetpair}"
34+
)
35+
36+
37+
type Cmd = ref object
38+
buf: string
39+
40+
proc addf(self: Cmd, name: string) =
41+
self.buf &= " "
42+
43+
if name.len == 1:
44+
self.buf &= "-"
45+
else:
46+
self.buf &= "--"
47+
48+
self.buf &= name
49+
50+
proc addf(self: Cmd, name, value: string, quoted: bool = false) =
51+
self.addf(name)
52+
self.buf &= ":"
53+
self.buf &= (if quoted: "\"" & value & "\"" else: value)
54+
55+
macro addd(buf, name: untyped): untyped =
56+
result = newCall(ident"addf", buf, newLit("define"), name.toStrLit)
57+
58+
proc addp(self: Cmd, pkg: string) =
59+
self.addf "p", "nimbledeps" / "pkgs2" / pkg, true
60+
61+
proc addExtras(self: Cmd) =
62+
when not defined(nohttp):
63+
self.addd ssl
64+
self.addp "nargparse-1.0.0-d77b6d27d997463cb62f2067272cddcc7d82de87"
65+
self.addp "noise-0.1.10-c0cbecd0917a5c13cab331cb959a5280acd3401e"
66+
self.addp "regex-0.26.3-4d24e7d7441137cd202e16f2359a5807ddbdc31f"
67+
self.addp "unicodedb-0.13.2-739102d885d99bb4571b1955f5f12aee423c935b"
68+
69+
proc run(self: Cmd) =
70+
self.addExtras()
71+
self.buf &= " src" / "page.nim"
72+
cmd self.buf
73+
74+
75+
let paramc = paramCount() - 1
76+
77+
if not dirExists(distdir):
78+
mkdir distdir
79+
80+
81+
if paramc == 0:
82+
let buf = Cmd(buf: nimc)
83+
buf.addd debug
84+
buf.addf "out", bindir / "page"
85+
buf.run()
86+
else:
87+
let cmd = paramStr(2)
88+
89+
case cmd
90+
of "host":
91+
let buf = Cmd(buf: nimc)
92+
buf.addd release
93+
buf.addf "forceBuild", "on"
94+
95+
let (exepath, _) = getPack("host")
96+
97+
buf.addf("out", exepath)
98+
99+
buf.run()
100+
of "macos":
101+
let buf = Cmd(buf: nimc)
102+
buf.addd release
103+
buf.addf "out", bindir / "host" / "page"
104+
buf.addf "cc", "clang"
105+
buf.addf "clang.exe", "clang"
106+
buf.addf "clang.linkerexe", "clang"
107+
buf.addf "forceBuild", "on"
108+
buf.addf "os", "macosx"
109+
buf.addf "cpu", "arm64"
110+
111+
let (exepath, pack) = getPack("aarch64-macos")
112+
113+
buf.addf("out", exepath)
114+
115+
buf.run()
116+
pack()
117+
of "some":
118+
let targets = @[
119+
("linux", @[
120+
("amd64", "x86_64-linux-gnu"),
121+
("i386", "x86-linux-gnu"),
122+
("arm64", "aarch64-linux-gnu"),
123+
("amd64", "x86_64-linux-musl"),
124+
("i386", "x86-linux-musl"),
125+
("arm64", "aarch64-linux-musl")
126+
]),
127+
("windows", @[
128+
("amd64", "x86_64-windows"),
129+
("i386", "x86-windows")
130+
])
131+
]
132+
133+
for (os, pairs) in targets:
134+
for (cpu, triple) in pairs:
135+
let buf = Cmd(buf: nimc)
136+
buf.addd release
137+
buf.addf "cc", "clang"
138+
buf.addf "clang.exe", "zigcc"
139+
buf.addf "clang.linkerexe", "zigcc"
140+
buf.addf "passC", fmt"-target {triple}", true
141+
buf.addf "passL", fmt"-target {triple}", true
142+
buf.addf "os", os
143+
buf.addf "cpu", cpu
144+
buf.addf "forceBuild", "on"
145+
146+
let (exepath, pack) = getPack(triple)
147+
148+
buf.addf("out", exepath)
149+
150+
buf.run()
151+
pack()
152+
else:
153+
echo fmt"Unknown subcommand '{cmd}'"
154+
quit 1

build.sh

Lines changed: 0 additions & 202 deletions
This file was deleted.

contrib.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
## Code of conduct
44

5-
Basically, be nice to everyone and use common sense.
5+
Basically, be polite to everyone and use common sense.
66

77
## Repository structure
88

99
- `examples/` - the language examples; just various snippets I wrote to show off the language.
1010
- `out/`, `dist/` - the binary output folders, these contains the resulting executables and the zip files created from them, respectively; these should **always** be gitignored.
1111
- `src/builtins.nim` - the builtin functions that are always available without importing.
12-
- `src/builtinlibs/` - the internal libraries that come built into NPScript, such as `strings` and `http`.
12+
- `src/builtinlibs/` - the internal libraries that come built into Page, such as `strings` and `http`.
1313
- `src/valueimpls` - the implementations for the individual value objects, which get `include`'d into `src/values.nim`; this folder may get removed in the future, see item No. 1 of [todo.md](/todo.md)
14-
- `src/std/` - the parts of the standard library implementated in NPScript that are written to `~/.npscript/std/`.
14+
- `src/std/` - the parts of the standard library implementated in Page that are written to `~/.page/std/`.
1515
- `src/data/` - miscellaneous data that gets included into the binary at compile-time.
1616

1717
## Code styling
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)