Visual Studio 2010 build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

some time ago I posted a script that removes mobile platforms from 
Visual studio solutions and projects. It removed everything except Win32 
so I am sending new version that preserves x64 platform as well.

Save the script to pjproject root and run:
CD \path\to\pjproject
\path\to\php.exe _pj_rm_mobile.php

And build PJSIP with VS 2010 smoothly!

Cheers,
- Vali

PS. If someone rewrote the script to Python, please, post it. :-)







-------------- next part --------------
#!/usr/bin/php -n
<?php

function process_dir($dir)
{
	if (substr($dir, -1) !== DIRECTORY_SEPARATOR)
		$dir .= DIRECTORY_SEPARATOR;
	$d = opendir($dir);
	while (($f = readdir($d)) !== false) {
		if ($f[0] === ".") continue;
		$f = $dir . $f;
		if (is_dir($f)) {
			if (preg_match("/\\Wthird_party\\W(BaseClasses|portaudio)\$/i", $f))
				continue;
			process_dir($f);
		} elseif (preg_match("/\\.sln\$/i", $f))
			fix_sln($f);
		elseif (preg_match("/\\.vcproj\$/i", $f))
			fix_proj($f);
	}
	closedir($d);
}


function fix_sln($fn)
{
	echo $fn, PHP_EOL;
	$sln = '';
	$f = fopen($fn, "rb");  // b: preserve line endings
	while (($ln = fgets($f)) !== false) {
		if (preg_match("/^\\s*build\\\\vs\\\\pjproject-vs8-wm/", $ln))
			continue;
		if (preg_match("/^\\s*(\\{[\\dA-Fa-f-]+\\}\\.)?(Debug|Release)(-Dynamic|-Static)?\\|(?!(Win32|x64))/", $ln))
			continue;
		if (preg_match("/\\.(ActiveCfg|Build\\.\\d+)\\s*=\\s*(Debug|Release)(-Dynamic|-Static)?\\|(?!(Win32|x64))\$/", $ln))
			continue;
		$sln .= $ln;
	}
	fclose($f);
	file_put_contents($fn, $sln);
}


function fix_proj($fn)
{
	echo $fn, PHP_EOL;
	$doc = new DOMDocument;
	$doc->load($fn);
	$platforms = $doc->getElementsByTagName("Platform");
	for ($i = $platforms->length - 1; $i >= 0; $i--) {
		$p = $platforms->item($i);
		if (($p->getAttribute("Name") != "Win32") && ($p->getAttribute("Name") != "x64"))
			$p->parentNode->removeChild($p);
	}
	$configurations = $doc->getElementsByTagName("Configuration");
	for ($i = $configurations->length - 1; $i >= 0; $i--) {
		$c = $configurations->item($i);
		if (!preg_match("/\\|(Win32|x64)\$/", $c->getAttribute("Name")))
			$c->parentNode->removeChild($c);
	}
	$fileConfigurations = $doc->getElementsByTagName("FileConfiguration");
	for ($i = $fileConfigurations->length - 1; $i >= 0; $i--) {
		$fc = $fileConfigurations->item($i);
		if (!preg_match("/\\|(Win32|x64)\$/", $fc->getAttribute("Name")))
			$fc->parentNode->removeChild($fc);
	}
	$proj = $doc->saveXML();
	$f = fopen($fn, "wt");  // t: platform-specific line endings
	fwrite($f, $proj);
	fclose($f);
}


process_dir(realpath("."));
?>





[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux