瀏覽代碼

oops, forgot to add files

David Rose 21 年之前
父節點
當前提交
ae7aa58e8c
共有 2 個文件被更改,包括 107 次插入0 次删除
  1. 60 0
      dtool/src/attach/ctproj.pl
  2. 47 0
      dtool/src/attach/ctutils.pl

+ 60 - 0
dtool/src/attach/ctproj.pl

@@ -0,0 +1,60 @@
+require "$tool/include/ctutils.pl" ;
+
+# return the root of the given project.
+sub CTProjRoot {
+    local( $CTPRtmp ) = $_[0] ;
+    $CTPRtmp =~ tr/a-z/A-Z/ ;
+    local( $CTPRret ) = $ENV{ $CTPRtmp } ;
+    $CTPRret ;
+}
+
+# return the package we're currently in.
+# input:
+#   $_[0] = project
+sub CTProjPkg {
+    local( $CTPPret ) = &CTUCurrDir() ;
+    local( $CTPPtmp ) = $_[0] ;
+    $CTPPtmp  =~ tr/a-z/A-Z/ ;
+    $CTPPret =~ s/$ENV{ $CTPPtmp }// ;
+    $CTPPret =~ s/\/src\/// ;
+    $CTPPret =~ s/\/metalibs\/// ;
+    $CTPPret ;
+}
+
+# reutrn the project containing the given directory.  If no directory is given,
+# return the project containing the current directory.
+sub CTProj {
+   local( $CTPdir ) ;
+   if ($_[0] eq "") {
+      $CTPdir = &CTUCurrDir() ;
+   } else {
+      # provided directory
+      $CTPdir = $_[0] ;
+   }
+   local( $CTPprojs ) = $ENV{"CTPROJS"} ;
+   local( $CTPdone ) = "" ;
+   local( @CTPlist ) ;
+   @CTPlist = split( / /, $CTPprojs ) ;
+   local( @CTPlist2 ) ;
+   local( $CTPtry ) ;
+   while (( $CTPdone eq "" ) && ( @CTPlist != () )){
+      # pop the first one off the list
+      $CTPtmp = $CTPlist[0] ;
+      shift( @CTPlist ) ;
+      # split the project from it's flavor
+      @CTPlist2 = split( /:/, $CTPtmp );
+      $CTPtry = &CTProjRoot( $CTPlist2[0] ) ;
+      # is CTPtry prefix of CTPdir?  if so we have our winner
+      if ( $CTPdir =~ /^$CTPtry/ ) {
+	 $CTPdone = "yep" ;
+      }
+   }
+   if ( $CTPdone eq "" ) {
+      $CTPtry = "" ;
+   } else {
+      $CTPtry = $CTPlist2[0] ;
+   }
+   $CTPtry ;
+}
+
+1;

+ 47 - 0
dtool/src/attach/ctutils.pl

@@ -0,0 +1,47 @@
+# evaluate the given parameter to expand shell variables
+sub CTUShellEval {
+   local( *CTUSEFILE ) ;
+   open( CTUSEFILE, "echo $_[0] |" ) ;
+   local( $CTUSEret ) = <CTUSEFILE> ;
+   close( CTUSEFILE ) ;
+   $CTUSEret =~ s/\n$// ;
+   $CTUSEret ;
+}
+
+# if debug is on, print the argument
+sub CTUDebug {
+    if ( $ctdebug ) {
+	print STDERR $_[0] ;
+    }
+}
+
+use Cwd ;
+# get current directory
+sub CTUCurrDir {
+    local( $pwd ) = getcwd() ;
+    if ( $pwd =~ /^\/vobs/ ) {
+	local( *VFILE ) ;
+	open( VFILE, "cleartool pwv -short |" ) ;
+	local( $view ) = <VFILE> ;
+	close( VFILE ) ;
+	$view =~ s/\n$// ;
+	$pwd = "/view/" . $view . $pwd ;
+    }
+    $pwd ;
+}
+
+# turn a shell return code into a success/fail flag
+sub CTURetCode {
+    local( $ret ) ;
+    if ( $_[0] == 0 ) {
+	$ret = 1 ;
+    } else {
+	$ret = 0 ;
+    }
+    $ret ;
+}
+
+$ctdebug = $ENV{"CTATTACH_DEBUG"} ;
+$ctvspec_path = '/usr/local/etc' unless $ctvspec_path = $ENV{'CTVSPEC_PATH'};
+
+1;