Merge pull request #14437 from agh1/no-php-56
[civicrm-core.git] / xml / GenCode.php
... / ...
CommitLineData
1<?php
2
3if (PHP_SAPI !== 'cli') {
4 die("GenCode can only be run from command line.");
5}
6
7ini_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;
12switch ($memLimitUnit) {
13 case 'g':
14 $memLimit *= 1024;
15 case 'm':
16 $memLimit *= 1024;
17 case 'k':
18 $memLimit *= 1024;
19}
20
21if ($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// avoid php warnings if timezone is not set - CRM-10844
26date_default_timezone_set('UTC');
27
28define('CIVICRM_UF', 'Drupal');
29define('CIVICRM_UF_BASEURL', '/');
30
31require_once 'CRM/Core/ClassLoader.php';
32CRM_Core_ClassLoader::singleton()->register();
33
34# TODO: pull these settings from configuration
35$genCode = new CRM_Core_CodeGen_Main(
36 // $CoreDAOCodePath
37 '../CRM/Core/DAO/',
38 // $sqlCodePath
39 '../sql/',
40 // $phpCodePath
41 '../',
42 // $tplCodePath
43 '../templates/',
44 // IGNORE
45 NULL,
46 // cms
47 @$argv[3],
48 // db version
49 empty($argv[2]) ? NULL : $argv[2],
50 // schema file
51 empty($argv[1]) ? 'schema/Schema.xml' : $argv[1],
52 // path to digest file
53 getenv('CIVICRM_GENCODE_DIGEST') ? getenv('CIVICRM_GENCODE_DIGEST') : NULL
54);
55$genCode->main();