summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2003-06-20 13:12:30 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2003-06-20 13:12:30 +0000
commitffde12438c348d34433a81926b09f632ea6cc78c (patch)
treea5cd2268b65fbaf4d3d77613c01cac9d309cd737
parent3613febfe91d09cbe5abec910ac20284e2978c3e (diff)
downloadMPC-ffde12438c348d34433a81926b09f632ea6cc78c.tar.gz
ChangeLogTag: Fri Jun 20 08:10:11 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--modules/Creator.pm18
-rw-r--r--modules/Options.pm2
-rw-r--r--modules/Parser.pm4
-rw-r--r--modules/ProjectCreator.pm135
-rw-r--r--modules/WorkspaceCreator.pm4
5 files changed, 137 insertions, 26 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm
index 45ebc026..6d9d8c60 100644
--- a/modules/Creator.pm
+++ b/modules/Creator.pm
@@ -93,7 +93,7 @@ sub collect_line {
}
else {
($status, $errorString) = $self->parse_line($fh, $$lref);
- $$lref = "";
+ $$lref = '';
}
return $status, $errorString;
@@ -263,6 +263,12 @@ sub parse_known {
$status = 0;
}
}
+ elsif ($line =~ /^(feature)\s*\(([^\)]+)\)\s*{$/) {
+ my($type) = $1;
+ my($name) = $2;
+ my(@names) = split(/\s*,\s*/, $name);
+ push(@values, $type, \@names);
+ }
elsif (!$self->{$typecheck}) {
$errorString = "ERROR: No $type was defined";
$status = 0;
@@ -279,7 +285,7 @@ sub parse_known {
$name =~ s/\s*\)$//;
}
else {
- $name = 'default';
+ $name = $self->get_default_component_name();
}
push(@values, 'component', $comp, $name);
}
@@ -306,7 +312,7 @@ sub parse_scope {
$flags = {};
}
- while(<$fh>) {
+ while($_ = $fh->getline()) {
my($line) = $self->strip_line($_);
if ($line eq '') {
@@ -710,6 +716,12 @@ sub get_static {
return $self->{'static'};
}
+
+sub get_default_component_name {
+ #my($self) = shift;
+ return 'default';
+}
+
# ************************************************************
# Virtual Methods To Be Overridden
# ************************************************************
diff --git a/modules/Options.pm b/modules/Options.pm
index aacd1471..23c8a610 100644
--- a/modules/Options.pm
+++ b/modules/Options.pm
@@ -28,7 +28,7 @@ sub completion_command {
my($types) = shift;
my($str) = "complete $name " .
"'c/-/(global include type template relative " .
- "ti static noreldefs notoplevel feature_file" .
+ "ti static noreldefs notoplevel feature_file " .
"value_template value_project)/' " .
"'c/dll:/f/' 'c/dll_exe:/f/' 'c/lib_exe:/f/' 'c/lib:/f/' " .
"'n/-ti/(dll lib dll_exe lib_exe)/:' 'n/-type/(";
diff --git a/modules/Parser.pm b/modules/Parser.pm
index e7533e0c..2094496a 100644
--- a/modules/Parser.pm
+++ b/modules/Parser.pm
@@ -108,8 +108,8 @@ sub read_file {
$self->{'line_number'} = 0;
if (open($ih, $input)) {
- my($line) = "";
- while(<$ih>) {
+ my($line) = '';
+ while($_ = $ih->getline()) {
($status, $errorString) = $self->collect_line($ih, \$line, $_);
if (!$status) {
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm
index 146fb1d9..c9da93d0 100644
--- a/modules/ProjectCreator.pm
+++ b/modules/ProjectCreator.pm
@@ -20,6 +20,7 @@ use Creator;
use TemplateInputReader;
use TemplateParser;
use FeatureParser;
+use ArrayHandle;
use vars qw(@ISA);
@ISA = qw(Creator);
@@ -146,8 +147,10 @@ sub new {
$feature, 'project');
$self->{$self->{'type_check'}} = 0;
+ $self->{'feature_defined'} = 0;
$self->{'project_info'} = [];
$self->{'reading_parent'} = [];
+ $self->{'feature_definitions'} = [];
$self->{'dexe_template_input'} = undef;
$self->{'lexe_template_input'} = undef;
$self->{'lib_template_input'} = undef;
@@ -243,8 +246,14 @@ sub parse_line {
}
if ($status) {
- ## End of project; Write out the file.
- ($status, $errorString) = $self->write_project();
+ ## Now add in the features that have been defined
+ $self->{$typecheck} = 0;
+ ($status, $errorString) = $self->process_features();
+
+ if ($status) {
+ ## End of project; Write out the file.
+ ($status, $errorString) = $self->write_project();
+ }
foreach my $key (keys %{$self->{'valid_components'}}) {
delete $self->{$key};
@@ -256,6 +265,7 @@ sub parse_line {
$self->{'type_specific_assign'} = {};
$self->{'flag_overrides'} = {};
$self->{'parents_read'} = {};
+ $self->{'feature_definitions'} = [];
$self->reset_generating_types();
}
}
@@ -402,7 +412,7 @@ sub parse_line {
$name =~ s/\s*\)$//;
}
else {
- $name = 'default';
+ $name = $self->get_default_component_name();
}
my($vc) = $self->{'valid_components'};
@@ -434,6 +444,14 @@ sub parse_line {
}
}
}
+ elsif ($values[0] eq 'feature') {
+ $self->{'feature_defined'} = 1;
+ $self->save_feature($ih, $values[1]);
+ if ($self->{'feature_defined'}) {
+ $errorString = "ERROR: Did not find the end of the feature";
+ $status = 0;
+ }
+ }
else {
$errorString = "ERROR: Unrecognized line: $line";
$status = 0;
@@ -506,11 +524,10 @@ sub parse_components {
my($fh) = shift;
my($tag) = shift;
my($name) = shift;
- my($current) = '000_FILES';
+ my($current) = $self->get_default_element_name();
my($status) = 1;
my($names) = {};
my($comps) = {};
- my($order) = 0;
my($set) = 0;
my(%flags) = ();
my($custom) = defined $self->{'generated_exts'}->{$tag};
@@ -548,7 +565,7 @@ sub parse_components {
}
}
- while(<$fh>) {
+ while($_ = $fh->getline()) {
my($line) = $self->strip_line($_);
if ($line eq '') {
@@ -560,9 +577,8 @@ sub parse_components {
## so we remove it from the components
delete $$comps{$current};
}
- $current = sprintf("%03d_$1", $order);
+ $current = $1;
$set = 1;
- $order++;
if (!defined $$comps{$current}) {
$$comps{$current} = [];
}
@@ -627,7 +643,7 @@ sub parse_verbatim {
$self->{'verbatim'}->{$type}->{$loc} = [];
my($array) = $self->{'verbatim'}->{$type}->{$loc};
- while(<$fh>) {
+ while($_ = $fh->getline()) {
my($line) = $self->strip_line($_);
if ($line eq '') {
@@ -646,6 +662,81 @@ sub parse_verbatim {
}
+sub save_feature {
+ my($self) = shift;
+ my($fh) = shift;
+ my($names) = shift;
+ my(@lines) = ("project {\n");
+ my($curly) = 1;
+
+ while($_ = $fh->getline()) {
+ my($line) = $self->strip_line($_);
+ push(@lines, "$line\n");
+
+ ## This is a very simplistic way of finding the end of
+ ## the feature definition. It will work as long as no spurious
+ ## open curly braces are counted.
+ if ($line =~ /{$/) {
+ ++$curly;
+ }
+ elsif ($line =~ /^}$/) {
+ --$curly;
+ }
+ if ($curly == 0) {
+ $self->{'feature_defined'} = 0;
+ last;
+ }
+ }
+ push(@{$self->{'feature_definitions'}}, [ $names, \@lines ]);
+}
+
+
+sub process_features {
+ my($self) = shift;
+ my($status) = 1;
+ my($error) = '';
+
+ foreach my $feature (@{$self->{'feature_definitions'}}) {
+ my($names, $lines) = @$feature;
+ my($requires) = '';
+ my($avoids) = '';
+ foreach my $name (@$names) {
+ if ($name =~ /^!\s*(.*)$/) {
+ if ($avoids ne '') {
+ $avoids .= ' ';
+ }
+ $avoids .= $1;
+ }
+ else {
+ if ($requires ne '') {
+ $requires .= ' ';
+ }
+ $requires .= $name;
+ }
+ }
+
+ if ($self->check_features($requires, $avoids)) {
+ my($ah) = new ArrayHandle($lines);
+ push(@{$self->{'reading_parent'}}, "feature $requires $avoids");
+ my($line) = '';
+ while($_ = $ah->getline()) {
+ ($status, $error) = $self->collect_line($ah, \$line, $_);
+
+ if (!$status) {
+ last;
+ }
+ }
+ pop(@{$self->{'reading_parent'}});
+ }
+
+ if (!$status) {
+ last;
+ }
+ }
+ return $status, $error;
+}
+
+
sub process_array_assignment {
my($self) = shift;
my($aref) = shift;
@@ -701,7 +792,7 @@ sub parse_define_custom {
$self->{'matching_assignments'}->{$tag} = \@keys;
}
- while(<$fh>) {
+ while($_ = $fh->getline()) {
my($line) = $self->strip_line($_);
if ($line eq '') {
@@ -986,7 +1077,7 @@ sub generate_default_target_names {
my($exename) = undef;
foreach my $file (@sources) {
if (open($fh, $file)) {
- while(<$fh>) {
+ while($_ = $fh->getline()) {
## Remove c++ comments (ignore c style comments for now)
$_ =~ s/\/\/.*//;
@@ -1238,12 +1329,13 @@ sub generate_default_components {
}
else {
## Generate default values for undefined tags
+ my($defcomp) = $self->get_default_element_name();
my($names) = {};
$self->{$tag} = $names;
my($comps) = {};
- $$names{'default'} = $comps;
- $$comps{'000_FILES'} = [];
- my($array) = $$comps{'000_FILES'};
+ $$names{$self->get_default_component_name()} = $comps;
+ $$comps{$defcomp} = [];
+ my($array) = $$comps{$defcomp};
if (!$self->is_special_tag($tag)) {
$self->sift_files($files, $exts, $pchh, $pchc, $tag, $array);
@@ -1755,7 +1847,8 @@ sub get_custom_value {
sub check_features {
my($self) = shift;
- my($requires) = $self->get_assignment('requires');
+ my($requires) = shift;
+ my($avoids) = shift;
my($status) = 1;
if (defined $requires) {
@@ -1772,7 +1865,6 @@ sub check_features {
## If it passes the requires, then check the avoids
if ($status) {
- my($avoids) = $self->get_assignment('avoids');
if (defined $avoids) {
foreach my $avoid (split(/\s+/, $avoids)) {
my($fval) = $self->{'feature_parser'}->get_value($avoid);
@@ -1793,7 +1885,8 @@ sub check_features {
sub need_to_write_project {
my($self) = shift;
- if ($self->check_features()) {
+ if ($self->check_features($self->get_assignment('requires'),
+ $self->get_assignment('avoids'))) {
foreach my $key ('source_files', keys %{$self->{'generated_exts'}}) {
my($names) = $self->{$key};
foreach my $name (keys %$names) {
@@ -1851,7 +1944,7 @@ sub write_output_file {
print $fh $line;
}
close($fh);
-
+
if (-r $name &&
-s $tmp == -s $name && compare($tmp, $name) == 0) {
$different = 0;
@@ -2077,6 +2170,12 @@ sub generate_recursive_input_list {
$ProjectCreatorExtension);
}
+
+sub get_default_element_name {
+ #my($self) = shift;
+ return 'FILES';
+}
+
# ************************************************************
# Virtual Methods To Be Overridden
# ************************************************************
diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm
index b26ac7ee..6e6ed9ab 100644
--- a/modules/WorkspaceCreator.pm
+++ b/modules/WorkspaceCreator.pm
@@ -249,14 +249,14 @@ sub parse_exclude {
my($status) = 0;
my($errorString) = 'ERROR: Unable to process exclude';
- if ($typestr eq 'default') {
+ if ($typestr eq $self->get_default_component_name()) {
$typestr = $self->{'wctype'};
}
my(@types) = split(/\s*,\s*/, $typestr);
my(@exclude) = ();
- while(<$fh>) {
+ while($_ = $fh->getline()) {
my($line) = $self->strip_line($_);
if ($line eq '') {