#!/bin/sh function msg { echo "" echo "" echo "****************************************" echo "* Processing errors encountered *" echo "* *" echo "* Dummy versions of the AST encoder *" echo "* have been left in astencode_gen.rs. *" echo "* Fix the compilation errors and rerun *" echo "* this script to generate the real *" echo "* versions. *" echo "****************************************" } M=src/rustc/metadata GEN_TYPES="syntax::ast::item syntax::ast::def middle::typeck::method_origin \ middle::freevars::freevar_entry syntax::ast::def_id syntax::ast::inlined_item middle::last_use::is_last_use" BUILD_DIR=$1 if test $BUILD_DIR == ""; then BUILD_DIR="." fi # Find serializer tool: for S in $BUILD_DIR/*/stage1/bin/serializer; do echo "Generating src/rustc/metadata/astencode_gen.rs" # First, generate dummy fns so that the compiler can type # everything. echo "// TEMPORARY DEFINITIONS: re-run gen-astencode" \ > $M/astencode_gen.rs for T in $GEN_TYPES; do echo "fn serialize_${T//::/_}(_s: S, _v: $T) {}" \ >> $M/astencode_gen.rs echo "fn deserialize_${T//::/_}(_s: S) -> $T { fail; }" \ >> $M/astencode_gen.rs done # Find rustc and serializer: D=$(dirname "$S") R="${D}/../../stage0/bin/rustc" if [ ! -x "$R" ]; then echo "rustc not found or not executable at path '$R'" msg exit 1 fi if [ ! -x "$S" ]; then echo "serializer excutable not found; try 'make serializer'" msg exit 1 fi # Generate the real code into a temporary file. if ! "$S" src/rustc/rustc.rc $GEN_TYPES > tmp.$$.rs then msg rm tmp.$$.rs exit 1 fi # Copy over into the final destination and clean up. "$R" --pretty normal tmp.$$.rs > $M/astencode_gen.rs # rm -f tmp.$$.rs exit 0 done # If we made it this far, must not have found any # serializer: echo "serializer tool not found."