Add configuration generator for tvOS and watchOS. (#625)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
diff --git a/generate-darwin-source-and-headers.py b/generate-darwin-source-and-headers.py
index 516464f..9921b0d 100755
--- a/generate-darwin-source-and-headers.py
+++ b/generate-darwin-source-and-headers.py
@@ -6,15 +6,14 @@ import collections
import glob
import argparse
+
class Platform(object):
pass
+
class simulator_platform(Platform):
- directory = 'darwin_ios'
- sdk = 'iphonesimulator'
arch = 'i386'
triple = 'i386-apple-darwin11'
- version_min = '-miphoneos-version-min=7.0'
prefix = "#ifdef __i386__\n\n"
suffix = "\n\n#endif"
@@ -23,11 +22,8 @@ class simulator_platform(Platform):
class simulator64_platform(Platform):
- directory = 'darwin_ios'
- sdk = 'iphonesimulator'
arch = 'x86_64'
triple = 'x86_64-apple-darwin13'
- version_min = '-miphoneos-version-min=7.0'
prefix = "#ifdef __x86_64__\n\n"
suffix = "\n\n#endif"
@@ -36,11 +32,8 @@ class simulator64_platform(Platform):
class device_platform(Platform):
- directory = 'darwin_ios'
- sdk = 'iphoneos'
arch = 'armv7'
triple = 'arm-apple-darwin11'
- version_min = '-miphoneos-version-min=7.0'
prefix = "#ifdef __arm__\n\n"
suffix = "\n\n#endif"
@@ -49,11 +42,8 @@ class device_platform(Platform):
class device64_platform(Platform):
- directory = 'darwin_ios'
- sdk = 'iphoneos'
arch = 'arm64'
triple = 'aarch64-apple-darwin13'
- version_min = '-miphoneos-version-min=7.0'
prefix = "#ifdef __arm64__\n\n"
suffix = "\n\n#endif"
@@ -61,6 +51,30 @@ class device64_platform(Platform):
src_files = ['sysv.S', 'ffi.c', 'internal.h']
+class ios_simulator_platform(simulator_platform):
+ directory = 'darwin_ios'
+ sdk = 'iphonesimulator'
+ version_min = '-miphoneos-version-min=7.0'
+
+
+class ios_simulator64_platform(simulator64_platform):
+ directory = 'darwin_ios'
+ sdk = 'iphonesimulator'
+ version_min = '-miphoneos-version-min=7.0'
+
+
+class ios_device_platform(device_platform):
+ directory = 'darwin_ios'
+ sdk = 'iphoneos'
+ version_min = '-miphoneos-version-min=7.0'
+
+
+class ios_device64_platform(device64_platform):
+ directory = 'darwin_ios'
+ sdk = 'iphoneos'
+ version_min = '-miphoneos-version-min=7.0'
+
+
class desktop32_platform(Platform):
directory = 'darwin_osx'
sdk = 'macosx'
@@ -87,6 +101,31 @@ class desktop64_platform(Platform):
src_files = ['unix64.S', 'ffi64.c', 'ffiw64.c', 'win64.S', 'internal64.h', 'asmnames.h']
+class tvos_simulator64_platform(simulator64_platform):
+ directory = 'darwin_tvos'
+ sdk = 'appletvsimulator'
+ version_min = '-mtvos-version-min=9.0'
+
+
+class tvos_device64_platform(device64_platform):
+ directory = 'darwin_tvos'
+ sdk = 'appletvos'
+ version_min = '-mtvos-version-min=9.0'
+
+
+class watchos_simulator_platform(simulator_platform):
+ directory = 'darwin_watchos'
+ sdk = 'watchsimulator'
+ version_min = '-mwatchos-version-min=4.0'
+
+
+class watchos_device_platform(device_platform):
+ directory = 'darwin_watchos'
+ sdk = 'watchos'
+ arch = 'armv7k'
+ version_min = '-mwatchos-version-min=4.0'
+
+
def mkdir_p(path):
try:
os.makedirs(path)
@@ -163,27 +202,44 @@ def build_target(platform, platform_headers):
platform_headers[filename].add((platform.prefix, platform.arch, platform.suffix))
-def generate_source_and_headers(generate_osx=True, generate_ios=True):
+def generate_source_and_headers(
+ generate_osx=True,
+ generate_ios=True,
+ generate_tvos=True,
+ generate_watchos=True,
+):
copy_files('src', 'darwin_common/src', pattern='*.c')
copy_files('include', 'darwin_common/include', pattern='*.h')
if generate_ios:
- copy_src_platform_files(simulator_platform)
- copy_src_platform_files(simulator64_platform)
- copy_src_platform_files(device_platform)
- copy_src_platform_files(device64_platform)
+ copy_src_platform_files(ios_simulator_platform)
+ copy_src_platform_files(ios_simulator64_platform)
+ copy_src_platform_files(ios_device_platform)
+ copy_src_platform_files(ios_device64_platform)
if generate_osx:
copy_src_platform_files(desktop64_platform)
+ if generate_tvos:
+ copy_src_platform_files(tvos_simulator64_platform)
+ copy_src_platform_files(tvos_device64_platform)
+ if generate_watchos:
+ copy_src_platform_files(watchos_simulator_platform)
+ copy_src_platform_files(watchos_device_platform)
platform_headers = collections.defaultdict(set)
if generate_ios:
- build_target(simulator_platform, platform_headers)
- build_target(simulator64_platform, platform_headers)
- build_target(device_platform, platform_headers)
- build_target(device64_platform, platform_headers)
+ build_target(ios_simulator_platform, platform_headers)
+ build_target(ios_simulator64_platform, platform_headers)
+ build_target(ios_device_platform, platform_headers)
+ build_target(ios_device64_platform, platform_headers)
if generate_osx:
build_target(desktop64_platform, platform_headers)
+ if generate_tvos:
+ build_target(tvos_simulator64_platform, platform_headers)
+ build_target(tvos_device64_platform, platform_headers)
+ if generate_watchos:
+ build_target(watchos_simulator_platform, platform_headers)
+ build_target(watchos_device_platform, platform_headers)
mkdir_p('darwin_common/include')
for header_name, tag_tuples in platform_headers.items():
@@ -196,6 +252,13 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--only-ios', action='store_true', default=False)
parser.add_argument('--only-osx', action='store_true', default=False)
+ parser.add_argument('--only-tvos', action='store_true', default=False)
+ parser.add_argument('--only-watchos', action='store_true', default=False)
args = parser.parse_args()
- generate_source_and_headers(generate_osx=not args.only_ios, generate_ios=not args.only_osx)
+ generate_source_and_headers(
+ generate_osx=not args.only_ios and not args.only_tvos and not args.only_watchos,
+ generate_ios=not args.only_osx and not args.only_tvos and not args.only_watchos,
+ generate_tvos=not args.only_ios and not args.only_osx and not args.only_watchos,
+ generate_watchos=not args.only_ios and not args.only_osx and not args.only_tvos,
+ )