From: Frank Stettner Date: Sun, 26 Mar 2023 14:22:47 +0000 (+0200) Subject: Add ci scripts for the pulseview MXE build X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a018c12ea46577c8cd0b8934945b83da96671358;p=sigrok-build.git Add ci scripts for the pulseview MXE build --- diff --git a/ci/contrib-mxe/FileAssociation.nsh b/ci/contrib-mxe/FileAssociation.nsh new file mode 100644 index 0000000..f824516 --- /dev/null +++ b/ci/contrib-mxe/FileAssociation.nsh @@ -0,0 +1,190 @@ +/* +_____________________________________________________________________________ + + File Association +_____________________________________________________________________________ + + Based on code taken from http://nsis.sourceforge.net/File_Association + + Usage in script: + 1. !include "FileAssociation.nsh" + 2. [Section|Function] + ${FileAssociationFunction} "Param1" "Param2" "..." $var + [SectionEnd|FunctionEnd] + + FileAssociationFunction=[RegisterExtension|UnRegisterExtension] + +_____________________________________________________________________________ + + ${RegisterExtension} "[executable]" "[extension]" "[description]" + +"[executable]" ; executable which opens the file format + ; +"[extension]" ; extension, which represents the file format to open + ; +"[description]" ; description for the extension. This will be display in Windows Explorer. + ; + + + ${UnRegisterExtension} "[extension]" "[description]" + +"[extension]" ; extension, which represents the file format to open + ; +"[description]" ; description for the extension. This will be display in Windows Explorer. + ; + +_____________________________________________________________________________ + + Macros +_____________________________________________________________________________ + + Change log window verbosity (default: 3=no script) + + Example: + !include "FileAssociation.nsh" + !insertmacro RegisterExtension + ${FileAssociation_VERBOSE} 4 # all verbosity + !insertmacro UnRegisterExtension + ${FileAssociation_VERBOSE} 3 # no script +*/ + + +!ifndef FileAssociation_INCLUDED +!define FileAssociation_INCLUDED + +!include Util.nsh + +!verbose push +!verbose 3 +!ifndef _FileAssociation_VERBOSE + !define _FileAssociation_VERBOSE 3 +!endif +!verbose ${_FileAssociation_VERBOSE} +!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE` +!verbose pop + +!macro FileAssociation_VERBOSE _VERBOSE + !verbose push + !verbose 3 + !undef _FileAssociation_VERBOSE + !define _FileAssociation_VERBOSE ${_VERBOSE} + !verbose pop +!macroend + + + +!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION + !verbose push + !verbose ${_FileAssociation_VERBOSE} + Push `${_DESCRIPTION}` + Push `${_EXTENSION}` + Push `${_EXECUTABLE}` + ${CallArtificialFunction} RegisterExtension_ + !verbose pop +!macroend + +!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION + !verbose push + !verbose ${_FileAssociation_VERBOSE} + Push `${_EXTENSION}` + Push `${_DESCRIPTION}` + ${CallArtificialFunction} UnRegisterExtension_ + !verbose pop +!macroend + + + +!define RegisterExtension `!insertmacro RegisterExtensionCall` +!define un.RegisterExtension `!insertmacro RegisterExtensionCall` + +!macro RegisterExtension +!macroend + +!macro un.RegisterExtension +!macroend + +!macro RegisterExtension_ + !verbose push + !verbose ${_FileAssociation_VERBOSE} + + Exch $R2 ;exe + Exch + Exch $R1 ;ext + Exch + Exch 2 + Exch $R0 ;desc + Exch 2 + Push $0 + Push $1 + + ReadRegStr $1 HKCR $R1 "" ; read current file association + StrCmp "$1" "" NoBackup ; is it empty + StrCmp "$1" "$R0" NoBackup ; is it our own + WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value +NoBackup: + WriteRegStr HKCR $R1 "" "$R0" ; set our file association + + ReadRegStr $0 HKCR $R0 "" + StrCmp $0 "" 0 Skip + WriteRegStr HKCR "$R0" "" "$R0" + WriteRegStr HKCR "$R0\shell" "" "open" + WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0" +Skip: + WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"' + WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0" + WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"' + + Pop $1 + Pop $0 + Pop $R2 + Pop $R1 + Pop $R0 + + !verbose pop +!macroend + + + +!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall` +!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall` + +!macro UnRegisterExtension +!macroend + +!macro un.UnRegisterExtension +!macroend + +!macro UnRegisterExtension_ + !verbose push + !verbose ${_FileAssociation_VERBOSE} + + Exch $R1 ;desc + Exch + Exch $R0 ;ext + Exch + Push $0 + Push $1 + + ReadRegStr $1 HKCR $R0 "" + StrCmp $1 $R1 0 NoOwn ; only do this if we own it + ReadRegStr $1 HKCR $R0 "backup_val" + StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key + DeleteRegKey HKCR $R0 + Goto NoOwn + +Restore: + WriteRegStr HKCR $R0 "" $1 + DeleteRegValue HKCR $R0 "backup_val" + DeleteRegKey HKCR $R1 ;Delete key with association name settings + +NoOwn: + + Pop $1 + Pop $0 + Pop $R1 + Pop $R0 + + !verbose pop +!macroend + +!endif # !FileAssociation_INCLUDED diff --git a/ci/contrib-mxe/pyconfig.patch b/ci/contrib-mxe/pyconfig.patch new file mode 100644 index 0000000..a5ffb1c --- /dev/null +++ b/ci/contrib-mxe/pyconfig.patch @@ -0,0 +1,37 @@ +Fix for bug #1195. + +Patch taken from the MSYS2 MINGW-packages repo, filename +0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch, +but applied to pyconfig.h instead of pyport.h. + +Without this, Py_ssize_t ends up being 4 on 64bit Windows (where it +should be 8) and all kinds of weird issues happen as a result, +including 4GB allocations for no apparent reason, and none of the +protocol decoders working (at all). + +The respective Py_ssize_t related code is in pyport.h. + +--- pyconfig.h.orig 2018-09-29 18:06:33.625204450 +0200 ++++ pyconfig.h 2018-09-29 18:34:09.165488139 +0200 +@@ -1,6 +1,21 @@ + #ifndef Py_CONFIG_H + #define Py_CONFIG_H + ++#ifdef __MINGW32__ ++/* Translate GCC[mingw*] platform specific defines to those ++ * used in python code. ++ */ ++#if !defined(MS_WIN64) && defined(_WIN64) ++# define MS_WIN64 ++#endif ++#if !defined(MS_WIN32) && defined(_WIN32) ++# define MS_WIN32 ++#endif ++#if !defined(MS_WINDOWS) && defined(MS_WIN32) ++# define MS_WINDOWS ++#endif ++#endif /* __MINGW32__*/ ++ + /* pyconfig.h. NOT Generated automatically by configure. + + This is a manually maintained version used for the Watcom, diff --git a/ci/sigrok-mxe-build-dependencies.sh b/ci/sigrok-mxe-build-dependencies.sh new file mode 100755 index 0000000..cf51751 --- /dev/null +++ b/ci/sigrok-mxe-build-dependencies.sh @@ -0,0 +1,112 @@ +#!/bin/sh +## +## This file is part of the sigrok-util project. +## +## Copyright (C) 2013-2018 Uwe Hermann +## Copyright (C) 2018-2023 Frank Stettner +## +## 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 2 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 . +## + +set -e + +mkdir -p "$INSTALL_DIR" + +BUILD_DIR=./build +mkdir -p $BUILD_DIR +cd $BUILD_DIR + +# Cross-compiling Python is highly non-trivial, so we avoid it for now. +# The download below is a repackaged tarball of the official Python 3.4.4 MSI +# installer for Windows: +# - https://www.python.org/ftp/python/3.4.4/python-3.4.4.msi +# - https://www.python.org/ftp/python/3.4.4/python-3.4.4.amd64.msi +# The MSI file has been installed on a Windows box and then c:\Python34\libs +# and c:\Python34\include have been stored in the Python34_*.tar.gz tarball. +$WGET https://sigrok.org/tmp/Python34_$TARGET.tar.gz -O "$INSTALL_DIR"/Python34.tar.gz +tar xzf "$INSTALL_DIR"/Python34.tar.gz -C "$INSTALL_DIR" + +# Fix for bug #1195. +if [ "$TARGET" = "x86_64" ]; then + patch -p1 "$INSTALL_DIR"/Python34/include/pyconfig.h < ../contrib-mxe/pyconfig.patch +fi + +# Create a dummy python3.pc file so that pkg-config finds Python 3. +mkdir -p "$INSTALL_DIR"/lib/pkgconfig +cat > "$INSTALL_DIR"/lib/pkgconfig/python3.pc < +## Copyright (C) 2018-2021 Frank Stettner +## +## 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 2 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 . +## + +set -e + +export PARALLEL="-j$(nproc)" + +# We need to find tools in the toolchain. +export PATH="$MXE_DIR/usr/bin":"$PATH" + +TOOLCHAIN_TRIPLET="$TARGET-w64-mingw32.static.posix" + +export CMAKE="$TOOLCHAIN_TRIPLET-cmake" + +P="$INSTALL_DIR/lib/pkgconfig" +P2="$MXE_DIR/usr/$TOOLCHAIN_TRIPLET/lib/pkgconfig" +export C="--host=$TOOLCHAIN_TRIPLET --prefix=$INSTALL_DIR CPPFLAGS=-D__printf__=__gnu_printf__" +export L="--disable-shared --enable-static" + +if [ "$TARGET" = "i686" ]; then + export PKG_CONFIG_PATH_i686_w64_mingw32_static_posix="$P:$P2" +else + export PKG_CONFIG_PATH_x86_64_w64_mingw32_static_posix="$P:$P2" +fi +