2018-10-04 20:20:53 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
import sys, os
|
|
|
|
|
|
|
|
|
|
import vars_init
|
2018-10-30 23:23:04 -04:00
|
|
|
vars_init.init_no_state()
|
2018-10-04 20:20:53 -04:00
|
|
|
|
2018-10-30 23:23:04 -04:00
|
|
|
import paths
|
2018-10-04 20:20:53 -04:00
|
|
|
from log import err
|
|
|
|
|
|
|
|
|
|
if len(sys.argv[1:]) != 1:
|
|
|
|
|
err('%s: exactly one argument expected.\n' % sys.argv[0])
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
want = sys.argv[1]
|
2018-11-03 03:36:13 -04:00
|
|
|
if not want:
|
|
|
|
|
err('cannot build the empty target ("").\n')
|
|
|
|
|
sys.exit(204)
|
|
|
|
|
|
2018-10-30 23:21:37 -04:00
|
|
|
abswant = os.path.abspath(want)
|
2018-10-30 23:23:04 -04:00
|
|
|
for dodir,dofile,basedir,basename,ext in paths.possible_do_files(abswant):
|
2018-10-04 20:20:53 -04:00
|
|
|
dopath = os.path.join('/', dodir, dofile)
|
|
|
|
|
relpath = os.path.relpath(dopath, '.')
|
|
|
|
|
exists = os.path.exists(dopath)
|
|
|
|
|
assert('\n' not in relpath)
|
2018-10-30 23:21:37 -04:00
|
|
|
print relpath
|
2018-10-04 20:20:53 -04:00
|
|
|
if exists:
|
2018-10-30 23:21:37 -04:00
|
|
|
sys.exit(0)
|
2018-10-04 20:20:53 -04:00
|
|
|
sys.exit(1) # no appropriate dofile found
|