14 from SCons.Script
import GetOption
15 from SCons.Builder
import Builder
18 if not hasattr(os.path,
'relpath'):
20 def relpath(path, start=os.path.curdir):
21 """Return a relative version of a path"""
24 raise ValueError(
'no path specified')
26 start_list = os.path.abspath(start).split(os.path.sep)
27 path_list = os.path.abspath(path).split(os.path.sep)
30 i = len(os.path.commonprefix([start_list, path_list]))
32 rel_list = [os.path.pardir] * (len(start_list) - i) + path_list[i:]
35 return os.path.join(*rel_list)
37 os.path.relpath = relpath
40 def create_symlink(target, source, env):
41 """Create a symbolic link from source to target"""
43 source = os.path.relpath(source, os.path.dirname(target))
45 os.symlink(source, target)
48 if e.errno == errno.EEXIST:
50 os.symlink(source, target)
56 copy_file = Builder(action=
'cp -pf $SOURCE $TARGET')
57 copy_file.action.cmdstr =
'${COPYCOMSTR}'
61 if not GetOption(
'no-symlink'):
62 env[
'INSTALL'] = create_symlink
63 env[
'BUILDERS'][
'Copy'] = copy_file