mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #320 from chinmaygarde/skyx_review
Load SkyX files on iOS where available
This commit is contained in:
commit
6bf652ccfe
@ -15,9 +15,24 @@ PLUTIL = [
|
||||
'plutil'
|
||||
]
|
||||
|
||||
def MakeDirectories(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EEXIST and os.path.isdir(path):
|
||||
return 0
|
||||
else:
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def ProcessInfoPlist(args):
|
||||
output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist'))
|
||||
|
||||
if MakeDirectories(os.path.dirname(output_plist_file)) == -1:
|
||||
return -1
|
||||
|
||||
return subprocess.check_call( PLUTIL + [
|
||||
'-convert',
|
||||
'binary1',
|
||||
@ -42,18 +57,6 @@ def PerformCodeSigning(args):
|
||||
])
|
||||
|
||||
|
||||
def MakeDirectories(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EEXIST and os.path.isdir(path):
|
||||
return 0
|
||||
else:
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def GenerateProjectStructure(args):
|
||||
application_path = os.path.join( args.dir, args.name + ".app" )
|
||||
return MakeDirectories( application_path )
|
||||
|
||||
@ -56,6 +56,10 @@ template("resource_copy_ios") {
|
||||
set_sources_assignment_filter([])
|
||||
sources = _resources
|
||||
outputs = [ "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}" ]
|
||||
|
||||
if (defined(invoker.deps)) {
|
||||
deps = invoker.deps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,14 +119,14 @@ template("ios_app") {
|
||||
script = ios_app_script
|
||||
|
||||
sources = [ invoker.info_plist ]
|
||||
outputs = [ "$root_build_dir/Info.plist" ]
|
||||
outputs = [ "$root_build_dir/plist/$app_name/Info.plist" ]
|
||||
|
||||
args = [
|
||||
"plist",
|
||||
"-i",
|
||||
rebase_path(invoker.info_plist, root_build_dir),
|
||||
"-o",
|
||||
rebase_path(root_build_dir),
|
||||
rebase_path("$root_build_dir/plist/$app_name"),
|
||||
]
|
||||
}
|
||||
|
||||
@ -131,7 +135,7 @@ template("ios_app") {
|
||||
copy_gen_target_name = target_name + "_copy"
|
||||
copy(copy_gen_target_name) {
|
||||
sources = [
|
||||
"$root_build_dir/Info.plist",
|
||||
"$root_build_dir/plist/$app_name/Info.plist",
|
||||
"$root_build_dir/$app_name",
|
||||
]
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import("//sky/build/skyx.gni")
|
||||
template("sky_app") {
|
||||
skyx_target_name = target_name
|
||||
|
||||
if (is_android) {
|
||||
if (is_android || is_ios) {
|
||||
skyx_target_name = "app"
|
||||
}
|
||||
|
||||
@ -89,5 +89,45 @@ template("sky_app") {
|
||||
deps += invoker.deps
|
||||
}
|
||||
}
|
||||
} else if (is_ios && defined(invoker.info_plist)) {
|
||||
import("//build/config/ios/rules.gni")
|
||||
import("//build/config/ios/ios_sdk.gni")
|
||||
|
||||
ios_app(target_name) {
|
||||
app_name = target_name + "_app"
|
||||
|
||||
code_signing_identity = ios_code_signing_identity
|
||||
|
||||
info_plist = invoker.info_plist
|
||||
|
||||
if (defined(invoker.entitlements_path)) {
|
||||
entitlements_path = invoker.entitlements_path
|
||||
} else {
|
||||
entitlements_path = "//sky/shell/ios/Entitlements.xcent"
|
||||
}
|
||||
|
||||
resources_gen_target_name = target_name + "_res"
|
||||
resource_copy_ios(resources_gen_target_name) {
|
||||
resources = [
|
||||
"//third_party/icu/android/icudtl.dat",
|
||||
"$target_gen_dir/app.skyx",
|
||||
]
|
||||
bundle_directory = "."
|
||||
deps = [ ":app" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//sky/shell:ios_scaffolding",
|
||||
":$resources_gen_target_name",
|
||||
":$skyx_target_name",
|
||||
]
|
||||
|
||||
if (defined(invoker.deps)) {
|
||||
deps += invoker.deps
|
||||
}
|
||||
}
|
||||
} else {
|
||||
group(target_name) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,5 +14,7 @@ sky_app("game") {
|
||||
deps = [
|
||||
"//sky/packages/sky/example/game/apk:resources",
|
||||
]
|
||||
} else if (is_ios) {
|
||||
info_plist = "ios/Info.plist"
|
||||
}
|
||||
}
|
||||
|
||||
52
sky/packages/sky/example/game/ios/Info.plist
Normal file
52
sky/packages/sky/example/game/ios/Info.plist
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
|
||||
<!--
|
||||
This executable name must match the name of the app provided to the
|
||||
ios_app GN template
|
||||
-->
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>game_app</string>
|
||||
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.domokit.sky.game</string>
|
||||
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>game_app</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>DTPlatformName</key>
|
||||
<string>iphonesimulator</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>iphonesimulator8.3</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.3</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>iPhoneSimulator</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -169,10 +169,36 @@ if (is_android) {
|
||||
import("//build/config/ios/rules.gni")
|
||||
import("//build/config/ios/ios_sdk.gni")
|
||||
|
||||
source_set("ios_scaffolding") {
|
||||
sources = [
|
||||
"ios/main_ios.mm",
|
||||
"ios/sky_app_delegate.h",
|
||||
"ios/sky_app_delegate.mm",
|
||||
"ios/sky_surface.h",
|
||||
"ios/sky_surface.mm",
|
||||
"ios/sky_view_controller.h",
|
||||
"ios/sky_view_controller.mm",
|
||||
]
|
||||
|
||||
set_sources_assignment_filter([])
|
||||
sources += [
|
||||
"mac/platform_mac.h",
|
||||
"mac/platform_mac.mm",
|
||||
"mac/platform_service_provider_mac.cc",
|
||||
"mac/platform_view_mac.h",
|
||||
"mac/platform_view_mac.mm",
|
||||
]
|
||||
set_sources_assignment_filter(sources_assignment_filter)
|
||||
|
||||
deps = common_deps + [
|
||||
":common",
|
||||
"//sky/services/ns_net",
|
||||
]
|
||||
}
|
||||
|
||||
ios_app("shell") {
|
||||
app_name = "SkyShell"
|
||||
info_plist = "ios/Info.plist"
|
||||
scaffolding_target = "ios_scaffolding"
|
||||
entitlements_path = "ios/Entitlements.xcent"
|
||||
code_signing_identity = ios_code_signing_identity
|
||||
|
||||
@ -181,35 +207,8 @@ if (is_android) {
|
||||
bundle_directory = "."
|
||||
}
|
||||
|
||||
source_set(scaffolding_target) {
|
||||
sources = [
|
||||
"ios/main_ios.mm",
|
||||
"ios/sky_app_delegate.h",
|
||||
"ios/sky_app_delegate.mm",
|
||||
"ios/sky_surface.h",
|
||||
"ios/sky_surface.mm",
|
||||
"ios/sky_view_controller.h",
|
||||
"ios/sky_view_controller.mm",
|
||||
]
|
||||
|
||||
set_sources_assignment_filter([])
|
||||
sources += [
|
||||
"mac/platform_mac.h",
|
||||
"mac/platform_mac.mm",
|
||||
"mac/platform_service_provider_mac.cc",
|
||||
"mac/platform_view_mac.h",
|
||||
"mac/platform_view_mac.mm",
|
||||
]
|
||||
set_sources_assignment_filter(sources_assignment_filter)
|
||||
|
||||
deps = common_deps + [
|
||||
":common",
|
||||
"//sky/services/ns_net",
|
||||
]
|
||||
}
|
||||
|
||||
deps = [
|
||||
":$scaffolding_target",
|
||||
":ios_scaffolding",
|
||||
":sky_resources",
|
||||
]
|
||||
}
|
||||
|
||||
@ -131,16 +131,32 @@ static sky::InputEventPtr BasicInputEventFromRecognizer(
|
||||
if (server && target) {
|
||||
return [NSString stringWithFormat:@"http://%@/%@", server, target];
|
||||
}
|
||||
|
||||
return [NSBundle mainBundle].infoDictionary[@"org.domokit.sky.load_url"];
|
||||
}
|
||||
|
||||
- (NSString*)skyInitialBundleURL {
|
||||
return [[NSBundle mainBundle] pathForResource:@"app" ofType:@"skyx"];
|
||||
}
|
||||
|
||||
- (void)connectToEngineAndLoad {
|
||||
auto interface_request = mojo::GetProxy(&_sky_engine);
|
||||
self.platformView->ConnectToEngine(interface_request.Pass());
|
||||
|
||||
mojo::String string(self.skyInitialLoadURL.UTF8String);
|
||||
_sky_engine->RunFromNetwork(string);
|
||||
NSString *endpoint = self.skyInitialBundleURL;
|
||||
if (endpoint.length > 0) {
|
||||
// Load from bundle
|
||||
mojo::String string(endpoint.UTF8String);
|
||||
_sky_engine->RunFromBundle(string);
|
||||
return;
|
||||
}
|
||||
|
||||
endpoint = self.skyInitialLoadURL;
|
||||
if (endpoint.length > 0) {
|
||||
// Load from URL
|
||||
mojo::String string(endpoint.UTF8String);
|
||||
_sky_engine->RunFromNetwork(string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifySurfaceDestruction {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user