| 1 | <?php |
| 2 | |
| 3 | if (PHP_SAPI !== 'cli') { |
| 4 | die("GenCode can only be run from command line."); |
| 5 | } |
| 6 | |
| 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) { |
| 13 | case 'g': |
| 14 | $memLimit *= 1024; |
| 15 | case 'm': |
| 16 | $memLimit *= 1024; |
| 17 | case 'k': |
| 18 | $memLimit *= 1024; |
| 19 | } |
| 20 | |
| 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); |
| 24 | } |
| 25 | date_default_timezone_set('UTC'); // avoid php warnings if timezone is not set - CRM-10844 |
| 26 | |
| 27 | define('CIVICRM_UF', 'Drupal'); |
| 28 | define('CIVICRM_UF_BASEURL', '/'); |
| 29 | |
| 30 | require_once 'CRM/Core/ClassLoader.php'; |
| 31 | CRM_Core_ClassLoader::singleton()->register(); |
| 32 | |
| 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 |
| 39 | NULL, // IGNORE |
| 40 | @$argv[3], // cms |
| 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 |
| 44 | ); |
| 45 | $genCode->main(); |