2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/base/program-functions.h"
19 #include "hphp/runtime/base/emulate-zend.h"
20 #include "hphp/hhvm/process-init.h"
21 #include "hphp/compiler/compiler.h"
22 #include "hphp/hhbbc/hhbbc.h"
24 #include "hphp/util/embedded-data.h"
25 #include "hphp/util/embedded-vfs.h"
26 #include "hphp/util/text-util.h"
28 int main(int argc
, char** argv
) {
30 int len
= strlen(argv
[0]);
31 if (len
>= 4 && !strcmp(argv
[0] + len
- 4, "hphp")) {
32 return HPHP::compiler_main(argc
, argv
);
34 if (argc
> 1 && !strcmp(argv
[1], "--hphp")) {
36 return HPHP::compiler_main(argc
- 1, argv
+ 1);
39 if (len
>= 5 && !strcmp(argv
[0] + len
- 5, "hhbbc")) {
40 return HPHP::HHBBC::main(argc
, argv
);
42 if (argc
> 1 && !strcmp(argv
[1], "--hhbbc")) {
44 return HPHP::HHBBC::main(argc
- 1, argv
+ 1);
47 HPHP::register_process_init();
48 if (len
>= 3 && !strcmp(argv
[0] + len
- 3, "php")) {
49 return HPHP::emulate_zend(argc
, argv
);
51 if (argc
> 1 && !strcmp(argv
[1], "--php")) {
53 return HPHP::emulate_zend(argc
- 1, argv
+ 1);
56 HPHP::embedded_data data
;
57 if (!HPHP::get_embedded_data("repo", &data
)) {
58 return HPHP::execute_program(argc
, argv
);
61 HPHP::string_printf(repo
, "%s:%u:%u",
62 data
.m_filename
.c_str(),
63 (unsigned)data
.m_start
, (unsigned)data
.m_len
);
64 HPHP::sqlite3_embedded_initialize(nullptr, true);
66 std::vector
<char*> args
;
67 args
.push_back(argv
[0]);
68 args
.push_back("-vRepo.Authoritative=true");
69 args
.push_back("-vRepo.Local.Mode=r-");
70 repo
= "-vRepo.Local.Path=" + repo
;
71 args
.push_back(const_cast<char*>(repo
.c_str()));
73 args
.insert(args
.end(), argv
+ 1, argv
+ argc
);
75 return HPHP::execute_program(args
.size(), &args
[0]);