Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions bootstrap.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,29 @@
set -Eeuo pipefail


(cd bootstrap && go build && rm -f bootstrap.peg.go)
# Clean the file produced by ./bootstrap
rm -f bootstrap/bootstrap.peg.go


cd cmd/peg-bootstrap

# Build peg0
./../../bootstrap/bootstrap
go build -tags bootstrap -o peg0
rm -f bootstrap.peg.go
# Remove artefacts from a previous incomplete build
rm -f bootstrap.peg.go peg[123].peg.go peg-bootstrap.peg.go
# Remove binaries produced by previous versions of the build
rm -f peg[0123] peg-bootstrap

# Build peg1
./peg0 < bootstrap.peg > peg1.peg.go
go build -tags bootstrap -o peg1
rm -f peg1.peg.go
go run ../../bootstrap
go run -tags bootstrap main.go bootstrap.peg.go < bootstrap.peg > peg1.peg.go
go run -tags bootstrap main.go peg1.peg.go < peg.bootstrap.peg > peg2.peg.go
go run -tags bootstrap main.go peg2.peg.go < ../../peg.peg > peg3.peg.go
go run -tags bootstrap main.go peg3.peg.go < ../../peg.peg > peg-bootstrap.peg.go
go run -tags bootstrap main.go peg-bootstrap.peg.go < ../../peg.peg > ../../peg.peg.go

# Build peg2
./peg1 < peg.bootstrap.peg > peg2.peg.go
go build -tags bootstrap -o peg2
rm -f peg2.peg.go
# Remove artefacts from the build
rm -f bootstrap.peg.go peg[123].peg.go peg-bootstrap.peg.go

# Build peg3
./peg2 < ../../peg.peg > peg3.peg.go
go build -tags bootstrap -o peg3
rm -f peg3.peg.go

# Build peg-bootstrap
./peg3 < ../../peg.peg > peg-bootstrap.peg.go
go build -tags bootstrap -o peg-bootstrap
rm -f peg-bootstrap.peg.go

# Build peg
# Final rebuild
cd ../..
./cmd/peg-bootstrap/peg-bootstrap < peg.peg > peg.peg.go
go tool peg -inline -switch peg.peg