diff --git a/build/config/mac/rules.gni b/build/config/mac/rules.gni
index 8624beebe23..66f0de42e00 100644
--- a/build/config/mac/rules.gni
+++ b/build/config/mac/rules.gni
@@ -87,6 +87,10 @@ template("resource_copy_mac") {
set_sources_assignment_filter([])
sources = _resources
outputs = [ "$root_build_dir/$_app_name.app/$_bundle_directory/Contents/Resources/{{source_file_part}}" ]
+
+ if (defined(invoker.deps)) {
+ deps = invoker.deps
+ }
}
}
@@ -147,14 +151,14 @@ template("mac_app") {
script = mac_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"),
]
}
@@ -163,7 +167,7 @@ template("mac_app") {
copy_plist_gen_target_name = target_name + "_plist_copy"
copy(copy_plist_gen_target_name) {
sources = [
- "$root_build_dir/Info.plist",
+ "$root_build_dir/plist/$app_name/Info.plist",
]
outputs = [
diff --git a/sky/build/sky_app.gni b/sky/build/sky_app.gni
index 3d739151b29..ce66f6b5340 100644
--- a/sky/build/sky_app.gni
+++ b/sky/build/sky_app.gni
@@ -7,7 +7,7 @@ import("//sky/build/skyx.gni")
template("sky_app") {
skyx_target_name = target_name
- if (is_android || is_ios) {
+ if (is_android || is_ios || is_mac) {
skyx_target_name = "app"
}
@@ -113,7 +113,9 @@ template("sky_app") {
"$target_gen_dir/app.skyx",
]
- resources += invoker.launcher_resources
+ if (defined(invoker.launcher_resources)) {
+ resources += invoker.launcher_resources
+ }
bundle_directory = "."
deps = [ ":app" ]
@@ -129,7 +131,41 @@ template("sky_app") {
deps += invoker.deps
}
}
- } else if(is_ios) {
+ } else if(is_mac && defined(invoker.info_plist)) {
+ import("//build/config/mac/rules.gni")
+
+ mac_app(target_name) {
+
+ app_name = target_name + "_app"
+ info_plist = invoker.info_plist
+ xibs = invoker.xibs
+
+ resources_gen_target_name = target_name + "_res"
+ resource_copy_mac(resources_gen_target_name) {
+ resources = [
+ "//third_party/icu/android/icudtl.dat",
+ "$target_gen_dir/app.skyx",
+ ]
+
+ if (defined(invoker.launcher_resources)) {
+ resources += invoker.launcher_resources
+ }
+
+ bundle_directory = "."
+ deps = [ ":app" ]
+ }
+
+ deps = [
+ ":$resources_gen_target_name",
+ "//sky/shell:mac_scaffolding",
+ ]
+
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+
+ } else if(is_ios || is_mac) {
# No Info.plist specified. But we still need an empty target
group(target_name) {
}
diff --git a/sky/packages/sky/example/game/BUILD.gn b/sky/packages/sky/example/game/BUILD.gn
index cceaf0ab9c6..3cfd1c07f40 100644
--- a/sky/packages/sky/example/game/BUILD.gn
+++ b/sky/packages/sky/example/game/BUILD.gn
@@ -21,5 +21,8 @@ sky_app("game") {
"assets/Icon@2x.png",
"ios/LaunchScreen.storyboardc",
]
+ } else if (is_mac) {
+ info_plist = "mac/Info.plist"
+ xibs = [ "mac/sky_mac.xib" ]
}
}
diff --git a/sky/packages/sky/example/game/mac/Info.plist b/sky/packages/sky/example/game/mac/Info.plist
new file mode 100644
index 00000000000..f885c99a9a5
--- /dev/null
+++ b/sky/packages/sky/example/game/mac/Info.plist
@@ -0,0 +1,34 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ game_app
+ CFBundleIconFile
+
+ CFBundleIdentifier
+ org.domokit.sky.asteroids
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ Asteroids
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1
+ LSMinimumSystemVersion
+ 10.6
+ NSHumanReadableCopyright
+ Copyright © 2015 The Chromium Authors. All rights reserved.
+ NSMainNibFile
+ sky_mac
+ NSPrincipalClass
+ SkyApplication
+
+
diff --git a/sky/packages/sky/example/game/mac/sky_mac.xib b/sky/packages/sky/example/game/mac/sky_mac.xib
new file mode 100644
index 00000000000..0173ec3d28e
--- /dev/null
+++ b/sky/packages/sky/example/game/mac/sky_mac.xib
@@ -0,0 +1,695 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sky/shell/BUILD.gn b/sky/shell/BUILD.gn
index bc152d1eeda..5ac0e0f5809 100644
--- a/sky/shell/BUILD.gn
+++ b/sky/shell/BUILD.gn
@@ -235,10 +235,34 @@ if (is_android) {
} else if (is_mac) {
import("//build/config/mac/rules.gni")
+ source_set("mac_scaffolding") {
+ sources = [
+ "mac/main_mac.mm",
+ "mac/platform_mac.h",
+ "mac/platform_mac.mm",
+ "mac/platform_service_provider_mac.cc",
+ "mac/platform_view_mac.h",
+ "mac/platform_view_mac.mm",
+ "mac/sky_app_delegate.h",
+ "mac/sky_app_delegate.m",
+ "mac/sky_application.h",
+ "mac/sky_application.mm",
+ "mac/sky_window.h",
+ "mac/sky_window.mm",
+ "testing/test_runner.cc",
+ "testing/test_runner.h",
+ ]
+
+ deps = common_deps + [
+ ":common",
+ "//sky/services/ns_net",
+ "//sky/services/testing:interfaces",
+ ]
+ }
+
mac_app("shell") {
app_name = "SkyShell"
info_plist = "mac/Info.plist"
- scaffolding_target = "mac_scaffolding"
# entitlements_path = ""
# code_signing_identity = ""
@@ -250,33 +274,8 @@ if (is_android) {
bundle_directory = "."
}
- source_set(scaffolding_target) {
- sources = [
- "mac/main_mac.mm",
- "mac/platform_mac.h",
- "mac/platform_mac.mm",
- "mac/platform_service_provider_mac.cc",
- "mac/platform_view_mac.h",
- "mac/platform_view_mac.mm",
- "mac/sky_app_delegate.h",
- "mac/sky_app_delegate.m",
- "mac/sky_application.h",
- "mac/sky_application.mm",
- "mac/sky_window.h",
- "mac/sky_window.mm",
- "testing/test_runner.cc",
- "testing/test_runner.h",
- ]
-
- deps = common_deps + [
- ":common",
- "//sky/services/ns_net",
- "//sky/services/testing:interfaces",
- ]
- }
-
deps = [
- ":$scaffolding_target",
+ ":mac_scaffolding",
":sky_resources",
]
}
diff --git a/sky/shell/mac/sky_window.mm b/sky/shell/mac/sky_window.mm
index f16c8a13cc0..e55dfacebf3 100644
--- a/sky/shell/mac/sky_window.mm
+++ b/sky/shell/mac/sky_window.mm
@@ -70,12 +70,29 @@ static inline sky::EventType EventTypeFromNSEventPhase(NSEventPhase phase) {
.infoDictionary objectForKey:@"org.domokit.sky.load_url"];
}
+- (NSString*)skyInitialBundleURL {
+ return [[NSBundle mainBundle] pathForResource:@"app" ofType:@"skyx"];
+}
+
- (void)setupAndLoadDart {
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)windowDidResize:(NSNotification*)notification {