Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6bf652c

Browse files
committed
Merge pull request #320 from chinmaygarde/skyx_review
Load SkyX files on iOS where available
2 parents a342f44 + 1d44d3a commit 6bf652c

File tree

7 files changed

+164
-48
lines changed

7 files changed

+164
-48
lines changed

build/config/ios/ios_app.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,24 @@
1515
'plutil'
1616
]
1717

18+
def MakeDirectories(path):
19+
try:
20+
os.makedirs(path)
21+
except OSError as exc:
22+
if exc.errno == errno.EEXIST and os.path.isdir(path):
23+
return 0
24+
else:
25+
return -1
26+
27+
return 0
28+
1829

1930
def ProcessInfoPlist(args):
2031
output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist'))
32+
33+
if MakeDirectories(os.path.dirname(output_plist_file)) == -1:
34+
return -1
35+
2136
return subprocess.check_call( PLUTIL + [
2237
'-convert',
2338
'binary1',
@@ -42,18 +57,6 @@ def PerformCodeSigning(args):
4257
])
4358

4459

45-
def MakeDirectories(path):
46-
try:
47-
os.makedirs(path)
48-
except OSError as exc:
49-
if exc.errno == errno.EEXIST and os.path.isdir(path):
50-
return 0
51-
else:
52-
return -1
53-
54-
return 0
55-
56-
5760
def GenerateProjectStructure(args):
5861
application_path = os.path.join( args.dir, args.name + ".app" )
5962
return MakeDirectories( application_path )

build/config/ios/rules.gni

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ template("resource_copy_ios") {
5656
set_sources_assignment_filter([])
5757
sources = _resources
5858
outputs = [ "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}" ]
59+
60+
if (defined(invoker.deps)) {
61+
deps = invoker.deps
62+
}
5963
}
6064
}
6165

@@ -115,14 +119,14 @@ template("ios_app") {
115119
script = ios_app_script
116120

117121
sources = [ invoker.info_plist ]
118-
outputs = [ "$root_build_dir/Info.plist" ]
122+
outputs = [ "$root_build_dir/plist/$app_name/Info.plist" ]
119123

120124
args = [
121125
"plist",
122126
"-i",
123127
rebase_path(invoker.info_plist, root_build_dir),
124128
"-o",
125-
rebase_path(root_build_dir),
129+
rebase_path("$root_build_dir/plist/$app_name"),
126130
]
127131
}
128132

@@ -131,7 +135,7 @@ template("ios_app") {
131135
copy_gen_target_name = target_name + "_copy"
132136
copy(copy_gen_target_name) {
133137
sources = [
134-
"$root_build_dir/Info.plist",
138+
"$root_build_dir/plist/$app_name/Info.plist",
135139
"$root_build_dir/$app_name",
136140
]
137141

sky/build/sky_app.gni

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import("//sky/build/skyx.gni")
77
template("sky_app") {
88
skyx_target_name = target_name
99

10-
if (is_android) {
10+
if (is_android || is_ios) {
1111
skyx_target_name = "app"
1212
}
1313

@@ -89,5 +89,45 @@ template("sky_app") {
8989
deps += invoker.deps
9090
}
9191
}
92+
} else if (is_ios && defined(invoker.info_plist)) {
93+
import("//build/config/ios/rules.gni")
94+
import("//build/config/ios/ios_sdk.gni")
95+
96+
ios_app(target_name) {
97+
app_name = target_name + "_app"
98+
99+
code_signing_identity = ios_code_signing_identity
100+
101+
info_plist = invoker.info_plist
102+
103+
if (defined(invoker.entitlements_path)) {
104+
entitlements_path = invoker.entitlements_path
105+
} else {
106+
entitlements_path = "//sky/shell/ios/Entitlements.xcent"
107+
}
108+
109+
resources_gen_target_name = target_name + "_res"
110+
resource_copy_ios(resources_gen_target_name) {
111+
resources = [
112+
"//third_party/icu/android/icudtl.dat",
113+
"$target_gen_dir/app.skyx",
114+
]
115+
bundle_directory = "."
116+
deps = [ ":app" ]
117+
}
118+
119+
deps = [
120+
"//sky/shell:ios_scaffolding",
121+
":$resources_gen_target_name",
122+
":$skyx_target_name",
123+
]
124+
125+
if (defined(invoker.deps)) {
126+
deps += invoker.deps
127+
}
128+
}
129+
} else {
130+
group(target_name) {
131+
}
92132
}
93133
}

sky/packages/sky/example/game/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ sky_app("game") {
1414
deps = [
1515
"//sky/packages/sky/example/game/apk:resources",
1616
]
17+
} else if (is_ios) {
18+
info_plist = "ios/Info.plist"
1719
}
1820
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
8+
<!--
9+
This executable name must match the name of the app provided to the
10+
ios_app GN template
11+
-->
12+
<key>CFBundleExecutable</key>
13+
<string>game_app</string>
14+
15+
<key>CFBundleIdentifier</key>
16+
<string>org.domokit.sky.game</string>
17+
18+
<key>CFBundleInfoDictionaryVersion</key>
19+
<string>6.0</string>
20+
<key>CFBundleName</key>
21+
<string>game_app</string>
22+
<key>CFBundlePackageType</key>
23+
<string>APPL</string>
24+
<key>CFBundleShortVersionString</key>
25+
<string>1.0</string>
26+
<key>CFBundleVersion</key>
27+
<string>1</string>
28+
<key>LSRequiresIPhoneOS</key>
29+
<true/>
30+
<key>UIRequiredDeviceCapabilities</key>
31+
<array>
32+
<string>armv7</string>
33+
</array>
34+
<key>DTPlatformName</key>
35+
<string>iphonesimulator</string>
36+
<key>DTSDKName</key>
37+
<string>iphonesimulator8.3</string>
38+
<key>LSRequiresIPhoneOS</key>
39+
<true/>
40+
<key>MinimumOSVersion</key>
41+
<string>8.3</string>
42+
<key>UIDeviceFamily</key>
43+
<array>
44+
<integer>1</integer>
45+
<integer>2</integer>
46+
</array>
47+
<key>CFBundleSupportedPlatforms</key>
48+
<array>
49+
<string>iPhoneSimulator</string>
50+
</array>
51+
</dict>
52+
</plist>

sky/shell/BUILD.gn

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,36 @@ if (is_android) {
169169
import("//build/config/ios/rules.gni")
170170
import("//build/config/ios/ios_sdk.gni")
171171

172+
source_set("ios_scaffolding") {
173+
sources = [
174+
"ios/main_ios.mm",
175+
"ios/sky_app_delegate.h",
176+
"ios/sky_app_delegate.mm",
177+
"ios/sky_surface.h",
178+
"ios/sky_surface.mm",
179+
"ios/sky_view_controller.h",
180+
"ios/sky_view_controller.mm",
181+
]
182+
183+
set_sources_assignment_filter([])
184+
sources += [
185+
"mac/platform_mac.h",
186+
"mac/platform_mac.mm",
187+
"mac/platform_service_provider_mac.cc",
188+
"mac/platform_view_mac.h",
189+
"mac/platform_view_mac.mm",
190+
]
191+
set_sources_assignment_filter(sources_assignment_filter)
192+
193+
deps = common_deps + [
194+
":common",
195+
"//sky/services/ns_net",
196+
]
197+
}
198+
172199
ios_app("shell") {
173200
app_name = "SkyShell"
174201
info_plist = "ios/Info.plist"
175-
scaffolding_target = "ios_scaffolding"
176202
entitlements_path = "ios/Entitlements.xcent"
177203
code_signing_identity = ios_code_signing_identity
178204

@@ -181,35 +207,8 @@ if (is_android) {
181207
bundle_directory = "."
182208
}
183209

184-
source_set(scaffolding_target) {
185-
sources = [
186-
"ios/main_ios.mm",
187-
"ios/sky_app_delegate.h",
188-
"ios/sky_app_delegate.mm",
189-
"ios/sky_surface.h",
190-
"ios/sky_surface.mm",
191-
"ios/sky_view_controller.h",
192-
"ios/sky_view_controller.mm",
193-
]
194-
195-
set_sources_assignment_filter([])
196-
sources += [
197-
"mac/platform_mac.h",
198-
"mac/platform_mac.mm",
199-
"mac/platform_service_provider_mac.cc",
200-
"mac/platform_view_mac.h",
201-
"mac/platform_view_mac.mm",
202-
]
203-
set_sources_assignment_filter(sources_assignment_filter)
204-
205-
deps = common_deps + [
206-
":common",
207-
"//sky/services/ns_net",
208-
]
209-
}
210-
211210
deps = [
212-
":$scaffolding_target",
211+
":ios_scaffolding",
213212
":sky_resources",
214213
]
215214
}

sky/shell/ios/sky_surface.mm

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,32 @@ - (NSString*)skyInitialLoadURL {
131131
if (server && target) {
132132
return [NSString stringWithFormat:@"http://%@/%@", server, target];
133133
}
134-
135134
return [NSBundle mainBundle].infoDictionary[@"org.domokit.sky.load_url"];
136135
}
137136

137+
- (NSString*)skyInitialBundleURL {
138+
return [[NSBundle mainBundle] pathForResource:@"app" ofType:@"skyx"];
139+
}
140+
138141
- (void)connectToEngineAndLoad {
139142
auto interface_request = mojo::GetProxy(&_sky_engine);
140143
self.platformView->ConnectToEngine(interface_request.Pass());
141144

142-
mojo::String string(self.skyInitialLoadURL.UTF8String);
143-
_sky_engine->RunFromNetwork(string);
145+
NSString *endpoint = self.skyInitialBundleURL;
146+
if (endpoint.length > 0) {
147+
// Load from bundle
148+
mojo::String string(endpoint.UTF8String);
149+
_sky_engine->RunFromBundle(string);
150+
return;
151+
}
152+
153+
endpoint = self.skyInitialLoadURL;
154+
if (endpoint.length > 0) {
155+
// Load from URL
156+
mojo::String string(endpoint.UTF8String);
157+
_sky_engine->RunFromNetwork(string);
158+
return;
159+
}
144160
}
145161

146162
- (void)notifySurfaceDestruction {

0 commit comments

Comments
 (0)