⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen_config.pl

📁 MMI层OBJ不能完全编译
💻 PL
📖 第 1 页 / 共 2 页
字号:
##############################
### edit_master_cfg subroutine
##############################
sub edit_master_cfg
{
   my $end_of_edit = 0;
   my $next_config_set = 0;
   my $config;
   my $key;
   my @data;
      
   # Parse var_def.txt files
   parse_var_def_txt_file();
   
   # Open master.cfg file
   unless (open OUT, ">master.cfg") {
                     error_message("Unable to open master.cfg\n");}
   
   # Write header file
   print OUT "# master.cfg\n";
   print OUT "#\n";
   print OUT "# Configuration file for ABC build system.\n";
   print OUT "# Generated automatically with gen_config.pl.\n";
   print OUT "# !!!!! Do not modify !!!!!\n";
   print OUT "#\n";
   print OUT "# (C) Texas Instruments 2004\n";

   # Each set of configs is analyzed
   while(!$end_of_edit)
   {
      $end_of_edit = 1;
   
      # Write comments for a new set of configs
      my $i = 0;
      my $filename_written = 0;
      foreach $config (keys %main::g_configs_definition)
      {
         if ($i < $next_config_set)
         {
           $i++;
         }
         else
         {
            # Write the filename only one time
            if (!$filename_written)
            {
               $end_of_edit = 0;
               $filename_written = 1;
               ($key) = ($config =~ /^(.+TCS[0-9]+)/);
               @data = split(/:/,$main::g_configs_definition{$config});
               print OUT "\n# Config file $data[0]\n#\n"; # Filename
            }

            # Write the comment for each config of the new set
            if ($config =~ /$key/)
            {
               @data = split(/:/,$main::g_configs_definition{$config});
               if ($data[1] ne "") # Included section do not have comments
               {
                  print OUT "# $config"." "x(20 - length($config))."$data[1]\n"; # Comment
               }
            }
         }
      }
      
      # If a new set of configs is found, read it
      if (!$end_of_edit)
      {
         $i = 0;
         foreach $config (keys %main::g_configs_definition)
         {
            # Go to the beginning of the new set
            if ($i < $next_config_set)
            {
              $i++;
            }
            # Read only the new set
            elsif ($config =~ /$key/)
            {
               $i++;
               # Start to fulfill a specific section
               print OUT "\n[$config]\n\n" ;
               @data = split(/:/,$main::g_configs_definition{$config}) ;

               my $j = 2;         
               while ($j < $#data)
               {
                  if ($data[$j] eq "INCLUDE")
                  {
                     $config =~ /^(.+TCS[0-9]+_)/;
                     print OUT "&$1"."$data[$j+1]\n\n";
                  }
                  else
                  {
                     my $line;

                     if (exists($g_abc_variables{$data[$j]}))
                     {
                        $g_abc_variables{$data[$j]} =~ /(.+):(.+)/;
                        if ($2 eq "EXPORTED")
                        {
                           $line = "\$$1"."_"."$data[$j]";
                        }
                        else
                        {
                           $line = "$1"."_"."$data[$j]";
                        }

                        $line .= " "x(40-length($line))."= $data[$j+1]\n";
                        print OUT $line;
         
                     }
                     else
                     {
                        close(OUT);
                        error_message("Variable $data[$j] not defined in $g_var_def_txt")
                     }
                  }
                  
                  $j += 2;
               }
            }
         }

         $next_config_set = $i;
      }
   }
   
   close(OUT);
}


####################################
### edit_configdefs_files subroutine
####################################
sub edit_configdefs_files
{
   my $i = 0;
   my $path = "../../system/busyb/configdefs";

   foreach my $config (keys %main::g_configs_definition)
   {
      unless (open OUT, ">$path/configdef_".lc($config).".xml") {
         error_message("Unable to create $path/configdef_".lc($config).".xml\n");}

      # Start to fulfill a specific configdef
      print OUT "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" ;
      print OUT "<!-- Configuration file for BuSyB build system.  -->\n";
      print OUT "<!-- Generated automatically with gen_config.pl. -->\n";
      print OUT "<!-- !!!!! Do not modify !!!!!                   -->\n\n";
      print OUT "<!-- (C) Texas Instruments 2004 -->\n\n";

      my @data = split(/:/,$main::g_configs_definition{$config}) ;

      # Print filename
      print OUT "<!-- Imported from $data[0] -->\n\n";
      
      # Print comment
      if ($data[1] ne "")
      {
         print OUT "<!-- $data[1] -->\n\n";
      }
      
      (my $program_id) = ($config =~ m/TCS([0-9]+)/);
      print OUT "<configDef name=\"$config\" description=\"$config section\" reference=\"\">\n";
   
      # Workaround for L1 which allows to add these lines for specific configuration CFGx
      if ($config =~ m/^L1.+CFG/)
      {
         $config =~ m/CFG([0-9]+)/ ;
         print OUT "   <property name=\"PROGRAM\" value=\"$program_id\" />\n";
         print OUT "   <property name=\"CONFIG\" value=\"$1\" />\n";
         print OUT "   <property include=\"configdef_undef_var_l1.xml\"/>\n";
      }
   
      $i = 2;
      while ($i < $#data)
      {
         if ($data[$i] eq "INCLUDE")
         {
            my $filename = "configdef_tcs$program_id"."_".lc($data[$i+1]).".xml";
            print OUT "   <property include=\"$filename\"/>\n";
         }
         else 
         {
            print OUT "   <property name=\"$data[$i]\""." "x(25-length($data[$i]))."value=\"$data[$i+1]\" />\n";
         }
         
         $i += 2;
      }
      
      print OUT "</configDef>\n";
      close(OUT);
   }
}

############################
### edit_batch_build_files subroutine
############################
sub edit_batch_build_files
{
   my $path = ".";

   unless (open OUT_ABC, ">$path/configs_abc.bs") {
      error_message("Unable to create \"configs_abc.bs\"\n");}
   unless (open OUT_BUSYB, ">$path/configs_busyb.bs") {
      error_message("Unable to create \"configs_busyb.bs\"\n");}

   print OUT_ABC "# configs_abc.bs\n";
   print OUT_ABC "#\n";
   print OUT_ABC "# Format: [-]<Config Spec>::<Working Directory>::<Pre-Build>::<Build>::<Post-Build>::<Target>\n";
   print OUT_ABC "#\n";
   print OUT_ABC "# (C) Texas Instruments 2004\n\n";

   print OUT_BUSYB "# configs_busyb.bs\n";
   print OUT_BUSYB "#\n";
   print OUT_BUSYB "# Format: [-]<Config Spec>::<Working Directory>::<Pre-Build>::<Build>::<Post-Build>::<Target>\n";
   print OUT_BUSYB "#\n";
   print OUT_BUSYB "# (C) Texas Instruments 2004\n\n";

   foreach my $config (keys %main::g_configs_definition)
   {
      # The files are created for L1 only
      if ($config =~ /^L1_/ && $config =~ /CFG/)
      {
         print OUT_ABC "::L1/layer1/tools::::perl abc.pl ".$config."::::../link_out/".$config."/l1*.out\n";
         print OUT_BUSYB "::L1/layer1/tools::l1_pre_bb.bat ".lc($config)."::make -f ".lc($config).".mak::::../../__out__/".lc($config)."/bin/l1*.out\n";
      }
   }
   
   close (OUT_ABC);
   close (OUT_BUSYB);
}


###################################
### check_files_validity subroutine
###################################
sub check_files_validity
{
   # Get list of files that must be parsed in the working directory
   # Check if var_def.txt exists
   if (! -f $g_var_def_txt)
   {
      error_message("$g_var_def_txt not existing");
   }

   # Update the list of variant files to be checked
   if ($g_options ne "none" && $g_options ne "all")
   {
      if (! -f $g_options)
      {
         error_message("$g_options file not existing");
      }
      push(@g_configs_xxx_txt, $g_options);
   }
   else
   {
      # Retrieve the list of variants file and store it
      @g_configs_xxx_txt = glob($g_input_file_name_pattern);
      if (!@g_configs_xxx_txt)
      {
         error_message("Config files matching with $g_input_file_name_pattern not existing");
      }
   }
   
   # Check if input files contain tab characters, if yes, stop the process
   my $tabs_in_files = 0;
   
   $tabs_in_files = search_tab_in_file($g_var_def_txt);
   
   if ($tabs_in_files == 1)
   {
      error_message("Tabulations not authorized in $g_var_def_txt file");
   }
   
   foreach my $file (@g_configs_xxx_txt)
   {
      $tabs_in_files = search_tab_in_file($file);
      if ($tabs_in_files == 1)
      {
         error_message("Tabulations not authorized in $file file");
      }
   }
}

#################################
### search_tab_in_file subroutine
#################################
sub search_tab_in_file
{
   my $line;
   
   open (IN, "<$_[0]")
     or die "ERROR: could not open file $_[0]" ;
   
   while ($line = <IN>)
   {
     # Check if variable a TAB character exist in the file
     if ( $line =~ /\t/ )
     {
        close(IN);
        return(1);
     }
   }
   close(IN);
   return(0);
}


############################
### error_message subroutine
############################
sub error_message
{
   print "\nERROR : $_[0]\n";
   print "\nPlease press a key to exit ...";
   <STDIN>;
   exit(0);
}

####################
### usage subroutine
####################
sub usage
{
   print "\nUSAGE:
   perl gen_config.pl [OPTIONS]

Generate master.cfg and ConfigDefs XML file for Layer1 variants

OPTIONS:
   -all              Generate master.cfg and Configdefs files for all the variants
   -p o_config_file  Generate master.cfg and Configdefs files for the specific variants
                     defined by the config file
   -h | -help        Display this help

EXAMPLES:
   perl gen_config.pl
   perl gen_config.pl -all
   perl gen_config.pl -p l1_configs_tcs211.txt
";

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -