diff --git a/BUILDING.md b/BUILDING.md index 92c78d06c..8ba85332f 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -30,7 +30,7 @@ If you use a custom binary, you'll need to replace `composer` usages in this gui Preprocessor requires that the `cpp` (c preprocessor) is available in your PATH. ## Building `PocketMine-MP.phar` -Run `build/server-phar.php` using your preferred PHP binary. It'll drop a `PocketMine-MP.phar` into the current working directory. +Run `composer make-server` using your preferred PHP binary. It'll drop a `PocketMine-MP.phar` into the current working directory. You can also use the `--out` option to change the output filename. diff --git a/build/server-phar.php b/build/server-phar.php index 7b9cf5eb1..ea8fd273d 100644 --- a/build/server-phar.php +++ b/build/server-phar.php @@ -41,6 +41,7 @@ use function rtrim; use function sprintf; use function str_replace; use function unlink; +use const PHP_EOL; require dirname(__DIR__) . '/vendor/autoload.php'; @@ -129,6 +130,10 @@ function main() : void{ echo "Set phar.readonly to 0 with -dphar.readonly=0" . PHP_EOL; exit(1); } + if(file_exists(dirname(__DIR__) . '/vendor/phpunit')){ + echo "Remove Composer dev dependencies before building (composer install --no-dev)" . PHP_EOL; + exit(1); + } $opts = getopt("", ["out:", "git:"]); if(isset($opts["git"])){ diff --git a/composer.json b/composer.json index a880d5245..8c291d43a 100644 --- a/composer.json +++ b/composer.json @@ -74,5 +74,12 @@ "platform": { "php": "7.3.0" } + }, + "scripts": { + "make-devtools": "@php -dphar.readonly=0 tests/plugins/DevTools/src/DevTools/ConsoleScript.php --make tests/plugins/DevTools --out plugins/DevTools.phar", + "make-server": [ + "@composer install --no-dev --classmap-authoritative", + "@php -dphar.readonly=0 build/server-phar.php" + ] } } diff --git a/tests/travis.sh b/tests/travis.sh index 149c1896a..e16a28333 100755 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -11,17 +11,19 @@ while getopts "t:" OPTION 2> /dev/null; do done #Run-the-server tests -DATA_DIR="test_data" +DATA_DIR="$(pwd)/test_data" PLUGINS_DIR="$DATA_DIR/plugins" rm -rf "$DATA_DIR" rm PocketMine-MP.phar 2> /dev/null +mkdir "$DATA_DIR" +mkdir "$PLUGINS_DIR" cd tests/plugins/DevTools -php -dphar.readonly=0 ./src/DevTools/ConsoleScript.php --make ./ --relative ./ --out ../../../DevTools.phar +php -dphar.readonly=0 ./src/DevTools/ConsoleScript.php --make ./ --relative ./ --out "$PLUGINS_DIR/DevTools.phar" cd ../../.. +composer make-server -php -dphar.readonly=0 ./build/server-phar.php ./PocketMine-MP.phar if [ -f PocketMine-MP.phar ]; then echo Server phar created successfully. else @@ -29,9 +31,6 @@ else exit 1 fi -mkdir "$DATA_DIR" -mkdir "$PLUGINS_DIR" -mv DevTools.phar "$PLUGINS_DIR" cp -r tests/plugins/TesterPlugin "$PLUGINS_DIR" echo -e "stop\n" | php PocketMine-MP.phar --no-wizard --disable-ansi --disable-readline --debug.level=2 --data="$DATA_DIR" --plugins="$PLUGINS_DIR" --anonymous-statistics.enabled=0 --settings.async-workers="$PM_WORKERS" --settings.enable-dev-builds=1