2 * Copyright (c) 2014, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
10 #define CAML_NAME_SPACE
11 #include <caml/memory.h>
12 #include <caml/alloc.h>
20 extern const char* const BuildInfo_kRevision
;
21 extern const uint64_t BuildInfo_kRevisionCommitTimeUnix
;
24 * Export the constants provided by Facebook's build system to ocaml-land, since
25 * their FFI only allows you to call functions, not reference variables. Doing
26 * it this way makes sense for Facebook internally since our build system has
27 * machinery for providing these two constants automatically (and no machinery
28 * for doing codegen in a consistent way to build an ocaml file with them) but
29 * is very roundabout for external users who have to have CMake codegen these
30 * constants anyways. Sorry about that.
32 value
hh_get_build_revision(void) {
36 size_t len
= strlen(BuildInfo_kRevision
);
37 result
= caml_alloc_string(len
);
39 memcpy(String_val(result
), BuildInfo_kRevision
, len
);
43 value
hh_get_build_commit_time_string(void) {
49 localtime_r((time_t*)&BuildInfo_kRevisionCommitTimeUnix
, &p
);
50 strftime(s
, sizeof(s
), "%c", &p
);
52 result
= caml_copy_string(s
);
56 value
hh_get_build_commit_time(void) {
57 return Val_long(BuildInfo_kRevisionCommitTimeUnix
);