|
| 1 | +# swift_build_support/products/stdlib_docs.py -------------------*- python -*- |
| 2 | +# |
| 3 | +# This source file is part of the Swift.org open source project |
| 4 | +# |
| 5 | +# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors |
| 6 | +# Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +# |
| 8 | +# See https://swift.org/LICENSE.txt for license information |
| 9 | +# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +# |
| 11 | +# ---------------------------------------------------------------------------- |
| 12 | + |
| 13 | +import os |
| 14 | + |
| 15 | +from . import product |
| 16 | +from . import swiftdocc |
| 17 | +from . import swiftdoccrender |
| 18 | +from .. import shell |
| 19 | + |
| 20 | + |
| 21 | +class StdlibDocs(product.Product): |
| 22 | + @classmethod |
| 23 | + def is_build_script_impl_product(cls): |
| 24 | + return False |
| 25 | + |
| 26 | + @classmethod |
| 27 | + def is_before_build_script_impl_product(cls): |
| 28 | + return False |
| 29 | + |
| 30 | + @classmethod |
| 31 | + def is_swiftpm_unified_build_product(cls): |
| 32 | + return False |
| 33 | + |
| 34 | + def should_build(self, host_target): |
| 35 | + return self.args.build_stdlib_docs |
| 36 | + |
| 37 | + def build(self, host_target): |
| 38 | + toolchain_path = self.install_toolchain_path(host_target) |
| 39 | + docc_path = os.path.join(toolchain_path, "bin", "docc") |
| 40 | + |
| 41 | + swift_build_dir = os.path.join( |
| 42 | + os.path.dirname(self.build_dir), |
| 43 | + f'swift-{host_target}' |
| 44 | + ) |
| 45 | + symbol_graph_dir = os.path.join(swift_build_dir, "lib", "symbol-graph") |
| 46 | + output_path = os.path.join(swift_build_dir, "Swift.doccarchive") |
| 47 | + |
| 48 | + docc_cmd = [ |
| 49 | + docc_path, |
| 50 | + "convert", # TODO: give people the option to preview instead |
| 51 | + "--additional-symbol-graph-dir", |
| 52 | + symbol_graph_dir, |
| 53 | + "--output-path", |
| 54 | + output_path, |
| 55 | + "--default-code-listing-language", |
| 56 | + "swift", |
| 57 | + "--fallback-display-name", |
| 58 | + "Swift", |
| 59 | + "--fallback-bundle-identifier", |
| 60 | + "org.swift.swift", |
| 61 | + ] |
| 62 | + |
| 63 | + shell.call(docc_cmd) |
| 64 | + |
| 65 | + def should_test(self, host_target): |
| 66 | + return False |
| 67 | + |
| 68 | + def should_install(self, host_target): |
| 69 | + return False |
| 70 | + |
| 71 | + @classmethod |
| 72 | + def get_dependencies(cls): |
| 73 | + """Return a list of products that this product depends upon""" |
| 74 | + return [ |
| 75 | + swiftdocc.SwiftDocC, |
| 76 | + swiftdoccrender.SwiftDocCRender |
| 77 | + ] |
0 commit comments