From f30a26f02c118822c1b7594f8b64fb928ee97c01 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 8 Mar 2017 05:19:47 -0800 Subject: [PATCH] [refmt] wrap refmt into scripts/refmt.sh Summary: Avoids code duplication. Reviewed By: jberdine Differential Revision: D4658689 fbshipit-source-id: b34797c --- infer/src/Makefile | 4 ++-- scripts/refmt.sh | 22 ++++++++++++++++++++++ scripts/reup.sh | 14 ++++++++++---- {infer/src => scripts}/unary.txt | 0 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100755 scripts/refmt.sh rename {infer/src => scripts}/unary.txt (100%) diff --git a/infer/src/Makefile b/infer/src/Makefile index d0d288e5b..1b666a867 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -250,10 +250,10 @@ rei: # convert to reason %.re : %.ml - refmt -assume-explicit-arity -heuristics-file unary.txt -parse ml -print re $< > $*.re + $(SCRIPT_DIR)/refmt.sh -parse ml -print re $< > $*.re %.rei : %.mli - refmt -assume-explicit-arity -heuristics-file unary.txt -parse ml -print re $< > $*.rei + $(SCRIPT_DIR)/refmt.sh -parse ml -print re $< > $*.rei roots:=Infer InferAnalyzeExe InferClang InferPrintExe StatsAggregator clusters:=base clang java IR diff --git a/scripts/refmt.sh b/scripts/refmt.sh new file mode 100755 index 000000000..86dd99be4 --- /dev/null +++ b/scripts/refmt.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Copyright (c) 2016 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + + +# refmt with infer options + +set -e +set -o pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +refmt \ + -assume-explicit-arity \ + -print-width 100 \ + -heuristics-file "$SCRIPT_DIR/unary.txt" \ + "$@" diff --git a/scripts/reup.sh b/scripts/reup.sh index b698ed146..647f1ed53 100755 --- a/scripts/reup.sh +++ b/scripts/reup.sh @@ -1,4 +1,4 @@ -#/bin/bash +#!/bin/bash # Copyright (c) 2016 - present Facebook, Inc. # All rights reserved. @@ -10,7 +10,13 @@ # re-format reason code +set -e +set -o pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + base=`basename $0` -TMPFILE=`mktemp -t ${base}` || exit 1 -refmt -print-width 100 -heuristics-file unary.txt -parse re -print re $1 > $TMPFILE -mv $TMPFILE $1 +tmpfile=`mktemp -t "${base}.XXXX"` + +"$SCRIPT_DIR/refmt.sh" -parse re -print re "$@" > "$tmpfile" +mv "$tmpfile" "${@: -1}" diff --git a/infer/src/unary.txt b/scripts/unary.txt similarity index 100% rename from infer/src/unary.txt rename to scripts/unary.txt