Compile only one project at a time

This commit is contained in:
Jakub Vrana 2012-09-22 07:53:50 -07:00
parent b684569f7c
commit 29e65523d3

View file

@ -275,6 +275,12 @@ function compile_file($match) {
return "latin_binary('" . add_apo_slashes(binary_latin($file)) . "')";
}
$project = "adminer";
if ($_SERVER["argv"][1] == "editor") {
$project = "editor";
array_shift($_SERVER["argv"]);
}
$driver = "";
if (file_exists(dirname(__FILE__) . "/adminer/drivers/" . $_SERVER["argv"][1] . ".inc.php")) {
$driver = $_SERVER["argv"][1];
@ -284,12 +290,15 @@ if (file_exists(dirname(__FILE__) . "/adminer/drivers/" . $_SERVER["argv"][1] .
unset($_COOKIE["adminer_lang"]);
$_SESSION["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from session
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
if (isset($_SESSION["lang"])) {
if (isset($_SERVER["argv"][2]) || !isset($langs[$_SESSION["lang"]])) {
echo "Usage: php compile.php [driver] [lang]\nPurpose: Compile adminer[-driver][-lang].php and editor[-driver][-lang].php.\n";
exit(1);
}
if (isset($langs[$_SESSION["lang"]])) {
include dirname(__FILE__) . "/adminer/lang/$_SESSION[lang].inc.php";
array_shift($_SERVER["argv"]);
}
if ($_SERVER["argv"][1]) {
echo "Usage: php compile.php [editor] [driver] [lang]\n";
echo "Purpose: Compile adminer[-driver][-lang].php or editor[-driver][-lang].php.\n";
exit(1);
}
// check function definition in drivers
@ -310,7 +319,6 @@ foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($driver ? $driver : "*"
include dirname(__FILE__) . "/adminer/include/pdo.inc.php";
$features = array("call" => "routine", "dump", "event", "privileges", "procedure" => "routine", "processlist", "routine", "scheme", "sequence", "status", "trigger", "type", "user" => "privileges", "variables", "view");
foreach (array("adminer", "editor") as $project) {
$lang_ids = array(); // global variable simplifies usage in a callback function
$file = file_get_contents(dirname(__FILE__) . "/$project/index.php");
if ($driver) {
@ -365,4 +373,3 @@ foreach (array("adminer", "editor") as $project) {
$filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($driver ? "-$driver" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php";
fwrite(fopen($filename, "w"), $file); // file_put_contents() since PHP 5
echo "$filename created (" . strlen($file) . " B).\n";
}