Skip to content

Commit

Permalink
working MAC build on arm and x86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgriffin committed Dec 21, 2024
1 parent 56bd09e commit 2d02305
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-mac-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
required: false
type: boolean

push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]

jobs:
build:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Python Tests with PyQt6

# on:
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
Expand Down
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build mac",
"type": "python",
"request": "launch",
"program": "tools/build.py",
"args": [
"--targets", "mac",
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build Linux (Current Files)",
"type": "python",
Expand All @@ -149,6 +159,17 @@
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build Mac (Current Files)",
"type": "python",
"request": "launch",
"program": "tools/build.py",
"args": [
"--targets", "mac",
"--commit", "None",
],
"console": "integratedTerminal",
"preLaunchTask": "Poetry Install" // label of the task
},{
"name": "Build Windows (Current Files)",
"type": "python",
Expand Down
55 changes: 53 additions & 2 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,60 @@ def build_in_docker(

def build_dmg(
self,
build_commit: None | str | Literal["current_commit"] = "current_commit",
):
PROJECT_ROOT = Path(".").resolve().absolute()
run_local(PROJECT_ROOT / "tools" / "build-mac" / "make_osx.sh")
PROJECT_ROOT_OR_FRESHCLONE_ROOT = PROJECT_ROOT = Path(".").resolve().absolute()
DISTDIR = PROJECT_ROOT / "dist"

if build_commit == "current_commit":
# Get the current git HEAD commit
result = subprocess.run(
["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True, text=True
)
build_commit = result.stdout.strip()

if not build_commit:
# Local development build
logger.info(f"Building within current project")

# Possibly do a fresh clone
FRESH_CLONE = False
if build_commit:
logger.info(f"BITCOINSAFE_BUILD_COMMIT={build_commit}. Doing fresh clone and git checkout.")
FRESH_CLONE = Path(f"/tmp/{build_commit.replace(' ','')}/fresh_clone/bitcoin_safe")
try:
run_local(f'rm -rf "{FRESH_CLONE}"')
except subprocess.CalledProcessError:
logger.info("We need sudo to remove previous FRESH_CLONE.")
run_local(f'sudo rm -rf "{FRESH_CLONE}"')
os.umask(0o022)
run_local(f'git clone "{PROJECT_ROOT}" "{FRESH_CLONE}"')
os.chdir(str(FRESH_CLONE))
run_local(f'git checkout "{build_commit}"')
PROJECT_ROOT_OR_FRESHCLONE_ROOT = FRESH_CLONE
else:
logger.info("Not doing fresh clone.")

Source_Dist_dir = PROJECT_ROOT_OR_FRESHCLONE_ROOT / "dist"

os.chdir(str(PROJECT_ROOT_OR_FRESHCLONE_ROOT))
run_local(f'bash {PROJECT_ROOT_OR_FRESHCLONE_ROOT / "tools" / "build-mac" / "make_osx.sh"}')

os.chdir(str(PROJECT_ROOT))

# Ensure the resulting binary location is independent of fresh_clone
if Source_Dist_dir != DISTDIR:
os.makedirs(DISTDIR, exist_ok=True)
for file in Source_Dist_dir.iterdir():
# only move the .app directory (no need for the unsigned dmg)
if file.is_dir() and file.name.endswith(".app"):
logger.info(f"Moving {file} --> {DISTDIR / file.name}")
# Replace module name with formatted app name in the directory name
new_dir_name = file.name.replace(
self.module_name, self.app_name_formatter(self.module_name)
)
# Perform the move
shutil.move(str(file), str(DISTDIR / new_dir_name))

def briefcase_appimage(self, **kwargs):
# briefcase appimage building works on some systems, but not on others... unknown why.
Expand Down

0 comments on commit 2d02305

Please sign in to comment.