IUCompilerCourse / Essentials-of-Compilation

A book about compiling Racket and Python to x86-64 assembly
1.28k stars 140 forks source link

Added build support for Python and Racket versions #95

Closed stefanos82 closed 1 year ago

stefanos82 commented 2 years ago

@jsiek while I was playing with #91 I have decided to find a simple way to add build support for both Racket and Python versions.

I have modified the Makefile and now a user can choose which version to build.

The updated Makefile code looks like this:

.PHONY: all cont continuous racket clean publish

LATEXMK= latexmk -pdf

all:
    $(LATEXMK) book

cont: continuous
continuous:
    $(LATEXMK) -pvc book

racket:
    sed 's|\\def\\edition{1}|\\def\\edition{0}|g' book.tex > racket.tex
    $(LATEXMK) racket

clean:
    $(LATEXMK) -C book
    $(RM) \
        *.idx *.ilg *.ind *.aux *.bbl *.bcf \
        *.blg *.fdb_latexmk *.fls *.lof *.log \
        *.lot *.out *.run.xml *.toc \
        racket.tex racket.pdf book.pdf

# Build with a fixed snapshot of NixPkgs 17.03.  Known-to-work.
# For a very clean version, run git clean -fxd followed by this:
#
# This may take a long time and build a complete version of texlive.
# Since it is fixed-in-time it may not have binary caches available and
# may need to build from source.
nix:
    NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/51a83266d164195698f04468d90d2c6238ed3491.tar.gz $(MAKE) nix-head

# This is a compromise.  Build faster by using a binary cache, but
# still allow minor version patches by pointing at the head of a
# (dynamic) channel.
nix-fast:
    NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-17.03.tar.gz $(MAKE) nix-head

# Build with whatever version of nixpkgs is in the users environment:
nix-head:
    nix-shell --pure --run make

# Specific to Fall16:
publish:
    scp build/book.pdf tank.soic.indiana.edu:p523-web/book.pdf

The reason I decided to generate temporary .tex file is because if we modify book.tex it would affect the file stage and would create conflicts with future pull requests from user.

Also, the newly created .tex file should be added in .gitignore so we could generate PDF files without complains.

Any thoughts with this workaround?