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

📄 getdep.pl

📁 在高通的手机平台下,一个下载手机.bin文件到手机的flash中的工具,包含PC端的程序代码和运行在基带处理器中的代码.
💻 PL
字号:
#! /usr/bin/env perl

#############################################################################
#
#                             G E T D E P
#
# GENERAL DESCRIPTION
#   Process the output of the C preprocessor into a nice list of dependencies.
#   The -M option on tcc works poorly, and can't handle an assembly file.
#   The first argument is the name of our object file.
#   The second object is the name of our source (needed for <stdin>
#   replacement).
#
# INVOCATION
#   perl getdep.pl file.o file.c [custfile] [targfile]
#
# Copyright (c) 1998 - 2002 by QUALCOMM Incorporated.  All Rights Reserved.
#############################################################################
#
#                        EDIT HISTORY FOR FILE
#
# $PVCSPath:  L:/src/asw/MSM6050/vcs/getdep.plv   1.1   10 Apr 2002 12:28:48   ropalsky  $
# $Header: //depot/asic/msm6050/tools/uuidgen/getdep.pl#3 $ $DateTime: 2002/07/02 14:19:53 $ $Author: ropalsky $
#
# when       who     what, where, why
# --------   ---     -------------------------------------------------------- 
# 07/02/02    ro     Fix parsing of target directory - change '\' to '/'.
#                    Support new parameters - custfile and targfile.
#                    Replace cust and targfile file variables in dependencies.
# 04/09/02    ro     Support dependencies that are in the build's subdirectories
# 07/13/01   jmk     Modified #line pattern matching string to accept leading
#                    whitespace as well
# 02/21/00    mt     Changes for GNU make - put source as first dependency.
# 09/15/00    mt     Change algorithm to remove dependencies on files that
#                    are not in the directory.  Previous algorithm did not
#                    always remove them.  Also, we now only want to remove
#                    dependencies that are .h files.  This is because for
#                    internal RAM builds we have dependencies that are
#                    source files located in TARGETDIR.
# 06/20/00   jcw     Changed TARGET to TARGETDIR since they can be different
#                    in MSM5000 builds
# 10/13/98   dlb     Initial version.
#
#############################################################################

# table to store dependencies
my %deps = ();

# filenames
my $object;
my $source;
my $custfile = undef;
my $targfile = undef;

my $name;

# make sure that at least the object and source files are specified
die "Usage: perl getdep.pl file.o file.c [custfile] [targfile]\n"
  unless ($#ARGV >= 1);

$object = $ARGV[0];
$source = $ARGV[1];

# The name of the custfile is optional 3rd parameter
if ($ARGV[2] ne undef) {
  $custfile = $ARGV[2];
}

# The name of the target file is optional 4th parameter
if ($ARGV[3] ne undef) {
  $targfile = $ARGV[3];
}

# Substitute the variable "TARGETDIR" for the object directory in the path
$object =~ s/^[A-Z0-9a-z]+\//\$\(TARGETDIR\)\//;

# Extract the lines containing dependencies and save the file names
while (<STDIN>) {
  # Process lines that match "#line <num> "file"
  next unless (/^\s*\#line\s+\d+\s+\"(.*)\"/);

  # Fix up a few names.
  $name = $1;

  # replace "<stdin>" with the name of the source file
  $name =~ s/\<stdin\>/$source/;
  
  # Save the dependencies excluding the source file
  $deps{$name} = 1 if $name !~ /$source/;
}

# Print out the dependencies with the C source being the first.
# GNU make requires that the C Source file is the first dependency in the list
print "$object: $source\n";

for $name (sort keys %deps) {

  # Support dependencies that are in the build's directory tree.
  # Remove dependencies that are not in the build's directory tree.
  
  # Strip the drive letter and/or any leading '\' from the path
  # if it is present.
  if (($name =~ /^\s*[a-zA-Z]:\\(.*\\\w+\.h)\s*$/) ||
      ($name =~ /^\s*\\(.*\\\w+\.h)\s*$/))
  {
    $name = $1;
  }

  # Does the file exist in this directory tree?
  next unless -f $name;

  # Replace the custfile and targfile with variables
  $name =~ s/$custfile/\$\(CUSTFILE\)/ if $custfile ne undef;
  $name =~ s/$targfile/\$\(TARGFILE\)/ if $targfile ne undef;
  
  print "$object: $name\n";
}

###########################################################################
# End of Perl script.
###########################################################################

⌨️ 快捷键说明

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