| 266 | b2.build.type.register('INSTALLED_SHARED_LIB', [], 'SHARED_LIB') |
| 267 | |
| 268 | class InstalledSharedLibGenerator(generators.Generator): |
| 269 | |
| 270 | def __init__(self): |
| 271 | generators.Generator.__init__(self, 'install-shared-lib', False, ['SHARED_LIB'], ['INSTALLED_SHARED_LIB']) |
| 272 | |
| 273 | def run(self, project, name, ps, source): |
| 274 | |
| 275 | source = source[0] |
| 276 | if ps.get('os') in ['NT', 'CYGWIN'] or ps.get('target-os') in ['windows', 'cygwin']: |
| 277 | copied = copy_file(project, None, source, ps) |
| 278 | return [get_manager().virtual_targets().register(copied)] |
| 279 | else: |
| 280 | a = source.action() |
| 281 | if not a: |
| 282 | # Non-derived file, just copy. |
| 283 | copied = copy_file(project, source, ps) |
| 284 | else: |
| 285 | |
| 286 | need_relink = ps.get('dll-path') != source.action().properties().get('dll-path') |
| 287 | |
| 288 | if need_relink: |
| 289 | # Rpath changed, need to relink. |
| 290 | copied = relink_file(project, source, ps) |
| 291 | else: |
| 292 | copied = copy_file(project, None, source, ps) |
| 293 | |
| 294 | result = [get_manager().virtual_targets().register(copied)] |
| 295 | # If the name is in the form NNN.XXX.YYY.ZZZ, where all 'X', 'Y' and |
| 296 | # 'Z' are numbers, we need to create NNN.XXX and NNN.XXX.YYY |
| 297 | # symbolic links. |
| 298 | m = re.match("(.*)\\.([0123456789]+)\\.([0123456789]+)\\.([0123456789]+)$", |
| 299 | copied.name()); |
| 300 | if m: |
| 301 | # Symlink without version at all is used to make |
| 302 | # -lsome_library work. |
| 303 | result.append(symlink(m.group(1), project, copied, ps)) |
| 304 | |
| 305 | # Symlinks of some libfoo.N and libfoo.N.M are used so that |
| 306 | # library can found at runtime, if libfoo.N.M.X has soname of |
| 307 | # libfoo.N. That happens when the library makes some binary |
| 308 | # compatibility guarantees. If not, it is possible to skip those |
| 309 | # symlinks. |
| 310 | if ps.get('install-no-version-symlinks') != ['on']: |
| 311 | |
| 312 | result.append(symlink(m.group(1) + '.' + m.group(2), project, copied, ps)) |
| 313 | result.append(symlink(m.group(1) + '.' + m.group(2) + '.' + m.group(3), |
| 314 | project, copied, ps)) |
| 315 | |
| 316 | return result |
| 317 | |
| 318 | generators.register(InstalledSharedLibGenerator()) |
| 319 | |