From d330201b2bd7848ef8dcb3402a9d642535d3f75f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 31 May 2023 20:21:14 -0700 Subject: [PATCH] Update resource generation for ARM64 platforms (e.g. Apple M2) --- .gitignore | 3 +- .gitlab-ci.yml | 19 ++++++++++-- scripts/generate_resources.sh | 19 +++++++++--- scripts/resources.arm64.patch | 54 +++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 scripts/resources.arm64.patch diff --git a/.gitignore b/.gitignore index 69c1c286f..267509ccc 100644 --- a/.gitignore +++ b/.gitignore @@ -42,8 +42,7 @@ openlp.cfg openlp.pro openlp/core/resources.py openlp/core/resources.py.old -openlp/plugins/presentations/lib/vendor/Pyro4 -openlp/plugins/presentations/lib/vendor/serpent.py +openlp/plugins/presentations/lib/vendor/* output package-lock.json tags diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0cae99802..d0c618d75 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,10 +51,25 @@ test-arch: - sh scripts/generate_resources.sh - xvfb-run -s '-screen 0 1024x768x24' pytest --color=no --disable-warnings -test-macos: +test-macos-intel: stage: test tags: - - macos + - apple-amd64 + script: + - export PATH=/opt/local/bin:$PATH + - sh scripts/generate_resources.sh + - python3 -m pytest --color=no --disable-warnings --cov openlp + - mv .coverage macos.coverage + artifacts: + paths: + - macos.coverage + only: + - master@openlp/openlp + +test-macos-arm: + stage: test + tags: + - apple-arm script: - export PATH=/opt/local/bin:$PATH - sh scripts/generate_resources.sh diff --git a/scripts/generate_resources.sh b/scripts/generate_resources.sh index 9b3eab029..a8f2e5f3a 100755 --- a/scripts/generate_resources.sh +++ b/scripts/generate_resources.sh @@ -35,19 +35,30 @@ ############################################################################### # Backup the existing resources if [ -f "openlp/core/resources.py" ]; then + echo "Backup old resources file" mv openlp/core/resources.py openlp/core/resources.py.old fi # Create the new data from the updated qrc +echo "Generate new resources file" pyrcc5 -o openlp/core/resources.py.new resources/images/openlp-2.qrc # Remove patch breaking lines +echo "Remove 'Created by' line" cat openlp/core/resources.py.new | sed '/# Created by: /d' > openlp/core/resources.py # Patch resources.py to OpenLP coding style -patch --posix -s openlp/core/resources.py scripts/resources.patch +ARCH=`uname -m` +echo "Architecture is: $ARCH" +if [ "$ARCH" == "arm64" ]; then + echo "Running ARM64 patch" + patch --posix -s openlp/core/resources.py scripts/resources.arm64.patch +else + echo "Running x86 patch" + patch --posix -s openlp/core/resources.py scripts/resources.patch +fi # Remove temporary file -rm openlp/core/resources.py.new 2>/dev/null -rm openlp/core/resources.py.old 2>/dev/null -rm openlp/core/resources.py.orig 2>/dev/null +rm -f openlp/core/resources.py.new 2>/dev/null +rm -f openlp/core/resources.py.old 2>/dev/null +rm -f openlp/core/resources.py.orig 2>/dev/null diff --git a/scripts/resources.arm64.patch b/scripts/resources.arm64.patch new file mode 100644 index 000000000..06062c876 --- /dev/null +++ b/scripts/resources.arm64.patch @@ -0,0 +1,54 @@ +=== modified file 'openlp/core/resources.py' +--- openlp/core/resources.py ++++ openlp/core/resources.py +@@ -1,10 +1,28 @@ + # -*- coding: utf-8 -*- +- +-# Resource object code +-# +-# +-# WARNING! All changes made in this file will be lost! +- ++# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ++ ++########################################################################## ++# OpenLP - Open Source Lyrics Projection # ++# ---------------------------------------------------------------------- # ++# Copyright (c) 2008-2023 OpenLP Developers # ++# ---------------------------------------------------------------------- # ++# This program is free software: you can redistribute it and/or modify # ++# it under the terms of the GNU General Public License as published by # ++# the Free Software Foundation, either version 3 of the License, or # ++# (at your option) any later version. # ++# # ++# This program is distributed in the hope that it will be useful, # ++# but WITHOUT ANY WARRANTY; without even the implied warranty of # ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # ++# GNU General Public License for more details. # ++# # ++# You should have received a copy of the GNU General Public License # ++# along with this program. If not, see . # ++########################################################################## ++""" ++The :mod:`resources` module provides application images and icons in a central ++store for use by OpenLP. ++""" + from PyQt5 import QtCore + + qt_resource_data = b"\ +@@ -61434,9 +61452,13 @@ else: + qt_resource_struct = qt_resource_struct_v2 + + def qInitResources(): ++ """ ++ Initialise OpenLP resources at application startup. ++ """ + QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + + def qCleanupResources(): ++ """ ++ Cleanup OpenLP resources when the application shuts down. ++ """ + QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) +- +-qInitResources()