• Stars
    star
    262
  • Rank 156,136 (Top 4 %)
  • Language
    C
  • License
    Other
  • Created over 2 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tiny Racket for scripting

This is a mirror of the Zuo sources in the racket/src/zuo directory of the Racket repository.

Zuo: A Tiny Racket for Scripting

You should use Racket to write scripts. But what if you need something much smaller than Racket for some reason — or what if you're trying to script a build of Racket itself? Zuo is a tiny Racket with primitives for dealing with files and running processes, and it comes with a make-like embedded DSL.

Zuo is a Racket variant in the sense that program files start with #lang, and the module path after #lang determines the parsing and expansion of the file content. That's how the make-like DSL is defined, and even the base Zuo language is defined by layers of #langs. One of the early layers implements macros.

Some Example Scripts

See local/hello.zuo, local/tree.zuo, local/image.zuo, and build.zuo.

Building and Running Zuo

Compile zuo.c with a C compiler. No additional files are needed, other than system and C library headers. No compiler flags should be needed, although flags like -o zuo or -O2 are a good idea.

You can also use configure, make, and make install, where make targets mostly invoke a Zuo script after compiling zuo.c. If you don't use configure but compile to zuo in the current directory, then ./zuo build.zuo and ./zuo build.zuo install (omit the ./ on Windows) will do the same thing as make and make install with a default configuration.

The Zuo executable runs only modules. If you run Zuo with no command-line arguments, then it loads main.zuo. Use the -c flag to provide module text as an argument. Otherwise, the first argument to Zuo is a file to run or a directory containing a main.zuo to run, and additional arguments are delivered to that Zuo program via the runtime-env procedure. Running the command ./zuo build install, for example, runs the build/main.zuo program with the argument install. Whatever initial script is run, if it has a main submodule, that submodule is also run.

Library Modules and Startup Performance

Except for the built-in zuo/kernel language module, Zuo finds languages and modules through a collection of libraries. By default, Zuo looks for a directory lib relative to the executable as the root of the library-collection tree. You can supply an alternate collection path with the -X command-line flag.

You can also create an instance of Zuo with a set of libraries embedded as a heap image. Embedding a heap image has two advantages:

  • No extra directory of library modules is necessary.

  • Zuo can start especially quickly, competitive with the fastest command-line programs.

The local/image.zuo script generates a .c file that is a copy of zuo.c plus embedded modules. By default, the zuo module and its dependencies are included, but you can specify others with ++lib. In addition, the default collection-root path is disabled in the generated copy, unless you supply --keep-collects to local/image.zuo.

When you use configure and make or ./zuo build.zuo, the default build target creates a to-run/zuo that embeds the zuo library, as well as a to-install/zuo that has the right internal path to find other libraries after make install or ./zuo build.zuo install.

You can use heap images without embedding. The dump-heap-and-exit Zuo kernel permitive creates a heap image, and a -B or --boot command-line flag for Zuo uses the given boot image on startup. You can also embed an image created with dump-image-and-exit by using local/image.zuo with the --image flag.

A boot image is machine-independent, whether in a stand-alone file or embedded in .c source.

Cross Compiling

If you use ./configure --host=... to cross compile, then you will also need to add something like CC_FOR_BUILD=cc as a ./configure argument to specify the compiler for a zuo to use on the build machine. If necessary, you can also specify CFLAGS_FOR_BUILD, LDFLAGS_FOR_BUILD, and/or LIBS_FOR_BUILD.

Embedding Zuo in Another Application

Zuo can be embedded in a larger application, with or without an embedded boot image. To support embedding, compile zuo.c or the output of local/image.zuo with the ZUO_EMBEDDED preprocessor macro defined (to anything); the zuo.h header will be used in that case, and zuo.h should also be used by the embedding application. Documentation for the embedding API is provided as comments within zuo.h.

More Information

Install the zuo-doc directory as a package in Racket to render the documentation there, or see docs.racket-lang.org.

More Repositories

1

racket

The Racket repository
Racket
4,789
star
2

typed-racket

Typed Racket
Racket
525
star
3

drracket

DrRacket, IDE for Racket
Racket
453
star
4

rhombus

Rhombus programming language
Racket
333
star
5

scribble

Racket
200
star
6

racket7

Racket
169
star
7

htdp

Racket
91
star
8

redex

Racket
91
star
9

web-server

Racket
90
star
10

realm

Racket
68
star
11

racket-lang-org

Racket
67
star
12

gui

Racket
63
star
13

docker

Docker images for various Racket versions
Shell
61
star
14

games

Racket
46
star
15

datalog

Racket
43
star
16

plot

Racket
40
star
17

eopl

Racket
37
star
18

slideshow

Racket
34
star
19

math

Racket
34
star
20

db

Racket
21
star
21

2d

2d syntax
Racket
19
star
22

frtime

Racket
18
star
23

rackunit

Racket
18
star
24

honu

Racket
18
star
25

draw

Racket
17
star
26

data

Racket
16
star
27

racklog

Racket
16
star
28

pict

Racket
15
star
29

swindle

Racket
12
star
30

mzscheme

Racket
12
star
31

libs

Racket libraries
Racket
12
star
32

algol60

Racket
11
star
33

parser-tools

Racket
11
star
34

srfi

HTML
10
star
35

handin

Handin server and client
Racket
10
star
36

expeditor

Racket
9
star
37

unix-socket

Racket
9
star
38

racket-pkg-website

A frontend for the Racket Package Catalog.
Racket
9
star
39

remote-shell

Racket
9
star
40

syntax-color

Racket
8
star
41

macro-debugger

Racket
8
star
42

picturing-programs

Racket
8
star
43

errortrace

Racket
8
star
44

plai

Racket
8
star
45

old-plt

The very old history of Racket
Scheme
8
star
46

xrepl

Racket
7
star
47

r5rs

HTML
7
star
48

pkg-index

CSS
7
star
49

sgl

Racket
7
star
50

lazy

Racket
7
star
51

raco-cross

Racket
7
star
52

distro-build

Racket
7
star
53

r6rs

HTML
6
star
54

string-constants

Racket
6
star
55

shell-completion

Shell
6
star
56

racket-ci

Repo for organizing CI efforts
6
star
57

plt-service-monitor

Racket
5
star
58

pkg-build

Racket
5
star
59

snip

Racket
5
star
60

images

Racket
5
star
61

drdr

Racket
5
star
62

compatibility

Racket
5
star
63

make

Racket
5
star
64

readline

Racket
5
star
65

compiler

THIS REPOSITORY IS OBSELETE
Racket
5
star
66

deinprogramm

Racket
4
star
67

plt-build-plot

Racket
4
star
68

release-catalog

Catalog for Racket release candiate and final release builds
Racket
4
star
69

preprocessor

Racket
3
star
70

distributed-places

Racket
3
star
71

future-visualizer

Racket
3
star
72

option-contract

Racket
3
star
73

plt-web

CSS
3
star
74

simple-tree-text-markup

Racket
3
star
75

pb

3
star
76

sandbox-lib

Racket
3
star
77

icons

Racket
2
star
78

scheme-lib

Racket
2
star
79

planet

Racket
2
star
80

wxme

Racket
2
star
81

ds-store

Racket
2
star
82

trace

Racket
2
star
83

slatex

Racket
2
star
84

pict-snip

Racket
2
star
85

readline-gpl

Racket
2
star
86

contract-profile

Racket
2
star
87

sasl

Racket
2
star
88

gui-pkg-manager

Racket
2
star
89

gnats-bugs

Archived data from bugs.racket-lang.org
2
star
90

class-iop

Racket
2
star
91

cext-lib

Racket
2
star
92

infrastructure-userdb

Racket
2
star
93

unstable

Racket
2
star
94

main-distribution

Racket
2
star
95

pkg-push

Racket
2
star
96

profile

Racket
1
star
97

serialize-cstruct-lib

Racket
1
star
98

unstable-debug-lib

Racket
1
star
99

pcps-test

Tests for Jean-Paul Roy's book
Scheme
1
star
100

unstable-redex

Racket
1
star