git: 76f1820a7ee2 - main - Uses/electronfix.mk: Framework for quick porting of Electron apps.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Nov 2023 11:03:25 UTC
The branch main has been updated by arrowd: URL: https://cgit.FreeBSD.org/ports/commit/?id=76f1820a7ee2ad20f481d45c43c6dea886da07b1 commit 76f1820a7ee2ad20f481d45c43c6dea886da07b1 Author: Gleb Popov <arrowd@FreeBSD.org> AuthorDate: 2023-09-22 18:30:11 +0000 Commit: Gleb Popov <arrowd@FreeBSD.org> CommitDate: 2023-11-06 11:02:22 +0000 Uses/electronfix.mk: Framework for quick porting of Electron apps. The idea behind this USES is to take a binary distribution of some Electron app and replace Linux binaries with the native ones. Not only this allows for quick porting, but it is also a way to get closed-source Electron apps (Obsidian, XMind) working on FreeBSD. Sponsored by: Serenity Cybersecurity, LLC --- Mk/Uses/electronfix.mk | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Mk/Uses/electronfix.mk b/Mk/Uses/electronfix.mk new file mode 100644 index 000000000000..f2655c634bf5 --- /dev/null +++ b/Mk/Uses/electronfix.mk @@ -0,0 +1,61 @@ +# Provide support for easy porting of Electron applications that are distributed +# in binary form. +# +# Feature: electronfix +# Usage: USES=electronfix:version +# +# An example usage might be: +# USES= electronfix:24 +# +# Variables, which can be set by the port: +# +# ELECTRONFIX_SYMLINK_FILES List of files to be symlinked from Electron distribution. +# +# ELECTRONFIX_MAIN_EXECUTABLE File name of the main executable to be replaced +# with the original Electron binary. + +.if !defined(_INCLUDE_USES_ELECTRONFIX_MK) +_INCLUDE_USES_ELECTRONFIX_MK= yes + +_ELECTRONFIX_MK_VALID_VERSIONS= 22 23 24 25 + +# === parse version arguments === +_ELECTRONFIX_MK_VERSION= # empty +. for _ver in ${_ELECTRONFIX_MK_VALID_VERSIONS} +. if ${electronfix_ARGS:M${_ver}} +. if !empty(_ELECTRONFIX_MK_VERSION) +BROKEN= USES=electronfix:${electronfix_ARGS} contains multiple version definitions +. else +_ELECTRONFIX_MK_VERSION= ${_ver} +. endif +. endif +. endfor + +BUILD_DEPENDS+= electron${_ELECTRONFIX_MK_VERSION}:devel/electron${_ELECTRONFIX_MK_VERSION} +RUN_DEPENDS+= electron${_ELECTRONFIX_MK_VERSION}:devel/electron${_ELECTRONFIX_MK_VERSION} + +ELECTRONFIX_SYMLINK_FILES?= \ + chromedriver \ + libEGL.so \ + libGLESv2.so \ + libffmpeg.so \ + libvk_swiftshader.so \ + libvulkan.so \ + resources.pak \ + snapshot_blob.bin \ + v8_context_snapshot.bin + +_USES_install= 701:electronfix-post-install + +electronfix-post-install: + ${RM} ${STAGEDIR}${DATADIR}/chrome-sandbox + ${RM} ${STAGEDIR}${DATADIR}/libvulkan.so.1 +. for f in ${ELECTRONFIX_SYMLINK_FILES} + ${RM} ${STAGEDIR}${DATADIR}/${f} + ${LN} -s ${LOCALBASE}/share/electron${_ELECTRONFIX_MK_VERSION}/${f} ${STAGEDIR}${DATADIR}/${f} +. endfor +. ifdef ELECTRONFIX_MAIN_EXECUTABLE +# We have to copy the electron binary instead of symlinking + ${CP} ${LOCALBASE}/share/electron${_ELECTRONFIX_MK_VERSION}/electron ${STAGEDIR}${DATADIR}/${ELECTRONFIX_MAIN_EXECUTABLE} +. endif +.endif