Skip to content

Commit 24ce4f6

Browse files
committed
Weird clang bug-fix
1 parent 98fd4ee commit 24ce4f6

File tree

2 files changed

+163
-4
lines changed

2 files changed

+163
-4
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
From b207fb6c15dc5ebdabe22a9985cb2ecf39daaf9f Mon Sep 17 00:00:00 2001
2+
From: Kreijstal <[email protected]>
3+
Date: Tue, 25 Feb 2025 10:23:52 +0100
4+
Subject: [PATCH] Weird bug where clang requires explicit json definitions
5+
6+
---
7+
common/settings/bom_settings.cpp | 3 +-
8+
common/settings/json_settings.cpp | 1 +
9+
kicad/tools/kicad_manager_control.cpp | 2 +-
10+
kicad/update_manager.cpp | 2 +-
11+
libs/core/include/core/json_serializers.h | 62 ++++++++++++++++++++++-
12+
5 files changed, 65 insertions(+), 5 deletions(-)
13+
14+
diff --git a/common/settings/bom_settings.cpp b/common/settings/bom_settings.cpp
15+
index 69d7fdbe81..8db15dfd97 100644
16+
--- a/common/settings/bom_settings.cpp
17+
+++ b/common/settings/bom_settings.cpp
18+
@@ -17,10 +17,9 @@
19+
* You should have received a copy of the GNU General Public License along
20+
* with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
-
23+
+#include <core/json_serializers.h>
24+
#include <settings/bom_settings.h>
25+
#include <nlohmann/json.hpp>
26+
-#include <core/json_serializers.h>
27+
#include <wx/translation.h>
28+
29+
30+
diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp
31+
index 7d946df47d..159e0e09a5 100644
32+
--- a/common/settings/json_settings.cpp
33+
+++ b/common/settings/json_settings.cpp
34+
@@ -26,6 +26,7 @@
35+
36+
#include <locale_io.h>
37+
#include <gal/color4d.h>
38+
+#include <core/json_serializers.h>
39+
#include <settings/json_settings.h>
40+
#include <settings/json_settings_internals.h>
41+
#include <settings/nested_settings.h>
42+
diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp
43+
index 4401cf82b5..91be5e24a5 100644
44+
--- a/kicad/tools/kicad_manager_control.cpp
45+
+++ b/kicad/tools/kicad_manager_control.cpp
46+
@@ -17,7 +17,7 @@
47+
* You should have received a copy of the GNU General Public License along
48+
* with this program. If not, see <http://www.gnu.org/licenses/>.
49+
*/
50+
-
51+
+#include <core/json_serializers.h>
52+
#include <wildcards_and_files_ext.h>
53+
#include <env_vars.h>
54+
#include <executable_names.h>
55+
diff --git a/kicad/update_manager.cpp b/kicad/update_manager.cpp
56+
index d854a73a75..47556598b0 100644
57+
--- a/kicad/update_manager.cpp
58+
+++ b/kicad/update_manager.cpp
59+
@@ -28,6 +28,7 @@
60+
#include <string>
61+
#include <sstream>
62+
63+
+#include <core/json_serializers.h>
64+
#include "settings/settings_manager.h"
65+
#include "settings/kicad_settings.h"
66+
#include <notifications_manager.h>
67+
@@ -39,7 +40,6 @@
68+
#include <dialogs/dialog_update_notice.h>
69+
70+
#include <nlohmann/json.hpp>
71+
-#include <core/json_serializers.h>
72+
73+
#include <wx/log.h>
74+
#include <wx/event.h>
75+
diff --git a/libs/core/include/core/json_serializers.h b/libs/core/include/core/json_serializers.h
76+
index b5079fc209..285e951c89 100644
77+
--- a/libs/core/include/core/json_serializers.h
78+
+++ b/libs/core/include/core/json_serializers.h
79+
@@ -25,6 +25,7 @@
80+
#define JSON_SERIALIZERS_H_
81+
82+
#include <nlohmann/json.hpp>
83+
+#include <wx/gdicmn.h>
84+
#include <wx/string.h>
85+
#include <optional>
86+
87+
@@ -89,7 +90,66 @@ struct adl_serializer<std::optional<T>>
88+
}
89+
}
90+
};
91+
+
92+
+// Clang-specific stubs for wxPoint, wxSize, wxRect
93+
+#ifdef __clang__
94+
+template <>
95+
+ struct adl_serializer<wxPoint>
96+
+ {
97+
+ static void to_json(json& j, const wxPoint& p)
98+
+ {
99+
+ j["x"] = p.x;
100+
+ j["y"] = p.y;
101+
+ }
102+
+
103+
+ static void from_json(const json& j, wxPoint& p)
104+
+ {
105+
+ j.at("x").get_to(p.x);
106+
+ j.at("y").get_to(p.y);
107+
+ }
108+
+ };
109+
+
110+
+ template <>
111+
+ struct adl_serializer<wxSize>
112+
+ {
113+
+ static void to_json(json& j, const wxSize& s)
114+
+ {
115+
+ j["width"] = s.GetWidth();
116+
+ j["height"] = s.GetHeight();
117+
+ }
118+
+
119+
+ static void from_json(const json& j, wxSize& s)
120+
+ {
121+
+ int w, h;
122+
+ j.at("width").get_to(w);
123+
+ j.at("height").get_to(h);
124+
+ s = wxSize(w, h); // Use constructor
125+
+ }
126+
+ };
127+
+
128+
+ template <>
129+
+ struct adl_serializer<wxRect>
130+
+ {
131+
+ static void to_json(json& j, const wxRect& r)
132+
+ {
133+
+ j["x"] = r.x;
134+
+ j["y"] = r.y;
135+
+ j["width"] = r.width;
136+
+ j["height"] = r.height;
137+
+ }
138+
+
139+
+ static void from_json(const json& j, wxRect& r)
140+
+ {
141+
+ int x, y, w, h;
142+
+ j.at("x").get_to(x);
143+
+ j.at("y").get_to(y);
144+
+ j.at("width").get_to(w);
145+
+ j.at("height").get_to(h);
146+
+ r = wxRect(x, y, w, h); // Use constructor instead of Set
147+
+ }
148+
+ };
149+
+#endif // __clang__
150+
} // namespace nlohmann
151+
152+
153+
-#endif // JSON_SERIALIZERS_H_
154+
\ No newline at end of file
155+
+#endif // JSON_SERIALIZERS_H_
156+
--
157+
2.43.0
158+

mingw-w64-kicad/PKGBUILD

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,24 @@ for _doclang in ${_doc[@]}; do
6666
done
6767
source=(
6868
"https://gitlab.com/kicad/code/kicad/-/archive/${pkgver}/kicad-${pkgver}.tar.bz2"
69-
'001-fix-build-with-fmt-11.patch'
7069
'002-ki-6.0-cmake-fixes-for-MINGW-CLANG.patch'
7170
'003-ki-6.0-code-fixes-for-GNUC-CLANG.patch'
7271
'004-fix-loading-ngspice-dll.patch'
7372
'005-clang-fmt-workaround.patch'
7473
'006-ki-6.0-rewrite-kiwin32_rc_for_clang.patch'
7574
'007-llvm-libcxx-19.patch'
7675
'008-fix-version-header-dependency.patch'
76+
'009-clang-needs-explicit-json-implementations.patch'
7777
)
7878
sha256sums=('628b5fbdf6a4bab5ec5f5fe3e1a314229deb389dc4db87d6637f04899df3f067'
79-
'3c51482f1e452e37e75c06a65996aa5d631a93e82fbef7dd8274ae8ebbd53601'
8079
'2924a86849c02aecd21cded0bd2069353fca33c3364f9b41f9bfdd80e19085cf'
8180
'd8d5f4bdd0aa6d8a907710c523f6f95840636cb2ef69e5275c6ed4966f134353'
8281
'f35a96c2393c21c266dbcd42616df64f9ee13b2423478bf6de029a3ad4e0ee8a'
8382
'bc7ad66d81d56dcfc237dfffe31fff58addff98622f65f64c45df11f70088c37'
8483
'3155b9515ec7c094221441ce337c566c346bf76bb7aa42e86660cfdfb599e307'
8584
'5531acad48988772e4453f42ac749f4001170e4be892d3f224b37e0e606ab5ab'
86-
'2ce8ff7710c64616bdc160cfe7e4079778520c21d2500840dbf74d6f79276727')
85+
'2ce8ff7710c64616bdc160cfe7e4079778520c21d2500840dbf74d6f79276727'
86+
'5cd9f8274757b3d19de3fddd595302a3cf8a3ec5c2e228c14b188a5b90b74070')
8787

8888
# Helper macros to help make tasks easier #
8989
apply_patch_with_msg() {
@@ -104,7 +104,8 @@ prepare() {
104104
005-clang-fmt-workaround.patch \
105105
006-ki-6.0-rewrite-kiwin32_rc_for_clang.patch \
106106
007-llvm-libcxx-19.patch \
107-
008-fix-version-header-dependency.patch
107+
008-fix-version-header-dependency.patch \
108+
009-clang-needs-explicit-json-implementations.patch
108109
}
109110

110111
build() {

0 commit comments

Comments
 (0)