--- a/generate_system_models.pl Mon May 17 15:34:18 2010 +0100
+++ b/generate_system_models.pl Tue May 18 15:36:51 2010 +0100
@@ -9,10 +9,7 @@
chdir("tmp");
print "\n\n### CLONE MCL/sftools/fbf/projects/packages REPO ###\n";
-system("hg clone -r HighFidelityModel http://developer.symbian.org/oss/MCL/sftools/fbf/projects/packages");
-my $changeset = `hg -R packages identify -i`;
-chomp $changeset;
-print "-->$changeset<--\n";
+system("hg clone http://developer.symbian.org/oss/MCL/sftools/fbf/projects/packages");
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
my $timestamp = sprintf "%4d%02d%02d%02d%02d%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec;
#print "\n\n### CLONE MCL/sf/os/buildtools REPO ###\n";
@@ -25,6 +22,8 @@
my @codelines = grep(($_ !~ /^\.\.?$/ and $_ =~ /^symbian/), readdir(DIR));
close(DIR);
+my $packages_changeset = '';
+
# loop over codelines
for my $codeline (@codelines)
{
@@ -37,6 +36,12 @@
my $updatehifi_cmd = "hg -R packages update -r HighFidelityModel";
print "$updatehifi_cmd\n";
system($updatehifi_cmd);
+ if (!$packages_changeset)
+ {
+ $packages_changeset = `hg -R packages identify -i`;
+ chomp $packages_changeset;
+ print "-->$packages_changeset<--\n";
+ }
my $full_cmd = "$XALAN_C -o $codeline\\full_system_model_3.0.xml $ROOT_SYSDEF $SYSDEFTOOLS_PATH\\joinsysdef.xsl";
print "$full_cmd\n";
system($full_cmd);
@@ -90,21 +95,27 @@
mkdir("platforms\\$codeline\\single") if (!-d "platforms\\$codeline\\single");
mkdir("platforms\\$codeline\\single\\sysdefs") if (!-d "platforms\\$codeline\\single\\sysdefs");
mkdir("platforms\\$codeline\\single\\sysdefs\\auto") if (!-d "platforms\\$codeline\\single\\sysdefs\\auto");
- system("copy $codeline\\system_model.xml platforms\\$codeline\\single\\sysdefs\\auto\\model_$timestamp\_$changeset.xml");
+ system("copy $codeline\\system_model.xml platforms\\$codeline\\single\\sysdefs\\auto\\model_$timestamp\_$packages_changeset.xml");
system("hg -R platforms add");
- system("hg -R platforms commit -m \"Add auto generated $codeline system model (packages\@$changeset)\" -u\"Dario Sestito <darios\@symbian.org>\"");
- system("hg -R platforms push http://darios:symbian696b\@developer.symbian.org/oss/MCL/sftools/fbf/projects/platforms");
+ system("hg -R platforms commit -m \"Add auto generated $codeline system model (packages\@$packages_changeset)\" -u\"Dario Sestito <darios\@symbian.org>\"");
+ #system("hg -R platforms push http://darios:symbian696b\@developer.symbian.org/oss/MCL/sftools/fbf/projects/platforms");
# Split model into package models
print "\n\n### SPLIT MODEL INTO PACKAGE MODELS ###\n";
my $updatedefault_cmd = "hg -R packages update -r default";
print "$updatedefault_cmd\n";
system($updatedefault_cmd);
+ my $rmdir_cmd = "del /S packages\\symbian3\\package_definition.xml";
+ print "$rmdir_cmd\n";
+ system($rmdir_cmd);
my $splitmodel_cmd = "perl ..\\split_sysdef.pl -s $codeline\\system_model.xml -o packages\\$codeline";
print "$splitmodel_cmd\n";
system($splitmodel_cmd);
if ($codeline eq 'symbian3') # also update CompilerCompatibility
{
+ my $rmdir2_cmd = "del /S packages\\CompilerCompatibility\\package_definition.xml";
+ print "$rmdir2_cmd\n";
+ system($rmdir2_cmd);
my $splitmodel2_cmd = "perl ..\\split_sysdef.pl -s $codeline\\system_model.xml -o packages\\CompilerCompatibility";
print "$splitmodel2_cmd\n";
system($splitmodel2_cmd);
@@ -114,15 +125,15 @@
my @diff_output = `$diff_cmd`;
if (@diff_output)
{
- my $add_cmd = "hg -R packages add";
- print "$add_cmd\n";
- system($add_cmd);
- my $commit_cmd = "hg -R packages commit -m \"Update package models from auto generated system model (packages\@$changeset)\" -u\"Dario Sestito <darios\@symbian.org>\"";
+ my $addremove_cmd = "hg -R packages addremove";
+ print "$addremove_cmd\n";
+ system($addremove_cmd);
+ my $commit_cmd = "hg -R packages commit -m \"Update package models from auto generated system model (packages\@$packages_changeset)\" -u\"Dario Sestito <darios\@symbian.org>\"";
print "$commit_cmd\n";
system($commit_cmd);
my $push_cmd = "hg -R packages push http://darios:symbian696b\@developer.symbian.org/oss/MCL/sftools/fbf/projects/packages";
print "$push_cmd\n";
- system($push_cmd);
+ #system($push_cmd);
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/split_sysdef.pl Tue May 18 15:36:51 2010 +0100
@@ -0,0 +1,141 @@
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Split a system model file into many package model files (one per package)
+
+use strict;
+use Getopt::Long;
+use XML::DOM;
+
+my $DEFAULT_OUTDIR = "models";
+
+my $sysdef = '';
+my $outdir = $DEFAULT_OUTDIR;
+my $help = 0;
+GetOptions((
+ 'sysdef=s' => \$sysdef,
+ 'outdir:s' => \$outdir,
+ 'help!' => \$help
+));
+
+$help = 1 if (!$sysdef);
+
+if ($help)
+{
+ print "Split a system model file into many package model files (one per package)\n";
+ print "Usage: perl split_sysdef.pl --sysdef=FILE [OPTIONS]\n";
+ print "where:\n";
+ print "\tFILE is the input file to split\n";
+ print "and OPTIONS are:\n";
+ print "\t--outdir=DIR Generate package model files under DIR (default: $DEFAULT_OUTDIR)\n";
+ exit(0);
+}
+
+mkdir("$outdir") if (!-d$outdir);
+
+my $parser = new XML::DOM::Parser;
+my $doc = $parser->parsefile ($sysdef);
+
+# fix bldFile and mrp paths
+for my $unit ( $doc->getElementsByTagName("unit") )
+{
+ my $bldfile = $unit->getAttribute("bldFile");
+ if ($bldfile)
+ {
+ $bldfile =~ s,\\,/,g;
+ $bldfile = "/$bldfile" if ( $bldfile !~ m,^/, );
+ $bldfile = "/sf$bldfile" if ( $bldfile !~ m,^/sf, );
+ if ($bldfile =~ m,^/sf/(os|mw|app|tools|ostools|adaptation)/,)
+ {
+ $unit->setAttribute("bldFile", $bldfile);
+ }
+ else
+ {
+ print "WARNING: unexpected path in bldFile: $bldfile. Keeping as is\n";
+ }
+ }
+
+ my $mrp = $unit->getAttribute("mrp");
+ if ($mrp)
+ {
+ $mrp =~ s,\\,/,g;
+ $mrp = "/$mrp" if ( $mrp !~ m,^/, );
+ $mrp = "/sf$mrp" if ( $mrp !~ m,^/sf, );
+ if ($mrp =~ m,^/sf/(os|mw|app|tools|ostools|adaptation)/,)
+ {
+ $unit->setAttribute("mrp", $mrp);
+ }
+ else
+ {
+ print "WARNING: unexpected path in mrp: $mrp. Keeping as is\n" ;
+ }
+ }
+}
+
+my $packagedef_header = '';
+my $packagedef_trailer = '';
+
+my $systemdefinition = $doc->getElementsByTagName("SystemDefinition")->item(0);
+my $systemdefinition_attributes = $systemdefinition->getAttributes();
+my $systemdefinition_attributes_tostring = '';
+for ($systemdefinition_attributes->getValues) {$systemdefinition_attributes_tostring .= " ".$_->getName."=\"".$_->getValue."\"";}
+$packagedef_header .= "<SystemDefinition$systemdefinition_attributes_tostring>\n";
+$packagedef_trailer = "\n</SystemDefinition>".$packagedef_trailer;
+
+my $systemmodel = $systemdefinition->getElementsByTagName("systemModel")->item(0);
+my $systemmodel_attributes = $systemmodel->getAttributes();
+my $systemmodel_attributes_tostring = '';
+for ($systemmodel_attributes->getValues) {$systemmodel_attributes_tostring .= " ".$_->getName."=\"".$_->getValue."\"";}
+$packagedef_header .= "<systemModel$systemmodel_attributes_tostring>\n";
+$packagedef_trailer = "\n</systemModel>".$packagedef_trailer;
+
+for my $layer ( $systemmodel->getElementsByTagName("layer") )
+{
+ my $layer_name = $layer->getAttribute("name");
+
+ my $layer_attributes = $layer->getAttributes();
+ my $layer_attributes_tostring = '';
+ for ($layer_attributes->getValues) {$layer_attributes_tostring .= " ".$_->getName."=\"".$_->getValue."\"";}
+ my $layer_header = "<layer$layer_attributes_tostring>\n";
+ my $layer_trailer = "\n</layer>";
+
+ for my $block ( $layer->getElementsByTagName("block") )
+ {
+ my $block_name = $block->getAttribute("name");
+
+ mkdir("$outdir/$layer_name") if (!-d "$outdir/$layer_name");
+ mkdir("$outdir/$layer_name/$block_name") if (!-d "$outdir/$layer_name/$block_name");
+
+ # what source code doesn't belong to this package ?
+ for my $unit ( $block->getElementsByTagName("unit") )
+ {
+ my $bldinf = $unit->getAttribute("bldFile");
+ if ($bldinf and $bldinf !~ m,^/sf/$layer_name/$block_name,)
+ {
+ print "WARNING: $bldinf is in package: $layer_name/$block_name\n";
+ }
+ }
+
+ open(FILE, ">$outdir/$layer_name/$block_name/package_definition.xml");
+ print FILE $doc->getXMLDecl->toString."\n" if ($doc->getXMLDecl);
+ print FILE $doc->getDoctype->toString."\n" if ($doc->getDoctype);
+ print FILE $packagedef_header;
+ print FILE $layer_header;
+ print FILE $block->toString;
+ print FILE $layer_trailer;
+ print FILE $packagedef_trailer;
+ close(FILE);
+ }
+}
+
+$doc->dispose;
+