1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# Maintainer: Kat Crichton-Seager <kat@crichton-seager.com>
pkgname=hopsan
pkgver=2.23.1
pkgrel=1
pkgdesc='Multi-domain system simulation platform for fluid power and mechatronic systems'
arch=('x86_64')
url='https://github.com/Hopsan/hopsan'
license=('Apache-2.0' 'GPL-3.0-or-later')
depends=(
'gcc-libs'
'hicolor-icon-theme'
'qt5-base'
'qt5-svg'
'zeromq'
)
makedepends=(
'cmake'
'cppzmq'
'git'
'patchelf'
'python'
'qt5-tools'
)
optdepends=(
'python: scripting support and component generation'
'qt5-webengine: embedded HTML help browser (dropped from Arch repos; build from AUR if desired)'
)
# The git source is used (rather than a tarball) because several HopsanCore
# dependencies (sundials, libnumhop, indexingcsvparser, DCPLib) are git
# submodules whose content is absent from GitHub archive tarballs.
# Bundled deps (qwt, msgpack-c, discount, etc.) are downloaded and built during
# prepare() via the upstream setup scripts — network access is required at
# build time. zeromq uses the system package instead of a bundled build.
source=(
"git+https://github.com/Hopsan/hopsan.git#tag=v${pkgver}"
)
b2sums=('SKIP')
prepare() {
cd hopsan
# qt5-webengine was dropped from Arch repos and the installed version is
# linked against an older ICU. Strip WebEngine from the build entirely;
# WebviewWrapper.cpp falls back to a QLabel with a link when neither
# USEWEBENGINE nor USEWEBKIT is defined.
sed -i '/QT += webenginewidgets/d; /DEFINES \*= USEWEBENGINE/d' \
HopsanGUI/HopsanGUI.pro
# Populate the submodules needed by HopsanCore and hopsandcp
git submodule update --init \
HopsanCore/dependencies/indexingcsvparser \
HopsanCore/dependencies/libnumhop \
HopsanCore/dependencies/sundials \
dependencies/tools
# GCC 15 no longer implicitly provides stdint types in system headers
sed -i '/#include <memory>/a #include <cstdint>' hopsandcp/include/dcpserver.h
cd dependencies
# Download and unpack bundled dependency sources.
# zeromq/cppzmq are provided as system packages and skipped here.
python3 download-dependencies.py \
asio dcplib discount fmi4c katex libzip msgpack-c qwt tclap xerces
# dcplib defines ipToString() in a header included by multiple TUs — add inline
# to avoid a multiple-definition link error when LTO is active.
# Must run after download-dependencies.py since dcplib-code is downloaded, not a submodule.
sed -i 's/^std::string ipToString(/inline std::string ipToString(/' \
dcplib-code/include/core/dcp/model/pdu/IpToStr.hpp
# Build and install each bundled dependency into its own directory so the
# qmake .pri files can find headers and libs. setupAll.sh is not used
# because it references a non-existent setupFMILibrary.sh.
# Some bundled deps declare cmake_minimum_required < 3.5, which CMake 4.x
# rejects. Patch each setup script to pass the policy minimum flag, and
# remove any stale build dirs so cmake always starts from a clean state.
# cmake 4.x no longer accepts cmake_minimum_required < 3.5
sed -i 's/cmake -Wno-dev/cmake -Wno-dev -DCMAKE_POLICY_VERSION_MINIMUM=3.5/g' setup*.sh
# msgpack-c 3.1.1 tests conflict with system gtest requiring C++17
sed -i 's/\${codedir}/-DMSGPACK_BUILD_TESTS=OFF \${codedir}/' setupMsgpack.sh
# xerces-c 3.2.2 is incompatible with ICU 78 — use gnuiconv transcoder
sed -i 's/cmake -Wno-dev\(.*\) \${codedir}/cmake -Wno-dev\1 -Dtranscoder=gnuiconv \${codedir}/' setupXerces.sh
# discount 2.2.x: GCC 15 made -Wincompatible-pointer-types a hard error
sed -i 's|\./configure\.sh|CFLAGS="-Wno-incompatible-pointer-types" ./configure.sh|' setupDiscount.sh
for dep in asio dcplib discount fmi4c katex libzip msgpack-c qwt tclap xerces; do
rm -rf "${dep}-build"
done
source setHopsanBuildPaths.sh
for script in \
setupAsio \
setupDiscount \
setupFmi4c \
setupKatex \
setupLibzip \
setupMsgpack \
setupQwt \
setupTclap \
setupXerces; do
bash "${script}.sh"
done
}
build() {
cd hopsan
source ./dependencies/setHopsanBuildPaths.sh
mkdir -p builddir
cd builddir
# DESTDIR in the .pro files is $PWD/../bin, so executables land in hopsan/bin/
qmake ../HopsanNG.pro -r -spec linux-g++ CONFIG+=release
make -j"$(nproc)"
}
package() {
local _srcdir="${srcdir}/hopsan"
local _installdir="${pkgdir}/opt/${pkgname}"
install -d "${_installdir}"
# The install script copies compiled binaries, libraries, component libraries,
# documentation, models, and bundled deps into the destination directory.
# It also uses patchelf to strip build-tree runpaths from ELF binaries.
cd "${_srcdir}"
bash packaging/copyInstallHopsan.sh "${_srcdir}" "${_installdir}"
# Symlinks so hopsangui and hopsancli are on PATH
install -d "${pkgdir}/usr/bin"
ln -s "/opt/${pkgname}/bin/hopsangui" "${pkgdir}/usr/bin/hopsangui"
ln -s "/opt/${pkgname}/bin/hopsancli" "${pkgdir}/usr/bin/hopsancli"
# Desktop entry
install -Dm644 packaging/HopsanGUI.desktop \
"${pkgdir}/usr/share/applications/hopsan.desktop"
# Icon — the build places a 128×128 PNG in bin/; expose it to the icon theme
local _icon="${_installdir}/bin/hopsan128x128.png"
if [[ -f "${_icon}" ]]; then
install -Dm644 "${_icon}" \
"${pkgdir}/usr/share/icons/hicolor/128x128/apps/hopsan128x128.png"
fi
# Licenses
install -Dm644 LICENSE-ALv2 "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-ALv2"
install -Dm644 LICENSE-GPLv3 "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-GPLv3"
}
|