Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions build/config/ios/ios_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,24 @@
'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',
Expand All @@ -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 )
Expand Down
10 changes: 7 additions & 3 deletions build/config/ios/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -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" ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not a big fan of adding a new top level build directory, but we can fix this in another pass.


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"),
]
}

Expand All @@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root_build_dir seems wrong. That's like out/ios_sim_Debug, I think you want $target_gen_dir or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter if we are still giving the intermediate plist files from each target their own directory?

"$root_build_dir/$app_name",
]

Expand Down
42 changes: 41 additions & 1 deletion sky/build/sky_app.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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) {
}
}
}
2 changes: 2 additions & 0 deletions sky/packages/sky/example/game/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 52 additions & 0 deletions sky/packages/sky/example/game/ios/Info.plist
Original file line number Diff line number Diff line change
@@ -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>
57 changes: 28 additions & 29 deletions sky/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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",
]
}
Expand Down
22 changes: 19 additions & 3 deletions sky/shell/ios/sky_surface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,32 @@ - (NSString*)skyInitialLoadURL {
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 {
Expand Down