13from SCons.Script
import GetOption
14from SCons.Builder
import Builder
17if not hasattr(os.path,
'relpath'):
19 def relpath(path, start=os.path.curdir):
20 """Return a relative version of a path"""
23 raise ValueError(
'no path specified')
25 start_list = os.path.abspath(start).split(os.path.sep)
26 path_list = os.path.abspath(path).split(os.path.sep)
29 i = len(os.path.commonprefix([start_list, path_list]))
31 rel_list = [os.path.pardir] * (len(start_list) - i) + path_list[i:]
34 return os.path.join(*rel_list)
36 os.path.relpath = relpath
39def create_symlink(target, source, env):
40 """Create a symbolic link from source to target"""
42 source = os.path.relpath(source, os.path.dirname(target))
44 os.symlink(source, target)
47 if e.errno == errno.EEXIST:
49 os.symlink(source, target)
55copy_file = Builder(action=
'cp -pf $SOURCE $TARGET')
56copy_file.action.cmdstr =
'${COPYCOMSTR}'
60 if not GetOption(
'no-symlink'):
61 env[
'INSTALL'] = create_symlink
62 env[
'BUILDERS'][
'Copy'] = copy_file