message: cxx: fix/update PatchAndInstall
  This version is wrong (it uses `os.path.filename` which does not
  exist).  Fs has (and uses) its own version, which is more general and
  used in several places.  So replace the former with the latter.
diff: @@ -2113,13 +2113,53 @@ class CompilationDatabase(drake.Node):
  super().__init__(path)
  CompilationDatabase.Builder(self)
  +
  class PatchAndInstall(drake.Install):
  +
  def execute(self):
  - if not super.execute():
  + if not super().execute():
  return False
  - output = subprocess.check_output(['otool', '-L', self.target.path()])
  - lines = output.decode('utf-8').strip().split('\n')
  - lines = [x.split(' ')[0] for x in lines if 'libstdc++' in x or 'libgcc_s.1' in x]
  - for l in lines:
  - self.cmd('Localize libstdc++ of %s' % self.target,
  - ['install_name_tool', '-change', l, '@rpath/%s' % (os.path.filename(l))], throw = True)
  + if os.path.islink(str(self.target.path())):
  + return True
  + if cxx_toolkit.os == drake.os.macos:
  + def set_lib_id(path):
  + subprocess.check_output([
  + 'install_name_tool',
  + '-id',
  + '@rpath/%s' % os.path.basename(str(path)),
  + str(path)])
  +
  + def get_deps_fix_rpaths(path):
  + os.chmod(str(path), 0o755)
  + if 'dylib' in str(path):
  + set_lib_id(path)
  + if cxx_toolkit.kind is drake.cxx.GccToolkit.Kind.gcc:
  + otool_out = subprocess.check_output(['otool', '-L', str(path)])
  + otool_lines = otool_out.decode('utf-8').strip().split('\n')
  + otool_lines = [
  + x.replace('\t', '').split(' ')[0]
  + for x in otool_lines[1:] if 'libstdc++' in x or 'libgcc_s' in x
  + ]
  + for l in otool_lines:
  + drake.command([
  + 'install_name_tool', '-change',
  + l, '@rpath/%s' % (os.path.basename(l)), str(path)
  + ])
  + dep_dir = os.path.normpath(
  + os.path.join(os.path.dirname(str(path)), '..', 'lib'))
  + dep_file = \
  + os.path.normpath(os.path.join(dep_dir, os.path.basename(l)))
  + if not os.path.exists(dep_dir):
  + os.makedirs(dep_dir)
  + if not os.path.exists(dep_file):
  + import shutil
  + shutil.copy(l, dep_dir)
  + get_deps_fix_rpaths(drake.Path(dep_file))
  + os.chmod(dep_file, 0o755)
  + set_lib_id(dep_file)
  + os.chmod(dep_file, 0o555)
  + os.chmod(str(path), 0o555)
  +
  + path = self.target.path()
  + get_deps_fix_rpaths(path)
  + return True
  