Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62167655
xhpast_parse.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, May 11, 09:00
Size
1 KB
Mime Type
text/x-php
Expires
Mon, May 13, 09:00 (2 d)
Engine
blob
Format
Raw Data
Handle
17613542
Attached To
rPHU libphutil
xhpast_parse.php
View Options
<?php
/**
* @group xhpast
*/
function
xhpast_is_available
()
{
static
$available
;
if
(
$available
===
null
)
{
$available
=
false
;
$bin
=
xhpast_get_binary_path
();
if
(
Filesystem
::
pathExists
(
$bin
))
{
list
(
$err
,
$stdout
)
=
exec_manual
(
'%s --version'
,
$bin
);
if
(!
$err
)
{
$version
=
trim
(
$stdout
);
if
(
$version
===
"xhpast version 5.5.8/1e"
)
{
$available
=
true
;
}
}
}
}
return
$available
;
}
/**
* @group xhpast
*/
function
xhpast_get_binary_path
()
{
if
(
phutil_is_windows
())
{
return
dirname
(
__FILE__
).
'
\\
xhpast.exe'
;
}
return
dirname
(
__FILE__
).
'/xhpast'
;
}
/**
* @group xhpast
*/
function
xhpast_get_build_instructions
()
{
$root
=
phutil_get_library_root
(
'phutil'
);
$make
=
$root
.
'/../scripts/build_xhpast.sh'
;
$make
=
Filesystem
::
resolvePath
(
$make
);
return
<<<EOHELP
Your version of 'xhpast' is unbuilt or out of date. Run this script to build it:
\$ {$make}
EOHELP;
}
/**
* @group xhpast
*/
function
xhpast_get_parser_future
(
$data
)
{
if
(!
xhpast_is_available
())
{
try
{
// Try to build XHPAST automatically. If we can't then just ask the user
// to build it themselves.
xhpast_build
();
}
catch
(
CommandException
$e
)
{
throw
new
Exception
(
xhpast_get_build_instructions
());
}
}
$future
=
new
ExecFuture
(
'%s'
,
xhpast_get_binary_path
());
$future
->
write
(
$data
);
return
$future
;
}
/**
* @group xhpast
*/
function
xhpast_build
()
{
$root
=
phutil_get_library_root
(
'phutil'
);
execx
(
'%s'
,
$root
.
'/../scripts/build_xhpast.sh'
);
}
Event Timeline
Log In to Comment