added build script to easily create zip files

This commit is contained in:
PMKuipers 2023-06-03 16:05:27 +02:00
parent 8d41b42697
commit 80187c7056
3 changed files with 57 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/.vs /.vs
/node_modules /node_modules
/amd/build /amd/build
/build

53
build.php Normal file
View File

@ -0,0 +1,53 @@
<?php
$plugin = new stdClass;
include('version.php');
$a = explode("_",$plugin->component,2);
$plugin->type = $a[0];
$plugin->name = $a[1];
$exclude_paths = [
"build", // dir for build zip files
"build/*",
"build.*",
"amd/src",
"amd/src/*",
".git",
".git/*",
".gitignore",
"*.zip",
];
// Determine some paths
$wd = realpath(dirname(__FILE__));
$parent = dirname($wd);
$plugindirname = basename($wd);
$builddir = $wd."/"."build";
$zipname = $builddir."/"."{$plugin->name}-{$plugin->version}.zip";
// create the exclude line
$exclude = "-x ";
foreach($exclude_paths as $x){
$exclude .= "'{$plugindirname}/{$x}' ";
}
if(!is_dir($builddir)){
mkdir($builddir);
if(!is_dir($builddir)){
print("Cannot access dir '{$builddir}' to store zip files\n");
exit(1);
}
}
if(is_file($zipfile)){
unlink($zipfile);
}
$cwd = getcwd();
chdir($parent);
$cmd = "zip -r '{$zipname}' '{$plugindirname}' {$exclude}";
system($cmd);
chdir($cwd);

3
build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
php ${SCRIPT_DIR}/build.php $@