Skip to content

Commit 05ce1d3

Browse files
committed
build: add a CMake based build
This is a first approximation of a CMake based build for this repository. The intent here is to localize the build rules for the repository to allow it to be consumed during the build of the toolchain. This allows the source list to be maintained in the repository as the source of truth rather than be explicitly listed in the swift repository. For general purpose development, the SPM based build is recommended. Unless there is a specific need for the tests to be included, testing should be done via the SPM build. This change is sufficient to build the content though does not perform the install or export steps which will be required to consume the results in the Swift build. Example invocation: ~~~ cmake -B S:\b\16 ^ -D CMAKE_BUILD_TYPE=Release ^ -D ArgumentParser_DIR=S:\b\10\cmake\modules ^ -G Ninja ^ -S S:\SourceCache\swift-experimental-string-processing cmake --build S:\b\16 ~~~
1 parent ba702f0 commit 05ce1d3

File tree

7 files changed

+152
-0
lines changed

7 files changed

+152
-0
lines changed

CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
cmake_minimum_required(VERSION 3.18)
3+
project(SwiftExperimentalStringProcessing
4+
LANGUAGES Swift)
5+
6+
if(CMAKE_SYSTEM_NAME STREQUAL Windows OR CMAKE_SYSTEM_NAME STREQUAL Darwin)
7+
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
8+
endif()
9+
10+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
11+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
12+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
13+
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
14+
15+
find_package(ArgumentParser CONFIG)
16+
17+
add_subdirectory(Sources)

Sources/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
add_subdirectory(_Unicode)
3+
add_subdirectory(_MatchingEngine)
4+
add_subdirectory(_StringProcessing)
5+
add_subdirectory(Prototypes)
6+
add_subdirectory(VariadicsGenerator)

Sources/Prototypes/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
add_library(Prototypes
3+
Combinators/Combinators.swift
4+
PEG/PEG.swift
5+
PEG/PEGCode.swift
6+
PEG/PEGCompile.swift
7+
PEG/PEGCore.swift
8+
PEG/PEGInterpreter.swift
9+
PEG/PEGTranspile.swift
10+
PEG/PEGVM.swift
11+
PEG/PEGVMExecute.swift
12+
PEG/Printing.swift
13+
PTCaRet/Interpreter.swift
14+
PTCaRet/PTCaRet.swift
15+
TourOfTypes/CharacterClass.swift
16+
TourOfTypes/Literal.swift)
17+
target_link_libraries(Prototypes PUBLIC
18+
_MatchingEngine)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
add_executable(VariadicsGenerator
3+
VariadicsGenerator.swift)
4+
target_compile_options(VariadicsGenerator PRIVATE
5+
-parse-as-library)
6+
target_link_libraries(VariadicsGenerator PUBLIC
7+
ArgumentParser)
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
add_library(_MatchingEngine
3+
Engine/Backtracking.swift
4+
Engine/Builder.swift
5+
Engine/Capture.swift
6+
Engine/Consume.swift
7+
Engine/Engine.swift
8+
Engine/InstPayload.swift
9+
Engine/Instruction.swift
10+
Engine/Processor.swift
11+
Engine/Program.swift
12+
Engine/Registers.swift
13+
Engine/Tracing.swift
14+
Regex/AST/AST.swift
15+
Regex/AST/ASTAction.swift
16+
Regex/AST/ASTProtocols.swift
17+
Regex/AST/Atom.swift
18+
Regex/AST/Conditional.swift
19+
Regex/AST/CustomCharClass.swift
20+
Regex/AST/Group.swift
21+
Regex/AST/MatchingOptions.swift
22+
Regex/AST/Quantification.swift
23+
Regex/Parse/CaptureStructure.swift
24+
Regex/Parse/CharacterPropertyClassification.swift
25+
Regex/Parse/Diagnostics.swift
26+
Regex/Parse/LexicalAnalysis.swift
27+
Regex/Parse/Mocking.swift
28+
Regex/Parse/Parse.swift
29+
Regex/Parse/Source.swift
30+
Regex/Parse/SourceLocation.swift
31+
Regex/Parse/SyntaxOptions.swift
32+
Regex/Printing/DumpAST.swift
33+
Regex/Printing/PrettyPrinter.swift
34+
Regex/Printing/PrintAsCanonical.swift
35+
Regex/Printing/PrintAsPattern.swift
36+
Regex/Printing/RenderRanges.swift
37+
Utility/AllScalars.swift
38+
Utility/Formatting.swift
39+
Utility/Misc.swift
40+
Utility/MissingUnicode.swift
41+
Utility/Protocols.swift
42+
Utility/TypeConstruction.swift
43+
Utility/TypedIndex.swift
44+
Utility/TypedInt.swift)
45+
target_compile_options(_MatchingEngine PRIVATE
46+
-enable-library-evolution)
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
add_library(_StringProcessing
3+
Algorithms/Algorithms/Contains.swift
4+
Algorithms/Algorithms/FirstRange.swift
5+
Algorithms/Algorithms/Ranges.swift
6+
Algorithms/Algorithms/Replace.swift
7+
Algorithms/Algorithms/Split.swift
8+
Algorithms/Algorithms/StartsWith.swift
9+
Algorithms/Algorithms/Trim.swift
10+
Algorithms/Consumers/CollectionConsumer.swift
11+
Algorithms/Consumers/FixedPatternConsumer.swift
12+
Algorithms/Consumers/ManyConsumer.swift
13+
Algorithms/Consumers/PredicateConsumer.swift
14+
Algorithms/Consumers/RegexConsumer.swift
15+
Algorithms/Searchers/CollectionSearcher.swift
16+
Algorithms/Searchers/ConsumerSearcher.swift
17+
Algorithms/Searchers/NaivePatternSearcher.swift
18+
Algorithms/Searchers/PatternOrEmpty.swift
19+
Algorithms/Searchers/PredicateSearcher.swift
20+
Algorithms/Searchers/TwoWaySearcher.swift
21+
Algorithms/Searchers/ZSearcher.swift
22+
ASTBuilder.swift
23+
Capture.swift
24+
CharacterClass.swift
25+
Compiler.swift
26+
ConsumerInterface.swift
27+
Executor.swift
28+
Legacy/HareVM.swift
29+
Legacy/LegacyCompile.swift
30+
Legacy/RECode.swift
31+
Legacy/TortoiseVM.swift
32+
Legacy/VirtualMachine.swift
33+
RegexDSL/Builder.swift
34+
RegexDSL/Concatenation.swift
35+
RegexDSL/Core.swift
36+
RegexDSL/DSL.swift
37+
RegexDSL/DSLCapture.swift
38+
RegexDSL/DynamicCaptures.swift)
39+
target_compile_options(_StringProcessing PRIVATE
40+
-enable-library-evolution)
41+
target_link_libraries(_StringProcessing PUBLIC
42+
_MatchingEngine)

Sources/_Unicode/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
add_library(_Unicode
3+
CaseConversion.swift
4+
CharacterProps.swift
5+
Comparison.swift
6+
Decoding.swift
7+
Encodings.swift
8+
Formatting.swift
9+
Graphemes.swift
10+
NecessaryEvils.swift
11+
Normaliation.swift
12+
NumberParsing.swift
13+
ScalarProps.swift
14+
Transcoding.swift
15+
UCD.swift
16+
Validation.swift)

0 commit comments

Comments
 (0)