Ver código fonte

Added toolchain target and restructured binary paths a bit

Taddeus Kroes 11 anos atrás
pai
commit
4b9d4222bc
10 arquivos alterados com 39 adições e 17 exclusões
  1. 2 1
      .gitignore
  2. 12 4
      Makefile
  3. 15 0
      bin/README
  4. 0 0
      bin/civas
  5. 0 0
      bin/civvm
  6. 6 0
      bin/run.sh
  7. BIN
      bin32/civcc
  8. 1 0
      civcc
  9. 0 9
      run
  10. 3 3
      test/run.bash

+ 2 - 1
.gitignore

@@ -1,5 +1,5 @@
 ._*/
-civcc
+bin/civcc
 *.cmo
 *.cmi
 *.cmx
@@ -11,3 +11,4 @@ parser.ml
 parser.mli
 *.tgz
 *.tar.gz
+doc/

+ 12 - 4
Makefile

@@ -1,5 +1,6 @@
 # Config for OCamlMakefile
-RESULT := civcc
+BIN_DIR := bin
+RESULT := $(BIN_DIR)/civcc
 GLOBALS := types globals stringify util
 PHASES := load parse print desug context typecheck dimreduce boolop constprop \
 	unroll index assemble peephole output
@@ -11,8 +12,8 @@ PRE_TARGETS := types.ml $(addsuffix .cmi,$(GLOBALS))
 LIBS := str unix
 
 # Other config
-CIVAS := bin32/civas
-CIVVM := bin32/civvm
+CIVAS := $(BIN_DIR)/civas
+CIVVM := $(BIN_DIR)/civvm
 
 DIST_TGT := civicaml.tar.gz
 DIST_FILES := $(RESULT) $(SOURCES) Makefile OCamlMakefile README.md test bin32 \
@@ -21,7 +22,7 @@ DIST_FILES := $(RESULT) $(SOURCES) Makefile OCamlMakefile README.md test bin32 \
 TESTSUITE_TGT := testsuite.tar.gz
 
 # Set debugging flag to enable exception backtraces for OCAMLRUNPARAM=b
-OCAMLFLAGS := -g
+#OCAMLFLAGS := -g
 
 OCAMLYACC := menhir
 YFLAGS := --infer --explain
@@ -61,4 +62,11 @@ myclean:
 cleaner: clean
 	rm -rf doc/$(RESULT)
 
+TOOLCHAIN_TGT := toolchain.tar.gz
+
+toolchain: $(TOOLCHAIN_TGT)
+
+$(TOOLCHAIN_TGT): $(RESULT) $(CIVAS) $(CIVVM)
+	tar -czf $@ $(BIN_DIR)
+
 include OCamlMakefile

+ 15 - 0
bin/README

@@ -0,0 +1,15 @@
+There are three binaries in the toolchain:
+
+- The compiler "civcc", which compiles CiviC source code to assembly source
+
+- The assembler "civas", which compiles assembly source to an object file that
+  can be run by the VM.
+
+- The virtual machine "civvm", which runs one or more object files, one of
+  which should export a "main" function.
+
+Additionally, there is a run script "run.sh" which takes one file name argument
+and runs it through the entire pipeline, deleting intermediate files
+afterwards. E.g. for the first assignment you may want to run:
+$ bin/run.sh euclid.cvc
+<output of your main function>

+ 0 - 0
bin32/civas → bin/civas


+ 0 - 0
bin32/civvm → bin/civvm


+ 6 - 0
bin/run.sh

@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+$DIR/civcc -o _tmp.s ${@:2} $1 &&
+$DIR/civas -o _tmp.out _tmp.s &&
+$DIR/civvm _tmp.out
+rm -f _tmp.s _tmp.out

BIN
bin32/civcc


+ 1 - 0
civcc

@@ -0,0 +1 @@
+bin/civcc

+ 0 - 9
run

@@ -1,9 +0,0 @@
-#!/bin/bash
-CIVCC=./civcc
-CIVAS=bin32/civas
-CIVVM=bin32/civvm
-
-$CIVCC -o _tmp.s ${@:2} $1 &&
-$CIVAS -o _tmp.out _tmp.s &&
-$CIVVM _tmp.out
-rm -f _tmp.s _tmp.out

+ 3 - 3
test/run.bash

@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
-CIVAS=${CIVAS-../bin32/civas}
-CIVVM=${CIVVM-../bin32/civvm}
-CIVCC=${CIVCC-../civcc}
+CIVAS=${CIVAS-../bin/civas}
+CIVVM=${CIVVM-../bin/civvm}
+CIVCC=${CIVCC-../bin/civcc}
 CFLAGS=${CFLAGS-}
 RUN_FUNCTIONAL=${RUN_FUNCTIONAL-1}