(*
 * Copyright (c) 2009 - 2013 Monoidics ltd.
 * Copyright (c) 2013 - 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.
 *)

open! Utils

let major = @INFER_MAJOR@
let minor = @INFER_MINOR@
let patch = @INFER_PATCH@

let commit = "@INFER_GIT_COMMIT@"
let branch = "@INFER_GIT_BRANCH@"
let is_release = string_equal "@IS_RELEASE_TREE@" "yes"
let tag = Printf.sprintf "v%d.%d.%d" major minor patch

let versionString =
  if is_release then tag
  else Printf.sprintf "%s-%s" tag commit

let versionJson = String.concat "\n" [
    "{"; "\"major\": " ^ (string_of_int major) ^ ", ";
    "\"minor\": " ^ (string_of_int minor) ^ ", ";
    "\"patch\": " ^ (string_of_int patch) ^ ", ";
    "\"commit\": \"" ^ commit ^ "\", ";
    "\"branch\": \"" ^ branch ^ "\", ";
    "\"tag\": \"" ^ tag ^ "\""; "}" ]
