summaryrefslogtreecommitdiffstats
path: root/scripts/xmi2qt.pl
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-08-24 02:23:56 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-08-24 07:22:46 +0200
commit8d1209966085829e94894472be5e08c88de1554d (patch)
treecb5a4a5b36b81a39232c546df593f02707db567a /scripts/xmi2qt.pl
parenta0a9212f0e2e9cdd28f56d0d43c1b967e1d01c65 (diff)
Provide better support for multi-threaded artifact generation from xmi
Change-Id: I6b6e9a992b83b0b7e65c709e21dc5a8ba1c08237 Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts/xmi2qt.pl')
-rwxr-xr-xscripts/xmi2qt.pl21
1 files changed, 10 insertions, 11 deletions
diff --git a/scripts/xmi2qt.pl b/scripts/xmi2qt.pl
index 4a648b32..9ed092c6 100755
--- a/scripts/xmi2qt.pl
+++ b/scripts/xmi2qt.pl
@@ -57,7 +57,9 @@ my $xmi = XML::XPath->new(filename => $options{i});
my $namespace = $xmi->findvalue('//uml:Package/@name');
make_path($options{o}."/".$namespace);
-binmode STDOUT, ':utf8';
+
+{
+local *STDOUT;
my $globalHeader = "qt".lc($namespace)."global.h";
open STDOUT, '>', $options{o}."/".$namespace."/".$globalHeader;
@@ -93,9 +95,9 @@ if ($tt->process('module.pro', {
}) ne 1) { print $tt->error(); }
close STDOUT;
+}
+
my $classset = $xmi->find('//packagedElement[@xmi:type=\'uml:Class\']');
-my $count = 0;
-my @pids;
foreach my $class ($classset->get_nodelist) {
my $className = $class->findvalue('@name');
die "could not fork" unless defined(my $pid = fork);
@@ -103,13 +105,10 @@ foreach my $class ($classset->get_nodelist) {
exec "./generate-class.pl", "-i", $options{i}, "-o", $options{o}, "-c", $className;
die "exec of generate-class.pl failed";
}
- push @pids, $pid;
- $count = $count + 1;
- if ($count % $options{p} == 0) {
- for my $pid (@pids) {
- waitpid $pid, 0;
- }
- @pids=();
- }
+ my $buf;
+ do {
+ sleep(1);
+ $buf = `ps -ef | grep generate-class | grep -v grep | wc -l`;
+ } while ($buf >= $options{p});
}