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 | |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 17 | ini_set("memory_limit", "64M"); |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 18 | require(dirname(__FILE__) . "/../system/backend_functions.php"); |
| 19 | |
| 20 | global $addon; |
| 21 | $context = $addon->callHook('context'); |
| 22 | |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 23 | require(dirname(__FILE__) . "/../system/dbconnection.class.php"); |
| 24 | require(dirname(__FILE__) . "/../system/feature.class.php"); |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 25 | $dbc = new DBConnection(); |
| 26 | $dbh = $dbc->connect(); |
| 27 | |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 28 | |
| 29 | $work_dir = $addon->callHook('babel_working'); |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 30 | |
| 31 | $work_context_dir = $work_dir . $context . "_feature/"; |
| 32 | $tmp_dir = $work_context_dir . "tmp/"; |
| 33 | $output_dir = $work_context_dir . "output/"; |
| 34 | $features_dir = $work_context_dir . "features/"; |
| 35 | |
| 36 | exec("rm -rf $work_context_dir*"); |
| 37 | exec("mkdir -p $output_dir"); |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame] | 38 | exec("mkdir -p $features_dir"); |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 39 | |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 40 | //iterate over all the release trains |
atoulme | cab9de9 | 2008-11-24 15:04:02 +0000 | [diff] [blame] | 41 | foreach(ReleaseTrain::all() as $train) { |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 42 | // create a dedicated folder for each of them |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame] | 43 | exec("mkdir -p $features_dir/$train->id"); |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 44 | // create the output folder for temporary artifacts |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 45 | $output_dir_for_train = "$output_dir/$train->id/"; |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 46 | // iterate over each language |
atoulme | dfee65f | 2008-11-24 14:59:26 +0000 | [diff] [blame] | 47 | foreach(Language::all() as $lang) { |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 48 | // create a new feature object |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 49 | $feature = new Feature($lang, $train, $tmp_dir, $output_dir_for_train); |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 50 | // make it generate itself |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 51 | $feature->generateAll(); |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 52 | // now zip it directly |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame] | 53 | $featureZip = $feature->zip("$features_dir/$train->id"); |
atoulme | dd1ac3c | 2008-12-03 12:51:19 +0000 | [diff] [blame] | 54 | // output the creation of the feature notification |
atoulme | a556369 | 2008-12-01 11:25:57 +0000 | [diff] [blame] | 55 | echo "Feature created here: $featureZip\n"; |
atoulme | 425b6c8 | 2008-11-24 14:00:27 +0000 | [diff] [blame] | 56 | } |
| 57 | } |