2016-02-18 18:50:02 +00:00
|
|
|
""" This module represents an abstraction of an lldb target / host platform. """
|
|
|
|
|
|
|
|
# System modules
|
|
|
|
import itertools
|
|
|
|
|
|
|
|
# LLDB modules
|
|
|
|
import lldb
|
|
|
|
|
2023-05-25 08:48:57 -07:00
|
|
|
(
|
2020-11-05 15:32:03 +01:00
|
|
|
windows,
|
|
|
|
linux,
|
|
|
|
macosx,
|
|
|
|
darwin,
|
|
|
|
ios,
|
|
|
|
tvos,
|
|
|
|
watchos,
|
|
|
|
bridgeos,
|
|
|
|
darwin_all,
|
|
|
|
darwin_embedded,
|
|
|
|
darwin_simulator,
|
|
|
|
freebsd,
|
|
|
|
netbsd,
|
|
|
|
bsd_all,
|
|
|
|
android,
|
|
|
|
) = range(15)
|
|
|
|
|
|
|
|
__darwin_embedded = ["ios", "tvos", "watchos", "bridgeos"]
|
|
|
|
__darwin_simulators = ["iphonesimulator", "watchsimulator", "appletvsimulator"]
|
2016-02-18 18:50:02 +00:00
|
|
|
|
|
|
|
__name_lookup = {
|
|
|
|
windows: ["windows"],
|
|
|
|
linux: ["linux"],
|
|
|
|
macosx: ["macosx"],
|
|
|
|
darwin: ["darwin"],
|
2020-11-05 15:32:03 +01:00
|
|
|
ios: ["ios", "iphonesimulator"],
|
|
|
|
tvos: ["tvos", "appletvsimulator"],
|
|
|
|
watchos: ["watchos", "watchsimulator"],
|
2017-09-25 18:19:39 +00:00
|
|
|
bridgeos: ["bridgeos"],
|
2020-11-05 15:32:03 +01:00
|
|
|
darwin_all: ["macosx", "darwin"] + __darwin_embedded + __darwin_simulators,
|
|
|
|
darwin_embedded: __darwin_embedded + __darwin_simulators,
|
|
|
|
darwin_simulator: __darwin_simulators,
|
2016-02-18 18:50:02 +00:00
|
|
|
freebsd: ["freebsd"],
|
|
|
|
netbsd: ["netbsd"],
|
|
|
|
bsd_all: ["freebsd", "netbsd"],
|
|
|
|
android: ["android"],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def translate(values):
|
2022-08-05 13:35:20 -06:00
|
|
|
if isinstance(values, int):
|
2016-02-18 18:50:02 +00:00
|
|
|
# This is a value from the platform enumeration, translate it.
|
|
|
|
return __name_lookup[values]
|
2022-08-05 13:35:20 -06:00
|
|
|
elif isinstance(values, str):
|
2016-02-18 18:50:02 +00:00
|
|
|
# This is a raw string, return it.
|
|
|
|
return [values]
|
|
|
|
elif hasattr(values, "__iter__"):
|
|
|
|
# This is an iterable, convert each item.
|
|
|
|
result = [translate(x) for x in values]
|
|
|
|
result = list(itertools.chain(*result))
|
|
|
|
return result
|
|
|
|
return values
|