Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mwu-tow committed Nov 16, 2023
1 parent 9f4d2bf commit 9acf59c
Show file tree
Hide file tree
Showing 5 changed files with 340 additions and 887 deletions.
9 changes: 8 additions & 1 deletion build/build/src/ci_gen/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub fn expose_os_specific_signing_secret(os: OS, step: Step) -> Step {
}
}

/// The command that bumps the version of the Electron-Builder to
/// The sequence of steps that bumps the version of the Electron-Builder to
/// [`ELECTRON_BUILDER_MACOS_VERSION`].
pub fn bump_electron_builder() -> Vec<Step> {
let npm_install =
Expand All @@ -269,6 +269,10 @@ pub fn bump_electron_builder() -> Vec<Step> {
vec![npm_install, uninstall_old, install_new]
}

/// Prepares the packaging steps for the given OS.
///
/// This involves exposing secrets necessary for code signing and notarization. Additionally, on
/// macOS, it bumps the version of the Electron Builder to [`ELECTRON_BUILDER_MACOS_VERSION`].
pub fn prepare_packaging_steps(os: OS, step: Step) -> Vec<Step> {
let mut steps = Vec::new();
if os == OS::MacOS {
Expand All @@ -278,6 +282,9 @@ pub fn prepare_packaging_steps(os: OS, step: Step) -> Vec<Step> {
steps
}

/// Convenience for [`prepare_packaging_steps`].
///
/// This function is useful when you want to use [`prepare_packaging_steps`] as a closure.
pub fn with_packaging_steps(os: OS) -> impl FnOnce(Step) -> Vec<Step> {
move |step| prepare_packaging_steps(os, step)
}
Expand Down
22 changes: 22 additions & 0 deletions build/build/src/ide/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ pub mod env {
/// appropriate identity from your keychain will be automatically used.
CSC_IDENTITY_AUTO_DISCOVERY, bool;

/// Path to the python2 executable, used by electron-builder on macOS to package DMG.
PYTHON_PATH, PathBuf;

/// Note that enabling CSC_FOR_PULL_REQUEST can pose serious security risks. Refer to the
/// [CircleCI documentation](https://circleci.com/docs/1.0/fork-pr-builds/) for more
/// information. If the project settings contain SSH keys, sensitive environment variables,
Expand Down Expand Up @@ -379,6 +382,24 @@ impl IdeDesktop {
let icons_build = self.build_icons(&icons_dist);
let (icons, _content) = try_join(icons_build, client_build).await?;

let python_path = if TARGET_OS == OS::MacOS && !env::PYTHON_PATH.is_set() {
// On macOS electron-builder will fail during DMG creation if there is no python2
// installed. It is looked for in `/usr/bin/python` which is not valid place on newer
// MacOS versions.
// We can work around this by setting the `PYTHON_PATH` env variable. We attempt to
// locate `python2` in PATH which is enough to work on GitHub-hosted macOS
// runners.
ide_ci::program::lookup("python2")
.inspect_err(|e| {
// We do not fail, as this requirement might have been lifted by the
// electron-builder bump. As for now, we do best effort to support both cases.
warn!("Failed to locate python2 in PATH: {e}");
})
.ok()
} else {
None
};

let target_args = match target {
Some(target) => vec!["--target".to_string(), target],
None => vec![],
Expand All @@ -390,6 +411,7 @@ impl IdeDesktop {
.set_env(env::ENSO_BUILD_GUI, gui.as_ref())?
.set_env(env::ENSO_BUILD_IDE, output_path.as_ref())?
.set_env(env::ENSO_BUILD_PROJECT_MANAGER, project_manager.as_ref())?
.set_env_opt(env::PYTHON_PATH, python_path.as_ref())?
.workspace(Workspaces::Enso)
// .args(["--loglevel", "verbose"])
.run("dist")
Expand Down
11 changes: 11 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ helper tools for that. We recommend:
**For users of M1 Mac**: installing GraalVM on M1 Mac requires manual actions,
please refer to a [dedicated documentation](./graalvm-m1-mac.md).

**For users of MacOS Monterey and later**: building desktop IDE currently
requires Python 2 installed in the system. It can be installed using the
following commands:

```sh
brew install pyenv
pyenv install 2.7.18
pyenv global 2.7.18
export PYTHON_PATH=$(pyenv root)/shims/python
```

The flatbuffers `flatc` compiler can be installed from the following locations:

- Using the `conda` package manager (`conda install flatbuffers`). This will
Expand Down
Loading

0 comments on commit 9acf59c

Please sign in to comment.