3 if (PHP_SAPI
!== 'cli') {
4 die("GenCode can only be run from command line.");
7 $includes = ['.', '../packages', '../../civicrm-packages', '..'];
8 ini_set('include_path', implode(PATH_SEPARATOR
, $includes));
9 // make sure the memory_limit is at least 512 MB
10 $memLimitString = trim(ini_get('memory_limit'));
11 $memLimitUnit = strtolower(substr($memLimitString, -1));
12 $memLimit = (int) $memLimitString;
13 switch ($memLimitUnit) {
22 if ($memLimit >= 0 and $memLimit < 536870912) {
23 // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM.
24 ini_set('memory_limit', -1);
26 // avoid php warnings if timezone is not set - CRM-10844
27 date_default_timezone_set('UTC');
29 define('CIVICRM_UF', 'Drupal');
30 define('CIVICRM_UF_BASEURL', '/');
31 define('CIVICRM_L10N_BASEDIR', getenv('CIVICRM_L10N_BASEDIR') ?
getenv('CIVICRM_L10N_BASEDIR') : __DIR__
. '/../l10n');
33 require_once 'CRM/Core/ClassLoader.php';
34 CRM_Core_ClassLoader
::singleton()->register();
36 # TODO: pull these settings from configuration
37 $genCode = new CRM_Core_CodeGen_Main(
51 empty($argv[2]) ?
NULL : $argv[2],
53 empty($argv[1]) ?
'schema/Schema.xml' : $argv[1],
54 // path to digest file
55 getenv('CIVICRM_GENCODE_DIGEST') ?
getenv('CIVICRM_GENCODE_DIGEST') : NULL