sbsv1_os/e32toolp/group/setupprj.bat
branchRCL_3
changeset 1 d4b442d23379
parent 0 83f4b4db085c
child 2 99082257a271
equal deleted inserted replaced
0:83f4b4db085c 1:d4b442d23379
    24 
    24 
    25 my $EPOCRoot;
    25 my $EPOCRoot;
    26 
    26 
    27 BEGIN {
    27 BEGIN {
    28 	$EPOCRoot = $ENV{EPOCROOT};
    28 	$EPOCRoot = $ENV{EPOCROOT};
       
    29 	$EPOCRoot .= "\\" unless($EPOCRoot =~ /\\$/);
    29 	die "ERROR: Must set the EPOCROOT environment variable\n" if (!defined($EPOCRoot));
    30 	die "ERROR: Must set the EPOCROOT environment variable\n" if (!defined($EPOCRoot));
    30 	$EPOCRoot =~ s-/-\\-go;	# for those working with UNIX shells
    31 	$EPOCRoot =~ s-/-\\-go;	# for those working with UNIX shells
    31 	die "ERROR: EPOCROOT must be an absolute path\n" if ($EPOCRoot !~ /^\\/);
       
    32 	die "ERROR: EPOCROOT must not be a UNC path\n" if ($EPOCRoot =~ /^\\\\/);
    32 	die "ERROR: EPOCROOT must not be a UNC path\n" if ($EPOCRoot =~ /^\\\\/);
    33 	die "ERROR: EPOCROOT must end with a backslash\n" if ($EPOCRoot !~ /\\$/);
    33 	die "ERROR: EPOCROOT must end with a backslash\n" if ($EPOCRoot !~ /\\$/);
    34 	die "ERROR: EPOCROOT must specify an existing directory\n" if (!-d $EPOCRoot);
    34 	die "ERROR: EPOCROOT must specify an existing directory\n" if (!-d $EPOCRoot);
    35 }
    35 }
    36 
    36 
    76 	}
    76 	}
    77 $GroupDir=~s-^(.*\\)[^\\]+$-$1-o; # remove filename, leaving just path
    77 $GroupDir=~s-^(.*\\)[^\\]+$-$1-o; # remove filename, leaving just path
    78 # strip the resulting path of excess occurrences of . and ..
    78 # strip the resulting path of excess occurrences of . and ..
    79 while ($GroupDir=~s-\\\.\\-\\-go) { }
    79 while ($GroupDir=~s-\\\.\\-\\-go) { }
    80 while ($GroupDir=~s-\\(?!\.{2}\\)[^\\]*\\\.{2}(?=\\)--go) { }
    80 while ($GroupDir=~s-\\(?!\.{2}\\)[^\\]*\\\.{2}(?=\\)--go) { }
    81 
       
    82 my $GroupToRoot=&UpToRoot($GroupDir);
       
    83 chop $GroupToRoot;
       
    84 
       
    85 my $GroupToToolsPath="$GroupToRoot$EPOCToolsPath";
       
    86 
       
    87 my $GroupToToolsConfigFilePath="$GroupToRoot$EPOCToolsConfigFilePath";
       
    88 
       
    89 my $GroupToDocsPath="$GroupToRoot$DocsPath";
       
    90 	
       
    91 my $GroupToTemplatePath="$GroupToRoot$TemplateFilePath";
       
    92 
       
    93 my $GroupToShellPath="$GroupToRoot$ShellFilePath";
       
    94 
       
    95 my $GroupToBinPath="$GroupToRoot$BinFilePath";
       
    96 
    81 
    97 $GroupDir=~s-\\$--o;	# remove trailing backslash
    82 $GroupDir=~s-\\$--o;	# remove trailing backslash
    98 chdir "$GroupDir" or die "Can't cd to $GroupDir: $!\n";
    83 chdir "$GroupDir" or die "Can't cd to $GroupDir: $!\n";
    99 
    84 
   100 my %Files=();
    85 my %Files=();
   183 &Output(
   168 &Output(
   184 	"\@echo off\n",
   169 	"\@echo off\n",
   185 	"\@goto invoke\n",
   170 	"\@goto invoke\n",
   186 	"\n",
   171 	"\n",
   187 	"#!perl\n",
   172 	"#!perl\n",
   188 	"unless (\@ARGV==1 && \$ARGV[0]=~/^(deb|rel|clean)\$/io) {\n",
   173 	"unless (\@ARGV==1 && \$ARGV[0]=~/^(deb|rel|clean|releasables)\$/io) {\n",
   189 	"	die\n",
   174 	"	die\n",
   190 	"		\"E32TOOLP's bld.bat - usage\\n\",\n",
   175 	"		\"E32TOOLP's bld.bat - usage\\n\",\n",
   191 	"		\"BLD [param]\\n\",\n",
   176 	"		\"BLD [param]\\n\",\n",
   192 	"		\"where\\n\",\n",
   177 	"		\"where\\n\",\n",
   193 	"		\"param = DEB or REL or CLEAN\\n\"\n",
   178 	"		\"param = DEB or REL or CLEAN\\n\"\n",
   194 	"	;\n",
   179 	"	;\n",
   195 	"}\n",
   180 	"}\n",
   196 	"my \$Param=lc \$ARGV[0];\n",
   181 	"my \$Param=lc \$ARGV[0];\n",
   197 	"chdir \"$PrintGroupDir\";\n",
   182 	"chdir \"$PrintGroupDir\";\n",
       
   183 	"if (\$Param =~ /releasables/i)\n",
       
   184 	"{\n",
       
   185 	"open PIPE, \"..\\\\binutils\\\\make -s -f e32toolp.make \$Param |\" or die \"Can't invoke make: \$!\\n\";\n",
       
   186 	"while (<PIPE>) { print \$_; }\n",
       
   187 	"close PIPE;\n",
       
   188 	"\n",
       
   189 	"exit;\n",
       
   190 	"}\n",
   198 	"print \"..\\\\binutils\\\\make -s -f e32toolp.make \$Param\\n\";\n",
   191 	"print \"..\\\\binutils\\\\make -s -f e32toolp.make \$Param\\n\";\n",
   199 	"open PIPE, \"..\\\\binutils\\\\make -s -f e32toolp.make \$Param |\" or die \"Can't invoke make: \$!\\n\";\n",
   192 	"open PIPE, \"..\\\\binutils\\\\make -s -f e32toolp.make \$Param |\" or die \"Can't invoke make: \$!\\n\";\n",
   200 	"while (<PIPE>) {}\n",
   193 	"while (<PIPE>) { }\n",
   201 	"close PIPE;\n",
   194 	"close PIPE;\n",
   202 	"\n",
   195 	"\n",
   203 	"__END__\n",
   196 	"__END__\n",
   204 	"\n",
   197 	"\n",
   205 	":invoke\n",
   198 	":invoke\n",
   222 	"else\n",
   215 	"else\n",
   223 	"ERASE = \@erase\n",
   216 	"ERASE = \@erase\n",
   224 	"endif\n",
   217 	"endif\n",
   225 	"\n",
   218 	"\n",
   226 	"\n",
   219 	"\n",
   227 	"$GroupToToolsPath :\n",
   220 	"$EPOCToolsPath :\n",
   228 	"\t\@perl -w ..\\genutil\\emkdir.pl $GroupToToolsPath\n", 
   221 	"\t\@perl -w ..\\genutil\\emkdir.pl $EPOCToolsPath\n", 
   229 	"\n",
   222 	"\n",
   230 	"$GroupToTemplatePath :\n",
   223 	"$TemplateFilePath :\n",
   231 	"\t\@perl -w ..\\genutil\\emkdir.pl $GroupToTemplatePath\n", 
   224 	"\t\@perl -w ..\\genutil\\emkdir.pl $TemplateFilePath\n", 
   232 	"\n"
   225 	"\n"
   233 );
   226 );
   234 
   227 
   235 foreach (sort keys %TemplateDirs) {
   228 foreach (sort keys %TemplateDirs) {
   236 	&Output(
   229 	&Output(
   237 	"$GroupToTemplatePath\\$_ :\n",
   230 	"$TemplateFilePath\\$_ :\n",
   238 	"\t\@perl -w ..\\genutil\\emkdir.pl $GroupToTemplatePath\\$_\n", 
   231 	"\t\@perl -w ..\\genutil\\emkdir.pl $TemplateFilePath\\$_\n", 
   239 	"\n"
   232 	"\n"
   240 	);
   233 	);
   241 }
   234 }
   242 
   235 
   243 foreach (sort keys %BinDirs) {
   236 foreach (sort keys %BinDirs) {
   244  	&Output(
   237  	&Output(
   245  	"$GroupToBinPath\\$_ :\n",
   238  	"$BinFilePath\\$_ :\n",
   246  	"\t\@perl -w ..\\genutil\\emkdir.pl $GroupToBinPath\\$_\n", 
   239  	"\t\@perl -w ..\\genutil\\emkdir.pl $BinFilePath\\$_\n", 
   247  	"\n"
   240  	"\n"
   248  	);
   241  	);
   249 }
   242 }
   250 
   243 
   251 &Output(
   244 &Output(
   252 	"$GroupToShellPath :\n",
   245 	"$ShellFilePath :\n",
   253 	"\t\@perl -w ..\\genutil\\emkdir.pl $GroupToShellPath\n", 
   246 	"\t\@perl -w ..\\genutil\\emkdir.pl $ShellFilePath\n", 
   254 	"\n",
   247 	"\n",
   255 	"$GroupToToolsConfigFilePath :\n",
   248 	"$EPOCToolsConfigFilePath :\n",
   256 	"\t\@perl -w ..\\genutil\\emkdir.pl $GroupToToolsConfigFilePath\n", 
   249 	"\t\@perl -w ..\\genutil\\emkdir.pl $EPOCToolsConfigFilePath\n", 
   257 	"\n",
   250 	"\n",
   258 	"$GroupToDocsPath :\n",
   251 	"$DocsPath :\n",
   259 	"\t\@perl -w ..\\genutil\\emkdir.pl $GroupToDocsPath\n", 
   252 	"\t\@perl -w ..\\genutil\\emkdir.pl $DocsPath\n", 
   260 	"\n",
   253 	"\n",
   261 	"\n",
   254 	"\n",
   262 	"deb : $GroupToToolsPath $GroupToToolsConfigFilePath $GroupToDocsPath $GroupToTemplatePath $GroupToShellPath "
   255 	"deb : $EPOCToolsPath $EPOCToolsConfigFilePath $DocsPath $TemplateFilePath $ShellFilePath "
   263 );
   256 );
   264 
   257 
   265 foreach (sort keys %TemplateDirs) {
   258 foreach (sort keys %TemplateDirs) {
   266 	&Output(
   259 	&Output(
   267 	"$GroupToTemplatePath\\$_ "
   260 	"$TemplateFilePath\\$_ "
   268 	);
   261 	);
   269 }
   262 }
   270 
   263 
   271 foreach (sort keys %BinDirs) {
   264 foreach (sort keys %BinDirs) {
   272  	&Output(
   265  	&Output(
   273  	"$GroupToBinPath\\$_ "
   266  	"$BinFilePath\\$_ "
   274  	);
   267  	);
   275 }
   268 }
   276 
   269 
   277 &Output("\n");
   270 &Output("\n");
   278 
   271 
   279 my $File;
   272 my $File;
   280 foreach $File (keys %Files) {
   273 foreach $File (keys %Files) {
   281 	&Output(
   274 	&Output(
   282 		"\tcopy \"..\\$Files{$File}\" \"$GroupToToolsPath\\$File\" >nul\n"
   275 		"\tcopy \"..\\$Files{$File}\" \"$EPOCToolsPath\\$File\" >nul\n"
   283 	);
   276 	);
   284 }
   277 }
   285 
   278 
   286 my $ConfigFile;
   279 my $ConfigFile;
   287 foreach $ConfigFile (@ConfigFiles) {
   280 foreach $ConfigFile (@ConfigFiles) {
   288 	&Output(
   281 	&Output(
   289 		"\tcopy \"..\\platform\\$ConfigFile\" \"$GroupToToolsConfigFilePath\\$ConfigFile\" >nul\n"
   282 		"\tcopy \"..\\platform\\$ConfigFile\" \"$EPOCToolsConfigFilePath\\$ConfigFile\" >nul\n"
   290 	);
   283 	);
   291 }
   284 }
   292 
   285 
   293 foreach $File (@Docs) {
   286 foreach $File (@Docs) {
   294 	&Output(
   287 	&Output(
   295 			"\tcopy \"..\\Docs\\$File\" \"$GroupToDocsPath\\$File\" >nul\n"
   288 			"\tcopy \"..\\Docs\\$File\" \"$DocsPath\\$File\" >nul\n"
   296 	);
   289 	);
   297 }
   290 }
   298 
   291 
   299 my $tfile;
   292 my $tfile;
   300 foreach $tfile (@TemplateFiles) {
   293 foreach $tfile (@TemplateFiles) {
   301 	&Output(
   294 	&Output(
   302 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\extension\\$tfile\" \"$GroupToTemplatePath\\$tfile\" >nul\n"
   295 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\extension\\$tfile\" \"$TemplateFilePath\\$tfile\" >nul\n"
   303 	);
   296 	);
   304 }
   297 }
   305 
   298 
   306 my $bfile;
   299 my $bfile;
   307 foreach $bfile (@BinFiles) {
   300 foreach $bfile (@BinFiles) {
   308  	&Output(
   301  	&Output(
   309  			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\bin\\$bfile\" \"$GroupToBinPath\\$bfile\" >nul\n"
   302  			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\bin\\$bfile\" \"$BinFilePath\\$bfile\" >nul\n"
   310  	);
   303  	);
   311 }
   304 }
   312 
   305 
   313 my $sfile;
   306 my $sfile;
   314 foreach $sfile (@ShellFiles) {
   307 foreach $sfile (@ShellFiles) {
   315 	&Output(
   308 	&Output(
   316 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\shell\\$sfile\" \"$GroupToShellPath\\$sfile\" >nul\n"
   309 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\shell\\$sfile\" \"$ShellFilePath\\$sfile\" >nul\n"
   317 	);
   310 	);
   318 }
   311 }
   319 
   312 
   320 &Output(
   313 &Output(
   321 	"\n",
   314 	"\n",
   322 	"\n",
   315 	"\n",
   323 	"rel : $GroupToToolsPath $GroupToToolsConfigFilePath $GroupToDocsPath $GroupToTemplatePath $GroupToShellPath "
   316 	"rel : $EPOCToolsPath $EPOCToolsConfigFilePath $DocsPath $TemplateFilePath $ShellFilePath "
   324 );
   317 );
   325 
   318 
   326 foreach (sort keys %TemplateDirs) {
   319 foreach (sort keys %TemplateDirs) {
   327 	&Output(
   320 	&Output(
   328 	"$GroupToTemplatePath\\$_ "
   321 	"$TemplateFilePath\\$_ "
   329 	);
   322 	);
   330 }
   323 }
   331 
   324 
   332 foreach (sort keys %BinDirs) {
   325 foreach (sort keys %BinDirs) {
   333  	&Output(
   326  	&Output(
   334  	"$GroupToBinPath\\$_ "
   327  	"$BinFilePath\\$_ "
   335  	);
   328  	);
   336 }
   329 }
   337 
   330 
   338 &Output("\n");
   331 &Output("\n");
   339 
   332 
   340 	
   333 	
   341 foreach $File (keys %Files) {
   334 foreach $File (keys %Files) {
   342 	&Output(
   335 	&Output(
   343 		"\t.\\perlprep.bat \"..\\$Files{$File}\" \"$GroupToToolsPath\\$File\"\n"
   336 		"\t.\\perlprep.bat \"..\\$Files{$File}\" \"$EPOCToolsPath\\$File\"\n"
   344 	);
   337 	);
   345 }
   338 }
   346 
   339 
   347 foreach $ConfigFile (@ConfigFiles) {
   340 foreach $ConfigFile (@ConfigFiles) {
   348 	&Output(
   341 	&Output(
   349 		"\tcopy \"..\\platform\\$ConfigFile\" \"$GroupToToolsConfigFilePath\\$ConfigFile\" >nul\n"
   342 		"\tcopy \"..\\platform\\$ConfigFile\" \"$EPOCToolsConfigFilePath\\$ConfigFile\" >nul\n"
   350 	);
   343 	);
   351 }
   344 }
   352 
   345 
   353 foreach $File (@Docs) {
   346 foreach $File (@Docs) {
   354 	&Output(
   347 	&Output(
   355 			"\tcopy \"..\\Docs\\$File\" \"$GroupToDocsPath\\$File\" >nul\n"
   348 			"\tcopy \"..\\Docs\\$File\" \"$DocsPath\\$File\" >nul\n"
   356 	);
   349 	);
   357 }
   350 }
   358 
   351 
   359 foreach $tfile (@TemplateFiles) {
   352 foreach $tfile (@TemplateFiles) {
   360 	&Output(
   353 	&Output(
   361 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\extension\\$tfile\" \"$GroupToTemplatePath\\$tfile\" >nul\n"
   354 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\extension\\$tfile\" \"$TemplateFilePath\\$tfile\" >nul\n"
   362 	);
   355 	);
   363 }
   356 }
   364 foreach $bfile (@BinFiles) {
   357 foreach $bfile (@BinFiles) {
   365  	&Output(
   358  	&Output(
   366  			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\bin\\$bfile\" \"$GroupToBinPath\\$bfile\" >nul\n"
   359  			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\bin\\$bfile\" \"$BinFilePath\\$bfile\" >nul\n"
   367  	);
   360  	);
   368 }
   361 }
   369 foreach $sfile (@ShellFiles) {
   362 foreach $sfile (@ShellFiles) {
   370 	&Output(
   363 	&Output(
   371 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\shell\\$sfile\" \"$GroupToShellPath\\$sfile\" >nul\n"
   364 			"\tcopy \"..\\..\\..\\toolsandutils\\buildsystem\\shell\\$sfile\" \"$ShellFilePath\\$sfile\" >nul\n"
   372 	);
   365 	);
   373 }
   366 }
   374 &Output(
   367 &Output(
   375 	"\n",
   368 	"\n",
   376 	"rel deb : $GroupToToolsPath\\make.exe\n",
   369 	"rel deb : $EPOCToolsPath\\make.exe\n",
   377 	"$GroupToToolsPath\\make.exe: ..\\binutils\\make.exe\n",
   370 	"$EPOCToolsPath\\make.exe: ..\\binutils\\make.exe\n",
   378 	"\tcopy \$\? \$\@\n"
   371 	"\tcopy \$\? \$\@\n"
   379 );
   372 );
   380 
   373 
   381 &Output(
   374 &Output(
   382 	"\n",
   375 	"\n",
   383 	"rel deb : $GroupToToolsPath\\scpp.exe\n",
   376 	"rel deb : $EPOCToolsPath\\scpp.exe\n",
   384 	"$GroupToToolsPath\\scpp.exe: ..\\binutils\\scpp.exe\n",
   377 	"$EPOCToolsPath\\scpp.exe: ..\\binutils\\scpp.exe\n",
   385 	"\tcopy \$\? \$\@\n"
   378 	"\tcopy \$\? \$\@\n"
   386 );
   379 );
   387 
   380 
   388 
   381 
   389 &Output(
   382 &Output(
   390 	"\n",
   383 	"\n",
   391 	"clean :\n"
   384 	"clean :\n"
   392 );
   385 );
   393 foreach $File (keys %Files) {
   386 foreach $File (keys %Files) {
   394 	&Output(
   387 	&Output(
   395 		"\t-\$(ERASE) \"$GroupToToolsPath\\$File\"\n"
   388 		"\t-\$(ERASE) \"$EPOCToolsPath\\$File\"\n"
   396 	);
   389 	);
   397 }
   390 }
   398 foreach $ConfigFile (@ConfigFiles) {
   391 foreach $ConfigFile (@ConfigFiles) {
   399 	&Output(
   392 	&Output(
   400 		"\t-\$(ERASE) \"$GroupToToolsConfigFilePath\\$ConfigFile\"\n"
   393 		"\t-\$(ERASE) \"$EPOCToolsConfigFilePath\\$ConfigFile\"\n"
   401 	);
   394 	);
   402 }
   395 }
   403 foreach $File (@Docs) {
   396 foreach $File (@Docs) {
   404 	&Output(
   397 	&Output(
   405 			"\t-\$(ERASE) \"$GroupToDocsPath\\$File\"\n"
   398 			"\t-\$(ERASE) \"$DocsPath\\$File\"\n"
   406 	);
   399 	);
   407 }
   400 }
   408 foreach $tfile (@TemplateFiles) {
   401 foreach $tfile (@TemplateFiles) {
   409 	&Output(
   402 	&Output(
   410 			"\t-\$(ERASE) \"$GroupToTemplatePath\\$tfile\"\n"
   403 			"\t-\$(ERASE) \"$TemplateFilePath\\$tfile\"\n"
   411 	);
   404 	);
   412 }
   405 }
   413 foreach $bfile (@BinFiles) {
   406 foreach $bfile (@BinFiles) {
   414  	&Output(
   407  	&Output(
   415  			"\t-\$(ERASE) \"$GroupToBinPath\\$bfile\"\n"
   408  			"\t-\$(ERASE) \"$BinFilePath\\$bfile\"\n"
   416  	);
   409  	);
   417 }
   410 }
   418 foreach $sfile (@ShellFiles) {
   411 foreach $sfile (@ShellFiles) {
   419 	&Output(
   412 	&Output(
   420 			"\t-\$(ERASE) \"$GroupToShellPath\\$sfile\"\n"
   413 			"\t-\$(ERASE) \"$ShellFilePath\\$sfile\"\n"
       
   414 	);
       
   415 }
       
   416 
       
   417 &Output(
       
   418 	"\n",
       
   419 	"releasables :\n"
       
   420 );
       
   421 foreach $File (keys %Files) {
       
   422 	&Output(
       
   423 		"\t\@echo $EPOCToolsPath\\$File\n"
       
   424 	);
       
   425 }
       
   426 foreach $ConfigFile (@ConfigFiles) {
       
   427 	&Output(
       
   428 		"\t\@echo $EPOCToolsConfigFilePath\\$ConfigFile\n"
       
   429 	);
       
   430 }
       
   431 foreach $File (@Docs) {
       
   432 	&Output(
       
   433 			"\t\@echo $DocsPath\\$File\n"
       
   434 	);
       
   435 }
       
   436 foreach $tfile (@TemplateFiles) {
       
   437 	&Output(
       
   438 			"\t\@echo $TemplateFilePath\\$tfile\n"
       
   439 	);
       
   440 }
       
   441 foreach $bfile (@BinFiles) {
       
   442  	&Output(
       
   443  			"\t\@echo $BinFilePath\\$bfile\n"
       
   444  	);
       
   445 }
       
   446 foreach $sfile (@ShellFiles) {
       
   447 	&Output(
       
   448 			"\t\@echo $ShellFilePath\\$sfile\n"
   421 	);
   449 	);
   422 }
   450 }
   423 
   451 
   424 my $MAKEFILE="e32toolp.make";
   452 my $MAKEFILE="e32toolp.make";
   425 print "Creating File \"$MAKEFILE\"\n";
   453 print "Creating File \"$MAKEFILE\"\n";