From 15b8f80e1854d39682313949bbcb47fbb71607b3 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 25 Apr 2017 00:53:14 -0700 Subject: [PATCH] [build] record last modified date of --help data inside ./configure Summary: This will be needed to generate man pages with an accurate date. Reviewed By: jberdine, mbouaziz Differential Revision: D4937498 fbshipit-source-id: b5ebd31 --- .gitignore | 1 + Makefile | 2 ++ Makefile.autoconf.in | 1 + autogen.sh | 36 +++++++++++++++++++++++++++++++++++- configure.ac | 2 ++ infer/src/Makefile | 1 + infer/src/base/Version.ml.in | 2 ++ infer/src/base/Version.mli | 2 ++ 8 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a8f3b2877..6222ae8dc 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ duplicates.txt /aclocal.m4 /autom4te.cache /config.status +/m4/__GENERATED__*.m4 /configure /Makefile.autoconf /.buckversion diff --git a/Makefile b/Makefile index da2ccccea..b4ff7a07f 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,7 @@ endif .PHONY: all all: infer +ifeq ($(IS_INFER_RELEASE),no) configure: configure.ac $(wildcard m4/*.m4) # rerun ./autogen.sh in case of failure as the failure may be due to needing to rerun # ./configure @@ -99,6 +100,7 @@ Makefile.autoconf: configure Makefile.autoconf.in ./configure $(shell ./config.status --config || true),\ ./configure $(shell ./config.status --config || true))) || \ ./configure $(shell ./config.status --config || true) +endif .PHONY: fb-setup fb-setup: diff --git a/Makefile.autoconf.in b/Makefile.autoconf.in index b5631ebf0..2fbbf6e86 100644 --- a/Makefile.autoconf.in +++ b/Makefile.autoconf.in @@ -26,6 +26,7 @@ ENABLE_OCAMLOPT_CUSTOM_CC = @ENABLE_OCAMLOPT_CUSTOM_CC@ ENABLE_OCAML_BINANNOT = @ENABLE_OCAML_BINANNOT@ exec_prefix = @exec_prefix@ INFER_MAJOR = @INFER_MAJOR@ +INFER_MAN_LAST_MODIFIED = @INFER_MAN_LAST_MODIFIED@ INFER_MINOR = @INFER_MINOR@ INFER_PATCH = @INFER_PATCH@ INSTALL = @INSTALL@ diff --git a/autogen.sh b/autogen.sh index fa8cce072..9541271fd 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright (c) 2015 - present Facebook, Inc. # All rights reserved. @@ -9,6 +9,11 @@ set -e +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# make sure we run from the root of the repo +pushd "$SCRIPT_DIR" > /dev/null + # try to pull submodules if we are in a git repo # might fail if git is not installed (how did you even checkout the # repo in the first place?) @@ -20,6 +25,35 @@ else echo 'no git repository detected; not updating git submodules' fi +# We need to record the date that the documentation was last modified to put in our man +# pages. Unfortunately that information is only available reliably from `git`, which we don't have +# access to from other distributions of the infer source code, for instance our source +# releases. However, we do distribute the "configure" script in that case, so the idea is to bake +# this date inside "configure" so that it's available at build time. We do that by generating an m4 +# macro that hardcodes the date we compute in this script for "configure" to find. +MAN_LAST_MODIFIED_M4=m4/__GENERATED__ac_check_infer_man_last_modified.m4 +printf 'generating %s' "$MAN_LAST_MODIFIED_M4... " +if test -d '.git' ; then + # date at which the man pages were last modified, to record in the manpages themselves + MAN_FILES=( + infer/src/base/CommandLineOption.ml + infer/src/base/Config.ml + ) + MAN_DATE=$(git log -n 1 --pretty=format:%cd --date=short -- "${MAN_FILES[@]}") + INFER_MAN_LAST_MODIFIED=${INFER_MAN_LAST_MODIFIED:-$MAN_DATE} +else + echo 'no git repository detected; setting last modified date to today' + # best effort: get today's date + INFER_MAN_LAST_MODIFIED=${INFER_MAN_LAST_MODIFIED:-$(date +%Y-%m-%d)} +fi + +printf "AC_DEFUN([AC_CHECK_INFER_MAN_LAST_MODIFIED],\n" > "$MAN_LAST_MODIFIED_M4" +printf "[INFER_MAN_LAST_MODIFIED=%s\n" "$INFER_MAN_LAST_MODIFIED" >> "$MAN_LAST_MODIFIED_M4" +printf " AC_SUBST([INFER_MAN_LAST_MODIFIED])\n" >> "$MAN_LAST_MODIFIED_M4" +printf "])\n" >> "$MAN_LAST_MODIFIED_M4" +printf 'done\n' + +# older versions of `autoreconf` only support including macros via acinclude.m4 ACINCLUDE="acinclude.m4" printf "generating $ACINCLUDE..." cat m4/*.m4 > "$ACINCLUDE" diff --git a/configure.ac b/configure.ac index d1735f942..8d4ea071a 100644 --- a/configure.ac +++ b/configure.ac @@ -314,6 +314,8 @@ if test "$BREW" != "no"; then fi fi +AC_CHECK_INFER_MAN_LAST_MODIFIED() + AC_CONFIG_FILES([ Makefile.autoconf ]) diff --git a/infer/src/Makefile b/infer/src/Makefile index d4d1eff6a..0eb1fde56 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -394,6 +394,7 @@ base/Version.ml: base/Version.ml.in $(MAKEFILE_LIST) -e "s|@BUILD_C_ANALYZERS[@]|$(BUILD_C_ANALYZERS)|g" \ -e "s|@BUILD_JAVA_ANALYZERS[@]|$(BUILD_JAVA_ANALYZERS)|g" \ -e "s|@XCODE_SELECT[@]|$(XCODE_SELECT)|g" \ + -e "s|@INFER_MAN_LAST_MODIFIED[@]|$(INFER_MAN_LAST_MODIFIED)|g" \ $< > "$$TMPFILE"; \ cat "$$TMPFILE" > $@; \ $(REMOVE) "$$TMPFILE" diff --git a/infer/src/base/Version.ml.in b/infer/src/base/Version.ml.in index c652a3485..5692f14eb 100644 --- a/infer/src/base/Version.ml.in +++ b/infer/src/base/Version.ml.in @@ -37,3 +37,5 @@ let versionJson = String.concat ~sep:"\n" [ let clang_enabled = is_yes "@BUILD_C_ANALYZERS@" let java_enabled = is_yes "@BUILD_JAVA_ANALYZERS@" let xcode_enabled = is_not_no "@XCODE_SELECT@" + +let man_pages_last_modify_date = "@INFER_MAN_LAST_MODIFIED@" diff --git a/infer/src/base/Version.mli b/infer/src/base/Version.mli index 8294764ad..e3f2ee16e 100644 --- a/infer/src/base/Version.mli +++ b/infer/src/base/Version.mli @@ -16,3 +16,5 @@ val versionJson : string val clang_enabled : bool val java_enabled : bool val xcode_enabled : bool + +val man_pages_last_modify_date : string