Quellcode durchsuchen

Refactored build scripts

master
Said Achmiz vor 6 Jahren
Ursprung
Commit
f9cad74bd8
6 geänderte Dateien mit 65 neuen und 32 gelöschten Zeilen
  1. 1
    1
      README.md
  2. 56
    0
      build.php
  3. 0
    6
      build.sh
  4. 1
    5
      util/README-UTIL.md
  5. 0
    13
      util/build-all.php
  6. 7
    7
      util/package.php

+ 1
- 1
README.md Datei anzeigen

@@ -19,7 +19,7 @@ A browser extension that automatically gets rid of sticky elements on websites y

### 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


+ 56
- 0
build.php Datei anzeigen

@@ -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}`;
}

?>

+ 0
- 6
build.sh Datei anzeigen

@@ -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/

+ 1
- 5
util/README-UTIL.md Datei anzeigen

@@ -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.

## `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`

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`


+ 0
- 13
util/build-all.php Datei anzeigen

@@ -1,13 +0,0 @@
<?php

$platforms = [
"chrome",
"firefox"
];
$root = preg_replace('/\/[^\/]+$/', '', dirname(__FILE__));

foreach ($platforms as $platform) {
`{$root}/build.sh {$platform}`;
}

?>

+ 7
- 7
util/package.php Datei anzeigen

@@ -1,14 +1,14 @@
<?php

if ($argv[1] == "-b")
include_once("build-all.php");

$platforms = [
"chrome",
"firefox"
];
$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) {
$manifest = JSON_decode(file_get_contents("{$root}/build/{$platform}/manifest.json"), true);
$version = $manifest["version"];

Laden…
Abbrechen
Speichern