Kaydet (Commit) f8eb95df authored tarafından Vladimir Glazunov's avatar Vladimir Glazunov

#i107077#,#i107077# fix for incompatible builds(for from an such), for busy…

#i107077#,#i107077# fix for incompatible builds(for from an such), for busy waiting along with some minor fixes, typo fixes, and style changes
üst 867b9406
...@@ -96,18 +96,12 @@ ...@@ -96,18 +96,12 @@
$modules_number++; $modules_number++;
$perl = ""; $perl = "";
$remove_command = ""; $remove_command = "";
if ( $^O eq 'MSWin32' ) { use Cwd 'chdir';
$perl = "$ENV{PERL}"; $perl = 'perl';
$remove_command = "rmdir /S /Q"; $remove_command = 'rm -rf';
$nul = '> NULL'; $nul = '> /dev/null';
} else {
use Cwd 'chdir';
$perl = 'perl';
$remove_command = 'rm -rf';
$nul = '> /dev/null';
};
$QuantityToBuild = 0; $processes_to_run = 0;
# delete $pid when not needed # delete $pid when not needed
%projects_deps_hash = (); # hash of projects with no dependencies, %projects_deps_hash = (); # hash of projects with no dependencies,
# that could be built now # that could be built now
...@@ -117,7 +111,7 @@ ...@@ -117,7 +111,7 @@
%running_children = (); %running_children = ();
$dependencies_hash = 0; $dependencies_hash = 0;
$cmd_file = ''; $cmd_file = '';
$BuildAllParents = 0; $build_all_parents = 0;
$show = 0; $show = 0;
$checkparents = 0; $checkparents = 0;
$deliver = 0; $deliver = 0;
...@@ -135,7 +129,7 @@ ...@@ -135,7 +129,7 @@
@broken_modules_names = (); # array of modules, which cannot be built further @broken_modules_names = (); # array of modules, which cannot be built further
@dmake_args = (); @dmake_args = ();
%dead_parents = (); %dead_parents = ();
$CurrentPrj = ''; $initial_module = '';
$all_dependent = 1; # a flag indicating if the hash has independent keys $all_dependent = 1; # a flag indicating if the hash has independent keys
$build_from_with_branches = ''; $build_from_with_branches = '';
$build_all_cont = ''; $build_all_cont = '';
...@@ -207,12 +201,15 @@ ...@@ -207,12 +201,15 @@
my %module_paths = (); # hash with absolute module paths my %module_paths = (); # hash with absolute module paths
my %active_modules = (); my %active_modules = ();
my $generate_config = 0; my $generate_config = 0;
my $add_modules_to_config = 0;
my %add_to_config = (); my %add_to_config = ();
my %remove_from_config = (); my %remove_from_config = ();
my $clear_config = 0; my $clear_config = 0;
my $finisched_children = 0; my $finisched_children = 0;
my $debug = 0; my $debug = 0;
%module_deps_hash_pids = (); %module_deps_hash_pids = ();
my @argv = @ARGV;
my $source_config_file;
### main ### ### main ###
get_options(); get_options();
...@@ -234,11 +231,11 @@ ...@@ -234,11 +231,11 @@
$deliver_env{'L10N_framework'}++; $deliver_env{'L10N_framework'}++;
}; };
if ($generate_config) { if ($generate_config && ($clear_config || (scalar keys %remove_from_config)||(scalar keys %add_to_config))) {
generate_config_file(); generate_config_file();
exit 0; exit 0;
} }
$StandDir = get_stand_dir(); # This also sets $CurrentPrj $StandDir = get_stand_dir(); # This also sets $initial_module
get_module_and_buildlist_paths(); get_module_and_buildlist_paths();
provide_consistency() if (defined $ENV{CWS_WORK_STAMP} && defined($ENV{COMMON_ENV_TOOLS})); provide_consistency() if (defined $ENV{CWS_WORK_STAMP} && defined($ENV{COMMON_ENV_TOOLS}));
...@@ -278,14 +275,14 @@ ...@@ -278,14 +275,14 @@
start_interactive() if ($interactive); start_interactive() if ($interactive);
if ($checkparents) { if ($checkparents) {
GetParentDeps( $CurrentPrj, \%global_deps_hash ); get_parent_deps( $initial_module, \%global_deps_hash );
} else { } else {
BuildAll(); build_all();
} }
if (scalar keys %broken_build) { if (scalar keys %broken_build) {
cancel_build(); cancel_build();
# } elsif (!$custom_job && $post_custom_job) { # } elsif (!$custom_job && $post_custom_job) {
# do_post_custom_job(CorrectPath($StandDir.$CurrentPrj)); # do_post_custom_job(CorrectPath($StandDir.$initial_module));
}; };
print_warnings(); print_warnings();
if (scalar keys %active_modules) { if (scalar keys %active_modules) {
...@@ -294,11 +291,10 @@ ...@@ -294,11 +291,10 @@
}; };
}; };
if (scalar keys %dead_parents) { if (scalar keys %dead_parents) {
my ($DeadPrj);
print $new_line.$new_line; print $new_line.$new_line;
print $echo."WARNING! Project(s):\n"; print $echo."WARNING! Project(s):\n";
foreach $DeadPrj (keys %dead_parents) { foreach (keys %dead_parents) {
print $echo."$DeadPrj\n"; print $echo."$_\n";
}; };
print $new_line; print $new_line;
print $echo."not found and couldn't be built. Dependencies on that module(s) ignored. Maybe you should correct build lists.\n"; print $echo."not found and couldn't be built. Dependencies on that module(s) ignored. Maybe you should correct build lists.\n";
...@@ -352,7 +348,7 @@ sub rename_file { ...@@ -352,7 +348,7 @@ sub rename_file {
sub generate_config_file { sub generate_config_file {
my $source_config = SourceConfig -> new(); my $source_config = SourceConfig -> new();
my $source_config_file = $source_config->get_config_file_path(); $source_config_file = $source_config->get_config_file_path();
my $temp_config_file = File::Temp::tmpnam($ENV{TMP}); my $temp_config_file = File::Temp::tmpnam($ENV{TMP});
my @config_content_new = (); my @config_content_new = ();
my $addition_message; my $addition_message;
...@@ -364,7 +360,6 @@ sub generate_config_file { ...@@ -364,7 +360,6 @@ sub generate_config_file {
close SOURCE_CONFIG_FILE; close SOURCE_CONFIG_FILE;
my ($module_section, $repository_section); my ($module_section, $repository_section);
foreach (@config_content) { foreach (@config_content) {
$line++;
if ((!/^\S+/)||(/^\s*#+/)) { if ((!/^\S+/)||(/^\s*#+/)) {
push(@config_content_new, $_); push(@config_content_new, $_);
next; next;
...@@ -422,7 +417,7 @@ sub generate_config_file { ...@@ -422,7 +417,7 @@ sub generate_config_file {
}; };
print_warnings(); print_warnings();
print $addition_message if ($addition_message); print $addition_message if ($addition_message);
print "Module(s) $removal_message removed from $source_config_file\n" if ($removal_message); print "Module(s):\n$removal_message\nremoved from $source_config_file\n" if ($removal_message);
exit(0); exit(0);
}; };
...@@ -437,50 +432,25 @@ sub add_modules_to_source_config { ...@@ -437,50 +432,25 @@ sub add_modules_to_source_config {
$message .= "$_ "; $message .= "$_ ";
}; };
if ($message) { if ($message) {
return 'Module(s) ' .$message . 'are added to the ' . $source_config_file . "\n\n"; return "Module(s):\n" .$message . "\nare added to the " . $source_config_file . "\n\n";
} else { } else {
return ''; return '';
}; };
}; };
sub start_interactive { sub start_interactive {
if ( $^O eq 'MSWin32' ) { $pid = open(HTML_PIPE, "-|");
my $posix_sys_wait = 'POSIX ":sys_wait_h"'; print "Pipe is open\n";
eval "use $posix_sys_wait";
die "couldn't use $posix_sys_wait: $!\n" if ($@);
pipe(FROM_PARENT, TO_CHILD) or die "pipe: $!";
pipe(HTML_PIPE, TO_PARENT) or die "pipe: $!";
if (my $pid = fork()) {
$html_listener_pid = 1;
close FROM_PARENT;
close TO_PARENT;
ioctl(HTML_PIPE, 0x8004667e, 1);
return;
} else {
close HTML_PIPE;
close TO_CHILD;
select TO_PARENT;
$|++;
$parent_process = 0;
start_html_listener();
}
} else {
$pid = open(HTML_PIPE, "-|");
print "Pipe is open\n";
if ($pid) { # parent if ($pid) { # parent
# make file handle non-bloking # make file handle non-bloking
my $flags = ''; my $flags = '';
fcntl(HTML_PIPE, F_GETFL, $flags); fcntl(HTML_PIPE, F_GETFL, $flags);
$flags |= O_NONBLOCK; $flags |= O_NONBLOCK;
fcntl(HTML_PIPE, F_SETFL, $flags); fcntl(HTML_PIPE, F_SETFL, $flags);
} else { # child } else { # child
$parent_process = 0; $parent_process = 0;
start_html_listener(); start_html_listener();
};
}; };
}; };
...@@ -516,7 +486,6 @@ sub start_html_message_trigger { ...@@ -516,7 +486,6 @@ sub start_html_message_trigger {
if ($child_id) { if ($child_id) {
# parent # parent
$html_message_trigger{$child_id}++;
# print "started listener trigger\n"; # print "started listener trigger\n";
} else { } else {
my $buffer_size = 1024; my $buffer_size = 1024;
...@@ -673,20 +642,20 @@ sub get_build_list_path { ...@@ -673,20 +642,20 @@ sub get_build_list_path {
# #
# Get dependencies hash of the current and all parent projects # Get dependencies hash of the current and all parent projects
# #
sub GetParentDeps { sub get_parent_deps {
my (%parents_deps_hash, $module, $parent); my (%parents_deps_hash, $module, $parent);
my $prj_dir = shift; my $prj_dir = shift;
my $deps_hash = shift; my $deps_hash = shift;
my @UnresolvedParents = get_parents_array($prj_dir); my @unresolved_parents = get_parents_array($prj_dir);
$parents_deps_hash{$_}++ foreach (@UnresolvedParents); $parents_deps_hash{$_}++ foreach (@unresolved_parents);
$$deps_hash{$prj_dir} = \%parents_deps_hash; $$deps_hash{$prj_dir} = \%parents_deps_hash;
while ($module = pop(@UnresolvedParents)) { while ($module = pop(@unresolved_parents)) {
my %parents_deps_hash = (); my %parents_deps_hash = ();
$parents_deps_hash{$_}++ foreach (get_parents_array($module)); $parents_deps_hash{$_}++ foreach (get_parents_array($module));
$$deps_hash{$module} = \%parents_deps_hash; $$deps_hash{$module} = \%parents_deps_hash;
foreach $Parent (keys %parents_deps_hash) { foreach $Parent (keys %parents_deps_hash) {
if (!defined($$deps_hash{$Parent})) { if (!defined($$deps_hash{$Parent})) {
push (@UnresolvedParents, $Parent); push (@unresolved_parents, $Parent);
}; };
}; };
}; };
...@@ -743,19 +712,16 @@ sub reverse_dependensies { ...@@ -743,19 +712,16 @@ sub reverse_dependensies {
# #
# Build everything that should be built # Build everything that should be built
# #
sub BuildAll { sub build_all {
if ($BuildAllParents) { if ($build_all_parents) {
my ($Prj, $PrjDir, $orig_prj); my ($Prj, $PrjDir, $orig_prj);
GetParentDeps( $CurrentPrj, \%global_deps_hash); get_parent_deps( $initial_module, \%global_deps_hash);
if (scalar keys %active_modules) { if (scalar keys %active_modules) {
$active_modules{$CurrentPrj}++; $active_modules{$initial_module}++;
$modules_types{$CurrentPrj} = 'mod'; $modules_types{$initial_module} = 'mod';
}; };
modules_classify(keys %global_deps_hash); modules_classify(keys %global_deps_hash);
store_weights(\%global_deps_hash); store_weights(\%global_deps_hash);
if (keys %active_modules && ($build_from || $incompatible)) {
print_error("There are active module in $source_config_file. Please remove these modules to proceed.\n");
};
prepare_build_from(\%global_deps_hash) if ($build_from); prepare_build_from(\%global_deps_hash) if ($build_from);
prepare_incompatible_build(\%global_deps_hash) if ($incompatible); prepare_incompatible_build(\%global_deps_hash) if ($incompatible);
if ($build_all_cont || $build_since) { if ($build_all_cont || $build_since) {
...@@ -763,12 +729,25 @@ sub BuildAll { ...@@ -763,12 +729,25 @@ sub BuildAll {
push (@warnings, "\nThere are active module in $source_config_file. Inactive modules are skipped.\n\n"); push (@warnings, "\nThere are active module in $source_config_file. Inactive modules are skipped.\n\n");
prepare_build_all_cont(\%global_deps_hash); prepare_build_all_cont(\%global_deps_hash);
}; };
if ($generate_config) {
%add_to_config = %global_deps_hash;
generate_config_file();
exit 0;
} elsif (keys %incompatibles) {
my @missing_modules = ();
foreach (keys %global_deps_hash) {
push(@missing_modules, $_) if (!defined $active_modules{$_});
};
if (scalar @missing_modules) {
print_error("There are modules:\n@missing_modules\n\nthat should be built, but they are not activated. Please, verify your $source_config_file.\n");
};
};
backup_deps_hash(\%global_deps_hash, \%global_deps_hash_backup); backup_deps_hash(\%global_deps_hash, \%global_deps_hash_backup);
expand_dependencies (\%global_deps_hash_backup); expand_dependencies (\%global_deps_hash_backup);
reverse_dependensies(\%global_deps_hash_backup); reverse_dependensies(\%global_deps_hash_backup);
$modules_number = scalar keys %global_deps_hash; $modules_number = scalar keys %global_deps_hash;
initialize_html_info($_) foreach (keys %global_deps_hash); initialize_html_info($_) foreach (keys %global_deps_hash);
if ($QuantityToBuild) { if ($processes_to_run) {
build_multiprocessing(); build_multiprocessing();
return; return;
}; };
...@@ -789,7 +768,7 @@ sub BuildAll { ...@@ -789,7 +768,7 @@ sub BuildAll {
my $info_hash = $html_info{$Prj}; my $info_hash = $html_info{$Prj};
$$info_hash{DIRS} = check_deps_hash(\%LocalDepsHash, $Prj); $$info_hash{DIRS} = check_deps_hash(\%LocalDepsHash, $Prj);
$module_by_hash{\%LocalDepsHash} = $Prj; $module_by_hash{\%LocalDepsHash} = $Prj;
BuildDependent(\%LocalDepsHash); build_dependent(\%LocalDepsHash);
print $check_error_string; print $check_error_string;
}; };
...@@ -797,16 +776,16 @@ sub BuildAll { ...@@ -797,16 +776,16 @@ sub BuildAll {
$build_is_finished{$Prj}++; $build_is_finished{$Prj}++;
}; };
} else { } else {
store_build_list_content($CurrentPrj); store_build_list_content($initial_module);
get_module_dep_hash($CurrentPrj, \%LocalDepsHash); get_module_dep_hash($initial_module, \%LocalDepsHash);
initialize_html_info($CurrentPrj); initialize_html_info($initial_module);
my $info_hash = $html_info{$CurrentPrj}; my $info_hash = $html_info{$initial_module};
$$info_hash{DIRS} = check_deps_hash(\%LocalDepsHash, $CurrentPrj); $$info_hash{DIRS} = check_deps_hash(\%LocalDepsHash, $initial_module);
$module_by_hash{\%LocalDepsHash} = $CurrentPrj; $module_by_hash{\%LocalDepsHash} = $initial_module;
if ($server_mode) { if ($server_mode) {
run_server(); run_server();
} else { } else {
BuildDependent(\%LocalDepsHash); build_dependent(\%LocalDepsHash);
}; };
}; };
}; };
...@@ -884,7 +863,8 @@ sub dmake_dir { ...@@ -884,7 +863,8 @@ sub dmake_dir {
}; };
_exit(0); _exit(0);
} elsif ($error_code && ($error_code != -1)) { } elsif ($error_code && ($error_code != -1)) {
print_error("Error $? occurred while making $BuildDir"); return $error_code;
# print_error("Error $? occurred while making $BuildDir");
}; };
}; };
...@@ -1075,7 +1055,7 @@ sub get_deps_hash { ...@@ -1075,7 +1055,7 @@ sub get_deps_hash {
if (scalar @errors) { if (scalar @errors) {
my $message = "$module_to_build/prj/build.lst has wrongly written string(s):\n"; my $message = "$module_to_build/prj/build.lst has wrongly written string(s):\n";
$message .= "$_\n" foreach(@errors); $message .= "$_\n" foreach(@errors);
if ($QuantityToBuild) { if ($processes_to_run) {
$broken_build{$module_to_build} = $message; $broken_build{$module_to_build} = $message;
$dependencies_hash = undef; $dependencies_hash = undef;
return; return;
...@@ -1097,7 +1077,7 @@ sub get_deps_hash { ...@@ -1097,7 +1077,7 @@ sub get_deps_hash {
add_prerequisite_job($dependencies_hash, $module_to_build, $pre_custom_job); add_prerequisite_job($dependencies_hash, $module_to_build, $pre_custom_job);
add_prerequisite_job($dependencies_hash, $module_to_build, $pre_job); add_prerequisite_job($dependencies_hash, $module_to_build, $pre_job);
add_dependent_job($dependencies_hash, $module_to_build, $custom_job); add_dependent_job($dependencies_hash, $module_to_build, $custom_job);
add_dependent_job($dependencies_hash, $module_to_build, $post_job) if ($module_to_build ne $CurrentPrj); add_dependent_job($dependencies_hash, $module_to_build, $post_job) if ($module_to_build ne $initial_module);
add_dependent_job($dependencies_hash, $module_to_build, $post_custom_job); add_dependent_job($dependencies_hash, $module_to_build, $post_custom_job);
}; };
store_weights($dependencies_hash); store_weights($dependencies_hash);
...@@ -1163,11 +1143,7 @@ sub mark_platform { ...@@ -1163,11 +1143,7 @@ sub mark_platform {
# #
sub CorrectPath { sub CorrectPath {
$_ = shift; $_ = shift;
if ( ($^O eq 'MSWin32') && (!defined $ENV{SHELL})) { s/\\/\//g;
s/\//\\/g;
} else {;
s/\\/\//g;
};
return $_; return $_;
}; };
...@@ -1232,7 +1208,7 @@ sub get_stand_dir { ...@@ -1232,7 +1208,7 @@ sub get_stand_dir {
do { do {
foreach (@possible_build_lists) {# ('build.lst', 'build.xlist'); foreach (@possible_build_lists) {# ('build.lst', 'build.xlist');
if (-e $StandDir . '/prj/'.$_) { if (-e $StandDir . '/prj/'.$_) {
$CurrentPrj = File::Basename::basename($StandDir); $initial_module = File::Basename::basename($StandDir);
$StandDir = File::Basename::dirname($StandDir); $StandDir = File::Basename::dirname($StandDir);
return $StandDir; return $StandDir;
} elsif ($StandDir eq $previous_dir) { } elsif ($StandDir eq $previous_dir) {
...@@ -1381,9 +1357,9 @@ sub find_indep_prj { ...@@ -1381,9 +1357,9 @@ sub find_indep_prj {
my ($Dependencies, $i); my ($Dependencies, $i);
my @candidates = (); my @candidates = ();
$all_dependent = 1; $all_dependent = 1;
handle_dead_children(0) if ($QuantityToBuild); handle_dead_children(0) if ($processes_to_run);
my $children = children_number(); my $children = children_number();
return '' if (!$server_mode && $children && ($children >= $QuantityToBuild)); return '' if (!$server_mode && $children && ($children >= $processes_to_run));
$Dependencies = shift; $Dependencies = shift;
if (scalar keys %$Dependencies) { if (scalar keys %$Dependencies) {
foreach my $job (keys %$Dependencies) { foreach my $job (keys %$Dependencies) {
...@@ -1500,7 +1476,7 @@ sub print_error { ...@@ -1500,7 +1476,7 @@ sub print_error {
sub usage { sub usage {
print STDERR "\nbuild\n"; print STDERR "\nbuild\n";
print STDERR "Syntax: build [--all|-a[:prj_name]]|[--from|-f prj_name1[:prj_name2] [prj_name3 [...]]]|[--since|-c prj_name] [--with_branches|-b]|[--prepare|-p][:platform] [--deliver|-d [--dlv_switch deliver_switch]]] [-P processes|--server [--setenvstring \"string\"] [--client_timeout MIN] [--port port1[:port2:...:portN]]] [--show|-s] [--help|-h] [--file|-F] [--ignore|-i] [--version|-V] [--mode|-m OOo[,SO[,EXT]] [--html [--html_path html_file_path] [--dontgraboutput]] [--pre_job=pre_job_sring] [--job=job_string|-j] [--post_job=post_job_sring] [--stoponerror] [--genconf [--removeall|--clear|--remove|--add module1,module2[,...,moduleN]]] [--interactive]\n"; print STDERR "Syntax: build [--all|-a[:prj_name]]|[--from|-f prj_name1[:prj_name2] [prj_name3 [...]]]|[--since|-c prj_name] [--with_branches|-b]|[--prepare|-p][:platform] [--deliver|-d [--dlv_switch deliver_switch]]] [-P processes|--server [--setenvstring \"string\"] [--client_timeout MIN] [--port port1[:port2:...:portN]]] [--show|-s] [--help|-h] [--file|-F] [--ignore|-i] [--version|-V] [--mode|-m OOo[,SO[,EXT]] [--html [--html_path html_file_path] [--dontgraboutput]] [--pre_job=pre_job_sring] [--job=job_string|-j] [--post_job=post_job_sring] [--stoponerror] [--genconf [--removeall|--clear|--remove|--add [module1,module2[,...,moduleN]]]] [--interactive]\n";
print STDERR "Example1: build --from sfx2\n"; print STDERR "Example1: build --from sfx2\n";
print STDERR " - build all projects dependent from sfx2, starting with sfx2, finishing with the current module\n"; print STDERR " - build all projects dependent from sfx2, starting with sfx2, finishing with the current module\n";
print STDERR "Example2: build --all:sfx2\n"; print STDERR "Example2: build --all:sfx2\n";
...@@ -1555,10 +1531,10 @@ sub usage { ...@@ -1555,10 +1531,10 @@ sub usage {
sub get_options { sub get_options {
my ($arg, $dont_grab_output); my ($arg, $dont_grab_output);
while ($arg = shift @ARGV) { while ($arg = shift @ARGV) {
$arg =~ /^-P$/ and $QuantityToBuild = shift @ARGV and next; $arg =~ /^-P$/ and $processes_to_run = shift @ARGV and next;
$arg =~ /^-P(\d+)$/ and $QuantityToBuild = $1 and next; $arg =~ /^-P(\d+)$/ and $processes_to_run = $1 and next;
$arg =~ /^--all$/ and $BuildAllParents = 1 and next; $arg =~ /^--all$/ and $build_all_parents = 1 and next;
$arg =~ /^-a$/ and $BuildAllParents = 1 and next; $arg =~ /^-a$/ and $build_all_parents = 1 and next;
$arg =~ /^--show$/ and $show = 1 and next; $arg =~ /^--show$/ and $show = 1 and next;
$arg =~ /^--checkmodules$/ and $checkparents = 1 and $ignore = 1 and next; $arg =~ /^--checkmodules$/ and $checkparents = 1 and $ignore = 1 and next;
$arg =~ /^-s$/ and $show = 1 and next; $arg =~ /^-s$/ and $show = 1 and next;
...@@ -1571,17 +1547,17 @@ sub get_options { ...@@ -1571,17 +1547,17 @@ sub get_options {
$arg =~ /^--file$/ and $cmd_file = shift @ARGV and next; $arg =~ /^--file$/ and $cmd_file = shift @ARGV and next;
$arg =~ /^-F$/ and $cmd_file = shift @ARGV and next; $arg =~ /^-F$/ and $cmd_file = shift @ARGV and next;
$arg =~ /^--with_branches$/ and $BuildAllParents = 1 $arg =~ /^--with_branches$/ and $build_all_parents = 1
and $build_from_with_branches = shift @ARGV and next; and $build_from_with_branches = shift @ARGV and next;
$arg =~ /^-b$/ and $BuildAllParents = 1 $arg =~ /^-b$/ and $build_all_parents = 1
and $build_from_with_branches = shift @ARGV and next; and $build_from_with_branches = shift @ARGV and next;
$arg =~ /^--all:(\S+)$/ and $BuildAllParents = 1 $arg =~ /^--all:(\S+)$/ and $build_all_parents = 1
and $build_all_cont = $1 and next; and $build_all_cont = $1 and next;
$arg =~ /^-a:(\S+)$/ and $BuildAllParents = 1 $arg =~ /^-a:(\S+)$/ and $build_all_parents = 1
and $build_all_cont = $1 and next; and $build_all_cont = $1 and next;
if ($arg =~ /^--from$/ || $arg =~ /^-f$/) { if ($arg =~ /^--from$/ || $arg =~ /^-f$/) {
$BuildAllParents = 1; $build_all_parents = 1;
get_incomp_projects(); get_incomp_projects();
next; next;
}; };
...@@ -1589,11 +1565,11 @@ sub get_options { ...@@ -1589,11 +1565,11 @@ sub get_options {
$arg =~ /^-p$/ and $prepare = 1 and next; $arg =~ /^-p$/ and $prepare = 1 and next;
$arg =~ /^--prepare:/ and $prepare = 1 and $only_platform = $' and next; $arg =~ /^--prepare:/ and $prepare = 1 and $only_platform = $' and next;
$arg =~ /^-p:/ and $prepare = 1 and $only_platform = $' and next; $arg =~ /^-p:/ and $prepare = 1 and $only_platform = $' and next;
$arg =~ /^--since$/ and $BuildAllParents = 1 $arg =~ /^--since$/ and $build_all_parents = 1
and $build_since = shift @ARGV and next; and $build_since = shift @ARGV and next;
$arg =~ /^-c$/ and $BuildAllParents = 1 $arg =~ /^-c$/ and $build_all_parents = 1
and $build_since = shift @ARGV and next; and $build_since = shift @ARGV and next;
$arg =~ /^-s$/ and $BuildAllParents = 1 $arg =~ /^-s$/ and $build_all_parents = 1
and $build_since = shift @ARGV and next; and $build_since = shift @ARGV and next;
$arg =~ /^--help$/ and usage() and do_exit(0); $arg =~ /^--help$/ and usage() and do_exit(0);
$arg =~ /^-h$/ and usage() and do_exit(0); $arg =~ /^-h$/ and usage() and do_exit(0);
...@@ -1601,10 +1577,14 @@ sub get_options { ...@@ -1601,10 +1577,14 @@ sub get_options {
$arg =~ /^--genconf$/ and $generate_config = 1 and next; $arg =~ /^--genconf$/ and $generate_config = 1 and next;
if ($arg =~ /^--add$/) { if ($arg =~ /^--add$/) {
get_list_of_modules(\%add_to_config); get_list_of_modules(\%add_to_config);
$add_modules_to_config++;
next; next;
}; };
if ($arg =~ /^--remove$/) { if ($arg =~ /^--remove$/) {
get_list_of_modules(\%remove_from_config); get_list_of_modules(\%remove_from_config);
if (!scalar %remove_from_config) {
print_error('No module list supplied!!');
};
next; next;
}; };
($arg =~ /^--clear$/ || $arg =~ /^--removeall$/) and $clear_config = 1 and next; ($arg =~ /^--clear$/ || $arg =~ /^--removeall$/) and $clear_config = 1 and next;
...@@ -1637,7 +1617,7 @@ sub get_options { ...@@ -1637,7 +1617,7 @@ sub get_options {
# print_error('Please prepare the workspace on one of UNIX platforms') if ($prepare && ($ENV{GUI} ne 'UNX')); # print_error('Please prepare the workspace on one of UNIX platforms') if ($prepare && ($ENV{GUI} ne 'UNX'));
print_error('Switches --with_branches and --since collision') if ($build_from_with_branches && $build_since); print_error('Switches --with_branches and --since collision') if ($build_from_with_branches && $build_since);
if ($show) { if ($show) {
$QuantityToBuild = 0; $processes_to_run = 0;
$cmd_file = ''; $cmd_file = '';
}; };
print_error('Switches --job and --deliver collision') if ($custom_job && $deliver); print_error('Switches --job and --deliver collision') if ($custom_job && $deliver);
...@@ -1647,7 +1627,7 @@ sub get_options { ...@@ -1647,7 +1627,7 @@ sub get_options {
if ($prepare) { if ($prepare) {
print_error("--prepare is for use with --from switch only!\n") if (!$incompatible); print_error("--prepare is for use with --from switch only!\n") if (!$incompatible);
}; };
if ($QuantityToBuild) { if ($processes_to_run) {
if ($ignore && !$html) { if ($ignore && !$html) {
print_error("Cannot ignore errors in multiprocessing build"); print_error("Cannot ignore errors in multiprocessing build");
}; };
...@@ -1675,8 +1655,8 @@ sub get_options { ...@@ -1675,8 +1655,8 @@ sub get_options {
if ((scalar %add_to_config) || (scalar %remove_from_config)) { if ((scalar %add_to_config) || (scalar %remove_from_config)) {
print_error('"--add" or/and "--remove"' . $error_message); print_error('"--add" or/and "--remove"' . $error_message);
}; };
} elsif ((!scalar %add_to_config) && !$clear_config && (!scalar %remove_from_config)){ } elsif ((!scalar %add_to_config) && !$clear_config && (!scalar %remove_from_config) && !$build_all_parents){
print_error('Please supply necessary switch for "--genconf" (--add|--remove|--removeall)'); print_error('Please supply necessary switch for "--genconf" (--add|--remove|--removeall). --add can be used with --from and such');
}; };
if ($only_platform) { if ($only_platform) {
...@@ -1698,7 +1678,7 @@ sub get_options { ...@@ -1698,7 +1678,7 @@ sub get_options {
sub get_module_and_buildlist_paths { sub get_module_and_buildlist_paths {
my $source_config = SourceConfig -> new($StandDir); my $source_config = SourceConfig -> new($StandDir);
my $source_config_file = $source_config->get_config_file_path(); $source_config_file = $source_config->get_config_file_path();
$active_modules{$_}++ foreach ($source_config->get_active_modules()); $active_modules{$_}++ foreach ($source_config->get_active_modules());
my %active_modules_copy = %active_modules; my %active_modules_copy = %active_modules;
foreach ($source_config->get_all_modules()) { foreach ($source_config->get_all_modules()) {
...@@ -1744,33 +1724,37 @@ sub get_switch_options { ...@@ -1744,33 +1724,37 @@ sub get_switch_options {
# #
sub cancel_build { sub cancel_build {
# close_server_socket(); # close_server_socket();
$modules_number -= scalar keys %global_deps_hash;
my $broken_modules_number = scalar @broken_modules_names; my $broken_modules_number = scalar @broken_modules_names;
my $message_part = 'build ';
if (scalar keys %incompatibles) {
my @incompatible_modules = keys %incompatibles;
if ($stop_build_on_error) {
$message_part .= "--from @incompatible_modules:@broken_modules_names\n";
} else {
$message_part .= "--from @broken_modules_names\n";
};
} else {
$message_part .= "--all:@broken_modules_names\n";
};
if ($broken_modules_number) { if ($broken_modules_number) {
$modules_number -= $broken_modules_number;
print "\n"; print "\n";
print $broken_modules_number; print $broken_modules_number;
print " module(s): "; print " module(s): ";
foreach (@broken_modules_names) { foreach (@broken_modules_names) {
print "\n\t$_"; print "\n\t$_";
# RemoveFromDependencies($_, \%global_deps_hash);
}; };
print "\nneed(s) to be rebuilt\n\nReason(s):\n\n"; print "\nneed(s) to be rebuilt\n\nReason(s):\n\n";
foreach (keys %broken_build) { foreach (keys %broken_build) {
print "ERROR: error " . $broken_build{$_} . " occurred while making $_\n"; print "ERROR: error " . $broken_build{$_} . " occurred while making $_\n";
}; };
print "\nAttention: if you build and deliver the above module(s) you may prolongue your the build issuing command \"build --from @broken_modules_names\"\n"; print "\nAttention: if you fix the errors in above module(s) you may prolongue your the build issuing command:\n\n\t" . $message_part;
} else { } else {
# if ($ENV{GUI} eq 'WNT') { while (children_number()) {
while (children_number()) { handle_dead_children(1);
handle_dead_children(1); }
} foreach (keys %broken_build) {
foreach (keys %broken_build) { print "ERROR: error " . $broken_build{$_} . " occurred while making $_\n";
print "ERROR: error " . $broken_build{$_} . " occurred while making $_\n"; };
};
# } else {
# kill 9 => -$$;
# };
}; };
print "\n"; print "\n";
do_exit(1); do_exit(1);
...@@ -1827,9 +1811,9 @@ sub handle_dead_children { ...@@ -1827,9 +1811,9 @@ sub handle_dead_children {
}; };
}; };
}; };
sleep 1 if (children_number() >= $QuantityToBuild || ($force_wait && ($running_children == children_number()))); sleep 1 if (children_number() >= $processes_to_run || ($force_wait && ($running_children == children_number())));
} else { } else {
if (children_number() >= $QuantityToBuild || if (children_number() >= $processes_to_run ||
($force_wait && ($running_children == children_number()))) { ($force_wait && ($running_children == children_number()))) {
$pid = wait(); $pid = wait();
} else { } else {
...@@ -1845,7 +1829,7 @@ sub handle_dead_children { ...@@ -1845,7 +1829,7 @@ sub handle_dead_children {
$finisched_children++; $finisched_children++;
}; };
}; };
} while(children_number() >= $QuantityToBuild); } while(children_number() >= $processes_to_run);
}; };
sub give_second_chance { sub give_second_chance {
...@@ -1881,22 +1865,29 @@ sub clear_from_child { ...@@ -1881,22 +1865,29 @@ sub clear_from_child {
# #
# Build the entire project according to queue of dependencies # Build the entire project according to queue of dependencies
# #
sub BuildDependent { sub build_dependent {
$dependencies_hash = shift; $dependencies_hash = shift;
my $pid = 0; my $pid = 0;
my $child_nick = ''; my $child_nick = '';
$running_children{$dependencies_hash} = 0 if (!defined $running_children{$dependencies_hash}); $running_children{$dependencies_hash} = 0 if (!defined $running_children{$dependencies_hash});
while ($child_nick = pick_prj_to_build($dependencies_hash)) { while ($child_nick = pick_prj_to_build($dependencies_hash)) {
if ($QuantityToBuild) { if ($processes_to_run) {
do { do {
if (defined $modules_with_errors{$dependencies_hash} && !$ignore) { if (defined $modules_with_errors{$dependencies_hash} && !$ignore) {
return 0 if ($BuildAllParents); return 0 if ($build_all_parents);
last; last;
}; };
# start current child & all # start current child & all
# that could be started now # that could be started now
start_child($child_nick, $dependencies_hash) if ($child_nick); if ($child_nick) {
return 1 if ($BuildAllParents); start_child($child_nick, $dependencies_hash);
return 1 if ($build_all_parents);
} else {
if (!$build_all_parents && (scalar keys %$dependencies_hash)) {
handle_dead_children(1);
};
return 0 if ($build_all_parents);
};
$child_nick = pick_prj_to_build($dependencies_hash); $child_nick = pick_prj_to_build($dependencies_hash);
} while (scalar keys %$dependencies_hash || $child_nick); } while (scalar keys %$dependencies_hash || $child_nick);
while (children_number()) { while (children_number()) {
...@@ -1912,7 +1903,10 @@ sub BuildDependent { ...@@ -1912,7 +1903,10 @@ sub BuildDependent {
} }
mp_success_exit(); mp_success_exit();
} else { } else {
dmake_dir($child_nick); if (dmake_dir($child_nick)) {
push(@broken_modules_names, $module_by_hash{$dependencies_hash});
cancel_build();
};
}; };
$child_nick = ''; $child_nick = '';
}; };
...@@ -2010,7 +2004,7 @@ sub build_multiprocessing { ...@@ -2010,7 +2004,7 @@ sub build_multiprocessing {
sub mp_success_exit { sub mp_success_exit {
# close_server_socket(); # close_server_socket();
# if (!$custom_job && $post_custom_job) { # if (!$custom_job && $post_custom_job) {
# do_post_custom_job(CorrectPath($StandDir.$CurrentPrj)); # do_post_custom_job(CorrectPath($StandDir.$initial_module));
# }; # };
print "\nMultiprocessing build is finished\n"; print "\nMultiprocessing build is finished\n";
print "Maximal number of processes run: $maximal_processes\n"; print "Maximal number of processes run: $maximal_processes\n";
...@@ -2045,7 +2039,7 @@ sub build_actual_queue { ...@@ -2045,7 +2039,7 @@ sub build_actual_queue {
delete $$build_queue{$Prj}; delete $$build_queue{$Prj};
next; next;
}; };
$started_children =+ BuildDependent($projects_deps_hash{$Prj}); $started_children =+ build_dependent($projects_deps_hash{$Prj});
if ((!scalar keys %{$projects_deps_hash{$Prj}}) && if ((!scalar keys %{$projects_deps_hash{$Prj}}) &&
!$running_children{$projects_deps_hash{$Prj}}) { !$running_children{$projects_deps_hash{$Prj}}) {
if (!defined $modules_with_errors{$projects_deps_hash{$Prj}} || $ignore) if (!defined $modules_with_errors{$projects_deps_hash{$Prj}} || $ignore)
...@@ -2224,19 +2218,10 @@ sub provide_consistency { ...@@ -2224,19 +2218,10 @@ sub provide_consistency {
# #
sub get_workspace_lst sub get_workspace_lst
{ {
my $home; my $home = $ENV{HOME};
if ( $^O eq 'MSWin32' ) { my $inifile = $ENV{HOME}. '/localini/stand.lst';
$home = $ENV{TEMP};
}
else {
$home = $ENV{HOME};
}
my $inifile = "$home/localini/stand.lst";
if (-f $inifile) { if (-f $inifile) {
return $inifile; return $inifile;
# } else {
# $inifile = get_globalini() . "/stand.lst";
# return $inifile if (-f $inifile);
}; };
return ''; return '';
} }
...@@ -2416,7 +2401,7 @@ sub prepare_incompatible_build { ...@@ -2416,7 +2401,7 @@ sub prepare_incompatible_build {
if ($old_output_tree) { if ($old_output_tree) {
push(@warnings, 'Some module(s) contain old output tree(s)!'); push(@warnings, 'Some module(s) contain old output tree(s)!');
}; };
if (scalar @warnings) { if (!$generate_config && scalar @warnings) {
print "WARNING(S):\n"; print "WARNING(S):\n";
print STDERR "$_\n" foreach (@warnings); print STDERR "$_\n" foreach (@warnings);
print "\nATTENTION: If you are performing an incompatible build, please break the build with Ctrl+C and prepare the workspace with \"--prepare\" switch!\n\n" if (!$prepare); print "\nATTENTION: If you are performing an incompatible build, please break the build with Ctrl+C and prepare the workspace with \"--prepare\" switch!\n\n" if (!$prepare);
...@@ -2439,7 +2424,7 @@ sub prepare_build_from { ...@@ -2439,7 +2424,7 @@ sub prepare_build_from {
my ($prj, $deps_hash); my ($prj, $deps_hash);
$deps_hash = shift; $deps_hash = shift;
my %from_deps_hash = (); # hash of dependencies of the -from project my %from_deps_hash = (); # hash of dependencies of the -from project
GetParentDeps($build_from_with_branches, \%from_deps_hash); get_parent_deps($build_from_with_branches, \%from_deps_hash);
foreach $prj (keys %from_deps_hash) { foreach $prj (keys %from_deps_hash) {
delete $$deps_hash{$prj}; delete $$deps_hash{$prj};
RemoveFromDependencies($prj, $deps_hash); RemoveFromDependencies($prj, $deps_hash);
...@@ -2508,9 +2493,9 @@ sub get_list_of_modules { ...@@ -2508,9 +2493,9 @@ sub get_list_of_modules {
}; };
}; };
}; };
if (!scalar %$hash_ref) { # if (!scalar %$hash_ref) {
print_error('No module list supplied!!'); # print_error('No module list supplied!!');
}; # };
}; };
sub get_incomp_projects { sub get_incomp_projects {
...@@ -2530,6 +2515,26 @@ sub get_incomp_projects { ...@@ -2530,6 +2515,26 @@ sub get_incomp_projects {
}; };
}; };
sub get_workspace_platforms {
my $workspace_patforms = shift;
my $solver_path = $ENV{SOLARVERSION};
opendir(SOLVERDIR, $solver_path);
@dir_list = readdir(SOLVERDIR);
close SOLVERDIR;
foreach (@dir_list) {
next if /^common/;
next if /^\./;
if (open(LS, "ls $solver_path/$_/inc/*minor.mk 2>$nul |")) {
foreach my $string (<LS>) {
chomp $string;
if ($string =~ /minor.mk$/) {
$$workspace_patforms{$_}++
};
};
close LS;
};
};
};
sub get_platforms { sub get_platforms {
my $platforms_ref = shift; my $platforms_ref = shift;
...@@ -2542,17 +2547,22 @@ sub get_platforms { ...@@ -2542,17 +2547,22 @@ sub get_platforms {
my $workspace_lst = get_workspace_lst(); my $workspace_lst = get_workspace_lst();
if ($workspace_lst) { if ($workspace_lst) {
my $workspace_db = GenInfoParser->new(); my $workspace_db;
my $success = $workspace_db->load_list($workspace_lst); eval { $workspace_db = GenInfoParser->new(); };
if ( !$success ) { if (!$@) {
print_error("Can't load workspace list '$workspace_lst'.", 4); my $success = $workspace_db->load_list($workspace_lst);
} if ( !$success ) {
my $access_path = $ENV{WORK_STAMP} . '/Environments'; print_error("Can't load workspace list '$workspace_lst'.", 4);
my @platforms_available = $workspace_db->get_keys($access_path); }
my $solver = $ENV{SOLARVERSION}; my $access_path = $ENV{WORK_STAMP} . '/Environments';
foreach (@platforms_available) { my @platforms_available = $workspace_db->get_keys($access_path);
my $s_path = $solver . '/' . $_; my $solver = $ENV{SOLARVERSION};
$$platforms_ref{$_}++ if (-d $s_path); foreach (@platforms_available) {
my $s_path = $solver . '/' . $_;
$$platforms_ref{$_}++ if (-d $s_path);
};
} else {
get_workspace_platforms(\%platforms);
}; };
}; };
...@@ -2621,12 +2631,8 @@ sub read_ssolar_vars { ...@@ -2621,12 +2631,8 @@ sub read_ssolar_vars {
my ($setsolar, $tmp_file); my ($setsolar, $tmp_file);
$setsolar = $ENV{ENV_ROOT} . '/etools/setsolar.pl'; $setsolar = $ENV{ENV_ROOT} . '/etools/setsolar.pl';
my ($platform, $solar_vars) = @_; my ($platform, $solar_vars) = @_;
if ( $^O eq 'MSWin32' ) { $setsolar = '/net/jumbo2.germany/buildenv/r/etools/setsolar.pl' if ! -e $setsolar;
$tmp_file = $ENV{TEMP} . "\\solar.env.$$.tmp"; $tmp_file = $ENV{HOME} . "/.solar.env.$$.tmp";
} else {
$setsolar = '/net/jumbo2.germany/buildenv/r/etools/setsolar.pl' if ! -e $setsolar;
$tmp_file = $ENV{HOME} . "/.solar.env.$$.tmp";
};
if (!-e $setsolar) { if (!-e $setsolar) {
print STDERR "There is no setsolar found. Falling back to current platform settings\n"; print STDERR "There is no setsolar found. Falling back to current platform settings\n";
return; return;
...@@ -2663,14 +2669,8 @@ sub get_solar_vars { ...@@ -2663,14 +2669,8 @@ sub get_solar_vars {
next if(!/^\w+\s+(\w+)/o); next if(!/^\w+\s+(\w+)/o);
next if (!defined $deliver_env{$1}); next if (!defined $deliver_env{$1});
$var = $1; $var = $1;
if ( $^O eq 'MSWin32' ) { /\'(\S+)\'$/o;
my $string_tail = $'; $value = $1;
$string_tail =~ /=(\S+)$/o;
$value = $1;
} else {
/\'(\S+)\'$/o;
$value = $1;
};
$$solar_vars{$var} = $value; $$solar_vars{$var} = $value;
}; };
close SOLARTABLE; close SOLARTABLE;
...@@ -2691,8 +2691,8 @@ sub get_current_module { ...@@ -2691,8 +2691,8 @@ sub get_current_module {
if ( ! $result ) { if ( ! $result ) {
print_error("Cannot rename $module_name: $!\n"); print_error("Cannot rename $module_name: $!\n");
} }
if ( $CurrentPrj eq $link_name) { if ( $initial_module eq $link_name) {
$CurrentPrj = $module_name; $initial_module = $module_name;
} }
chdir $module_name; chdir $module_name;
getcwd(); getcwd();
...@@ -2700,26 +2700,17 @@ sub get_current_module { ...@@ -2700,26 +2700,17 @@ sub get_current_module {
sub check_dir { sub check_dir {
my $start_dir = getcwd(); my $start_dir = getcwd();
my @dir_entries = split(/[\\\/]/, $start_dir); my @dir_entries = split(/[\\\/]/, $ENV{PWD});
my $current_module = $dir_entries[$#dir_entries]; my $current_module = $dir_entries[$#dir_entries];
$current_module = $` if (($current_module =~ /(\.lnk)$/) || ($current_module =~ /(\.link)$/)); if (($current_module =~ /(\.lnk)$/) || ($current_module =~ /(\.link)$/)) {
my $link_name = $ENV{SOLARSRC}.'/'.$current_module.$1; $current_module = $`;
if ( $^O eq 'MSWin32' ) { # we're dealing with a link => fallback to SOLARSRC under UNIX
$start_dir =~ s/\\/\//go; $StandDir = $ENV{SOLARSRC}.'/';
$link_name =~ s/\\/\//go; get_current_module($current_module);
if (lc($start_dir) eq lc($link_name)) { return;
get_current_module($current_module); } else {
}; chdir $start_dir;
} elsif ((-l $link_name) && (chdir $link_name)) { getcwd();
if ($start_dir eq getcwd()) {
# we're dealing with link => fallback to SOLARSRC under UNIX
$StandDir = $ENV{SOLARSRC}.'/';
get_current_module($current_module);
return;
} else {
chdir $start_dir;
getcwd();
};
}; };
}; };
...@@ -2836,7 +2827,7 @@ sub generate_html_file { ...@@ -2836,7 +2827,7 @@ sub generate_html_file {
print HTML 'document.write(" </ul>");' . "\n"; print HTML 'document.write(" </ul>");' . "\n";
print HTML 'document.write(" </div>");' . "\n"; print HTML 'document.write(" </div>");' . "\n";
}; };
if ($BuildAllParents) { if ($build_all_parents) {
print HTML 'document.write("<table valign=top cellpadding=0 hspace=0 vspace=0 cellspacing=0 border=0>");' . "\n"; print HTML 'document.write("<table valign=top cellpadding=0 hspace=0 vspace=0 cellspacing=0 border=0>");' . "\n";
print HTML 'document.write(" <tr>");' . "\n"; print HTML 'document.write(" <tr>");' . "\n";
print HTML 'document.write(" <td><a id=ErroneousModules href=\"javascript:top.Error(\'\', \''; print HTML 'document.write(" <td><a id=ErroneousModules href=\"javascript:top.Error(\'\', \'';
...@@ -3517,7 +3508,7 @@ sub get_job_string { ...@@ -3517,7 +3508,7 @@ sub get_job_string {
my $build_queue = shift; my $build_queue = shift;
my $job = $dmake; my $job = $dmake;
my ($job_dir, $dependencies_hash); my ($job_dir, $dependencies_hash);
if ($BuildAllParents) { if ($build_all_parents) {
fill_modules_queue($build_queue); fill_modules_queue($build_queue);
do { do {
($job_dir, $dependencies_hash) = pick_jobdir($build_queue); ($job_dir, $dependencies_hash) = pick_jobdir($build_queue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment