-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support CMake target & SPM library prefixes/suffixes
- Loading branch information
1 parent
025ea5d
commit 5c3e434
Showing
9 changed files
with
177 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Generator/Sources/CodeWriters/CMake/CMakeCommandArgument.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
public struct CMakeCommandArgument: ExpressibleByStringLiteral { | ||
public let value: String | ||
public let quoted: Bool | ||
|
||
public init(_ value: String, quoted: Bool) { | ||
self.value = value | ||
self.quoted = quoted | ||
} | ||
|
||
public init(autoquote value: String) { | ||
assert(!value.contains("${")) | ||
self.init(value, quoted: value.contains(" ") || value.contains(";")) | ||
} | ||
|
||
public init(stringLiteral value: String) { | ||
self.init(autoquote: value) | ||
} | ||
|
||
public func write(to stream: inout some TextOutputStream) { | ||
if quoted { stream.write("\"") } | ||
stream.write(value.replacingOccurrences(of: "\\", with: "\\\\")) | ||
if quoted { stream.write("\"") } | ||
} | ||
|
||
public static func autoquote(_ value: String) -> CMakeCommandArgument { | ||
Self(autoquote: value) | ||
} | ||
|
||
public static func quoted(_ value: String) -> CMakeCommandArgument { | ||
Self(value, quoted: true) | ||
} | ||
|
||
public static func unquoted(_ value: String) -> CMakeCommandArgument { | ||
Self(value, quoted: false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
struct SPMOptions { | ||
public let libraryPrefix: String | ||
public let librarySuffix: String | ||
public let dynamicLibraries: Bool | ||
public let excludeCMakeLists: Bool | ||
|
||
public func getLibraryName(module: String) -> String { | ||
"\(libraryPrefix)\(module)\(librarySuffix)" | ||
} | ||
} | ||
|
||
struct CMakeOptions { | ||
public let targetPrefix: String | ||
public let targetSuffix: String | ||
public let dynamicLibraries: Bool | ||
|
||
public func getTargetName(module: String) -> String { | ||
"\(targetPrefix)\(module)\(targetSuffix)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.