11from build .c import cxxprogram , cxxlibrary , simplerule , clibrary
2- from build .ab import targetof , Rule , Target
2+ from build .ab import simplerule
33from build .pkg import package
4- from build .utils import filenamesmatchingof
54from glob import glob
65from functools import reduce
76import operator
1211 '-DIMHEX_PROJECT_NAME=\\ "fluxengine\\ "' ,
1312 "-DIMHEX_STATIC_LINK_PLUGINS" ,
1413 '-DIMHEX_VERSION=\\ "0.0.0\\ "' ,
15- ' -DLUNASVG_BUILD_STATIC' ,
14+ " -DLUNASVG_BUILD_STATIC" ,
1615 # "-DDEBUG",
1716]
1817if config .osx :
2221else :
2322 cflags = cflags + ["-DOS_LINUX" ]
2423
25- package (name = "freetype2_lib" , package = "freetype2" )
26- package (name = "libcurl_lib" , package = "libcurl" )
27- package (name = "glfw3_lib" , package = "glfw3" )
28- package (name = "md4c_lib" , package = "md4c" )
29- package (name = "magic_lib" , package = "libmagic" )
30- package (name = "nlohmannjson_lib" , package = "nlohmann_json" )
24+ r = simplerule (
25+ name = "glfw-windows-fallback" ,
26+ ins = [],
27+ outs = [
28+ "=glfw-3.4.bin.WIN32/include/GLFW/glfw3.h" ,
29+ "=glfw-3.4.bin.WIN32/include/GLFW/glfw3native.h" ,
30+ "=glfw-3.4.bin.WIN32/lib-mingw-w64/libglfw3.a" ,
31+ ],
32+ commands = [
33+ "curl -Ls https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.bin.WIN32.zip -o $[dir]/glfw.zip" ,
34+ "cd $[dir] && unzip -DD -o -q glfw.zip" ,
35+ ],
36+ label = "CURLLIBRARY" ,
37+ traits = {"clibrary" , "cheaders" },
38+ )
39+ r .args ["caller_cflags" ] = [f"-I{ r .dir } /glfw-3.4.bin.WIN32/include" ]
40+ r .args ["cheader_files" ] = [r ]
41+ r .args ["cheader_deps" ] = [r ]
3142
3243
3344def headers_from (path ):
@@ -43,6 +54,32 @@ def sources_from(path, except_for=[]):
4354 return srcs
4455
4556
57+ package (name = "freetype2_lib" , package = "freetype2" )
58+ package (name = "libcurl_lib" , package = "libcurl" )
59+ package (name = "glfw3_lib" , package = "glfw3" , fallback = ".+glfw-windows-fallback" )
60+
61+ cxxlibrary (
62+ name = "nlohmannjson_lib" ,
63+ srcs = [],
64+ hdrs = headers_from ("dep/nlohmann_json/single_include" ),
65+ )
66+
67+ clibrary (
68+ name = "magic_lib" ,
69+ srcs = sources_from (
70+ "dep/file/src" , except_for = ["dep/file/src/file.c" , "dep/file/src/seccomp.c" ]
71+ ),
72+ hdrs = {"magic.h" : "dep/file/src/magic.h.in" },
73+ )
74+
75+ clibrary (
76+ name = "md4c_lib" ,
77+ srcs = sources_from ("dep/md4c/src" ),
78+ hdrs = {"md4c.h" : "dep/md4c/src/md4c.h" },
79+ )
80+
81+ cxxlibrary (name = "cli11_lib" , srcs = [], hdrs = headers_from ("dep/cli11/include" ))
82+
4683if config .osx :
4784 clibrary (
4885 name = "libnfd" ,
@@ -83,7 +120,7 @@ def sources_from(path, except_for=[]):
83120 name = "lunasvg" ,
84121 srcs = sources_from ("dep/lunasvg/source" ),
85122 hdrs = headers_from ("dep/lunasvg/include" ),
86- deps = [".+plutovg" ],
123+ deps = [".+plutovg" , "+fmt_lib" ],
87124)
88125
89126cxxlibrary (
@@ -111,7 +148,7 @@ def sources_from(path, except_for=[]):
111148 "imgui_freetype.h" : "dep/imhex/lib/third_party/imgui/imgui/include/misc/freetype/imgui_freetype.h" ,
112149 "imconfig.h" : "./imhex_overrides/imconfig.h" ,
113150 },
114- deps = [".+freetype2_lib" , ".+lunasvg" ],
151+ deps = [".+freetype2_lib" , ".+lunasvg" , ".+glfw3_lib" ],
115152)
116153
117154cxxlibrary (name = "libxdgpp" , srcs = [], hdrs = {"xdg.hpp" : "dep/xdgpp/xdg.hpp" })
@@ -138,7 +175,11 @@ def sources_from(path, except_for=[]):
138175 cxxlibrary (
139176 name = "libwolv-io-fs" ,
140177 srcs = ["dep/libwolv/libs/io/source/io/file_win.cpp" ],
141- hdrs = headers_from ("dep/libwolv/libs/io/include" ),
178+ hdrs = (
179+ headers_from ("dep/libwolv/libs/io/include" )
180+ | headers_from ("dep/libwolv/libs/types/include" )
181+ | headers_from ("dep/libwolv/libs/utils/include" )
182+ ),
142183 cflags = cflags ,
143184 )
144185else :
@@ -154,13 +195,17 @@ def sources_from(path, except_for=[]):
154195 srcs = (
155196 [
156197 "dep/libwolv/libs/io/source/io/file.cpp" ,
157- "dep/libwolv/libs/io/source/io/file_unix.cpp" ,
158198 "dep/libwolv/libs/io/source/io/fs.cpp" ,
159199 "dep/libwolv/libs/io/source/io/handle.cpp" ,
160200 "dep/libwolv/libs/math_eval/source/math_eval/math_evaluator.cpp" ,
161201 "dep/libwolv/libs/utils/source/utils/string.cpp" ,
162202 ]
163203 + sources_from ("dep/libwolv/libs/net/source" )
204+ + (
205+ ["dep/libwolv/libs/io/source/io/file_unix.cpp" ]
206+ if config .osx or config .unix
207+ else []
208+ )
164209 ),
165210 hdrs = reduce (
166211 operator .ior ,
@@ -184,7 +229,13 @@ def sources_from(path, except_for=[]):
184229 | headers_from ("dep/pattern-language/generators/include" )
185230 | headers_from ("dep/pattern-language/cli/include" )
186231 ),
187- deps = [".+libthrowingptr" , ".+libwolv" ],
232+ deps = [
233+ ".+libthrowingptr" ,
234+ ".+libwolv" ,
235+ "+fmt_lib" ,
236+ ".+cli11_lib" ,
237+ ".+nlohmannjson_lib" ,
238+ ],
188239)
189240
190241cxxlibrary (name = "hacks" , srcs = [], hdrs = {"jthread.hpp" : "./imhex_overrides/jthread.hpp" })
@@ -205,6 +256,8 @@ def sources_from(path, except_for=[]):
205256 hdrs = headers_from ("dep/imhex/lib/libimhex/include" ),
206257 cflags = cflags ,
207258 )
259+ elif config .windows :
260+ cxxlibrary (name = "libimhex-utils" , srcs = [])
208261elif config .unix :
209262 cxxlibrary (
210263 name = "libimhex-utils" ,
0 commit comments