atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2007-2008 Eclipse Foundation and others. |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Antoine Toulme, Intalio Inc. bug 248845: Refactoring generate1.php into different files with a functional approach |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | /* |
| 14 | * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs |
| 15 | */ |
| 16 | |
| 17 | ob_start(); |
| 18 | ini_set("memory_limit", "64M"); |
| 19 | define("BABEL_BASE_DIR", "../../"); |
| 20 | require(BABEL_BASE_DIR . "html/common_functions.php"); |
| 21 | require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php"); |
| 22 | require(BABEL_BASE_DIR . "classes/system/feature.class.php"); |
| 23 | $dbc = new DBConnection(); |
| 24 | $dbh = $dbc->connect(); |
| 25 | |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame^] | 26 | $work_dir = "/tmp/babel-working/"; |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 27 | if (!($ini = @parse_ini_file(BABEL_BASE_DIR . "classes/base.conf"))) { |
| 28 | errorLog("Failed to find/read database conf file - aborting."); |
| 29 | exitTo("error.php?errNo=101300","error: 101300 - database conf can not be found"); |
| 30 | } |
| 31 | |
| 32 | $context = $ini['context']; |
| 33 | |
| 34 | $work_context_dir = $work_dir . $context . "_feature/"; |
| 35 | $tmp_dir = $work_context_dir . "tmp/"; |
| 36 | $output_dir = $work_context_dir . "output/"; |
| 37 | $features_dir = $work_context_dir . "features/"; |
| 38 | |
| 39 | exec("rm -rf $work_context_dir*"); |
| 40 | exec("mkdir -p $output_dir"); |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame^] | 41 | exec("mkdir -p $features_dir"); |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 42 | |
atoulme | cab9de9 | 2008-11-24 15:04:02 +0000 | [diff] [blame] | 43 | foreach(ReleaseTrain::all() as $train) { |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame^] | 44 | exec("mkdir -p $features_dir/$train->id"); |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 45 | $output_dir_for_train = "$output_dir/$train->id/"; |
atoulme | dfee65f | 2008-11-24 14:59:26 +0000 | [diff] [blame] | 46 | foreach(Language::all() as $lang) { |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 47 | $feature = new Feature($lang, $train, $tmp_dir, $output_dir_for_train); |
| 48 | $feature->generateAll(); |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame^] | 49 | $featureZip = $feature->zip("$features_dir/$train->id"); |
| 50 | echo "Feature created here: $featureZip\n"; |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 51 | } |
| 52 | } |