forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctattach.drv
More file actions
executable file
·150 lines (134 loc) · 4.01 KB
/
ctattach.drv
File metadata and controls
executable file
·150 lines (134 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/perl
# acceptable forms:
# ctattach - give usage message
# ctattach project - attach to the personal flavor of the project
# ctattach project flavor - attach to a specific flavor of the project
# ctattach - - list projects that can be attached to
# ctattach project - - list flavors of a given project
# ctattach - flavor - list projects with a certain flavor
# ctattach -def project flavor - attach to project, setting CTDEFAULT_FLAV
# to flavor for the scope of this attach
sub CTAttachUsage {
print STDERR "Usage: ctattach -def project flavor -or-\n" ;
print STDERR " ctattach project [flavor] -or-\n" ;
print STDERR " ctattach project - -or-\n" ;
print STDERR " ctattach - [flavor]\n" ;
&CTAttachWriteNullScript( $tmpname ) ;
print $tmpname . "\n" ;
exit;
}
$tool = $ENV{"DTOOL"} ;
if ( $tool eq "" ) {
die "\$" . "DTOOL environment must be set to use CTtools\n" ;
}
require "$tool/built/include/ctattch.pl" ;
$tmpname = "/tmp/script.$$" ;
if ( $#ARGV == -1 ) {
&CTUDebug( "got no arguments\n" ) ;
&CTAttachUsage ;
}
$idx = 0 ;
$proj = "" ;
$flav = "" ;
$noflav = 0 ;
$defflav = "" ;
$spread = 0 ;
$anydef = 0 ;
#
# parse arguemnts
#
if ( $ARGV[$idx] eq "-def" ) {
&CTUDebug( "got '-def' parameter\n" ) ;
if ( $#ARGV < ($idx + 2) ) {
&CTUDebug( "not enough arguments after -def\n" ) ;
&CTAttachUsage ;
}
$defflav = $ARGV[$idx+2] ;
$spread = 1;
&CTUDebug( "spread default flavor is '$defflav'\n" ) ;
$idx++ ;
} else {
if ( $ENV{"CTDEFAULT_FLAV"} ne "" ) {
$defflav = $ENV{"CTDEFAULT_FLAV"} ;
&CTUDebug( "environment default flavor is '$defflav'\n" ) ;
}
}
$proj = $ARGV[$idx] ;
&CTUDebug( "project is '$proj'\n" ) ;
if ( $defflav eq "" ) {
$defflav = "default" ;
&CTUDebug( "no environmental default, using 'default'\n" ) ;
}
if ( $#ARGV > $idx ) {
$flav = $ARGV[$idx+1] ;
&CTUDebug( "provided flavor is '$flav'\n" ) ;
} else {
if ( $proj ne "-" ) {
$flav = $defflav;
&CTUDebug( "using environment default flavor '$flav'\n" ) ;
$noflav = 1 ;
}
}
if (( $noflav == 1 ) || ( $flav eq "default" )) {
$anydef = 1 ;
}
#
# act on the arguments we got
#
require "$tool/built/include/ctquery.pl" ;
require "$tool/built/include/ctvspec.pl" ;
if (( $proj eq "-" ) || ( $flav eq "-" )) {
if ( $#ARGV == 0 ) {
# list projects that can be attached to
print STDERR "Projects that can be attached to:\n" ;
$_ = &CTListAllProjects ;
@projlist = split ;
foreach $item ( @projlist ) {
print STDERR " $item\n" ;
}
} elsif ( $proj eq "-" ) {
# list project that have a given flavor
print STDERR "Projects that have a '$flav' flavor:\n" ;
$_ = &CTListAllProjects ;
@projlist = split ;
foreach $item ( @projlist ) {
$tmp = &CTResolveSpec( $item, $flav ) ;
if ( $tmp ne "" ) {
print STDERR " $item\n" ;
}
}
} else {
# list flavors of a given project
print STDERR "Flavors of project '$proj':\n" ;
$_ = &CTListAllFlavors( $proj ) ;
@flavlist = split ;
foreach $item ( @flavlist ) {
print STDERR " $item\n" ;
}
}
&CTAttachWriteNullScript( $tmpname ) ;
print $tmpname . "\n" ;
} else {
# output a real attachment
$curflav = &CTQueryProj( $proj ) ;
if (( $curflav eq "" ) || ( $noflav == 0 )) {
$envsep{"PATH"} = ":" ;
$envsep{"LD_LIBRARY_PATH"} = ":" ;
$envsep{"DYLD_LIBRARY_PATH"} = ":" ;
$envsep{"PFPATH"} = ":" ;
$envsep{"SSPATH"} = ":" ;
$envsep{"STKPATH"} = ":" ;
$envsep{"DC_PATH"} = ":" ;
$spec = &CTAttachCompute( $proj, $flav, $anydef ) ;
if ( $spec eq "" ) {
&CTAttachWriteNullScript( $tmpname ) ;
print $tmpname . "\n" ;
} else {
&CTAttachWriteScript( $tmpname ) ;
print $tmpname . "\n" ;
}
} else {
&CTAttachWriteNullScript( $tmpname ) ;
print $tmpname . "\n" ;
}
}