Skip to content

Commit 69bbf2b

Browse files
authored
sourcekitd: using gyb to generate UIDs instead of a def file. NFC (swiftlang#14549)
Inspired by the infrastructure of SwiftSyntax, a gyb file can facilitate cross-language sharing.
1 parent c67cd28 commit 69bbf2b

File tree

9 files changed

+467
-356
lines changed

9 files changed

+467
-356
lines changed

tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ endif()
1111

1212
# Add generated libSyntax headers to global dependencies.
1313
list(APPEND LLVM_COMMON_DEPENDS swift-syntax-generated-headers)
14+
list(APPEND LLVM_COMMON_DEPENDS generated_sourcekit_uids)
1415

1516
add_swift_tool_subdirectory(driver)
1617
add_swift_tool_subdirectory(sil-opt)

tools/SourceKit/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ endif()
8383
include_directories(BEFORE
8484
${SOURCEKIT_BINARY_DIR}/include
8585
${SOURCEKIT_SOURCE_DIR}/include
86+
${SOURCEKIT_BINARY_DIR}/tools/SourceKit/include
8687
)
8788

8889
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
@@ -150,5 +151,6 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
150151
set(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH TRUE)
151152
endif()
152153

154+
add_subdirectory(include)
153155
add_subdirectory(lib)
154156
add_subdirectory(tools)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(SourceKit)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(Core)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_gyb_target(generated_sourcekit_uids ProtocolUIDs.def.gyb)

tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def

Lines changed: 0 additions & 356 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
%{
2+
# -*- mode: Python -*-
3+
from gyb_sourcekit_support.UIDs import UID_KEYS
4+
from gyb_sourcekit_support.UIDs import UID_REQUESTS
5+
from gyb_sourcekit_support.UIDs import UID_KINDS
6+
# Ignore the following admonition; it applies to the resulting .def file only
7+
}%
8+
//// Automatically Generated From ProtocolUIDs.def.gyb.
9+
//// Do Not Edit Directly!
10+
//===---------------- ProtocolUIDs.def.gyb - SourceKitd UIDS -------------===//
11+
//
12+
// This source file is part of the Swift.org open source project
13+
//
14+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
15+
// Licensed under Apache License v2.0 with Runtime Library Exception
16+
//
17+
// See https://swift.org/LICENSE.txt for license information
18+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
19+
//
20+
//===----------------------------------------------------------------------===//
21+
22+
#ifndef KEY
23+
#define KEY(NAME, CONTENT)
24+
#endif
25+
26+
#ifndef REQUEST
27+
#define REQUEST(NAME, CONTENT)
28+
#endif
29+
30+
#ifndef KIND
31+
#define KIND(NAME, CONTENT)
32+
#endif
33+
34+
% for K in UID_KEYS:
35+
KEY(${K.internalName}, "${K.externalName}")
36+
% end
37+
38+
% for R in UID_REQUESTS:
39+
REQUEST(${R.internalName}, "${R.externalName}")
40+
% end
41+
42+
% for K in UID_KINDS:
43+
KIND(${K.internalName}, "${K.externalName}")
44+
% end
45+
46+
#undef KIND
47+
#undef REQUEST
48+
#undef KEY

utils/gyb_sourcekit_support/UIDs.py

Lines changed: 397 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# gyb_sourcekit_support/__init__.py - Helpers for building Sourcekit -*-
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2018 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+
# This file needs to be here in order for Python to treat the
14+
# utils/gyb_sourcekit_support/ directory as a module.
15+
#
16+
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)