1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 10:34:38 +01:00
MadelineProto/tools/makephar.php

41 lines
1.7 KiB
PHP
Raw Normal View History

#!/usr/bin/env php
<?php
/*
2020-02-17 14:13:46 +01:00
Copyright 2016-2020 Daniil Gentili
(https://daniil.it)
This file is part of MadelineProto.
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with MadelineProto.
If not, see <http://www.gnu.org/licenses/>.
*/
if (!isset($argv[3])) {
2018-02-20 15:50:16 +01:00
echo 'Usage: '.$argv[0].' inputDir output.phar ref'.PHP_EOL;
die(1);
}
2022-12-08 20:16:40 +01:00
@unlink($argv[2]);
2019-12-25 19:13:48 +01:00
$p = new Phar(__DIR__.'/../'.$argv[2], 0, $argv[2]);
2022-12-08 20:16:40 +01:00
$p->buildFromDirectory(realpath($argv[1]), '/^((?!tests).)*(\.php|\.py|\.exe|\.tl|\.json|\.dat|\.h)$/i');
2023-01-04 15:26:06 +01:00
$p->addFromString('vendor/danog/madelineproto/.git/refs/heads/stable', $argv[3]);
$p->addFromString('.git/refs/heads/stable', $argv[3]);
$p->setStub('<?php
$backtrace = debug_backtrace();
2019-06-16 21:25:03 +02:00
if (!isset($backtrace[0]["file"]) || !in_array(basename($backtrace[0]["file"]), ["madeline.php", "phar.php", "testing.php"])) {
2019-06-16 21:27:23 +02:00
echo("madeline.phar cannot be required manually: use the automatic loader, instead: https://docs.madelineproto.xyz/docs/INSTALLATION.html#simple".PHP_EOL);
die(1);
2019-05-11 02:17:57 +02:00
}
2021-12-10 18:41:52 +01:00
if (defined("MADELINE_REAL_ROOT")) {
@chdir(MADELINE_REAL_ROOT);
2019-05-11 02:17:57 +02:00
}
2018-03-01 13:28:16 +01:00
2020-01-19 15:44:12 +01:00
Phar::interceptFileFuncs();
Phar::mapPhar("'.$argv[2].'");
2019-12-26 19:17:31 +01:00
return require_once "phar://'.$argv[2].'/vendor/autoload.php";
__HALT_COMPILER(); ?>');