Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rouffj committed Nov 20, 2010
0 parents commit c3a1f3f
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.swp
.DS_Store
thumbs.db
Icon?
Thumbs.db
78 changes: 78 additions & 0 deletions phing/tasks/my/MyDependTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

require_once "phing/Task.php";

class MyDependTask extends Task {

/**
* The dir passed in the buildfile.
*/
private $names = null;

/**
* The message passed in the buildfile.
*/
private $type = null;

/**
* The setter for the attribute "message"
*/
public function setNames($names) {
$names = explode(',', $names);
array_walk(&$names, 'trim');
$this->names = $names;
}

/**
* Specify the working directory for executing this command.
* @param PhingFile $dir
*/
function setType($type) {
$this->type = $type;
}

/**
* The init method: Do init steps.
*/
public function init() {
// nothing to do here
}

/**
* The main entry point method.
*/
public function main() {
if ($this->type == 'phpext')
$this->_checkPhpExt();
else
$this->_checkCmd();
}

private function _checkPhpExt() {
$line = "[%s] PHP EXTENSION \t: `%s`";
$content = array();
exec('php -m', &$content);
$content = implode("\n", $content);
foreach($this->names as $ext) {
if (preg_match('/'.$ext.'/', $content) > 0)
$this->log(sprintf($line, 'OK', $ext));
else
$this->log(sprintf($line, 'KO', $ext), Project::MSG_ERR);
}
}

private function _checkCmd() {
$line = "[%s] COMMAND \t: `%s`";
foreach($this->names as $bin) {
exec('which ' . $bin, &$content, &$return);
if ($return === 0)
$this->log(sprintf($line, 'OK', $bin));
else
$this->log(sprintf($line, 'KO', $bin), Project::MSG_ERR);
}
}

}

?>

70 changes: 70 additions & 0 deletions phing/tasks/my/MyRtexecTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

require_once "phing/Task.php";

class MyRtexecTask extends Task {

/**
* The dir passed in the buildfile.
*/
private $dir = null;

/**
* The message passed in the buildfile.
*/
private $command = null;

/**
* The setter for the attribute "message"
*/
public function setCommand($str) {
$this->command = $str;
}

/**
* Specify the working directory for executing this command.
* @param PhingFile $dir
*/
function setDir(PhingFile $dir) {
$this->dir = $dir;
}

/**
* The init method: Do init steps.
*/
public function init() {
// nothing to do here
}

/**
* The main entry point method.
*/
public function main() {

if ($this->dir !== null) {
if ($this->dir->isDirectory()) {
$currdir = getcwd();
@chdir($this->dir->getPath());
} else {
throw new BuildException("Can't chdir to:" . $this->dir->__toString());
}
}

$a = popen($this->command, 'r');

while($b = fgets($a)) {
$this->log($b);
flush();
}
pclose($a);

if ($this->dir !== null) {
@chdir($currdir);
}

}

}

?>

0 comments on commit c3a1f3f

Please sign in to comment.