-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c3a1f3f
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.swp | ||
.DS_Store | ||
thumbs.db | ||
Icon? | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} | ||
|
||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
?> | ||
|