Procházet zdrojové kódy

Refactored build scripts

master
Said Achmiz před 7 roky
rodič
revize
f9cad74bd8
6 změnil soubory, kde provedl 65 přidání a 32 odebrání
  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 Zobrazit soubor



### 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
- 0
build.php Zobrazit soubor

<?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 Zobrazit soubor

#!/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 Zobrazit soubor



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`



+ 0
- 13
util/build-all.php Zobrazit soubor

<?php

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

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

?>

+ 7
- 7
util/package.php Zobrazit soubor

<?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"];

Načítá se…
Zrušit
Uložit