Skip to content

Commit c2c6f0f

Browse files
author
Sam Schott
committed
resurrect app target
1 parent 54fedd9 commit c2c6f0f

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ briefcase.formats.linux =
9393
rpm = briefcase.platforms.linux.rpm
9494
snap = briefcase.platforms.linux.snap
9595
briefcase.formats.macOS =
96+
app = briefcase.platforms.macOS.app
9697
xcode = briefcase.platforms.macOS.xcode
97-
dmg = briefcase.platforms.macOS.dmg
9898
homebrew = briefcase.platforms.macOS.homebrew
9999
# briefcase.formats.tvOS =
100100
# xcode = briefcase.platforms.tvOS.xcode

src/briefcase/platforms/macOS/app.py

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import subprocess
2+
3+
from briefcase.commands import (
4+
BuildCommand,
5+
CreateCommand,
6+
PackageCommand,
7+
PublishCommand,
8+
RunCommand,
9+
UpdateCommand
10+
)
11+
from briefcase.config import BaseConfig
12+
from briefcase.exceptions import BriefcaseCommandError
13+
from briefcase.platforms.macOS import macOSMixin, macOSPackageMixin
14+
15+
16+
class macOSAppMixin(macOSMixin):
17+
output_format = 'app'
18+
19+
def binary_path(self, app):
20+
return self.bundle_path(app) / '{app.formal_name}.app'.format(app=app)
21+
22+
def distribution_path(self, app):
23+
return self.binary_path(app)
24+
25+
26+
class macOSAppCreateCommand(macOSAppMixin, CreateCommand):
27+
description = "Create and populate a macOS app."
28+
29+
30+
class macOSAppUpdateCommand(macOSAppMixin, UpdateCommand):
31+
description = "Update an existing macOS app."
32+
33+
34+
class macOSAppBuildCommand(macOSAppMixin, BuildCommand):
35+
description = "Build a macOS app."
36+
37+
38+
class macOSAppRunCommand(macOSAppMixin, RunCommand):
39+
description = "Run a macOS app."
40+
41+
def run_app(self, app: BaseConfig, **kwargs):
42+
"""
43+
Start the application.
44+
45+
:param app: The config object for the app
46+
:param base_path: The path to the project directory.
47+
"""
48+
print()
49+
print('[{app.app_name}] Starting app...'.format(
50+
app=app
51+
))
52+
try:
53+
print()
54+
self.subprocess.run(
55+
[
56+
'open',
57+
self.binary_path(app),
58+
],
59+
check=True,
60+
)
61+
except subprocess.CalledProcessError:
62+
print()
63+
raise BriefcaseCommandError(
64+
"Unable to start app {app.app_name}.".format(app=app)
65+
)
66+
67+
68+
class macOSAppPackageCommand(macOSAppMixin, macOSPackageMixin, PackageCommand):
69+
description = "Package a macOS app for distribution."
70+
71+
72+
class macOSAppPublishCommand(macOSAppMixin, PublishCommand):
73+
description = "Publish a macOS app."
74+
75+
76+
# Declare the briefcase command bindings
77+
create = macOSAppCreateCommand # noqa
78+
update = macOSAppUpdateCommand # noqa
79+
build = macOSAppBuildCommand # noqa
80+
run = macOSAppRunCommand # noqa
81+
package = macOSAppPackageCommand # noqa
82+
publish = macOSAppPublishCommand # noqa

0 commit comments

Comments
 (0)