js/src/frontend/binsource/build.sh
author Tooru Fujisawa <arai_a@mac.com>
Sun, 24 Feb 2019 09:42:26 +0000
changeset 518647 5ddf9d49a6b3c843ad1c353a8ba9d3195f63e44e
parent 510303 0d7629792afb8a8d932c4bef3359f39d83af13a5
permissions -rwxr-xr-x
Bug 1524967 - Check if BinAST auto-generated source is update in build.sh. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D20228

#!/bin/sh

cargo run -- \
      ../BinSource.webidl_ \
      ../BinSource.yaml \
      --out-class ../BinASTParser-tmp.h    \
      --out-impl ../BinASTParser-tmp.cpp   \
      --out-enum ../BinASTEnum-tmp.h    \
      --out-token ../BinToken-tmp.h

MACH=../../../../mach

${MACH} clang-format --path \
        ../BinASTParser-tmp.h \
        ../BinASTParser-tmp.cpp \
        ../BinASTEnum-tmp.h \
        ../BinToken-tmp.h

# Usage: update SRC DST
#
# If SRC file and DST file have different content, move SRC file to DST file.
# If not, remove SRC file.
update() {
  SRC=$1
  DST=$2

  if diff -q ${SRC} ${DST} > /dev/null; then
      echo "SKIPPED: ${DST} was not modified"
      rm ${SRC}
  else
      echo "UPDATED: ${DST} was modified"
      mv ${SRC} ${DST}
  fi
}

update ../BinASTParser-tmp.h ../BinASTParser.h
update ../BinASTParser-tmp.cpp ../BinASTParser.cpp
update ../BinASTEnum-tmp.h ../BinASTEnum.h
update ../BinToken-tmp.h ../BinToken.h