summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2003-05-22 12:38:13 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2003-05-22 12:38:13 +0000
commit7cabf3c850425caa8a341bf1daa76b16e6d50dda (patch)
treea97026f2e989232ea650038607732fd88817fdd1
parentdb19162502f36d80bf636959140deb7b3f5c82e5 (diff)
downloadMPC-7cabf3c850425caa8a341bf1daa76b16e6d50dda.tar.gz
ChangeLogTag: Thu May 22 07:35:23 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--modules/Creator.pm3
-rw-r--r--modules/Driver.pm17
-rw-r--r--modules/FeatureParser.pm79
-rw-r--r--modules/Options.pm41
-rw-r--r--modules/ProjectCreator.pm59
-rw-r--r--modules/WorkspaceCreator.pm31
6 files changed, 192 insertions, 38 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm
index 8f891cea..7a5d5e9d 100644
--- a/modules/Creator.pm
+++ b/modules/Creator.pm
@@ -26,6 +26,7 @@ use vars qw(@ISA);
my(@statekeys) = ('global', 'include', 'template', 'ti',
'dynamic', 'static', 'relative', 'addtemp',
'addproj', 'progress', 'toplevel', 'baseprojs',
+ 'feature_file',
);
my(%all_written) = ();
@@ -48,6 +49,7 @@ sub new {
my($progress) = shift;
my($toplevel) = shift;
my($baseprojs) = shift;
+ my($feature) = shift;
my($type) = shift;
my($self) = Parser::new($class, $inc);
@@ -70,6 +72,7 @@ sub new {
$self->{'baseprojs'} = $baseprojs;
$self->{'dynamic'} = $dynamic;
$self->{'static'} = $static;
+ $self->{'feature_file'} = $feature;
return $self;
}
diff --git a/modules/Driver.pm b/modules/Driver.pm
index be21ca50..a8eb65d9 100644
--- a/modules/Driver.pm
+++ b/modules/Driver.pm
@@ -101,6 +101,7 @@ sub optionError {
$spaces . "[-noreldefs] [-notoplevel] [-static] [-static_only]\n" .
$spaces . "[-value_template <NAME+=VAL | NAME=VAL | NAME-=VAL>]\n" .
$spaces . "[-value_project <NAME+=VAL | NAME=VAL | NAME-=VAL>]\n" .
+ $spaces . "[-feature_file <file name>]\n" .
$spaces . "[-type <";
my(@keys) = sort keys %{$self->{'types'}};
@@ -120,6 +121,9 @@ sub optionError {
print STDERR
" -base Add <project> as a base project to each generated\n" .
" project file.\n" .
+" -feature_file Specifies the feature file to read before processing.\n" .
+" The default feature file is default.features under the\n" .
+" config directory.\n" .
" -global Specifies the global input file. Values stored\n" .
" within this file are applied to all projects.\n" .
" -include Specifies a directory to search when looking for base\n" .
@@ -227,10 +231,19 @@ sub run {
}
}
+ ## Set the global feature file
+ my($global_feature_file) = $self->{'path'} . '/config/global.features';
+
## Set up default values
if (!defined $options->{'input'}->[0]) {
push(@{$options->{'input'}}, '');
}
+ if (!defined $options->{'feature_file'}) {
+ my($feature_file) = $self->{'path'} . '/config/default.features';
+ if (-r $feature_file) {
+ $options->{'feature_file'} = $feature_file;
+ }
+ }
if (!defined $options->{'global'}) {
my($global) = $self->{'path'} . '/config/global.mpb';
if (-r $global) {
@@ -310,7 +323,9 @@ sub run {
$options->{'addproj'},
(-t 1 ? \&progress : undef),
$options->{'toplevel'},
- $options->{'baseprojs'});
+ $options->{'baseprojs'},
+ $global_feature_file,
+ $options->{'feature_file'});
if ($base ne $file) {
my($dir) = ($base eq '' ? $file : dirname($file));
if (!$generator->cd($dir)) {
diff --git a/modules/FeatureParser.pm b/modules/FeatureParser.pm
new file mode 100644
index 00000000..4f232b63
--- /dev/null
+++ b/modules/FeatureParser.pm
@@ -0,0 +1,79 @@
+package FeatureParser;
+
+# ************************************************************
+# Description : Reads the feature files and store the values
+# Author : Chad Elliott
+# Create Date : 5/21/2003
+# ************************************************************
+
+# ************************************************************
+# Pragmas
+# ************************************************************
+
+use strict;
+
+use Parser;
+
+use vars qw(@ISA);
+@ISA = qw(Parser);
+
+# ************************************************************
+# Subroutine Section
+# ************************************************************
+
+sub new {
+ my($class) = shift;
+ my($global_file) = shift;
+ my($file) = shift;
+ my($self) = $class->SUPER::new();
+
+ ## Set the values associative array
+ $self->{'values'} = {};
+
+ ## Process each feature file
+ foreach my $f ($global_file, $file) {
+ if (defined $f) {
+ my($status, $warn) = $self->read_file($f);
+ if (!$status) {
+ ## We only want to warn the user about problems
+ ## with the feature file.
+ my($lnumber) = $self->line_number();
+ $warn =~ s/ERROR/WARNING/;
+ print "$f: line $lnumber:\n$warn\n";
+ }
+ }
+ }
+
+ return $self;
+}
+
+
+sub parse_line {
+ my($self) = shift;
+ my($if) = shift;
+ my($line) = shift;
+ my($status) = 1;
+ my($error) = '';
+
+ if ($line eq '') {
+ }
+ elsif ($line =~ /^(\w+)\s*=\s*(\d+)$/) {
+ $self->{'values'}->{$1} = $2;
+ }
+ else {
+ $status = 0;
+ $error = "ERROR: Unrecognized line: $line";
+ }
+
+ return $status, $error;
+}
+
+
+sub get_value {
+ my($self) = shift;
+ my($tag) = shift;
+ return $self->{'values'}->{$tag};
+}
+
+
+1;
diff --git a/modules/Options.pm b/modules/Options.pm
index db3295ba..aacd1471 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 " .
+ "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/(";
@@ -61,6 +61,7 @@ sub options {
my(%addproj) = ();
my($global) = undef;
my($template) = undef;
+ my($feature_f) = undef;
my($dynamic) = ($defaults ? 1 : undef);
my($reldefs) = ($defaults ? 1 : undef);
my($toplevel) = ($defaults ? 1 : undef);
@@ -108,6 +109,13 @@ sub options {
}
}
}
+ elsif ($arg eq '-feature_file') {
+ $i++;
+ $feature_f = $args[$i];
+ if (!defined $feature_f) {
+ $self->optionError('-feature_file requires a file name argument');
+ }
+ }
elsif ($arg eq '-global') {
$i++;
$global = $args[$i];
@@ -250,21 +258,22 @@ sub options {
}
}
- my(%options) = ('global' => $global,
- 'include' => \@include,
- 'input' => \@input,
- 'generators' => \@generators,
- 'baseprojs' => \@baseprojs,
- 'template' => $template,
- 'ti' => \%ti,
- 'dynamic' => $dynamic,
- 'static' => $static,
- 'relative' => \%relative,
- 'reldefs' => $reldefs,
- 'toplevel' => $toplevel,
- 'recurse' => $recurse,
- 'addtemp' => \%addtemp,
- 'addproj' => \%addproj,
+ my(%options) = ('global' => $global,
+ 'feature_file' => $feature_f,
+ 'include' => \@include,
+ 'input' => \@input,
+ 'generators' => \@generators,
+ 'baseprojs' => \@baseprojs,
+ 'template' => $template,
+ 'ti' => \%ti,
+ 'dynamic' => $dynamic,
+ 'static' => $static,
+ 'relative' => \%relative,
+ 'reldefs' => $reldefs,
+ 'toplevel' => $toplevel,
+ 'recurse' => $recurse,
+ 'addtemp' => \%addtemp,
+ 'addproj' => \%addproj,
);
return \%options;
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm
index 85340a46..6fc3f1c4 100644
--- a/modules/ProjectCreator.pm
+++ b/modules/ProjectCreator.pm
@@ -19,6 +19,7 @@ use File::Basename;
use Creator;
use TemplateInputReader;
use TemplateParser;
+use FeatureParser;
use vars qw(@ISA);
@ISA = qw(Creator);
@@ -134,11 +135,13 @@ sub new {
my($progress) = shift;
my($toplevel) = shift;
my($baseprojs) = shift;
+ my($gfeature) = shift;
+ my($feature) = shift;
my($self) = Creator::new($class, $global, $inc,
$template, $ti, $dynamic, $static,
$relative, $addtemp, $addproj,
$progress, $toplevel, $baseprojs,
- 'project');
+ $feature, 'project');
$self->{$self->{'type_check'}} = 0;
$self->{'project_info'} = [];
@@ -155,7 +158,7 @@ sub new {
$self->{'pctype'} = $self->extractType("$self");
$self->{'defaulted'} = {};
$self->{'custom_types'} = {};
-
+ $self->{'feature_parser'} = new FeatureParser($gfeature, $feature);
$self->reset_generating_types();
return $self;
@@ -1707,14 +1710,54 @@ sub get_custom_value {
}
+sub check_features {
+ my($self) = shift;
+ my($requires) = $self->get_assignment('requires');
+ my($status) = 1;
+
+ if (defined $requires) {
+ foreach my $require (split(/\s+/, $requires)) {
+ my($fval) = $self->{'feature_parser'}->get_value($require);
+
+ ## By default, if the feature is not listed, then it is enabled.
+ if (defined $fval && !$fval) {
+ $status = 0;
+ last;
+ }
+ }
+ }
+
+ ## 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);
+
+ ## By default, if the feature is not listed, then it is enabled.
+ if (!defined $fval || $fval) {
+ $status = 0;
+ last;
+ }
+ }
+ }
+ }
+
+ return $status;
+}
+
+
sub need_to_write_project {
my($self) = shift;
- foreach my $key ('source_files', keys %{$self->{'generated_exts'}}) {
- my($names) = $self->{$key};
- foreach my $name (keys %$names) {
- foreach my $key (keys %{$names->{$name}}) {
- if (defined $names->{$name}->{$key}->[0]) {
- return 1;
+
+ if ($self->check_features()) {
+ foreach my $key ('source_files', keys %{$self->{'generated_exts'}}) {
+ my($names) = $self->{$key};
+ foreach my $name (keys %$names) {
+ foreach my $key (keys %{$names->{$name}}) {
+ if (defined $names->{$name}->{$key}->[0]) {
+ return 1;
+ }
}
}
}
diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm
index 4a217fc0..f5f84f55 100644
--- a/modules/WorkspaceCreator.pm
+++ b/modules/WorkspaceCreator.pm
@@ -59,24 +59,27 @@ sub new {
my($progress) = shift;
my($toplevel) = shift;
my($baseprojs) = shift;
+ my($gfeature) = shift;
+ my($feature) = shift;
my($self) = Creator::new($class, $global, $inc,
$template, $ti, $dynamic, $static,
$relative, $addtemp, $addproj,
$progress, $toplevel, $baseprojs,
- 'workspace');
+ $feature, 'workspace');
my($typecheck) = $self->{'type_check'};
- $self->{'workspace_name'} = undef;
- $self->{$typecheck} = 0;
- $self->{'projects'} = [];
- $self->{'project_info'} = {};
- $self->{'reading_parent'} = [];
- $self->{'project_files'} = [];
- $self->{'scoped_assign'} = {};
- $self->{'cacheok'} = 1;
- $self->{'exclude'} = {};
- $self->{'wctype'} = $self->extractType("$self");
- $self->{'modified_count'} = 0;
+ $self->{'workspace_name'} = undef;
+ $self->{$typecheck} = 0;
+ $self->{'projects'} = [];
+ $self->{'project_info'} = {};
+ $self->{'reading_parent'} = [];
+ $self->{'project_files'} = [];
+ $self->{'scoped_assign'} = {};
+ $self->{'cacheok'} = 1;
+ $self->{'exclude'} = {};
+ $self->{'wctype'} = $self->extractType("$self");
+ $self->{'modified_count'} = 0;
+ $self->{'global_feature_file'} = $gfeature;
## Add a hash reference for our workspace type
if (!defined $previous_workspace_name{$self->{'wctype'}}) {
@@ -897,7 +900,9 @@ sub project_creator {
$parameters{'addproj'},
$parameters{'progress'},
$parameters{'toplevel'},
- $parameters{'baseprojs'});
+ $parameters{'baseprojs'},
+ $self->{'global_feature_file'},
+ $parameters{'feature_file'});
}