-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
civimix-schema - Split off major-version from core. Keep 5.x.
Before: * 'mixin/lib/civimix-schema' is numbered `5.x.x` * `mixin/lib/civimix-schema` is strictly pegged to the 'civicrm-core' After: * `mixin/lib/civimix-schema@5` is numbered `5.x.x.` * `mixin/lib/civimix-schema@5` is partially released from the numbering of `civicrm-core`. Comments: The version will still increment automatically (month-to-month; in parallel with core), but it will stay within 5.x. This is because it's supposed to be strictly SemVer, and we haven't actually made any major changes to it, so moving to 6.x would be a big hassle.
- Loading branch information
Showing
11 changed files
with
90 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,13 @@ | |
// | ||
// pathload()->addSearchDir(__DIR__ . '/lib'); | ||
// | ||
// However, that would detect version#'s from the filenames. In this folder, | ||
// we want all subprojects to have the same version-number as the main | ||
// project. It would be quite inconvenient to rename them every month. | ||
// However, that would detect version#'s from the filenames. While that | ||
// convention is handy for downstreams (using backports), it can be annoying | ||
// here (as canonical source). It would be inconvenient to have to rename | ||
// the canonical files/folders whenever we make an edit. | ||
// | ||
// So instead, we use `addSearchItem()` and register with explicit versions. | ||
// `addSearchItem()` allows us to register with a programmatic | ||
// version-number -- so we don't have to manually set the number. | ||
|
||
$version6 = \CRM_Utils_System::version() . '.1'; /* Higher priority than contrib copies of same version... */ | ||
$version5 = preg_replace_callback(';^6\.(\d+)\.;', function ($m) { | ||
|
@@ -18,7 +20,4 @@ | |
}, $version6); | ||
|
||
// Register [email protected] | ||
\pathload()->addSearchItem('civimix-schema', $version5, __DIR__ . '/civimix-schema'); | ||
|
||
// (Optional) Register [email protected] | ||
// \pathload()->addSearchItem('civimix-schema', $version6, __DIR__ . '/civimix-schema'); | ||
\pathload()->addSearchItem('civimix-schema@5', $version5, __DIR__ . '/civimix-schema'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,96 @@ | ||
#!/usr/bin/env bash | ||
|
||
#!/usr/bin/env php | ||
<?php | ||
|
||
## Take the contents of 'mixin/lib/' and export reusable library files. | ||
|
||
############################################################################### | ||
## Bootstrap | ||
|
||
## Determine the absolute path of the directory with the file | ||
## usage: absdirname <file-path> | ||
function absdirname() { | ||
pushd $(dirname $0) >> /dev/null | ||
pwd | ||
popd >> /dev/null | ||
} | ||
|
||
BINDIR=$(absdirname "$0") | ||
set -e | ||
|
||
############################################################################### | ||
|
||
function getCiviVer() { | ||
pushd "$1" >> /dev/null | ||
if [ -f xml/version.xml ]; then | ||
## Works in any git-based build, even if gencode hasn't run yet. | ||
php -r 'echo simplexml_load_file("xml/version.xml")->version_no;' | ||
else | ||
## works in any tar-based build. | ||
php -r 'require "civicrm-version.php"; $a = civicrmVersion(); echo $a["version"];' | ||
fi | ||
popd >> /dev/null | ||
/** | ||
* Get the CiviCRM version from the specified directory. | ||
* | ||
* @param string $directory | ||
* @return string|null | ||
*/ | ||
function getCiviVer(string $directory): ?string { | ||
$version = NULL; | ||
|
||
if (file_exists($directory . '/xml/version.xml')) { | ||
$version = simplexml_load_file($directory . '/xml/version.xml')->version_no; | ||
} | ||
elseif (file_exists($directory . '/civicrm-version.php')) { | ||
require $directory . '/civicrm-version.php'; | ||
$versionArray = civicrmVersion(); | ||
$version = $versionArray['version'] ?? NULL; | ||
} | ||
|
||
return $version; | ||
} | ||
|
||
/** | ||
* Execute a PHAR command. | ||
* | ||
* @param string $command | ||
* @return void | ||
*/ | ||
function executePhar(string $pwd, string $command): void { | ||
$cmd = 'cd ' . escapeshellarg($pwd) . ' && '; | ||
$cmd .= "php -d phar.readonly=0 `which phar` $command"; | ||
// echo "$cmd\n"; | ||
|
||
passthru($cmd, $result); | ||
if ($result !== 0) { | ||
throw new \RuntimeException("Failed to execute command: $cmd"); | ||
} | ||
} | ||
|
||
function PHAR() { | ||
php -d phar.readonly=0 `which phar` "$@" | ||
/** | ||
* Take a source folder and generate a PHAR. | ||
* | ||
* @param string $src | ||
* @param string $outputPhar | ||
* @return void | ||
*/ | ||
function buildLib(string $src, string $outputPhar): void { | ||
echo "\n====================================\n"; | ||
echo "Read $src\n"; | ||
echo "Create $outputPhar\n"; | ||
echo "\n"; | ||
|
||
if (file_exists($outputPhar)) { | ||
unlink($outputPhar); | ||
} | ||
|
||
$stubFile = escapeshellarg("$GLOBALS[toolMix]/src/empty-stub.php"); | ||
$outputPhar = escapeshellarg($outputPhar); | ||
executePhar($src, "pack -f $outputPhar -s $stubFile -i '.php$' ."); | ||
|
||
// Or for concatenated PHP format: | ||
// php "$CIVI_CORE/scripts/concat-php.php" pathload.main.php $( find src -name '*.php' ) >"$OUTPUT_PHP" | ||
} | ||
|
||
############################################################################### | ||
## Setup | ||
|
||
TOOLMIX=$(dirname "$BINDIR") | ||
CIVI_CORE=$(dirname $(dirname "$TOOLMIX")) | ||
OUTPUT="$1" | ||
VERSION=$(getCiviVer "$CIVI_CORE") | ||
|
||
if [ -z "$OUTPUT" ]; then | ||
echo 2>&1 "usage: $0 <output-dir>" | ||
echo 2>&1 "example: $0 /tmp/civimix" | ||
exit 1 | ||
fi | ||
$toolMix = dirname(__DIR__); | ||
$civiCore = dirname(dirname($toolMix)); | ||
$output = $argv[1] ?? NULL; | ||
$version = getCiviVer($civiCore); | ||
|
||
if [ ! -d "$OUTPUT" ]; then | ||
mkdir "$OUTPUT" | ||
fi | ||
|
||
for PACKAGE in civimix-schema ; do | ||
|
||
SRC="${CIVI_CORE}/mixin/lib/${PACKAGE}" | ||
OUTPUT_PHAR="${OUTPUT}/${PACKAGE}@${VERSION}.phar" | ||
#OUTPUT_PHP="${OUTPUT}/${PACKAGE}@${VERSION}.php" | ||
|
||
echo "Read $SRC" | ||
echo "Create $OUTPUT_PHAR" | ||
if (empty($output)) { | ||
fwrite(STDERR, "usage: build-lib <output-dir>\n"); | ||
fwrite(STDERR, "example: build-lib /tmp/civimix\n"); | ||
exit(1); | ||
} | ||
|
||
[ -f "$OUTPUT_PHAR" ] && rm -f "$OUTPUT_PHAR" || true | ||
#[ -f "$OUTPUT_PHP" ] && rm -f "$OUTPUT_PHP" || true | ||
if (!is_dir($output)) { | ||
mkdir($output, 0755, TRUE); | ||
} | ||
|
||
(cd "$SRC" ; PHAR pack -f "$OUTPUT_PHAR" -s "$TOOLMIX/src/empty-stub.php" -i '\.php$' . ) | ||
#php "$CIVI_CORE/scripts/concat-php.php" pathload.main.php $( find src -name '*.php' ) >"$OUTPUT_PHP" | ||
############################################################################### | ||
## Build rules | ||
|
||
done | ||
/* Tracked core version up until 5.83. After 6.0 split, this stayed on 5.x.*/ | ||
$civimixSchemaVer = preg_replace_callback(';^6\.(\d+)\.;', function ($m) { | ||
return '5.' . (83 + $m[1]) . '.'; | ||
}, getCiviVer($civiCore)); | ||
buildLib("$civiCore/mixin/lib/civimix-schema@5", "$output/civimix-schema@$civimixSchemaVer.phar"); |