forked from MoganLab/mogan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
1335 lines (1173 loc) · 48.6 KB
/
xmake.lua
File metadata and controls
1335 lines (1173 loc) · 48.6 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-------------------------------------------------------------------------------
--
-- MODULE : xmake.lua
-- DESCRIPTION : Xmake config file for TeXmacs
-- COPYRIGHT : (C) 2022 jingkaimori
-- 2022-2024 Darcy Shen
--
-- This software falls under the GNU general public license version 3 or later.
-- It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
-- in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
includes("xmake/vars.lua")
includes("xmake/stem.lua")
set_project(stem_project_name)
set_policy("run.autobuild", false)
set_languages("c++17")
set_encodings("utf-8")
add_requires("s7", {system=false})
add_requires("tbox", {system=false})
add_requires("cpr", {system=false})
includes("xmake/goldfish.lua")
option("mupdf")
set_default(true)
set_description("Enable MuPDF library")
option_end()
-- Temporary statement to move into MuPDF
set_config("mupdf", true)
-- Adjust community or commercial version
option("is_community")
set_default(true)
set_description("Adjust community or commercial version")
option_end()
set_config("is_community", is_community)
option("debug_with_timestamp")
set_default(true)
set_description("Enable timestamps in debug messages")
option_end()
set_config("debug_with_timestamp", true)
-- Generate build/config.h from template
add_configfiles("src/System/config.h.xmake", {
filename = "config.h",
variables = {
SIZEOF_VOID_P = 8,
VERSION = XMACS_VERSION,
USE_FREETYPE = 1,
USE_ICONV = true,
USE_PLUGIN_GS = true,
USE_PLUGIN_BIBTEX = true,
USE_PLUGIN_LATEX_PREVIEW = true,
USE_PLUGIN_TEX = true,
USE_PLUGIN_ISPELL = true,
USE_PLUGIN_PDF = true,
USE_PLUGIN_SPARKLE = false,
USE_PLUGIN_HTML = true,
OS_MACOS = is_plat("macosx"),
MACOSX_EXTENSIONS = is_plat("macosx"),
QTTEXMACS = true,
SANITY_CHECKS = true,
OS_MINGW = is_plat("mingw"),
OS_GNU_LINUX = is_plat("linux"),
OS_WIN = is_plat("windows"),
OS_WASM = is_plat("wasm"),
NOMINMAX = true,
QTPIPES = true,
USE_QT_PRINTER = true,
TM_DYNAMIC_LINKING = true,
USE_FONTCONFIG = true,
PDFHUMMUS_NO_TIFF = true,
USE_MUPDF_RENDERER = has_config("mupdf"),
IS_COMMUNITY = has_config("is_community"),
DEBUG_WITH_TIMESTAMP = has_config("debug_with_timestamp"),
}
})
-- because this cpp project use variant length arrays which is not supported by
-- msvc, this project will not support windows env.
-- because some package is not ported to cygwin env, this project will not
-- support cygwin env.
set_allowedplats("linux", "macosx", "windows")
if is_plat("windows") then
set_runtimes("MT")
end
if is_plat("linux") then
set_configvar("OS_GNU_LINUX", true)
else
set_configvar("OS_GNU_LINUX", false)
end
if is_plat("macosx") then
set_configvar("OS_MACOS", true)
else
set_configvar("OS_MACOS", false)
end
if is_plat("windows") then
set_configvar("OS_WIN", true)
else
set_configvar("OS_WIN", false)
end
-- add releasedbg, debug and release modes for different platforms.
-- debug mode cannot run on mingw with qt precompiled binary
set_allowedmodes("releasedbg", "release", "debug")
add_rules("mode.releasedbg", "mode.release", "mode.debug")
add_repositories("liii-repo xmake")
TBOX_VERSION= "1.7.5"
LOLLY_VERSION= "1.4.26"
S7_VERSION = "20240816"
package("liii-libaesgm")
set_homepage("https://github.com/xmake-mirror/libaesgm")
set_description("https://repology.org/project/libaesgm/packages")
set_sourcedir(path.join(os.scriptdir(), "3rdparty/libaesgm"))
on_install("linux", "macosx", "windows", "mingw", function (package)
if package:is_plat("windows", "mingw") and package:is_arch("arm", "arm64") then
-- Windows is always little endian
io.replace("brg_endian.h", [[
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN]], [[
#elif 1 /* Edited: Windows ARM is little endian */
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN]], { plain = true })
end
local configs = {}
if package:config("shared") then
configs.kind = "shared"
end
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("aes_init", {includes = "aes.h"}))
end)
package_end()
PDFHUMMUS_VERSION = "4.6.2"
package("liii-pdfhummus")
set_homepage("https://www.pdfhummus.com/")
set_description("High performance library for creating, modiyfing and parsing PDF files in C++ ")
set_license("Apache-2.0")
set_sourcedir(path.join(os.scriptdir(), "3rdparty/pdfhummus"))
add_deps("zlib", "liii-libaesgm")
add_deps("freetype", {configs={png=true}})
add_configs("libtiff", {description = "Supporting tiff image", default = false, type = "boolean"})
add_configs("libjpeg", {description = "Support DCT encoding", default = false, type = "boolean"})
add_configs("libpng", {description = "Support png image", default = false, type = "boolean"})
if is_plat("linux") then
add_syslinks("m")
end
on_load(function (package)
for _, dep in ipairs({"libtiff", "libpng", "libjpeg"}) do
if package:config(dep) then
package:add("deps", dep)
end
end
end)
on_install("linux", "windows", "mingw", "macosx", function (package)
local configs = {}
if package:config("shared") then
configs.kind = "shared"
end
for _, dep in ipairs({"libtiff", "libpng", "libjpeg"}) do
if package:config(dep) then
configs[dep] = true
end
end
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include "PDFWriter/PDFWriter.h"
#include <iostream>
using namespace std;
using namespace PDFHummus;
void test() {
PDFWriter pdfWriter;
pdfWriter.Reset();
}
]]}, {configs = {languages = "c++11"}}))
end)
package_end()
includes("@builtin/check")
configvar_check_cxxtypes("HAVE_INTPTR_T", "intptr_t", {includes = {"memory"}})
configvar_check_cxxincludes("HAVE_INTTYPES_H", "inttypes.h")
configvar_check_cxxincludes("HAVE_STDINT_H", "stdint.h")
function using_apt ()
return linuxos.name() == "debian"
or linuxos.name() == "ubuntu"
or linuxos.name() == "uos"
end
function using_legacy_apt ()
return (linuxos.name() == "uos") or (linuxos.name () == "ubuntu" and linuxos.version():major() == 20)
end
local LIBICONV_VERSION = "1.17"
add_requires("lolly", {system=false})
-- QWK is built locally from 3rdparty/qwindowkitty, no external package needed
if is_plat ("windows") then
add_requires("libiconv "..LIBICONV_VERSION, {system=false})
end
add_requires("libjpeg")
if is_plat("linux") then
add_requires("apt::libpng-dev", {alias="libpng"})
add_requires("apt::libcurl4-openssl-dev", {alias="libcurl"})
end
add_requires("liii-pdfhummus", {system=false,configs={libpng=true,libjpeg=true}})
add_requires("freetype "..FREETYPE_VERSION, {system=false, configs={png=true}})
add_requireconfs("liii-pdfhummus.freetype", {version = FREETYPE_VERSION, system = false, configs={png=true}, override=true})
add_requires("argh v1.3.2")
--- package: qt6widgets
QT6_VERSION="6.8.3"
add_requires("qt6widgets "..QT6_VERSION)
if has_config("mupdf") then
if (linuxos.name() == "debian" and linuxos.version():major() >= CURRENT_DEBIAN_VERSION) or
(linuxos.name() == "ubuntu" and linuxos.version():major() >= CURRENT_UBUNTU_VERSION)
then
add_requires("apt::libmupdf-dev", {alias="mupdf"})
else
add_requires("mupdf", {system=false})
end
end
set_configvar("USE_FREETYPE", 1)
function build_glue_on_config()
on_config(function (target)
import("core.project.depend")
-- use relative path here to avoid import failure on windows
local scheme_path = path.join("src", "Scheme")
local build_glue_path = path.join("src", "Scheme", "Glue")
local build_glue = import("build_glue", {rootdir = build_glue_path})
for _, filepath in ipairs(os.filedirs(path.join(scheme_path, "**/glue_*.lua"))) do
depend.on_changed(function ()
local glue_name = path.basename(filepath)
local glue_dir = path.directory(filepath)
local glue_table = import(glue_name, {rootdir = glue_dir})()
io.writefile(
path.join("$(buildir)/glue", glue_name .. ".cpp"),
build_glue(glue_table, glue_name))
cprint("generating scheme glue %s ... %s", glue_name, "${color.success}${text.success}")
end, {
values = {true},
files = {filepath, path.join(build_glue_path, "build_glue.lua")},
always_changed = false
})
end
os.mkdir(path.join("$(buildir)/glue"))
end)
end
target("libmoebius") do
set_kind ("static")
set_languages("c++17")
set_encodings("utf-8")
set_basename("moebius")
add_includedirs(moe_includedirs)
add_files(moe_files)
add_packages("lolly")
add_packages("s7")
on_install(function (target)
end)
end
target("libqhotkey") do
set_kind("static")
add_rules("qt.static")
add_rules("qt.moc")
add_packages("qt6widgets")
-- 添加平台特定依赖
if is_plat("linux") then
add_packages("x11")
end
-- 添加头文件搜索路径,供依赖此target的模块使用
add_includedirs("3rdparty", {public = true})
-- 通用源文件 - 需要MOC处理的头文件必须作为源文件添加
add_files("3rdparty/qhotkey/qhotkey.cpp")
add_files("3rdparty/qhotkey/qhotkey.h")
add_files("3rdparty/qhotkey/qhotkey_p.h")
add_headerfiles("3rdparty/qhotkey/(qhotkey.h)")
-- 平台特定源文件
if is_plat("macosx") then
add_files("3rdparty/qhotkey/qhotkey_mac.cpp")
elseif is_plat("linux") then
add_files("3rdparty/qhotkey/qhotkey_x11.cpp")
elseif is_plat("windows") then
add_files("3rdparty/qhotkey/qhotkey_win.cpp")
end
on_install(function (target)
end)
end
-- Add options for different features
option("style_agent")
set_default(false)
set_description("Enable Style Agent")
option_end()
option("windows_system_borders")
set_default(false)
set_description("Enable Windows System Borders")
option_end()
target("QWKCore")
-- Add library export define for shared library
set_kind("$(kind)")
if is_kind("shared") then
add_defines("QWK_CORE_LIBRARY")
elseif is_kind("static") then
add_defines("QWK_CORE_STATIC")
end
if is_plat("windows") then
add_cxxflags("/Zc:__cplusplus", "/permissive-")
add_syslinks("mpr", "userenv", "kernel32", "user32", "gdi32", "winspool", "shell32", "ole32", "oleaut32", "uuid", "comdlg32", "advapi32")
else
add_cxxflags("-fPIC", "-fvisibility=hidden", "-fvisibility-inlines-hidden")
end
add_packages("qt6base", "qt6core", "qt6gui", "qt6widgets")
if is_plat("macosx") then
add_mxflags("-fno-objc-arc")
add_frameworks("Foundation", "Cocoa", "AppKit")
add_frameworks("QtCore", "QtGui", "QtWidgets")
end
-- Generate config header before build
before_build(function (target)
-- Create build directories
os.mkdir("$(buildir)/include/QWKCore")
os.mkdir("$(buildir)/include/QWKCore/private")
-- Generate qwkconfig.h
local config_content = [[
#ifndef QWKCONFIG_H
#define QWKCONFIG_H
#define QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT ]] ..
"-1" .. [[
#define QWINDOWKIT_ENABLE_STYLE_AGENT ]] ..
(has_config("style_agent") and "1" or "-1") .. [[
#define QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS ]] ..
(has_config("windows_system_borders") and "1" or "-1") .. [[
#endif // QWKCONFIG_H
]]
local config_path = "$(buildir)/include/QWKCore/qwkconfig.h"
local existing_content = nil
if os.isfile(config_path) then
existing_content = io.readfile(config_path)
end
if existing_content ~= config_content then
io.writefile(config_path, config_content)
end
-- Copy header files without bumping timestamps when unchanged
os.vcp("3rdparty/qwindowkitty/src/core/*.h", "$(buildir)/include/QWKCore/")
os.vcp("3rdparty/qwindowkitty/src/core/*_p.h", "$(buildir)/include/QWKCore/private/")
os.vcp("3rdparty/qwindowkitty/src/core/contexts/*_p.h", "$(buildir)/include/QWKCore/private/")
os.vcp("3rdparty/qwindowkitty/src/core/contexts/*.h", "$(buildir)/include/QWKCore/private/")
os.vcp("3rdparty/qwindowkitty/src/core/kernel/*_p.h", "$(buildir)/include/QWKCore/private/")
os.vcp("3rdparty/qwindowkitty/src/core/shared/*_p.h", "$(buildir)/include/QWKCore/private/")
if has_config("style_agent") then
os.vcp("3rdparty/qwindowkitty/src/core/style/*_p.h", "$(buildir)/include/QWKCore/private/")
os.vcp("3rdparty/qwindowkitty/src/core/style/styleagent.h", "$(buildir)/include/QWKCore/styleagent.h")
end
local private_paths = {}
local qt_package = get_config("qt")
local qt_version = get_config("qt_sdkver")
local modules = {"QtCore", "QtGui"}
for _, module in ipairs(modules) do
local headers_path = ""
if is_plat("macosx") then
headers_path= path.join(qt_package, "lib", module .. ".framework", "Headers")
table.insert(private_paths, path.join(headers_path, qt_version, module, "private"))
table.insert(private_paths, path.join(headers_path, qt_version, module))
table.insert(private_paths, path.join(headers_path, qt_version))
else
headers_path= path.join(qt_package, "include")
table.insert(private_paths, path.join(headers_path, module, qt_version, module, "private"))
table.insert(private_paths, path.join(headers_path, module, qt_version, module))
table.insert(private_paths, path.join(headers_path, module, qt_version))
end
end
if is_plat("windows") then
table.insert(private_paths, path.join(qt_package, "mkspecs", "win32-msvc"))
end
target:add("includedirs", private_paths, {public = true})
end)
-- Include directories
add_includedirs("$(buildir)/include", {public = true})
add_includedirs("3rdparty/qwindowkitty/src/core", "3rdparty/qwindowkitty/src/core/kernel", "3rdparty/qwindowkitty/src/core/shared", "3rdparty/qwindowkitty/src/core/contexts", "3rdparty/qwindowkitty/src")
-- Defines
add_defines("QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT=-1")
if has_config("style_agent") then
add_defines("QWINDOWKIT_ENABLE_STYLE_AGENT=1")
else
add_defines("QWINDOWKIT_ENABLE_STYLE_AGENT=-1")
end
if has_config("windows_system_borders") then
add_defines("QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS=1")
else
add_defines("QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS=-1")
end
-- Enable MOC generation for Qt
add_rules("qt.moc")
-- Core source files
add_files("3rdparty/qwindowkitty/src/core/qwkglobal_p.h")
add_files("3rdparty/qwindowkitty/src/core/qwkglobal.cpp")
add_files("3rdparty/qwindowkitty/src/core/windowagentbase.cpp")
add_files("3rdparty/qwindowkitty/src/core/windowitemdelegate.cpp")
add_files("3rdparty/qwindowkitty/src/core/kernel/nativeeventfilter.cpp")
add_files("3rdparty/qwindowkitty/src/core/kernel/sharedeventfilter.cpp")
add_files("3rdparty/qwindowkitty/src/core/kernel/winidchangeeventfilter.cpp")
add_files("3rdparty/qwindowkitty/src/core/contexts/abstractwindowcontext.cpp")
if has_config("style_agent") then
add_files("3rdparty/qwindowkitty/src/core/style/styleagent.cpp")
add_files("3rdparty/qwindowkitty/src/core/style/styleagent_mac.mm")
end
if is_plat("windows") then
add_files("3rdparty/qwindowkitty/src/core/qwindowkit_windows.h")
add_files("3rdparty/qwindowkitty/src/core/qwindowkit_windows.cpp")
end
-- Add header files that need MOC processing (use add_files for Q_OBJECT headers)
add_files("3rdparty/qwindowkitty/src/core/windowagentbase.h")
add_files("3rdparty/qwindowkitty/src/core/windowagentbase_p.h")
add_files("3rdparty/qwindowkitty/src/core/contexts/abstractwindowcontext_p.h")
if is_plat("macosx") then
add_files("3rdparty/qwindowkitty/src/core/contexts/cocoawindowcontext_p.h")
add_files("3rdparty/qwindowkitty/src/core/contexts/cocoawindowcontext.mm")
end
if is_plat("linux") then
add_files("3rdparty/qwindowkitty/src/core/contexts/qtwindowcontext_p.h")
add_files("3rdparty/qwindowkitty/src/core/contexts/qtwindowcontext.cpp")
end
if is_plat("windows") then
add_files("3rdparty/qwindowkitty/src/core/contexts/win32windowcontext_p.h")
add_files("3rdparty/qwindowkitty/src/core/contexts/win32windowcontext.cpp")
end
if is_plat("windows") then
add_files("3rdparty/qwindowkitty/src/core/shared/qwkwindowsextra_p.h")
add_files("3rdparty/qwindowkitty/src/core/shared/windows10borderhandler_p.h")
add_files("3rdparty/qwindowkitty/src/core/shared/systemwindow_p.h")
end
if has_config("style_agent") then
add_files("3rdparty/qwindowkitty/src/core/style/styleagent.h")
end
-- Set install headers
add_headerfiles("$(buildir)/include/QWKCore/**.h", {prefixdir = "QWKCore"})
add_headerfiles("$(buildir)/include/QWKCore/private/**.h", {prefixdir = "QWKCore/private"})
on_install(function (target)
end)
target_end()
target("QWKWidgets")
set_kind("$(kind)")
-- Add library export define for shared library
if is_kind("shared") then
add_defines("QWK_WIDGETS_LIBRARY")
elseif is_kind("static") then
add_defines("QWK_CORE_STATIC")
add_defines("QWK_WIDGETS_STATIC")
end
if is_plat("windows") then
add_cxxflags("/Zc:__cplusplus", "/permissive-")
else
add_cxxflags("-fPIC", "-fvisibility=hidden", "-fvisibility-inlines-hidden")
end
add_deps("QWKCore")
add_packages("qt6core", "qt6gui", "qt6widgets")
if is_plat("macosx") then
add_mxflags("-fno-objc-arc")
add_frameworks("Foundation", "Cocoa", "AppKit")
add_frameworks("QtCore", "QtGui", "QtWidgets")
end
-- Enable MOC generation for Qt
add_rules("qt.moc")
-- Enable RCC generation for Qt resources used by this target
add_rules("qt.qrc")
-- Generate config header and copy headers before build
before_build(function (target)
os.mkdir("$(buildir)/include/QWKWidgets")
os.mkdir("$(buildir)/include/QWKWidgets/ui/widgetframe")
os.vcp("3rdparty/qwindowkitty/src/widgets/*.h", "$(buildir)/include/QWKWidgets/")
os.vcp("3rdparty/qwindowkitty/src/ui/widgetframe/*.h", "$(buildir)/include/QWKWidgets/ui/widgetframe/")
local private_paths = {}
local qt_package = get_config("qt")
local qt_version = get_config("qt_sdkver")
local modules = {"QtCore", "QtGui"}
for _, module in ipairs(modules) do
local headers_path = ""
if is_plat("macosx") then
headers_path= path.join(qt_package, "lib", module .. ".framework", "Headers")
table.insert(private_paths, path.join(headers_path, qt_version, module, "private"))
table.insert(private_paths, path.join(headers_path, qt_version, module))
table.insert(private_paths, path.join(headers_path, qt_version))
else
headers_path= path.join(qt_package, "include")
table.insert(private_paths, path.join(headers_path, module, qt_version, module, "private"))
table.insert(private_paths, path.join(headers_path, module, qt_version, module))
table.insert(private_paths, path.join(headers_path, module, qt_version))
end
end
if is_plat("windows") then
table.insert(private_paths, path.join(qt_package, "mkspecs", "win32-msvc"))
end
target:add("includedirs", private_paths, {public = true})
end)
-- Include directories
add_includedirs("$(buildir)/include", {public = true})
add_includedirs("3rdparty/qwindowkitty/src/widgets", "3rdparty/qwindowkitty/src")
-- Source files
add_files("3rdparty/qwindowkitty/src/widgets/widgetitemdelegate.cpp")
add_files("3rdparty/qwindowkitty/src/widgets/widgetwindowagent_p.h")
add_files("3rdparty/qwindowkitty/src/widgets/widgetwindowagent.h")
add_files("3rdparty/qwindowkitty/src/widgets/widgetwindowagent.cpp")
add_files("3rdparty/qwindowkitty/src/ui/widgetframe/windowbar.cpp")
add_files("3rdparty/qwindowkitty/src/ui/widgetframe/windowbar.h")
add_files("3rdparty/qwindowkitty/src/ui/widgetframe/windowbar_p.h")
add_files("3rdparty/qwindowkitty/src/ui/widgetframe/windowbutton.cpp")
add_files("3rdparty/qwindowkitty/src/ui/widgetframe/windowbutton.h")
if is_plat("macosx") then
add_files("3rdparty/qwindowkitty/src/widgets/widgetwindowagent_mac.cpp")
end
if is_plat("windows") then
add_files("3rdparty/qwindowkitty/src/widgets/widgetwindowagent_win.cpp")
end
add_files("3rdparty/qwindowkitty/src/styles/styles.qrc")
-- Set install headers
add_headerfiles("$(buildir)/include/QWKWidgets/**.h", {prefixdir = "QWKWidgets"})
on_install(function (target)
end)
target_end()
target("libmogan") do
set_basename("mogan")
local TEXMACS_VERSION = "2.1.4"
local DEVEL_VERSION = TEXMACS_VERSION
local DEVEL_RELEASE = 1
local STABLE_VERSION = TEXMACS_VERSION
local STABLE_RELEASE = 1
set_version(TEXMACS_VERSION)
if is_plat("windows") then
set_runtimes("MT")
add_defines("_USE_MATH_DEFINES")
end
set_languages("c++17")
set_policy("check.auto_ignore_flags", false)
set_encodings("utf-8")
add_deps("libmoebius")
add_deps("libqhotkey")
add_deps("QWKCore", "QWKWidgets")
-- 添加 3rdparty 头文件搜索路径(用于 qhotkey)
add_includedirs("3rdparty", {public = true})
set_policy("check.auto_ignore_flags", false)
add_rules("qt.static")
on_install(function (target)
print("No need to install libmogan")
end)
add_frameworks("QtGui", "QtWidgets", "QtCore", "QtPrintSupport", "QtSvg", "QtNetwork", "QtNetworkAuth")
build_glue_on_config()
set_configvar("QTTEXMACS", 1)
add_defines("QTTEXMACS")
set_configvar("QTPIPES", 1)
add_defines("QTPIPES")
set_configvar("USE_QT_PRINTER", 1)
add_defines("USE_QT_PRINTER")
add_packages("lolly")
add_packages("liii-pdfhummus")
add_packages("freetype")
add_packages("s7")
add_packages("argh")
if not is_plat("macosx") then
add_packages("libiconv")
end
if is_plat("windows") then
add_syslinks("secur32", "shell32", "winhttp", "rpcrt4", {public = true})
elseif is_plat("macosx") then
add_syslinks("iconv")
end
---------------------------------------------------------------------------
-- generate config files. see also:
-- * https://github.com/xmake-io/xmake/issues/320
-- * https://github.com/xmake-io/xmake/issues/342
---------------------------------------------------------------------------
set_configdir("src/System")
-- check for dl library
-- configvar_check_cxxfuncs("TM_DYNAMIC_LINKING","dlopen")
configvar_check_cxxincludes("HAVE_INTTYPES_H", "inttypes.h")
set_configvar("STDC_HEADERS", true)
set_configvar("GS_EXE", "/usr/bin/gs")
set_configvar("PDFHUMMUS_NO_TIFF", true)
add_configfiles(
"src/System/config.h.xmake", {
filename = "config.h",
variables = {
GS_FONTS = "../share/ghostscript/fonts:/usr/share/fonts:",
GS_LIB = "../share/ghostscript/9.06/lib:",
OS_MACOS = is_plat("macosx"),
MACOSX_EXTENSIONS = is_plat("macosx"),
SIZEOF_VOID_P = 8,
USE_ICONV = true,
USE_PLUGIN_GS = true,
USE_PLUGIN_BIBTEX = true,
USE_PLUGIN_LATEX_PREVIEW = true,
USE_PLUGIN_TEX = true,
USE_PLUGIN_ISPELL = true,
USE_PLUGIN_PDF = true,
USE_PLUGIN_SPARKLE = false,
USE_PLUGIN_HTML = true,
USE_MUPDF_RENDERER = has_config("mupdf"),
IS_COMMUNITY = has_config("is_community"),
DEBUG_WITH_TIMESTAMP = has_config("debug_with_timestamp"),
}})
if is_plat("linux") then
set_configvar("CONFIG_OS", "GNU_LINUX")
elseif is_subhost("cygwin") then
set_configvar("CONFIG_OS", "CYGWIN")
else
set_configvar("CONFIG_OS", "")
end
configvar_check_cxxsnippets(
"CONFIG_LARGE_POINTER", [[
#include <stdlib.h>
static_assert(sizeof(void*) == 8, "");]])
add_configfiles(
"src/System/tm_configure.hpp.xmake", {
filename = "tm_configure.hpp",
pattern = "@(.-)@",
variables = {
TEXMACS_VERSION = TEXMACS_VERSION,
XMACS_VERSION = XMACS_VERSION,
CACHE_NAME = stem_lab_big_name,
STEM_NAME = stem_binary_name,
CONFIG_USER = os.getenv("USER") or "unknown",
CONFIG_DATE = os.time(),
CONFIG_STD_SETENV = "#define STD_SETENV",
tm_devel = "Texmacs-" .. DEVEL_VERSION,
tm_devel_release = "Texmacs-" .. DEVEL_VERSION .. "-" .. DEVEL_RELEASE,
tm_stable = "Texmacs-" .. STABLE_VERSION,
tm_stable_release = "Texmacs-" .. STABLE_VERSION .. "-" .. STABLE_RELEASE,
tm_prefix_dir = stem_lab_name,
PDFHUMMUS_VERSION = PDFHUMMUS_VERSION,
LOLLY_VERSION = LOLLY_VERSION,
}})
---------------------------------------------------------------------------
-- add source and header files
---------------------------------------------------------------------------
add_includedirs(moe_includedirs)
add_includedirs({
"src/Data/Convert",
"src/Data/Document",
"src/Data/History",
"src/Data/Observers",
"src/Data/Parser",
"src/Data/String",
"src/Data/Tree",
"src/Edit",
"src/Edit/Editor",
"src/Edit/Interface",
"src/Edit/Modify",
"src/Edit/Process",
"src/Edit/Replace",
"src/Graphics/Bitmap_fonts",
"src/Graphics/Colors",
"src/Graphics/Fonts",
"src/Graphics/Gui",
"src/Graphics/Handwriting",
"src/Graphics/Mathematics",
"src/Graphics/Pictures",
"src/Graphics/Renderer",
"src/Graphics/Spacial",
"src/Graphics/Types",
"src/Kernel/Abstractions",
"src/Kernel/Types",
"src/Plugins",
"src/Plugins/Pdf",
"src/Plugins/Qt",
"src/Plugins/Html",
"src/Scheme",
"src/Scheme/L2",
"src/Scheme/L3",
"src/Scheme/L4",
"src/Scheme/L5",
"src/Scheme/Plugins",
"src/Scheme/S7",
"src/Scheme/Scheme",
"src/System",
"src/System/Boot",
"src/System/Classes",
"src/System/Config",
"src/System/Files",
"src/System/Language",
"src/System/Link",
"src/System/Misc",
"src/Texmacs",
"src/Texmacs/Data",
"src/Typeset",
"src/Typeset/Bridge",
"src/Typeset/Concat",
"src/Typeset/Page",
"TeXmacs/include",
"$(buildir)/glue",
"$(projectdir)/TeXmacs/plugins/goldfish/src/"
}, {public = true})
add_files({
"src/Data/**.cpp",
"src/Edit/**.cpp",
"src/Graphics/**.cpp",
"src/Kernel/**.cpp",
"src/Scheme/Scheme/**.cpp",
"src/Scheme/S7/**.cpp",
"src/Scheme/L2/**.cpp",
"src/Scheme/L3/**.cpp",
"src/Scheme/L4/**.cpp",
"src/Scheme/L5/**.cpp",
"src/Scheme/Plugins/**.cpp",
"src/System/**.cpp",
"src/Texmacs/Data/**.cpp",
"src/Texmacs/Server/**.cpp",
"src/Texmacs/Window/**.cpp",
"src/Typeset/**.cpp",
"src/Plugins/Bibtex/**.cpp",
"src/Plugins/Freetype/**.cpp",
"src/Plugins/Pdf/**.cpp",
"src/Plugins/Ghostscript/**.cpp",
"src/Plugins/Ispell/**.cpp",
"src/Plugins/Metafont/**.cpp",
"src/Plugins/LaTeX_Preview/**.cpp",
"src/Plugins/Openssl/**.cpp",
"src/Plugins/Tex/**.cpp",
"src/Plugins/Xml/**.cpp",
"src/Plugins/Html/**.cpp",
"src/Plugins/Updater/**.cpp",
"$(projectdir)/TeXmacs/plugins/goldfish/src/**.cpp"})
add_files("src/Plugins/Qt/**.cpp", "src/Plugins/Qt/**.hpp")
-- Add Qt resource file
add_rules("qt.qrc")
add_files("TeXmacs/misc/images/images.qrc")
if is_plat("macosx") then
plugin_macos_srcs = {
"$(projectdir)/src/Plugins/MacOS/HIDRemote.m",
"$(projectdir)/src/Plugins/MacOS/mac_spellservice.mm",
"$(projectdir)/src/Plugins/MacOS/mac_utilities.mm",
"$(projectdir)/src/Plugins/MacOS/mac_app.mm"
}
add_includedirs("src/Plugins/MacOS", {public = true})
add_files(plugin_macos_srcs)
end
if is_plat("macosx", "linux", "windows") then
add_includedirs("src/Plugins/QWindowKit", {public = true})
add_files("src/Plugins/QWindowKit/**.cpp")
add_files("src/Plugins/QWindowKit/**.hpp")
end
if has_config("mupdf") then
add_includedirs({
"src/Plugins/MuPDF"
}, {public = true})
add_files({
"src/Plugins/MuPDF/**.cpp"
})
add_packages("mupdf")
end
add_mxflags("-fno-objc-arc")
before_build(function (target)
target:add("forceincludes", path.absolute("src/System/config.h"))
target:add("forceincludes", path.absolute("src/System/tm_configure.hpp"))
end)
end
local stem_files = {
"$(projectdir)/TeXmacs(/doc/**)",
"$(projectdir)/TeXmacs(/langs/**)",
"$(projectdir)/TeXmacs(/misc/**)",
"$(projectdir)/TeXmacs(/packages/**)",
"$(projectdir)/TeXmacs(/progs/**)",
"$(projectdir)/TeXmacs(/styles/**)",
"$(projectdir)/TeXmacs(/texts/**)",
"$(projectdir)/TeXmacs/COPYING", -- copying files are different
"$(projectdir)/TeXmacs/INSTALL",
"$(projectdir)/LICENSE", -- license files are same
"$(projectdir)/TeXmacs/README",
"$(projectdir)/TeXmacs/TEX_FONTS",
"$(projectdir)/TeXmacs(/plugins/**)" -- plugin files
}
if is_plat("windows") then
target("liii_windows_icon") do
set_version(XMACS_VERSION)
set_kind("object")
add_configfiles("$(projectdir)/packages/windows/resource.rc.in", {
filename = "resource.rc"
})
add_configfiles("$(projectdir)/packages/windows/Xmacs.ico", {
onlycopy = true
})
add_files("$(buildir)/resource.rc")
end
end
target("stem") do
add_deps("goldfish")
if is_plat("windows") and is_mode("release") then
add_deps("liii_windows_icon")
end
if is_plat("linux") then
set_filename(stem_binary_linux)
elseif is_plat("macosx") then
set_filename(stem_binary_macos)
else
set_filename(stem_binary_windows)
end
local install_dir = "$(buildir)"
if is_plat("windows") then
install_dir = path.join("$(buildir)", "packages/stem/data/")
elseif is_plat("macosx") then
install_dir = path.join("$(buildir)", "macosx/$(arch)/$(mode)/" .. stem_binary_name .. ".app/Contents/Resources/")
else
if os.getenv("INSTALL_DIR") == nil then
install_dir = path.join("$(buildir)", "packages/stem/")
else
install_dir = os.getenv("INSTALL_DIR")
end
end
set_installdir(install_dir)
if is_plat("windows") then
add_installfiles(stem_files)
else
add_installfiles(stem_files, {prefixdir=stem_prefix_dir})
end
if is_plat("windows") then
add_installfiles("$(projectdir)/TeXmacs(/fonts/**)")
else
add_installfiles("$(projectdir)/TeXmacs(/fonts/**)", {prefixdir=stem_prefix_dir})
end
if is_plat("linux") then
-- add_installfiles("$(projectdir)/TeXmacs/misc/images/text-x-mogan.svg", {prefixdir="share/icons/hicolor/scalable/mimetypes"})
add_installfiles("$(projectdir)/TeXmacs/misc/mime/" .. stem_binary_name .. ".desktop", {prefixdir="share/applications"})
add_installfiles("$(projectdir)/TeXmacs/misc/images/" .. stem_binary_name .. ".png", {prefixdir="share/icons/hicolor/512x512/apps"})
-- add_installfiles("$(projectdir)/TeXmacs/misc/mime/mogan.xml", {prefixdir="share/mime/packages"})
end
-- package metadata
if is_plat("macosx") then
add_installfiles({
"$(projectdir)/packages/macos/stem.icns",
"$(projectdir)/packages/macos/TeXmacs-document.icns",
"$(projectdir)/src/Plugins/Cocoa/(en.lproj/**)",
"$(projectdir)/src/Plugins/Cocoa/(zh-Hans.lproj/**)"
})
end
if is_plat("windows") then
set_optimize("smallest")
set_runtimes("MT")
add_ldflags("/STACK:16777216")
end
if is_mode("debug", "releasedbg") and is_plat("windows") then
add_rules("qt.console")
else
add_rules("qt.widgetapp")
end
add_frameworks("QtGui", "QtWidgets", "QtCore", "QtPrintSupport", "QtSvg", "QtNetwork", "QtNetworkAuth")
add_packages("s7")
add_packages("lolly")
add_deps("libmogan")
if not is_plat("windows") then
add_syslinks("pthread", "dl", "m")
end
if is_plat("linux") then
add_syslinks("X11")
end
add_includedirs(moe_includedirs)
add_files("src/Mogan/Research/research.cpp")
-- install tm files for testing purpose
if is_mode("releasedbg") then
if is_plat("mingw", "windows") then
add_installfiles({
"$(projectdir)/TeXmacs(/tests/tm/*.tm)",
"$(projectdir)/TeXmacs(/tests/tex/*.tex)",
"$(projectdir)/TeXmacs(/tests/bib/*.bib)",
})
else
add_installfiles({
"$(projectdir)/TeXmacs(/tests/*.tm)",
"$(projectdir)/TeXmacs(/tests/*.bib)",
}, {prefixdir=stem_prefix_dir})
end
end
-- deploy necessary dll
if is_plat("windows") then
set_values("qt.deploy.flags", {"-printsupport", "--no-opengl-sw", "--no-translations", "--release"})
end
on_run(function (target)
local name = target:name()
-- path to the binary: for Windows we use the install dir's bin/, otherwise the build artifact
local binary
if is_plat("windows") then
binary = path.join(target:installdir(), "bin", target:filename())
else
binary = target:targetfile()
end
-- Default program parameters (kept to preserve old behaviour)
local params = {"-d", "-debug-bench"}
-- Allow overriding debug-run behavior by setting DEBUG or XMAKE_DEBUGGER env var.