Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks to allow certain build commands according to "build_on" platform. #2343

Merged
merged 6 commits into from
Jan 9, 2024
Merged
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
17 changes: 17 additions & 0 deletions sdk/python/packages/flet/src/flet/cli/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,49 @@ def __init__(self, parser: argparse.ArgumentParser) -> None:
"status_text": "Windows app",
"output": "build/windows/x64/runner/Release/*",
"dist": "windows",
"can_be_run_on": ["Windows"],
},
"macos": {
"build_command": "macos",
"status_text": "macOS bundle",
"output": "build/macos/Build/Products/Release/{project_name}.app",
"dist": "macos",
"can_be_run_on": ["Darwin"],
},
"linux": {
"build_command": "linux",
"status_text": "app for Linux",
"output": "build/linux/{arch}/release/bundle/*",
"dist": "linux",
"can_be_run_on": ["Linux"],
},
"web": {
"build_command": "web",
"status_text": "web app",
"output": "build/web/*",
"dist": "web",
"can_be_run_on": ["Darwin", "Windows", "Linux"],
},
"apk": {
"build_command": "apk",
"status_text": ".apk for Android",
"output": "build/app/outputs/flutter-apk/*",
"dist": "apk",
"can_be_run_on": ["Darwin", "Windows", "Linux"],
},
"aab": {
"build_command": "appbundle",
"status_text": ".aab bundle for Android",
"output": "build/app/outputs/bundle/release/*",
"dist": "aab",
"can_be_run_on": ["Darwin", "Windows", "Linux"],
},
"ipa": {
"build_command": "ipa",
"status_text": ".ipa bundle for iOS",
"output": "build/ios/archive/*",
"dist": "ipa",
"can_be_run_on": ["Darwin"],
},
}

Expand Down Expand Up @@ -267,6 +274,16 @@ def handle(self, options: argparse.Namespace) -> None:
sys.exit(1)

target_platform = options.target_platform.lower()
# platform check
current_platform = platform.system()
if current_platform not in self.platforms[target_platform]["can_be_run_on"]:
# make the platform name more user friendly
if current_platform == "Darwin":
current_platform = "macOS"

print(f"Can't build {target_platform} on {current_platform}")
sys.exit(1)

self.verbose = options.verbose

python_app_path = Path(options.python_app_path).resolve()
Expand Down