author | Alexander Rødseth
<xyproto@archlinux.org> 2020-10-09 08:40:32 UTC |
committer | Alexander Rødseth
<xyproto@archlinux.org> 2020-10-09 08:40:32 UTC |
parent | 5889d6d7956c74310bd0150c01da85e7bd17f6bb |
FindPySide2Tools.cmake | +112 | -0 |
PKGBUILD | +105 | -0 |
freecad.desktop | +14 | -0 |
freecad.xml | +9 | -0 |
diff --git a/FindPySide2Tools.cmake b/FindPySide2Tools.cmake new file mode 100644 index 0000000..216da5f --- /dev/null +++ b/FindPySide2Tools.cmake @@ -0,0 +1,112 @@ +# Try to find PySide2 utilities, PYSIDE2UIC and PYSIDE2RCC: +# PYSIDE2UICBINARY - Location of PYSIDE2UIC executable +# PYSIDE2RCCBINARY - Location of PYSIDE2RCC executable +# PYSIDE2_TOOLS_FOUND - PySide2 utilities found. + +# Also provides macro similar to FindQt4.cmake's WRAP_UI and WRAP_RC, +# for the automatic generation of Python code from Qt4's user interface +# ('.ui') and resource ('.qrc') files. These macros are called: +# - PYSIDE_WRAP_UI +# - PYSIDE_WRAP_RC + +IF(PYSIDE2UICBINARY AND PYSIDE2RCCBINARY) + # Already in cache, be silent + set(PYSIDE2_TOOLS_FOUND_QUIETLY TRUE) +ENDIF(PYSIDE2UICBINARY AND PYSIDE2RCCBINARY) + +if(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + #pyside2 tools are often in same location as python interpreter + get_filename_component(PYTHON_BIN_DIR ${PYTHON_EXECUTABLE} PATH) + set(PYSIDE_BIN_DIR ${PYTHON_BIN_DIR}) +endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + +# Since Qt v5.14, pyside2-uic and pyside2-rcc are directly provided by Qt5Core uic and rcc, with '-g python' option +# We test Qt5Core version to act accordingly + +FIND_PACKAGE(Qt5Core) + +IF(Qt5Core_VERSION VERSION_LESS 5.14) + # Legacy (< 5.14) + FIND_PROGRAM(PYSIDE2UICBINARY NAMES python2-pyside2-uic pyside2-uic pyside2-uic-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} pyuic5 HINTS ${PYSIDE_BIN_DIR}) + FIND_PROGRAM(PYSIDE2RCCBINARY NAMES pyside2-rcc pyside2-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} pyrcc5 HINTS ${PYSIDE_BIN_DIR}) + set(UICOPTIONS "") + set(RCCOPTIONS "") +ELSE(Qt5Core_VERSION VERSION_LESS 5.14) + # New (>= 5.14) + FIND_PROGRAM(PYSIDE2UICBINARY NAMES uic-qt5 uic pyside2-uic) + set(UICOPTIONS "--generator=python") + FIND_PROGRAM(PYSIDE2RCCBINARY NAMES rcc-qt5 rcc pyside2-rcc) + set(RCCOPTIONS "--generator=python" "--compress-algo=zlib" "--compress=1") +ENDIF(Qt5Core_VERSION VERSION_LESS 5.14) + +MACRO(PYSIDE_WRAP_UI outfiles) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.py) + #ADD_CUSTOM_TARGET(${it} ALL + # DEPENDS ${outfile} + #) + if(WIN32 OR APPLE) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${PYSIDE2UICBINARY} ${UICOPTIONS} ${infile} -o ${outfile} + MAIN_DEPENDENCY ${infile} + ) + else() + # Especially on Open Build Service we don't want changing date like + # pyside2-uic generates in comments at beginning., which is why + # we follow the tool command with in-place sed. + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND "${PYSIDE2UICBINARY}" ${UICOPTIONS} "${infile}" -o "${outfile}" + COMMAND sed -i "/^# /d" "${outfile}" + MAIN_DEPENDENCY "${infile}" + ) + endif() + list(APPEND ${outfiles} ${outfile}) + ENDFOREACH(it) +ENDMACRO (PYSIDE_WRAP_UI) + +MACRO(PYSIDE_WRAP_RC outfiles) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + SET(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}_rc.py") + #ADD_CUSTOM_TARGET(${it} ALL + # DEPENDS ${outfile} + #) + if(WIN32 OR APPLE) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${PYSIDE2RCCBINARY} ${RCCOPTIONS} ${infile} -o ${outfile} + MAIN_DEPENDENCY ${infile} + ) + else() + # Especially on Open Build Service we don't want changing date like + # pyside-rcc generates in comments at beginning, which is why + # we follow the tool command with in-place sed. + ADD_CUSTOM_COMMAND(OUTPUT "${outfile}" + COMMAND "${PYSIDE2RCCBINARY}" ${RCCOPTIONS} "${infile}" ${PY_ATTRIBUTE} -o "${outfile}" + COMMAND sed -i "/^# /d" "${outfile}" + MAIN_DEPENDENCY "${infile}" + ) + endif() + list(APPEND ${outfiles} ${outfile}) + ENDFOREACH(it) +ENDMACRO (PYSIDE_WRAP_RC) + +IF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY}) + set(PYSIDE2_TOOLS_FOUND TRUE) +ENDIF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY}) + +if(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) + if (NOT PySide2Tools_FIND_QUIETLY) + message(STATUS "Found PySide2 tools: ${PYSIDE2UICBINARY}, ${PYSIDE2RCCBINARY}") + endif (NOT PySide2Tools_FIND_QUIETLY) +else(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) + if(PySide2Tools_FIND_REQUIRED) + message(FATAL_ERROR "PySide2 tools could not be found, but are required.") + else(PySide2Tools_FIND_REQUIRED) + if (NOT PySide2Tools_FIND_QUIETLY) + message(STATUS "PySide2 tools: not found.") + endif (NOT PySide2Tools_FIND_QUIETLY) + endif(PySide2Tools_FIND_REQUIRED) +endif(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..1152c0d --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,105 @@ +# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org> +# Contributor: Gabriel Souza Franco <Z2FicmllbGZyYW5jb3NvdXphQGdtYWlsLmNvbQ==> +# Contributor: Florian Pritz +# Contributor: Jonas Heinrich <onny@project-insanity.org> +# Contributor: Jordi De Groof <jordi (dot) degroof (at) gmail (dot) com> +# Contributor: mickele +# Contributor: manwithgrenade +# Contributor: bricem13 +# Contributor: gborzi + +pkgname=freecad +pkgver=0.18.4 +pkgrel=1 +pkgdesc='General purpose 3D CAD modeler' +arch=(x86_64) +url='https://freecadweb.org/' +license=(LGPL) +depends=(boost-libs glew hicolor-icon-theme jsoncpp libspnav med netcdf opencascade openmpi pyside2-tools python-matplotlib python-pivy python-pyside2 qt5-declarative qt5-svg qt5-tools qt5-webkit qt5-x11extras shared-mime-info xerces-c) +makedepends=(boost cmake coin desktop-file-utils eigen gcc-fortran git ninja pyside2 python-shiboken2 shiboken2 swig) +optdepends=(graphviz openscad python-matplotlib) +source=("git+https://github.com/FreeCAD/FreeCAD#commit=980bf9060e28555fecd9e3462f68ca74007b70f8" # tag: 0.18.4 + 'https://raw.githubusercontent.com/FreeCAD/FreeCAD/d06d5687c1498354483aff95093d7f798c2985f2/cMake/FindPySide2Tools.cmake' + $pkgname.desktop + $pkgname.xml) +sha256sums=('SKIP' + '421a364ad214a25be578d81edc9960daab87d7b26f341022aa22dd15b9df621b' + '3f076dcd15114011b7f20d5f82fbb0bc89a2652cdbf0aa57f191dd4ea6cd4bf6' + '4ee1daf47c8371a3e17173d85a0dd4a106dacd7899d783ccd97a6f3e0dd1a21f') + +prepare() { + cd FreeCAD + + # Use the fixed version of FindPySide2Tools.cmake + cp -f "$srcdir/FindPySide2Tools.cmake" cMake/FindPySide2Tools.cmake + + # Fix Qt5 version detection + sed -i 's/Qt5Core_VERSION LESS/Qt5Core_VERSION VERSION_LESS/g' \ + cMake/FindPySide2Tools.cmake + + cd src + + # Update swigpyrun.in for Python 3.8 + sed -i 's/interp->modules/PyImport_GetModuleDict()/g' Base/swigpyrun.inl + + # Fix for Qt 5.15 + sed -i 's/\(.*\)include <QPainter>$/&\n\1include <QPainterPath>/' \ + Mod/Image/Gui/OpenGLImageBox.cpp + + # Compansate for the unusual Shiboken versioning scheme + sed -i 's/SHIBOKEN_MICRO_VERSION/0/g' Gui/WidgetFactory.cpp + + # Add missing "std::" qualifiers, sledgehammer style + find . \ + ! -wholename "*/Mod/Sketcher/*" \ + ! -wholename "*/Mod/PartDesign/*" \ + -name "*.cpp" -type f \ + -exec sed -i '1i using namespace std;' {} \; +} + +build() { + # OpenCascade requires that /bin comes before /usr/bin in $PATH + export PATH="/usr/bin:$PATH" + + # Configure with CMake and build with Ninja + mkdir -p build + cd build + cmake ../FreeCAD \ + -D BUILD_QT5=ON \ + -D CMAKE_BUILD_TYPE=Release \ + -D CMAKE_C_FLAGS="$CFLAGS -fPIC -w" \ + -D CMAKE_CXX_FLAGS="$CXXFLAGS -fPIC -w" \ + -D CMAKE_INSTALL_DATADIR="/usr/share/freecad" \ + -D CMAKE_INSTALL_DOCDIR="/usr/share/freecad/doc" \ + -D CMAKE_INSTALL_PREFIX="/usr/lib/freecad" \ + -D FREECAD_USE_EXTERNAL_PIVY=ON \ + -D FREECAD_USE_OCC_VARIANT="Official Version" \ + -D FREECAD_USE_QT_FILEDIALOG=ON \ + -D PYTHON_EXECUTABLE=/usr/bin/python \ + -G Ninja + ninja +} + +package() { + DESTDIR="$pkgdir" ninja -C build install + + # Package MIME info + install -Dm644 freecad.xml "$pkgdir/usr/share/mime/packages/freecad.xml" + + # Package desktop shortcut + desktop-file-install --dir="$pkgdir/usr/share/applications" $pkgname.desktop + + # Package icons + cd FreeCAD/src/Gui/Icons + for i in 16 32 48 64; do + install -Dm644 "freecad-icon-$i.png" "$pkgdir/usr/share/icons/hicolor/${i}x$i/apps/freecad.png" + done + install -Dm644 freecad.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/freecad.svg" + + # Package symlinks in /usr/bin + install -d "$pkgdir/usr/bin" + ln -sf /usr/lib/freecad/bin/FreeCAD "$pkgdir/usr/bin/freecad" + ln -sf /usr/lib/freecad/bin/FreeCAD "$pkgdir/usr/bin/FreeCAD" + ln -sf /usr/lib/freecad/bin/FreeCADCmd "$pkgdir/usr/bin/freecadcmd" + ln -sf /usr/lib/freecad/bin/FreeCADCmd "$pkgdir/usr/bin/FreeCADCmd" +} diff --git a/freecad.desktop b/freecad.desktop new file mode 100644 index 0000000..0ed9c2e --- /dev/null +++ b/freecad.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Version=1.0 +Encoding=UTF-8 +Name=FreeCAD +Comment=General purpose 3D CAD modeler +GenericName=CAD Application +Exec=/usr/bin/freecad %F +Path=/usr/share/freecad +Terminal=false +Type=Application +Icon=freecad +Categories=Application;Science;Math;Education; +StartupNotify=true +MimeType=application/x-extension-fcstd; diff --git a/freecad.xml b/freecad.xml new file mode 100644 index 0000000..d5930fb --- /dev/null +++ b/freecad.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> + <mime-type type="application/x-extension-fcstd"> + <sub-class-of type="application/zip"/> + <comment>FreeCAD document</comment> + <glob pattern="*.fcstd"/> + <icon name="freecad"/> + </mime-type> +</mime-info>