GenCode.php 1.42 KB
Newer Older
totten's avatar
totten committed
1
<?php
2 3 4 5 6

if (PHP_SAPI !== 'cli') {
  die("GenCode can only be run from command line.");
}

totten's avatar
totten committed
7
ini_set('include_path', '.' . PATH_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR . '..');
8 9
// make sure the memory_limit is at least 512 MB
$memLimitString = trim(ini_get('memory_limit'));
10 11
$memLimitUnit = strtolower(substr($memLimitString, -1));
$memLimit = (int) $memLimitString;
12
switch ($memLimitUnit) {
13 14 15 16 17 18
  case 'g':
    $memLimit *= 1024;
  case 'm':
    $memLimit *= 1024;
  case 'k':
    $memLimit *= 1024;
19 20 21
}

if ($memLimit >= 0 and $memLimit < 536870912) {
22 23
  // Note: When processing all locales, CRM_Core_I18n::singleton() eats a lot of RAM.
  ini_set('memory_limit', -1);
24
}
25 26
// avoid php warnings if timezone is not set - CRM-10844
date_default_timezone_set('UTC');
totten's avatar
totten committed
27 28

define('CIVICRM_UF', 'Drupal');
totten's avatar
totten committed
29
define('CIVICRM_UF_BASEURL', '/');
totten's avatar
totten committed
30 31 32 33

require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();

34 35
# TODO: pull these settings from configuration
$genCode = new CRM_Core_CodeGen_Main(
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  // $CoreDAOCodePath
  '../CRM/Core/DAO/',
  // $sqlCodePath
  '../sql/',
  // $phpCodePath
  '../',
  // $tplCodePath
  '../templates/',
  // IGNORE
  NULL,
  // cms
  @$argv[3],
  // db version
  empty($argv[2]) ? NULL : $argv[2],
  // schema file
  empty($argv[1]) ? 'schema/Schema.xml' : $argv[1],
  // path to digest file
  getenv('CIVICRM_GENCODE_DIGEST') ? getenv('CIVICRM_GENCODE_DIGEST') : NULL
totten's avatar
totten committed
54
);
totten's avatar
totten committed
55
$genCode->main();