You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
726 B

#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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> [<version>]
FILE="$1"
if [[ ! -z "$2" ]]; then
# second arg passed when called from opam
VERSION="$2"
else
# second arg omitted when called from src/dune
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 --dirty --always)
fi
fi
sed -e "s|%%VERSION%[%]|$VERSION|g" $FILE.in > $FILE