Refactored build scripts
This commit is contained in:
parent
950eebcc2d
commit
f9cad74bd8
@ -19,7 +19,7 @@ A browser extension that automatically gets rid of sticky elements on websites y
|
|||||||
|
|
||||||
### Building from source
|
### Building from source
|
||||||
|
|
||||||
You can build the extension from source, using the provided `build.sh` script, passing the argument `chrome` (for Chrome, Opera, Vivaldi, etc.) or `firefox` (for Firefox & other Gecko-based browsers).
|
You can build the extension from source, using the provided `build.php` script.
|
||||||
|
|
||||||
### Post-installation
|
### Post-installation
|
||||||
|
|
||||||
|
|||||||
56
build.php
Normal file
56
build.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
## Syntax:
|
||||||
|
## php build.php { <platform> | all }
|
||||||
|
## ('all' builds for all available platforms)
|
||||||
|
##
|
||||||
|
## This script will create build/ and build/<platform> if needed, then will
|
||||||
|
## copy files from src/ and src/platform/<platform> into build/<platform>/.
|
||||||
|
## The extension can then be loaded from build/<platform>.
|
||||||
|
|
||||||
|
## No platform specified.
|
||||||
|
if ($argc < 2) {
|
||||||
|
echo "Syntax is:\n";
|
||||||
|
echo "\tphp build.php { <platform> | all }\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
## Determine path to repository root.
|
||||||
|
$root = preg_replace('/\/[^\/]+$/', '', dirname(__FILE__));
|
||||||
|
|
||||||
|
## Determine what platforms are available.
|
||||||
|
$platforms = array_filter(scandir("{$root}/src/platform/"), function ($str) {
|
||||||
|
return strncmp($str, ".", 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
## No platform specified, or specified platform does not exist.
|
||||||
|
## NOTE: specifying 'all' will build for all platforms.
|
||||||
|
if ($argc < 2 || !(in_array($argv[1], $platforms) || $argv[1] == "all")) {
|
||||||
|
echo "Available platforms are:\n";
|
||||||
|
foreach ($platforms as $platform)
|
||||||
|
echo "\t{$platform}\n";
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
## Build for specified platform (or for all platforms, if 'all' is given).
|
||||||
|
if ($argv[1] == "all") {
|
||||||
|
foreach ($platforms as $platform) {
|
||||||
|
build_for_platform($platform);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
build_for_platform($argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_for_platform($platform) {
|
||||||
|
global $root;
|
||||||
|
echo "Building for: {$platform}\n";
|
||||||
|
|
||||||
|
$command = "cd {$root}; ";
|
||||||
|
$command .= "mkdir -p build/{$platform}; ";
|
||||||
|
$command .= "rm -rf build/{$platform}/*; ";
|
||||||
|
$command .= "cp -R src/{*.js,*.html,*.css,fonts,images} build/{$platform}/; ";
|
||||||
|
$command .= "cp -R src/platform/{$platform}/* build/{$platform}/";
|
||||||
|
|
||||||
|
`{$command}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
6
build.sh
6
build.sh
@ -1,6 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
mkdir -p build/$1
|
|
||||||
rm -rf build/$1/*
|
|
||||||
cp -R src/{*.js,*.html,*.css,fonts,images} build/$1/
|
|
||||||
cp -R src/platform/$1/* build/$1/
|
|
||||||
@ -2,15 +2,11 @@
|
|||||||
|
|
||||||
This folder contains some convenience scripts. They’re mostly for me, but may be useful for anyone who wants to contribute to developing AlwaysKillSticky, so they’re documented here for completeness.
|
This folder contains some convenience scripts. They’re mostly for me, but may be useful for anyone who wants to contribute to developing AlwaysKillSticky, so they’re documented here for completeness.
|
||||||
|
|
||||||
## `build-all.php`
|
|
||||||
|
|
||||||
Runs `build.sh` with all available platforms. This will create a `build/` directory (in the root directory of the repository) and subdirectories for each platform, and copy files from `src/` into those subdirectories. The extension can then be loaded from those subdirectories by the appropriate kind of browser.
|
|
||||||
|
|
||||||
## `package.php`
|
## `package.php`
|
||||||
|
|
||||||
Will create `.tar.gz` and `.zip` archives in the `release/` directory (creating it if needed) of the built extension for each platform (in `build/`). The archives will be named according to platform and version (read from `manifest.json` in each platform’s build directory).
|
Will create `.tar.gz` and `.zip` archives in the `release/` directory (creating it if needed) of the built extension for each platform (in `build/`). The archives will be named according to platform and version (read from `manifest.json` in each platform’s build directory).
|
||||||
|
|
||||||
Passing the `-b` flag will run `build-all.php` first, before packaging.
|
Passing the `-b` flag will run `build.php all` first, before packaging.
|
||||||
|
|
||||||
## `compute_FontAwesome_subset.php`
|
## `compute_FontAwesome_subset.php`
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$platforms = [
|
|
||||||
"chrome",
|
|
||||||
"firefox"
|
|
||||||
];
|
|
||||||
$root = preg_replace('/\/[^\/]+$/', '', dirname(__FILE__));
|
|
||||||
|
|
||||||
foreach ($platforms as $platform) {
|
|
||||||
`{$root}/build.sh {$platform}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ($argv[1] == "-b")
|
|
||||||
include_once("build-all.php");
|
|
||||||
|
|
||||||
$platforms = [
|
|
||||||
"chrome",
|
|
||||||
"firefox"
|
|
||||||
];
|
|
||||||
$root = preg_replace('/\/[^\/]+$/', '', dirname(__FILE__));
|
$root = preg_replace('/\/[^\/]+$/', '', dirname(__FILE__));
|
||||||
|
|
||||||
|
if ($argv[1] == "-b")
|
||||||
|
include_once("{$root}/build.php");
|
||||||
|
|
||||||
|
$platforms = array_filter(scandir("{$root}/src/platform/"), function ($str) {
|
||||||
|
return strncmp($str, ".", 1);
|
||||||
|
});
|
||||||
|
|
||||||
foreach ($platforms as $platform) {
|
foreach ($platforms as $platform) {
|
||||||
$manifest = JSON_decode(file_get_contents("{$root}/build/{$platform}/manifest.json"), true);
|
$manifest = JSON_decode(file_get_contents("{$root}/build/{$platform}/manifest.json"), true);
|
||||||
$version = $manifest["version"];
|
$version = $manifest["version"];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user