remove newline from get_build_commit_time_string
[hiphop-php.git] / hphp / hack / src / utils / get_build_id.c
blob34206c2882bdab000abb05546d0059f23029ccd8
1 /**
2 * Copyright (c) 2014, Facebook, Inc.
3 * All rights reserved.
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.
9 */
10 #define CAML_NAME_SPACE
11 #include <caml/memory.h>
12 #include <caml/alloc.h>
14 #include <assert.h>
15 #include <stdint.h>
16 #include <string.h>
18 #include <time.h>
20 extern const char* const BuildInfo_kRevision;
21 extern const uint64_t BuildInfo_kRevisionCommitTimeUnix;
23 /**
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) {
33 CAMLparam0();
34 CAMLlocal1(result);
36 size_t len = strlen(BuildInfo_kRevision);
37 result = caml_alloc_string(len);
39 memcpy(String_val(result), BuildInfo_kRevision, len);
40 CAMLreturn(result);
43 value hh_get_build_commit_time_string(void) {
44 CAMLparam0();
45 CAMLlocal1(result);
47 char s[25];
48 struct tm p;
49 localtime_r((time_t*)&BuildInfo_kRevisionCommitTimeUnix, &p);
50 strftime(s, sizeof(s), "%c", &p);
52 result = caml_copy_string(s);
53 CAMLreturn(result);
56 value hh_get_build_commit_time(void) {
57 return Val_long(BuildInfo_kRevisionCommitTimeUnix);