Skip to content
This repository was archived by the owner on Sep 13, 2019. It is now read-only.

Commit 3905680

Browse files
committed
expander & io: reduce dependencies
1 parent 385a76c commit 3905680

File tree

11 files changed

+1560
-64
lines changed

11 files changed

+1560
-64
lines changed

racket/src/cs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ regexp-rktl:
140140
io-demo: $(BUILDDIR)io.so
141141
$(SCHEME) $(IO_DEPS) $(BUILDDIR)io.so demo/io.ss
142142

143-
$(BUILDDIR)io.so: $(BUILDDIR)compiled/io.scm io.sls $(IO_DEPS) $(BUILDDIR)compiled/rktio.rktl $(COMPILE_FILE_DEPS)
143+
$(BUILDDIR)io.so: $(BUILDDIR)compiled/io.scm io.sls $(IO_DEPS) ../rktio/rktio.rktl $(COMPILE_FILE_DEPS)
144144
$(COMPILE_FILE) io.sls $(IO_DEPS)
145145

146146
$(BUILDDIR)compiled/io.scm: $(BUILDDIR)compiled/io.rktl $(CONVERT_DEPS)

racket/src/cs/README.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ Requirements
2626

2727
By default, `make` will use the enclosing Racket build. Go back to
2828
the root of this repository/distribution and build so that at least
29-
the "compiler-lib" and "parser-tools-lib" packages are installed,
30-
either with just `make` (for a full build) or with
29+
the "compiler-lib" package is installed, either with just `make`
30+
(for a full build) or with
3131

32-
make PKGS="compiler-lib parser-tools-lib"
32+
make PKGS="compiler-lib"
33+
34+
Note that if you build as described in "./c/README.txt", then you
35+
don't need the "compiler-lib" package.
3336

3437
If you'd like to use an existing installation of Racket, instead,
3538
you can use `make RACKET=...` to set the command for `racket`.

racket/src/cs/c/Makefile.in

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ RKTIO_RACKET = $(RACKET) $(SETUP_BOOT) '(GENERATED_RKTIO_RKTL)' $(builddir)/rkti
5858
CONVERT_RACKET = $(RACKET) $(SETUP_BOOT) convert $(builddir)/convert.d
5959

6060
racket-so:
61-
$(MAKE) bounce TARGET=build-racket-so RKTIO_LIBRARY_TARGET=skip
61+
$(MAKE) bounce TARGET=build-racket-so
6262

6363
RACKET_SO_ENV = @CONFIGURE_RACKET_SO_COMPILE@ env COMPILED_SCM_DIR="$(builddir)/compiled/"
6464

6565
build-racket-so:
6666
$(MAKE) expander
6767
$(MAKE) thread
68-
$(MAKE) io-rktio
6968
$(MAKE) io
7069
$(MAKE) regexp
7170
$(MAKE) schemify
@@ -85,12 +84,8 @@ expander:
8584
thread:
8685
cd $(srcdir)/../../thread && $(MAKE) $(builddir)/compiled/thread.rktl RACKET="$(BOOTSTRAP_RACKET)" BUILDDIR="$(builddir)/" DIRECT_DEP=""
8786

88-
io-rktio:
89-
cd $(srcdir)/../../io && $(MAKE) $(builddir)/compiled/rktio.rktl RACKET="$(BOOTSTRAP_RACKET)" BUILDDIR="$(builddir)/" DIRECT_DEP="" RKTIO_LIBRARY_TARGET=skip
90-
91-
RKTIO_ENV = env RKTIO_RKTL_DIR="$(builddir)/compiled/"
9287
io:
93-
cd $(srcdir)/../../io && $(RKTIO_ENV) $(MAKE) $(builddir)/compiled/io.rktl RACKET="$(BOOTSTRAP_RACKET)" BUILDDIR="$(builddir)/" DIRECT_DEP=""
88+
cd $(srcdir)/../../io && $(MAKE) $(builddir)/compiled/io.rktl RACKET="$(BOOTSTRAP_RACKET)" BUILDDIR="$(builddir)/" DIRECT_DEP=""
9489

9590
regexp:
9691
cd $(srcdir)/../../regexp && $(MAKE) $(builddir)/compiled/regexp.rktl RACKET="$(BOOTSTRAP_RACKET)" BUILDDIR="$(builddir)/" DIRECT_DEP=""
@@ -176,12 +171,9 @@ main.o: $(MAIN_DEPS)
176171
grmain.o: $(srcdir)/grmain.c $(MAIN_DEPS) $(srcdir)/../../start/gui_filter.inc
177172
$(CC) $(CFLAGS) $(DEF_C_DIRS) -c -o grmain.o $(srcdir)/grmain.c
178173

179-
boot.o: $(srcdir)/boot.c rktio.inc $(srcdir)/boot.h
174+
boot.o: $(srcdir)/boot.c $(srcdir)/../../rktio/rktio.inc $(srcdir)/boot.h
180175
$(CC) $(CFLAGS) -c -o boot.o $(srcdir)/boot.c
181176

182-
rktio.inc: $(srcdir)/../../rktio/parse.rkt $(srcdir)/../../rktio/rktio.h
183-
$(RACKET) $(srcdir)/../../rktio/parse.rkt -c -o rktio.inc $(srcdir)/../../rktio/rktio.h
184-
185177
starter: $(srcdir)/../../start/ustart.c
186178
$(CC) $(CFLAGS) -o starter $(srcdir)/../../start/ustart.c
187179

racket/src/cs/io.sls

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828

2929
;; ----------------------------------------
3030

31-
(include "include.ss")
32-
33-
;; ----------------------------------------
34-
3531
(module (|#%rktio-instance| ptr->address)
3632
(meta define (convert-type t)
3733
(syntax-case t (ref *ref rktio_bool_t rktio_const_string_t)
@@ -171,7 +167,7 @@
171167
(define (rktio-lookup name)
172168
(foreign-entry (symbol->string name)))
173169

174-
(include-generated "rktio.rktl")
170+
(include "../rktio/rktio.rktl")
175171

176172
(define (rktio_filesize_ref fs)
177173
(ftype-ref rktio_filesize_t () (make-ftype-pointer rktio_filesize_t (ptr->address fs))))
@@ -331,7 +327,7 @@
331327
'rktio_do_install_os_signal_handler rktio_do_install_os_signal_handler
332328
'rktio_get_ctl_c_handler rktio_get_ctl_c_handler]
333329
form ...)]))
334-
(include-generated "rktio.rktl"))))
330+
(include "../rktio/rktio.rktl"))))
335331

336332
;; ----------------------------------------
337333

@@ -385,6 +381,7 @@
385381
[(|#%rktio|) |#%rktio-instance|]
386382
[else #f]))
387383

384+
(include "include.ss")
388385
(include-generated "io.scm")
389386

390387
;; Initialize:

racket/src/expander/extract/decompile.rkt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#lang racket/base
22
(require '#%linklet
33
racket/pretty
4-
compiler/zo-parse
5-
compiler/decompile
64
"../run/status.rkt")
75

86
(provide compile-and-decompile)
@@ -19,8 +17,11 @@
1917
(write (hash->linklet-bundle (hasheq 0 linklet)) o)
2018

2119
(define i (open-input-bytes (get-output-bytes o)))
22-
(define zo (zo-parse i))
23-
(define decompiled-expr (decompile zo))
20+
21+
;; Dynamically load decompiler, so that it's not otherwise a
22+
;; dependency for running the expander-flattener
23+
(define zo ((dynamic-require 'compiler/zo-parse 'zo-parse) i))
24+
(define decompiled-expr ((dynamic-require 'compiler/decompile 'decompile) zo))
2425

2526
(call-with-output-file*
2627
print-extracted-to

racket/src/io/Makefile

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
RACKET = ../../bin/racket
55
RACO = $(RACKET) -N raco -l- raco
66

7-
# Set to `skip` if the stand-alone rktio
8-
# library is not needed
9-
RKTIO_LIBRARY_TARGET = rktio-library
10-
117
# Ignoring functions from `#%read` works beause they won't appear in
128
# the simplified expansion, and declaring "collect.rkt" pure works
139
# around a limitation of the flattener:
@@ -16,11 +12,11 @@ IGNORE = ++knot read - ++pure ../../collects/racket/private/collect.rkt
1612
# `$(GENERATED_RKTL)` appears as a dependency target in "$(BUILDDIR)expander.d"
1713
GENERATED_RKTL = $(BUILDDIR)compiled/io.rktl
1814

19-
io-src: $(BUILDDIR)compiled/rktio.rktl
15+
io-src: ../build/so-rktio/Makefile
2016
$(RACO) make ../expander/bootstrap-run.rkt
2117
$(MAKE) $(GENERATED_RKTL)
2218

23-
DIRECT_DEP = ../expander/compiled/bootstrap-run_rkt.zo compiled/rktio.rktl
19+
DIRECT_DEP = ../expander/compiled/bootstrap-run_rkt.zo ../rktio/rktio.rktl
2420
SAVE_DEPS = --depends $(GENERATED_RKTL) $(BUILDDIR)compiled/io.d
2521

2622
$(GENERATED_RKTL): $(DIRECT_DEP)
@@ -38,28 +34,14 @@ demo-thread: compiled/rktio.rktl
3834
$(RACO) make demo-thread.rkt
3935
$(RACKET) demo-thread.rkt
4036

41-
GENERATED_RKTIO_RKTL = $(BUILDDIR)compiled/rktio.rktl
42-
43-
$(GENERATED_RKTIO_RKTL): ../rktio/parse.rkt ../rktio/rktio.h
44-
$(MAKE) $(RKTIO_LIBRARY_TARGET)
45-
mkdir -p $(BUILDDIR)compiled
46-
$(RACKET) ../rktio/parse.rkt -o $(GENERATED_RKTIO_RKTL) ../rktio/rktio.h
47-
48-
-include $(BUILDDIR)compiled/rktio.d
4937

50-
skip:
51-
echo Not building stand-along rktio
52-
53-
rktio-library:
38+
../build/so-rktio/Makefile: ../rktio/configure ../rktio/Makefile.in ../rktio/rktio_config.h.in
39+
mkdir -p ../build/so-rktio
5440
$(MAKE) build-rktio RACKET="`$(RACKET) ../cs/absify.rkt --exec $(RACKET)`" PREFIX="`$(RACKET) ../cs/absify.rkt ../..`"
5541

5642
build-rktio:
57-
$(MAKE) ../build/so-rktio/Makefile
58-
cd ../build/so-rktio; make install-shared-object
59-
60-
../build/so-rktio/Makefile: ../rktio/configure ../rktio/Makefile.in ../rktio/rktio_config.h.in
61-
mkdir -p ../build/so-rktio
6243
cd ../build/so-rktio; ../../rktio/configure --enable-standalone --prefix=$(PREFIX)
44+
cd ../build/so-rktio; make install-shared-object
6345

6446

6547
.PHONY: io-src demo rktio build-rktio

racket/src/io/host/rktio.rkt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,7 @@
3838
(define-syntax-rule (define-function/errno+step _ _ _ name . _)
3939
(define-function () #f name))
4040

41-
;; Read "rktio.rktl" from a directory that can be
42-
;; configured through an environment variable(!)
43-
(define-syntax (include-rktio stx)
44-
(define dir (getenv "RKTIO_RKTL_DIR"))
45-
(with-syntax ([path (if dir
46-
(datum->syntax
47-
#'here
48-
`(file ,(string-append dir "rktio.rktl")))
49-
#'"../compiled/rktio.rktl")])
50-
#`(include-at/relative-to #,stx #,stx path)))
51-
(include-rktio)
41+
(include "../../rktio/rktio.rktl")
5242

5343
(define-function () #f rktio_filesize_ref)
5444
(define-function () #f rktio_timestamp_ref)

racket/src/rktio/Makefile.in

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ clean:
136136

137137
# ----------------------------------------
138138

139+
# To rebuild the S-expression form of "rktio.h"
140+
141+
rktio-rktl rktio-inc:
142+
$(MAKE) $(srcdir)/rktio.rktl
143+
$(MAKE) $(srcdir)/rktio.inc
144+
145+
$(srcdir)/rktio.rktl: $(srcdir)/rktio.h $(srcdir)/parse.rkt
146+
$(RACKET) $(srcdir)/parse.rkt -o $(srcdir)/rktio.rktl $(srcdir)/rktio.h
147+
148+
$(srcdir)/rktio.inc: $(srcdir)/rktio.h $(srcdir)/parse.rkt
149+
$(RACKET) $(srcdir)/parse.rkt -c -o $(srcdir)/rktio.inc $(srcdir)/rktio.h
150+
151+
# ----------------------------------------
152+
139153
@HIDE_NOT_STANDALONE@librktio:
140154
$(MAKE) librktio.@LIBSFX@
141155

@@ -148,7 +162,3 @@ install-shared-object:
148162
$(MAKE) librktio.@LIBSFX@
149163
mkdir -p "$(DESTDIR)$(libdir)/"
150164
$(ICP_LIB) librktio.@LIBSFX@ "$(DESTDIR)$(libdir)/librktio.@LIBSFX@"
151-
152-
# Builds an S-expression form of "rktio.h"
153-
rktio.rktl: $(srcdir)/rktio.h $(srcdir)/parse.rkt
154-
$(RACKET) $(srcdir)/parse.rkt -o rktio.rktl $(srcdir)/rktio.h

racket/src/rktio/parse.rkt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@
313313
(if output-file
314314
(with-output-to-file output-file
315315
#:exists 'truncate
316-
(lambda () (show-content)))
316+
(lambda ()
317+
(cond
318+
[c-mode?
319+
(printf "/* Extracted from rktio.h by rktio/parse.rkt */\n")]
320+
[else
321+
(printf ";; Extracted from rktio.h by rktio/parse.rkt\n")])
322+
(show-content)))
317323
(show-content))
318324

0 commit comments

Comments
 (0)