Merge pull request #16558 from eileenmcnaughton/523dupe
[civicrm-core.git] / xml / GenCode.php
CommitLineData
6a488035 1<?php
e06b5e14
TO
2
3if (PHP_SAPI !== 'cli') {
4 die("GenCode can only be run from command line.");
5}
6
0825dc24
TO
7$includes = ['.', '../packages', '../../civicrm-packages', '..'];
8ini_set('include_path', implode(PATH_SEPARATOR, $includes));
0d035206 9// make sure the memory_limit is at least 512 MB
10$memLimitString = trim(ini_get('memory_limit'));
56fdfc52
TO
11$memLimitUnit = strtolower(substr($memLimitString, -1));
12$memLimit = (int) $memLimitString;
0d035206 13switch ($memLimitUnit) {
56fdfc52
TO
14 case 'g':
15 $memLimit *= 1024;
16 case 'm':
17 $memLimit *= 1024;
18 case 'k':
19 $memLimit *= 1024;
0d035206 20}
21
22if ($memLimit >= 0 and $memLimit < 536870912) {
8652384e
TO
23 // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM.
24 ini_set('memory_limit', -1);
0d035206 25}
683bf891
SL
26// avoid php warnings if timezone is not set - CRM-10844
27date_default_timezone_set('UTC');
6a488035
TO
28
29define('CIVICRM_UF', 'Drupal');
2a8330d8 30define('CIVICRM_UF_BASEURL', '/');
1b94154b 31define('CIVICRM_L10N_BASEDIR', getenv('CIVICRM_L10N_BASEDIR') ? getenv('CIVICRM_L10N_BASEDIR') : __DIR__ . '/../l10n');
6a488035
TO
32
33require_once 'CRM/Core/ClassLoader.php';
34CRM_Core_ClassLoader::singleton()->register();
35
e39816b5
ARW
36# TODO: pull these settings from configuration
37$genCode = new CRM_Core_CodeGen_Main(
683bf891
SL
38 // $CoreDAOCodePath
39 '../CRM/Core/DAO/',
40 // $sqlCodePath
41 '../sql/',
42 // $phpCodePath
43 '../',
44 // $tplCodePath
45 '../templates/',
46 // IGNORE
47 NULL,
48 // cms
49 @$argv[3],
50 // db version
51 empty($argv[2]) ? NULL : $argv[2],
52 // schema file
53 empty($argv[1]) ? 'schema/Schema.xml' : $argv[1],
54 // path to digest file
55 getenv('CIVICRM_GENCODE_DIGEST') ? getenv('CIVICRM_GENCODE_DIGEST') : NULL
6a488035 56);
c59c0e21 57$genCode->main();