Skip to content

Commit

Permalink
Make HPHP compiler version and compiler id accesible via ini_get()
Browse files Browse the repository at this point in the history
Summary:
Pursuant to Task #489370, we need an easy way for PHP code to be able to
programmatically retrieve the HPHP compiler version (currently "1.000") and
the HPHP compiler id (a string providing the git revision and remote branch
that was used to build the compiler).

This diff updates ini_get() to support two new keys "hphp.compiler_version"
and "hphp.compiler_id" to give PHP code a way to programmatically access
the HPHP compiler version and HPHP compiler id.

Task ID: #489370

Blame Rev:

Reviewers: myang, qigao, mwilliams

CC: cbueno, jallen

Revert Plan:

Tags: hphp

- begin *PUBLIC* platform impact section -
Bugzilla: #
- end platform impact -

Differential Revision: 234008
  • Loading branch information
paroski authored and macvicar committed Apr 8, 2011
1 parent 53cc955 commit 5639ac0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/hphp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,14 @@ int prepareOptions(ProgramOptions &po, int argc, char **argv) {
}
if (vm.count("version")) {
#ifdef HPHP_VERSION
#undefine HPHP_VERSION
#undef HPHP_VERSION
#endif
#define HPHP_VERSION(v) cout << "HipHop Compiler v" #v << "\n";
#include "../version"

#ifdef COMPILER_ID
cout << "Compiler: " << COMPILER_ID << "\n";
#endif

return 1;
}

Expand Down
16 changes: 16 additions & 0 deletions src/runtime/base/hphp_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,21 @@ void Globals::fiberUnmarshal(Globals *src, FiberReferenceMap &refMap) {
}
}

#ifdef HPHP_VERSION
#undef HPHP_VERSION
#endif
#define HPHP_VERSION(v) return #v;
const char* getHphpCompilerVersion() {
#include "../../version"
}

const char* getHphpCompilerId() {
#ifdef COMPILER_ID
return COMPILER_ID;
#else
return "";
#endif
}

///////////////////////////////////////////////////////////////////////////////
}
3 changes: 3 additions & 0 deletions src/runtime/base/hphp_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class Globals : public LVariableTable {
ssize_t wrapIter(ssize_t it) const;
};

const char* getHphpCompilerVersion();
const char* getHphpCompilerId();

///////////////////////////////////////////////////////////////////////////////
} // namespace HPHP

Expand Down
9 changes: 9 additions & 0 deletions src/runtime/base/ini_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <runtime/base/complex_types.h>
#include <runtime/base/type_conversions.h>
#include <runtime/base/builtin_functions.h>
#include <runtime/base/hphp_system.h>
#include <runtime/base/runtime_option.h>
#include <runtime/base/timeout_thread.h>
#include <runtime/ext/extension.h>
Expand Down Expand Up @@ -223,6 +224,14 @@ bool IniSetting::Get(CStrRef name, String &value) {
value = String(RuntimeOption::BuildId);
return true;
}
if (name == "hphp.compiler_version") {
value = String(getHphpCompilerVersion());
return true;
}
if (name == "hphp.compiler_id") {
value = String(getHphpCompilerId());
return true;
}
if (name == "arg_separator.output") {
value = g_context->getArgSeparatorOutput();
return true;
Expand Down

0 comments on commit 5639ac0

Please sign in to comment.