1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

build: Remove workaround for missing os.path.relpath in Python < 2.6

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Mulder <dmulder@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Andrew Bartlett 2019-11-04 17:07:44 +13:00 committed by Andreas Schneider
parent dc5788056b
commit 92ce387ed0
13 changed files with 26 additions and 46 deletions

View File

@ -3,7 +3,7 @@
import os
from waflib import Build
from samba_utils import os_path_relpath, TO_LIST
from samba_utils import TO_LIST
from samba_autoconf import library_flags
def SAMBA3_IS_STATIC_MODULE(bld, module):
@ -31,7 +31,7 @@ def s3_fix_kwargs(bld, kwargs):
'''fix the build arguments for s3 build rules to include the
necessary includes, subdir and cflags options '''
s3dir = os.path.join(bld.env.srcdir, 'source3')
s3reldir = os_path_relpath(s3dir, bld.path.abspath())
s3reldir = os.path.relpath(s3dir, bld.path.abspath())
# the extra_includes list is relative to the source3 directory
extra_includes = [ '.', 'include', 'lib' ]

View File

@ -2,12 +2,12 @@
import os
from waflib import Build
from samba_utils import SET_TARGET_TYPE, os_path_relpath
from samba_utils import SET_TARGET_TYPE
def SAMBA_AUTOPROTO(bld, header, source):
'''rule for samba prototype generation'''
bld.SET_BUILD_GROUP('prototypes')
relpath = os_path_relpath(bld.path.abspath(), bld.srcnode.abspath())
relpath = os.path.relpath(bld.path.abspath(), bld.srcnode.abspath())
name = os.path.join(relpath, header)
SET_TARGET_TYPE(bld, name, 'PROTOTYPE')
t = bld(

View File

@ -8,7 +8,7 @@ from waflib.Configure import conf
from waflib import ConfigSet
from samba_bundled import BUILTIN_LIBRARY
from samba_utils import LOCAL_CACHE, TO_LIST, get_tgt_list, unique_list, os_path_relpath
from samba_utils import LOCAL_CACHE, TO_LIST, get_tgt_list, unique_list
from samba_autoconf import library_flags
@conf
@ -172,7 +172,7 @@ def build_includes(self):
mypath = self.path.abspath(bld.env)
for inc in inc_abs:
relpath = os_path_relpath(inc, mypath)
relpath = os.path.relpath(inc, mypath)
includes.append(relpath)
if getattr(self, 'local_include', True) and not getattr(self, 'local_include_first', True):
@ -188,7 +188,7 @@ def build_includes(self):
includes_top.append(i)
continue
absinc = os.path.join(self.path.abspath(), i)
relinc = os_path_relpath(absinc, self.bld.srcnode.abspath())
relinc = os.path.relpath(absinc, self.bld.srcnode.abspath())
includes_top.append('#' + relinc)
self.includes = unique_list(includes_top)
@ -267,7 +267,7 @@ def check_duplicate_sources(bld, tgt_list):
for t in tgt_list:
source_list = TO_LIST(getattr(t, 'source', ''))
tpath = os.path.normpath(os_path_relpath(t.path.abspath(bld.env), t.env.BUILD_DIRECTORY + '/default'))
tpath = os.path.normpath(os.path.relpath(t.path.abspath(bld.env), t.env.BUILD_DIRECTORY + '/default'))
obj_sources = set()
for s in source_list:
if not isinstance(s, str):

View File

@ -4,7 +4,7 @@
import os, sys, tarfile
from waflib import Utils, Scripting, Logs, Options
from waflib.Configure import conf
from samba_utils import os_path_relpath, get_string
from samba_utils import get_string
from waflib import Context
dist_dirs = None
@ -111,7 +111,7 @@ def vcs_dir_contents(path):
while repo != "/":
if os.path.isdir(os.path.join(repo, ".git")):
ls_files_cmd = [ 'git', 'ls-files', '--full-name',
os_path_relpath(path, repo) ]
os.path.relpath(path, repo) ]
cwd = None
env = dict(os.environ)
env["GIT_DIR"] = os.path.join(repo, ".git")

View File

@ -2,7 +2,7 @@
import os, re, sys, fnmatch
from waflib import Build, Logs, Utils, Errors
from samba_utils import TO_LIST, os_path_relpath
from samba_utils import TO_LIST
def header_install_path(header, header_path):
@ -42,7 +42,7 @@ def create_public_header(task):
if os.path.exists(tgt):
os.unlink(tgt)
relsrc = os_path_relpath(src, task.env.TOPDIR)
relsrc = os.path.relpath(src, task.env.TOPDIR)
infile = open(src, mode='r')
outfile = open(tgt, mode='w')
@ -149,8 +149,8 @@ def PUBLIC_HEADERS(bld, public_headers, header_path=None, public_headers_install
h_name = h
inst_name = os.path.basename(h)
curdir = bld.path.abspath()
relpath1 = os_path_relpath(bld.srcnode.abspath(), curdir)
relpath2 = os_path_relpath(curdir, bld.srcnode.abspath())
relpath1 = os.path.relpath(bld.srcnode.abspath(), curdir)
relpath2 = os.path.relpath(curdir, bld.srcnode.abspath())
targetdir = os.path.normpath(os.path.join(relpath1, bld.env.build_public_headers, inst_path))
if not os.path.exists(os.path.join(curdir, targetdir)):
raise Errors.WafError("missing source directory %s for public header %s" % (targetdir, inst_name))

View File

@ -205,24 +205,6 @@ def process_depends_on(self):
self.includes += " " + y.more_includes
os_path_relpath = getattr(os.path, 'relpath', None)
if os_path_relpath is None:
# Python < 2.6 does not have os.path.relpath, provide a replacement
# (imported from Python2.6.5~rc2)
def os_path_relpath(path, start):
"""Return a relative version of a path"""
start_list = os.path.abspath(start).split("/")
path_list = os.path.abspath(path).split("/")
# Work out how much of the filepath is shared by start and path.
i = len(os.path.commonprefix([start_list, path_list]))
rel_list = ['..'] * (len(start_list)-i) + path_list[i:]
if not rel_list:
return start
return os.path.join(*rel_list)
def unique_list(seq):
'''return a uniquified list in the same order as the existing list'''
seen = {}
@ -286,7 +268,7 @@ def recursive_dirlist(dir, relbase, pattern=None):
else:
if pattern and not fnmatch.fnmatch(f, pattern):
continue
ret.append(os_path_relpath(f2, relbase))
ret.append(os.path.relpath(f2, relbase))
return ret
@ -476,7 +458,7 @@ def RECURSE(ctx, directory):
# already done it
return
visited_dirs.add(key)
relpath = os_path_relpath(abspath, ctx.path.abspath())
relpath = os.path.relpath(abspath, ctx.path.abspath())
if ctxclass in ['tmp', 'OptionsContext', 'ConfigurationContext', 'BuildContext']:
return ctx.recurse(relpath)
if 'waflib.extras.compat15' in sys.modules:

View File

@ -3,7 +3,7 @@
import os, datetime, fnmatch
from waflib import Scripting, Utils, Options, Logs, Errors
from waflib import ConfigSet, Context
from samba_utils import LOCAL_CACHE, os_path_relpath
from samba_utils import LOCAL_CACHE
def run_task(t, k):
'''run a single build task'''
@ -24,7 +24,7 @@ def run_named_build_task(cmd):
# cope with builds of bin/*/*
if os.path.islink(cmd):
cmd = os_path_relpath(os.readlink(cmd), os.getcwd())
cmd = os.path.relpath(os.readlink(cmd), os.getcwd())
if cmd[0:12] == "bin/default/":
cmd = cmd[12:]

View File

@ -4,7 +4,7 @@
import os, re, subprocess
from waflib import Utils, Build, Options, Logs, Errors
from waflib.Logs import debug
from samba_utils import TO_LIST, LOCAL_CACHE, get_tgt_list, os_path_relpath
from samba_utils import TO_LIST, LOCAL_CACHE, get_tgt_list
# these are the data structures used in symbols.py:
#
@ -617,7 +617,7 @@ def symbols_dupcheck(task, fail_on_error=False):
build_library_dict(bld, tgt_list)
for t in tgt_list:
if t.samba_type == 'BINARY':
binname = os_path_relpath(t.link_task.outputs[0].abspath(bld.env), os.getcwd())
binname = os.path.relpath(t.link_task.outputs[0].abspath(bld.env), os.getcwd())
symbols_dupcheck_binary(bld, binname, fail_on_error)

View File

@ -858,7 +858,7 @@ def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
if trim_path:
files2 = []
for f in files:
files2.append(os_path_relpath(f, trim_path))
files2.append(os.path.relpath(f, trim_path))
files = files2
if exclude:

View File

@ -5,7 +5,6 @@
import os, sys
from waflib import Configure, Logs, Options, Utils, Context, Errors
import wafsamba
from samba_utils import os_path_relpath
from samba_utils import symlink
from optparse import SUPPRESS_HELP
@ -612,7 +611,7 @@ def build(bld):
# give a more useful message if the source directory has moved
curdir = bld.path.abspath()
srcdir = bld.srcnode.abspath()
relpath = os_path_relpath(curdir, srcdir)
relpath = os.path.relpath(curdir, srcdir)
if relpath.find('../') != -1:
Logs.error('bld.path %s is not a child of %s' % (curdir, srcdir))
raise Errors.WafError('''The top source directory has moved. Please run distclean and reconfigure''')

View File

@ -769,7 +769,7 @@ def build(bld):
continue
mode = os.lstat(fl).st_mode & MODE_777
if arg['trim_path']:
fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
arg['file_list'].append([fl, mode])
def SUBDIR_MODE(path, trim_path=None):

View File

@ -5,7 +5,7 @@ import os
import optparse
import textwrap
from waflib import Logs, Errors, Options, Build, Context
from samba_utils import EXPAND_VARIABLES, os_path_relpath
from samba_utils import EXPAND_VARIABLES
class SambaIndentedHelpFormatter (optparse.IndentedHelpFormatter):
"""Format help with indented section bodies.
@ -425,7 +425,7 @@ def build(bld):
bld.SAMBA_SUBSYSTEM('DYNCONFIG',
'dynconfig.c',
deps='replace',
public_headers=os_path_relpath(os.path.join(Context.launch_dir, version_header), bld.path.abspath()),
public_headers=os.path.relpath(os.path.join(Context.launch_dir, version_header), bld.path.abspath()),
header_path='samba',
cflags=cflags)

View File

@ -1,5 +1,4 @@
import os
from samba_utils import os_path_relpath
def build_test_headers(task):
'''symlink a header in the build tree'''
@ -13,7 +12,7 @@ def build_test_headers(task):
f.write('#include "%s"\n' % os.path.normpath(h))
f.close()
relpath1 = os_path_relpath(bld.srcnode.abspath(), bld.path.abspath())
relpath1 = os.path.relpath(bld.srcnode.abspath(), bld.path.abspath())
public_headers = []
for h in bld.env.public_headers_list:
public_headers.append(os.path.join(relpath1, bld.env.build_public_headers, h))