在同一套代码里面建立不同的项目,各项目之间又不能相互影响,那么最有效的方法即将各项目相互影响的文件独立出来,编译时拷贝各项目相应文件到相应目录;
下面是拷贝代码:写在文件makeMtk中:
可以搜索$project找到如下代码,比如项目名为:test_xxx1,test_xxx2,test_xxx3,中等为test
while ($#ARGV != -1)
{
if ($ARGV[0] =~ /^-(t|te|tee)/)
{
$tee = "TRUE";
}
elsif ($ARGV[0] =~ /^-h|help/)
{
&Usage;
}
elsif ($ARGV[0] =~ /^-(o|op|opt)=(.*)$/)
{
@mOpts = split(",", $2);
}
elsif ($ARGV[0] =~ /^(listp|listproject)/)
{
&p_system("perl mediatek/build/tools/listP.pl");
exit 0;
}
elsif ($ARGV[0] =~ /check-env|chk-env/)
{
&chkMustEnv;
exit 0;
}
else
{
$project = lc($ARGV[0]);
$project = "generic" if ($project eq "emulator");
$project_config_name = "null";
if(($project eq "test_xxx1"))
{
$project_config_name = "test_xxx1";
}
elsif(($project eq "test_xxx2"))
{
$project_config_name = "test_xxx2";
}
if($project_config_name ne "null")
{
print "caihr: Important Information.\n";
print "You are choose the project with the config file in vendor/test/makefile/${project_config_name}\n";
system("cp -f vendor/test/makefile/${project_config_name}/test.mk build/target/product/");
system("cp -f vendor/test/makefile/${project_config_name}/ProjectConfig.mk mediatek/config/ $project");
system("cp -f vendor/test/makefile/${project_config_name}/codegen.dws mediatek/custom/$project/kernel/dct/dct");
// $project = $project_config_name;
}
if (!-e "mediatek/config/${project}/ProjectConfig.mk")
{
if (-e $ini)
{
open (FILE_HANDLE, "<$ini") or die "cannot open $ini\n";
while (<FILE_HANDLE>)
{
if (/^(\S+)\s*=\s*(\S+)/)
{
$keyname = $1;
$${keyname} = $2;
}
}
close FILE_HANDLE;
$project = lc($project);
$project_config_name = "null";
if(($project eq "test_xxx1"))
{
$project_config_name = "test_xxx1";
}
elsif(($project eq "test_xxx2"))
{
$project_config_name = "test_xxx2";
}
if($project_config_name ne "null")
{
print "caihr: Important Information.\n";
print "You are choose the project with the config file in vendor/test/makefile/${project_config_name}\n";
system("cp -f vendor/test/makefile/${project_config_name}/test.mk build/target/product/");
system("cp -f vendor/test/makefile/${project_config_name}/ProjectConfig.mk mediatek/config/ $project");
system("cp -f vendor/test/makefile/${project_config_name}/codegen.dws mediatek/custom/$project/kernel/dct/dct");
// $project = $project_config_name;
}
die "Can NOT find project Makefile "
. "mediatek/config/${project}/ProjectConfig.mk from $ini\n"
if (!-e "mediatek/config/${project}/ProjectConfig.mk");
}
}
else
{
shift(@ARGV);
}
die "Can NOT recognize project Makefile "
. "mediatek/config/${project}/ProjectConfig.mk from command\n"
if (!-e "mediatek/config/${project}/ProjectConfig.mk");
$action = lc($ARGV[0]);
shift(@ARGV);
@arguments = @ARGV;
@ARGV = ();
}
shift(@ARGV);
}