File: gn.vim

package info (click to toggle)
generate-ninja 0.0~git20250917.1a7c151-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,640 kB
  • sloc: cpp: 87,856; python: 2,121; sh: 205; objc: 159; lisp: 130; makefile: 23; xml: 7
file content (26 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (18)
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
" Copyright 2017 The Chromium Authors. All rights reserved.
" Use of this source code is governed by a BSD-style license that can be
" found in the LICENSE file.

function! gn#TranslateToBuildFile(name) abort
  " Strip '//' prefix
  let l:new_path = substitute(a:name, '\v^//', '', '')

  " Strip the build target name (necessary if 'isfname' contains ':')
  let l:new_path = substitute(l:new_path, '\v:.*$', '', '')

  " Append 'BUILD.gn', only if this is a directory and not a file
  " Prefer using maktaba if it's available, but fallback to an alternative
  if exists('*maktaba#path#Basename')
    " Check if the last part of the path appears to be a file
    if maktaba#path#Basename(l:new_path) !~# '\V.'
      let l:new_path = maktaba#path#Join([l:new_path, 'BUILD.gn'])
    endif
  else
    " This will break if 'autochdir' is enabled
    if isdirectory(l:new_path)
      let l:new_path = substitute(l:new_path, '\v/?$', '/BUILD.gn', '')
    endif
  endif
  return l:new_path
endfunction