@@ -144,73 +144,24 @@ export class Runfiles {
144
144
const repoMappings : RepoMappings = Object . create ( null ) ;
145
145
const mappings = fs . readFileSync ( repoMappingPath , { encoding : "utf-8" } ) ;
146
146
147
+ // Each line of the repository mapping manifest has the form:
148
+ // canonical name of source repo,apparent name of target repo,target repo runfiles directory
149
+ // https://cs.opensource.google/bazel/bazel/+/1b073ac0a719a09c9b2d1a52680517ab22dc971e:src/main/java/com/google/devtools/build/lib/analysis/RepoMappingManifestAction.java;l=117
147
150
for ( const line of mappings . split ( "\n" ) ) {
148
151
if ( ! line ) continue ;
149
152
150
- try {
151
- const parsed = this . parseBzlmodRepoMappingLine ( line ) || this . parseLegacyRepoMappingLine ( line ) ;
152
-
153
- if ( parsed ) {
154
- const { sourceRepo, targetRepoApparentName, targetRepoDirectory } = parsed ;
155
- ( repoMappings [ sourceRepo ] ??= Object . create ( null ) ) [ targetRepoApparentName ] = targetRepoDirectory ;
156
- }
157
- } catch ( error ) {
158
- console . warn ( `Failed to parse repo mapping line: "${ line } "` ) ;
159
- }
160
- }
161
- return repoMappings ;
162
- }
153
+ const [ sourceRepo , targetRepoApparentName , targetRepoDirectory ] = line . split ( "," ) ;
163
154
164
- private parseBzlmodRepoMappingLine ( line : string ) : {
165
- sourceRepo : string ;
166
- targetRepoApparentName : string ;
167
- targetRepoDirectory : string ;
168
- } | null {
169
- const trimmedLine = line . trim ( ) ;
170
- if ( ! trimmedLine || trimmedLine . startsWith ( '#' ) ) {
171
- return null ;
155
+ ( repoMappings [ sourceRepo ] ??= Object . create ( null ) ) [ targetRepoApparentName ] = targetRepoDirectory ;
172
156
}
173
-
174
- const parts = trimmedLine . split ( ',' ) ;
175
- if ( parts . length < 3 ) {
176
- return null ;
177
- }
178
-
179
- const [ sourceRepo , targetRepoApparentName , targetRepoDirectory ] = parts ;
180
157
181
- if ( ! sourceRepo . trim ( ) || ! targetRepoApparentName . trim ( ) || ! targetRepoDirectory . trim ( ) ) {
182
- return null ;
158
+ // Ensure empty source repository mapping exists
159
+ if ( ! repoMappings [ "" ] ) {
160
+ repoMappings [ "" ] = Object . create ( null ) ;
161
+ repoMappings [ "" ] [ "__main__" ] = "__main__" ;
183
162
}
184
-
185
- return {
186
- sourceRepo : sourceRepo . trim ( ) ,
187
- targetRepoApparentName : targetRepoApparentName . trim ( ) ,
188
- targetRepoDirectory : targetRepoDirectory . trim ( )
189
- } ;
190
- }
191
-
192
- private parseLegacyRepoMappingLine ( line : string ) : {
193
- sourceRepo : string ;
194
- targetRepoApparentName : string ;
195
- targetRepoDirectory : string ;
196
- } | null {
197
- const trimmedLine = line . trim ( ) ;
198
- if ( ! trimmedLine ) {
199
- return null ;
200
- }
201
-
202
- const parts = trimmedLine . split ( ',' ) ;
203
- if ( parts . length !== 3 ) {
204
- return null ;
205
- }
206
-
207
- const [ sourceRepo , targetRepoApparentName , targetRepoDirectory ] = parts ;
208
-
209
- return {
210
- sourceRepo,
211
- targetRepoApparentName,
212
- targetRepoDirectory
213
- } ;
163
+
164
+ return repoMappings ;
214
165
}
215
166
216
167
/** Resolves the given module path. */
0 commit comments