#!/bin/bash # Copyright (c) 2018-present, Facebook, Inc. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # usage: gen_version.sh [] FILE="$1" if [[ ! -z "$2" ]]; then # second arg passed when called from opam VERSION="$2" else # second arg omitted when called from src/jbuild if [[ ! "%%VERSION%%" == "%%"*"%%" ]]; then # file has been watermarked when building distrib archive VERSION="%%VERSION%%" else # file has not been watermarked when building in dev git tree VERSION=$(git describe --tags --dirty --always) fi fi (test -e $FILE || touch $FILE); sed -e "s|%%VERSION%[%]|$VERSION|g" $FILE.in | diff $FILE - | patch --silent $FILE