Merge pull request #15888 from seamuslee001/lab_core_1406
[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
6a488035 7ini_set('include_path', '.' . PATH_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR . '..');
0d035206 8// make sure the memory_limit is at least 512 MB
9$memLimitString = trim(ini_get('memory_limit'));
56fdfc52
TO
10$memLimitUnit = strtolower(substr($memLimitString, -1));
11$memLimit = (int) $memLimitString;
0d035206 12switch ($memLimitUnit) {
56fdfc52
TO
13 case 'g':
14 $memLimit *= 1024;
15 case 'm':
16 $memLimit *= 1024;
17 case 'k':
18 $memLimit *= 1024;
0d035206 19}
20
21if ($memLimit >= 0 and $memLimit < 536870912) {
8652384e
TO
22 // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM.
23 ini_set('memory_limit', -1);
0d035206 24}
683bf891
SL
25// avoid php warnings if timezone is not set - CRM-10844
26date_default_timezone_set('UTC');
6a488035
TO
27
28define('CIVICRM_UF', 'Drupal');
2a8330d8 29define('CIVICRM_UF_BASEURL', '/');
6a488035
TO
30
31require_once 'CRM/Core/ClassLoader.php';
32CRM_Core_ClassLoader::singleton()->register();
33
e39816b5
ARW
34# TODO: pull these settings from configuration
35$genCode = new CRM_Core_CodeGen_Main(
683bf891
SL
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
6a488035 54);
c59c0e21 55$genCode->main();