#!/bin/sh M=src/comp/metadata GEN_TYPES="syntax::ast::item syntax::ast::def middle::typeck::method_origin \ middle::freevars::freevar_entry syntax::ast::def_id" # Find serializer tool: for S in build/*/stage2/bin/serializer; do # Find rustc: D=$(dirname "$S") R="${D}/rustc" if [ ! -x "$R" ]; then echo "rustc not found or not executable at path '$R'" exit 1 fi echo "Generating src/comp/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 # Generate the real code into a temporary file. if ! "$S" src/comp/rustc.rc $GEN_TYPES > tmp.$$.rs then echo "" echo "" echo "****************************************" echo "* Compilation 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 "****************************************" 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."