3 if (PHP_SAPI
!== 'cli') {
4 die("GenCode can only be run from command line.");
7 ini_set('include_path', '.' . PATH_SEPARATOR
. '..' . DIRECTORY_SEPARATOR
. 'packages' . PATH_SEPARATOR
. '..');
8 // make sure the memory_limit is at least 512 MB
9 $memLimitString = trim(ini_get('memory_limit'));
10 $memLimitUnit = strtolower(substr($memLimitString, -1));
11 $memLimit = (int) $memLimitString;
12 switch ($memLimitUnit) {
21 if ($memLimit >= 0 and $memLimit < 536870912) {
22 // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM.
23 ini_set('memory_limit', -1);
25 date_default_timezone_set('UTC'); // avoid php warnings if timezone is not set - CRM-10844
27 define('CIVICRM_UF', 'Drupal');
28 define('CIVICRM_UF_BASEURL', '/');
30 require_once 'CRM/Core/ClassLoader.php';
31 CRM_Core_ClassLoader
::singleton()->register();
33 # TODO: pull these settings from configuration
34 $genCode = new CRM_Core_CodeGen_Main(
35 '../CRM/Core/DAO/', // $CoreDAOCodePath
36 '../sql/', // $sqlCodePath
37 '../', // $phpCodePath
38 '../templates/', // $tplCodePath
41 empty($argv[2]) ?
NULL : $argv[2], // db version
42 empty($argv[1]) ?
'schema/Schema.xml' : $argv[1], // schema file
43 getenv('CIVICRM_GENCODE_DIGEST') ?
getenv('CIVICRM_GENCODE_DIGEST') : NULL // path to digest file