-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcompat.opencv.lua
More file actions
3451 lines (2880 loc) · 134 KB
/
Copy pathcompat.opencv.lua
File metadata and controls
3451 lines (2880 loc) · 134 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
-- Auto-generated by tools/compat-opencv/gen_descriptor.py — do not edit by hand.
-- Recipe: OpenCV 5.0.0 built FROM SOURCE by mcpp (no CMake at build
-- time). Scope: core imgproc imgcodecs highgui videoio (+ flann, geometry
-- dependency closure); hermetic profile (all external probes OFF, vendored
-- zlib/libpng/libjpeg-turbo incl. NASM SIMD units, headless highgui,
-- V4L2 + FFmpeg videoio (compat.ffmpeg dependency), WITH_UNIFONT=OFF); SIMD runtime
-- dispatch KEPT (per-ISA glob flags). Sources are the real tarball paths
-- (mcpp >= 0.0.97: obj-path disambiguation #233 + quoted spacey defines
-- #234 made the v1 forwarding-stub layer obsolete); only the libjpeg-turbo
-- BITS_IN_JSAMPLE=12/16 re-compiles and the build-time generators (fonts,
-- OpenCL kernel embeddings) are synthesized on the consumer by the embedded
-- build.mcpp — byte-faithful ports verified against the reference CMake
-- build. Regenerate: sh tools/compat-opencv/gen_config.sh (this repo).
package = {
spec = "1",
namespace = "compat",
name = "compat.opencv",
description = "OpenCV 5.0.0 (core/imgproc/imgcodecs/highgui/videoio incl. FFmpeg backend), full source build with SIMD dispatch",
licenses = {"Apache-2.0"},
repo = "https://github.com/opencv/opencv",
type = "package",
xpm = {
-- linux-x86_64 only for now: the config snapshot is target-specific.
linux = {
["5.0.0"] = {
url = {
GLOBAL = "https://github.com/opencv/opencv/archive/refs/tags/5.0.0.tar.gz",
CN = "https://gitcode.com/mcpp-res/opencv/releases/download/5.0.0/opencv-5.0.0.tar.gz",
},
sha256 = "b0528f5a1d379d59d4701cb28c36e22214cc51cf64594e5b56f2d3e6c0233095",
},
},
},
mcpp = {
language = "c++23", -- upstream min c++17; c++23 spike-validated (457 TU green)
deps = { ["compat.ffmpeg"] = "8.1.2" },
include_dirs = {
"mcpp_generated",
"*",
"*/3rdparty/dlpack/include",
"mcpp_generated/3rdparty/libjpeg-turbo",
"*/3rdparty/libjpeg-turbo/src",
"*/3rdparty/libjpeg-turbo/simd/nasm",
"*/3rdparty/libjpeg-turbo/simd/x86_64",
"mcpp_generated/3rdparty/zlib",
"*/3rdparty/zlib",
"*/modules/core/include",
"mcpp_generated/modules/core",
"*/modules/flann/include",
"mcpp_generated/modules/flann",
"*/modules/geometry/include",
"mcpp_generated/modules/geometry",
"*/modules/imgproc/include",
"mcpp_generated/modules/imgproc",
"*/3rdparty/mlas/inc",
"*/3rdparty/mlas/lib",
"*/modules/dnn/include",
"mcpp_generated/modules/dnn",
"*/modules/dnn/misc/caffe",
"*/modules/dnn/misc/tensorflow",
"*/modules/dnn/misc/onnx",
"*/modules/dnn/misc/tflite",
"*/3rdparty/flatbuffers/include",
"*/3rdparty/protobuf/src",
"*/3rdparty/libpng",
"*/modules/imgcodecs/include",
"mcpp_generated/modules/imgcodecs",
"*/modules/videoio/include",
"mcpp_generated/modules/videoio",
"*/modules/highgui/include",
"mcpp_generated/modules/highgui",
},
cxxflags = { "-msse3", "-w" },
cflags = { "-msse3", "-w" },
flags = {
{ glob = "**/modules/core/**", defines = { "HAVE_STDARG_H=1", "HAVE_UNISTD_H=1", "NDEBUG", "OPENCV_ALLOCATOR_STATS_COUNTER_TYPE=long long", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/modules/dnn/**", defines = { "ENABLE_PLUGINS", "HAVE_FLATBUFFERS=1", "HAVE_MLAS=1", "HAVE_PROTOBUF=1", "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/modules/flann/**", defines = { "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/modules/geometry/**", defines = { "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/modules/highgui/**", defines = { "ENABLE_PLUGINS", "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/modules/imgcodecs/**", defines = { "HAVE_IMGCODEC_HDR", "HAVE_IMGCODEC_PFM", "HAVE_IMGCODEC_PXM", "HAVE_IMGCODEC_SUNRASTER", "HAVE_STDARG_H=1", "HAVE_UNISTD_H=1", "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/modules/imgproc/**", defines = { "HAVE_STDARG_H=1", "HAVE_UNISTD_H=1", "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/3rdparty/libjpeg-turbo/**", defines = { "NDEBUG", "NO_GETENV", "NO_PUTENV" } },
{ glob = "**/tu/jpeg12/**", defines = { "BITS_IN_JSAMPLE=12", "NDEBUG", "NO_GETENV", "NO_PUTENV" } },
{ glob = "**/tu/jpeg16/**", defines = { "BITS_IN_JSAMPLE=16", "NDEBUG", "NO_GETENV", "NO_PUTENV" } },
{ glob = "**/3rdparty/mlas/**", defines = { "BUILD_MLAS_NO_ONNXRUNTIME=1", "MLAS_GEMM_ONLY=1", "MLAS_OPENCV_THREADING=1", "NDEBUG", "_GNU_SOURCE=1", "_USE_MATH_DEFINES", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/tu/mlasgemm/**", defines = { "BUILD_MLAS_NO_ONNXRUNTIME=1", "MLAS_GEMM_ONLY=1", "MLAS_OPENCV_THREADING=1", "NDEBUG", "_USE_MATH_DEFINES", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/3rdparty/libpng/**", defines = { "HAVE_STDARG_H=1", "HAVE_UNISTD_H=1", "NDEBUG", "PNG_INTEL_SSE_OPT=1" } },
{ glob = "**/3rdparty/protobuf/**", defines = { "HAVE_PTHREAD=1", "NDEBUG" } },
{ glob = "**/modules/videoio/**", defines = { "ENABLE_PLUGINS", "HAVE_CAMV4L2", "HAVE_FFMPEG", "HAVE_FFMPEG_LIBAVDEVICE", "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/3rdparty/zlib/**", defines = { "HAVE_STDARG_H=1", "HAVE_UNISTD_H=1", "NDEBUG" } },
{ glob = "**/*.asm", defines = { "ELF", "NO_GETENV", "NO_PUTENV", "PIC", "__CET__", "__x86_64__" } },
{ glob = "**/modules/core/**/*.avx.cpp", defines = { "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx" } },
{ glob = "**/modules/core/**/*.avx2.cpp", defines = { "CV_CPU_COMPILE_AVX2=1", "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_FMA3=1", "CV_CPU_COMPILE_FP16=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX2" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx", "-mf16c", "-mavx2", "-mfma" } },
{ glob = "**/modules/core/**/*.avx512_skx.cpp", defines = { "CV_CPU_COMPILE_AVX2=1", "CV_CPU_COMPILE_AVX512_COMMON=1", "CV_CPU_COMPILE_AVX512_SKX=1", "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_AVX_512F=1", "CV_CPU_COMPILE_FMA3=1", "CV_CPU_COMPILE_FP16=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX512_SKX" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx", "-mf16c", "-mavx2", "-mfma", "-mavx512f", "-mavx512f", "-mavx512cd", "-mavx512f", "-mavx512cd", "-mavx512vl", "-mavx512bw", "-mavx512dq" } },
{ glob = "**/modules/core/**/*.sse4_1.cpp", defines = { "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=SSE4_1" }, cxxflags = { "-mssse3", "-msse4.1" } },
{ glob = "**/modules/core/**/*.sse4_2.cpp", defines = { "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=SSE4_2" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2" } },
{ glob = "**/modules/dnn/**/*.avx.cpp", defines = { "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx" } },
{ glob = "**/modules/dnn/**/*.avx2.cpp", defines = { "CV_CPU_COMPILE_AVX2=1", "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_FMA3=1", "CV_CPU_COMPILE_FP16=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX2" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx", "-mf16c", "-mavx2", "-mfma" } },
{ glob = "**/modules/dnn/**/*.avx512_skx.cpp", defines = { "CV_CPU_COMPILE_AVX2=1", "CV_CPU_COMPILE_AVX512_COMMON=1", "CV_CPU_COMPILE_AVX512_SKX=1", "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_AVX_512F=1", "CV_CPU_COMPILE_FMA3=1", "CV_CPU_COMPILE_FP16=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX512_SKX" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx", "-mf16c", "-mavx2", "-mfma", "-mavx512f", "-mavx512f", "-mavx512cd", "-mavx512f", "-mavx512cd", "-mavx512vl", "-mavx512bw", "-mavx512dq" } },
{ glob = "**/modules/imgproc/**/*.avx.cpp", defines = { "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx" } },
{ glob = "**/modules/imgproc/**/*.avx2.cpp", defines = { "CV_CPU_COMPILE_AVX2=1", "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_FMA3=1", "CV_CPU_COMPILE_FP16=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX2" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx", "-mf16c", "-mavx2", "-mfma" } },
{ glob = "**/modules/imgproc/**/*.avx512_skx.cpp", defines = { "CV_CPU_COMPILE_AVX2=1", "CV_CPU_COMPILE_AVX512_COMMON=1", "CV_CPU_COMPILE_AVX512_SKX=1", "CV_CPU_COMPILE_AVX=1", "CV_CPU_COMPILE_AVX_512F=1", "CV_CPU_COMPILE_FMA3=1", "CV_CPU_COMPILE_FP16=1", "CV_CPU_COMPILE_POPCNT=1", "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSE4_2=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=AVX512_SKX" }, cxxflags = { "-mssse3", "-msse4.1", "-mpopcnt", "-msse4.2", "-mavx", "-mf16c", "-mavx2", "-mfma", "-mavx512f", "-mavx512f", "-mavx512cd", "-mavx512f", "-mavx512cd", "-mavx512vl", "-mavx512bw", "-mavx512dq" } },
{ glob = "**/modules/imgproc/**/*.sse4_1.cpp", defines = { "CV_CPU_COMPILE_SSE4_1=1", "CV_CPU_COMPILE_SSSE3=1", "CV_CPU_DISPATCH_MODE=SSE4_1" }, cxxflags = { "-mssse3", "-msse4.1" } },
{ glob = "**/clsrc/opencl_kernels_core.cpp", defines = { "HAVE_STDARG_H=1", "HAVE_UNISTD_H=1", "NDEBUG", "OPENCV_ALLOCATOR_STATS_COUNTER_TYPE=long long", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/clsrc/opencl_kernels_geometry.cpp", defines = { "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "**/clsrc/opencl_kernels_imgproc.cpp", defines = { "HAVE_STDARG_H=1", "HAVE_UNISTD_H=1", "NDEBUG", "_USE_MATH_DEFINES", "__OPENCV_BUILD=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_LIMIT_MACROS" } },
{ glob = "*/modules/core/src/alloc.cpp", defines = { "HAVE_MALLOC_H=1", "HAVE_MEMALIGN=1", "HAVE_POSIX_MEMALIGN=1" } },
{ glob = "*/modules/core/src/parallel/parallel.cpp", defines = { "PARALLEL_ENABLE_PLUGINS=1" } },
{ glob = "*/modules/core/src/system.cpp", defines = { "HAVE_GETAUXVAL=1" } },
{ glob = "*/3rdparty/mlas/lib/platform.cpp", cxxflags = { "-include", "unistd.h" } },
},
targets = {
opencv = { kind = "lib" },
},
-- `unifont`: Unicode/CJK putText coverage. Pulls the font asset
-- package and defines HAVE_UNIFONT (drawing_text.cpp gates on it);
-- build.mcpp sees MCPP_FEATURE_UNIFONT=1 and hex-embeds the font
-- (builtin_font_uni.h). Not part of the reference profile — the
-- embed machinery is byte-faithful to cmake's ocv_blob2hdr either way.
-- `dnn`: the deep-learning module as an ADDITIVE feature — its
-- sources (309 TUs: modules/dnn + vendored protobuf + mlas incl.
-- .S kernels) join the same lib; HAVE_OPENCV_DNN arrives via the
-- build.mcpp-selected opencv_modules.hpp variant, no extra deps.
features = {
["unifont"] = {
deps = { ["compat.opencv-unifont"] = "1.0.0" },
defines = { "HAVE_UNIFONT" },
},
["dnn"] = {
defines = { "HAVE_OPENCV_DNN" },
sources = {
"*/3rdparty/mlas/lib/*.cpp",
"*/3rdparty/mlas/lib/x86_64/*.S",
"*/3rdparty/protobuf/src/google/protobuf/*.cc",
"*/3rdparty/protobuf/src/google/protobuf/io/*.cc",
"*/3rdparty/protobuf/src/google/protobuf/stubs/*.cc",
"*/modules/dnn/misc/caffe/opencv-caffe.pb.cc",
"*/modules/dnn/misc/onnx/opencv-onnx.pb.cc",
"*/modules/dnn/misc/tensorflow/*.cc",
"*/modules/dnn/src/*.cpp",
"*/modules/dnn/src/caffe/caffe_io.cpp",
"*/modules/dnn/src/int8layers/*.cpp",
"*/modules/dnn/src/layers/*.cpp",
"*/modules/dnn/src/layers/cpu_kernels/*.cpp",
"*/modules/dnn/src/onnx/*.cpp",
"*/modules/dnn/src/tensorflow/*.cpp",
"*/modules/dnn/src/tflite/tflite_importer.cpp",
"*/modules/dnn/src/tokenizer/*.cpp",
"*/modules/dnn/src/vkcom/shader/*.cpp",
"*/modules/dnn/src/vkcom/src/*.cpp",
"*/modules/dnn/src/vkcom/vulkan/*.cpp",
"mcpp_generated/modules/dnn/int8layers/{conv2_int8_kernels.avx2,layers_common.avx2,layers_common.avx512_skx}.cpp",
"mcpp_generated/modules/dnn/layers/{layers_common.avx,layers_common.avx2,layers_common.avx512_skx}.cpp",
"mcpp_generated/modules/dnn/layers/cpu_kernels/{activation_kernels.avx,activation_kernels.avx2,conv2_depthwise.avx,conv2_depthwise.avx2,conv2_kernels.avx,conv2_kernels.avx2,conv_block.avx,conv_block.avx2,conv_depthwise.avx,conv_depthwise.avx2,conv_winograd_f63.avx,conv_winograd_f63.avx2,fast_gemm_kernels.avx,fast_gemm_kernels.avx2,gridsample_kernels.avx,gridsample_kernels.avx2,nary_eltwise_kernels.avx,nary_eltwise_kernels.avx2,reduce2_kernels.avx,reduce2_kernels.avx2,transpose_kernels.avx,transpose_kernels.avx2}.cpp",
"mcpp_generated/mlas_hgemm_stub.cpp",
},
},
},
linux = {
ldflags = { "-lpthread", "-ldl" },
},
sources = {
"*/3rdparty/libjpeg-turbo/simd/x86_64/jsimd.c",
"*/3rdparty/libjpeg-turbo/src/{jaricom,jcapimin,jcapistd,jcarith,jccoefct,jccolor,jcdctmgr,jcdiffct,jchuff,jcicc,jcinit,jclhuff,jclossls,jcmainct,jcmarker,jcmaster,jcomapi,jcparam,jcphuff,jcprepct,jcsample,jctrans,jdapimin,jdapistd,jdarith,jdatadst,jdatasrc,jdcoefct,jdcolor,jddctmgr,jddiffct,jdhuff,jdicc,jdinput,jdlhuff,jdlossls,jdmainct,jdmarker,jdmaster,jdmerge,jdphuff,jdpostct,jdsample,jdtrans,jerror,jfdctflt,jfdctfst,jfdctint,jidctflt,jidctfst,jidctint,jidctred,jmemmgr,jmemnobs,jpeg_nbits,jquant1,jquant2,jutils}.c",
"*/3rdparty/libpng/*.c",
"*/3rdparty/libpng/intel/*.c",
"*/3rdparty/zlib/*.c",
"*/modules/core/src/*.cpp",
"*/modules/core/src/opencl/runtime/*.cpp",
"*/modules/core/src/parallel/*.cpp",
"*/modules/core/src/utils/*.cpp",
"*/modules/flann/src/*.cpp",
"*/modules/geometry/src/*.cpp",
"*/modules/geometry/src/ptcloud/*.cpp",
"*/modules/geometry/src/usac/*.cpp",
"*/modules/highgui/src/{backend,roiSelector,window}.cpp",
"*/modules/imgcodecs/src/*.cpp",
"*/modules/imgproc/src/{accum,accum.dispatch,bilateral_filter.dispatch,blend,box_filter.dispatch,canny,clahe,color,color_hsv.dispatch,color_lab,color_rgb.dispatch,color_yuv.dispatch,colormap,connectedcomponents,contours_approx,contours_common,contours_link,contours_new,contours_truco,corner,corner.avx,cornersubpix,demosaicing,deriv,distransform,drawing,drawing_text,emd_new,filter.dispatch,fisheye,floodfill,gabor,generalized_hough,grabcut,histogram,hough,imgwarp,imgwarp.avx2,imgwarp.sse4_1,lsd,main,median_blur.dispatch,morph.dispatch,phasecorr,phasecorr_iterative,pyramids,resize,resize.avx2,resize.sse4_1,samplers,segmentation,smooth.dispatch,spatialgradient,stackblur,stb_truetype,sumpixels.dispatch,tables,templmatch,thresh,undistort.dispatch,utils}.cpp",
"*/modules/videoio/src/{backend_plugin,backend_static,cap,cap_ffmpeg,cap_images,cap_mjpeg_decoder,cap_mjpeg_encoder,cap_v4l,container_avi,videoio_registry}.cpp",
"mcpp_generated/modules/core/{arithm.avx2,arithm.sse4_1,convert.avx2,convert_scale.avx2,count_non_zero.avx2,has_non_zero.avx2,mathfuncs_core.avx,mathfuncs_core.avx2,matmul.avx2,matmul.avx512_skx,matmul.sse4_1,mean.avx2,merge.avx2,minmax.avx2,minmax.sse4_1,nan_mask.avx2,norm.avx,norm.avx2,norm.sse4_1,reduce.avx2,split.avx2,stat.avx2,stat.sse4_2,sum.avx2,transpose.avx,transpose.avx2}.cpp",
"mcpp_generated/modules/imgproc/{accum.avx,accum.avx2,accum.sse4_1,bilateral_filter.avx2,bilateral_filter.avx512_skx,box_filter.avx2,box_filter.avx512_skx,box_filter.sse4_1,color_hsv.avx2,color_hsv.sse4_1,color_rgb.avx2,color_rgb.sse4_1,color_yuv.avx2,color_yuv.sse4_1,filter.avx2,filter.sse4_1,median_blur.avx2,median_blur.avx512_skx,median_blur.sse4_1,morph.avx2,morph.sse4_1,smooth.avx2,smooth.sse4_1,sumpixels.avx2,sumpixels.avx512_skx,undistort.avx2,warp_kernels.avx2,warp_kernels.sse4_1}.cpp",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jsimdcpu.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm",
"*/3rdparty/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm",
},
generated_files = {
["build.mcpp"] = [==[
// build.mcpp for compat.opencv — consumer-side synthesis of OpenCV's
// build-time generated files from the frozen config snapshot. Embedded into
// pkgs/c/compat.opencv.lua by tools/compat-opencv5/gen_descriptor.py.
//
// What it does (all pure transforms of files already in the pinned tarball —
// nothing is downloaded, nothing depends on the host):
// 1. blob2hdr — modules/imgproc/fonts/*.ttf.gz → builtin_font_{sans,italic}.h
// (hex byte arrays; faithful port of cmake ocv_blob2hdr)
// 2. cl2cpp — modules/<m>/src/opencl/*.cl → opencl_kernels_<m>.{cpp,hpp}
// (comment-strip + string-escape + md5; faithful port of
// cmake/cl2cpp.cmake; content is #ifdef HAVE_OPENCL-guarded
// and inert in this profile, kept byte-faithful anyway)
// 3. tu stubs — ONLY for the libjpeg-turbo BITS_IN_JSAMPLE=12/16
// same-source re-compiles (one .c, three compiles — plain
// sources cannot express that), driven by
// mcpp_generated/tu_manifest.txt. Every other TU is a real
// tarball path in `sources` since mcpp 0.0.97 (#233/#234
// fixed). Stub basenames are group-prefixed so jpeg12 and
// jpeg16 never collide (also dodges mcpp#239).
// The raw `mcpp:` stdout protocol is used (no `import mcpp;`) so this file
// has zero non-standard dependencies.
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <initializer_list>
#include <sstream>
#include <string>
#include <vector>
namespace fs = std::filesystem;
// ── tiny MD5 (RFC 1321, public-domain style condensed implementation) ────
namespace md5impl {
struct MD5 {
uint32_t a0 = 0x67452301, b0 = 0xefcdab89, c0 = 0x98badcfe, d0 = 0x10325476;
static const uint32_t K[64];
static const uint32_t R[64];
void block(const uint8_t* p) {
uint32_t M[16];
for (int i = 0; i < 16; i++)
M[i] = (uint32_t)p[i*4] | ((uint32_t)p[i*4+1] << 8) | ((uint32_t)p[i*4+2] << 16) | ((uint32_t)p[i*4+3] << 24);
uint32_t A = a0, B = b0, C = c0, D = d0;
for (int i = 0; i < 64; i++) {
uint32_t F; int g;
if (i < 16) { F = (B & C) | (~B & D); g = i; }
else if (i < 32) { F = (D & B) | (~D & C); g = (5*i + 1) % 16; }
else if (i < 48) { F = B ^ C ^ D; g = (3*i + 5) % 16; }
else { F = C ^ (B | ~D); g = (7*i) % 16; }
F = F + A + K[i] + M[g];
A = D; D = C; C = B;
B = B + ((F << R[i]) | (F >> (32 - R[i])));
}
a0 += A; b0 += B; c0 += C; d0 += D;
}
static std::string hex(const std::string& data) {
MD5 m;
uint64_t bits = (uint64_t)data.size() * 8;
std::string buf = data;
buf.push_back((char)0x80);
while (buf.size() % 64 != 56) buf.push_back('\0');
for (int i = 0; i < 8; i++) buf.push_back((char)((bits >> (8*i)) & 0xff));
for (size_t o = 0; o < buf.size(); o += 64) m.block((const uint8_t*)buf.data() + o);
char out[33];
uint32_t w[4] = { m.a0, m.b0, m.c0, m.d0 };
for (int i = 0; i < 16; i++)
std::snprintf(out + 2*i, 3, "%02x", (w[i/4] >> (8*(i%4))) & 0xff);
return std::string(out, 32);
}
};
const uint32_t MD5::K[64] = {
0xd76aa478,0xe8c7b756,0x242070db,0xc1bdceee,0xf57c0faf,0x4787c62a,0xa8304613,0xfd469501,
0x698098d8,0x8b44f7af,0xffff5bb1,0x895cd7be,0x6b901122,0xfd987193,0xa679438e,0x49b40821,
0xf61e2562,0xc040b340,0x265e5a51,0xe9b6c7aa,0xd62f105d,0x02441453,0xd8a1e681,0xe7d3fbc8,
0x21e1cde6,0xc33707d6,0xf4d50d87,0x455a14ed,0xa9e3e905,0xfcefa3f8,0x676f02d9,0x8d2a4c8a,
0xfffa3942,0x8771f681,0x6d9d6122,0xfde5380c,0xa4beea44,0x4bdecfa9,0xf6bb4b60,0xbebfbc70,
0x289b7ec6,0xeaa127fa,0xd4ef3085,0x04881d05,0xd9d4d039,0xe6db99e5,0x1fa27cf8,0xc4ac5665,
0xf4292244,0x432aff97,0xab9423a7,0xfc93a039,0x655b59c3,0x8f0ccc92,0xffeff47d,0x85845dd1,
0x6fa87e4f,0xfe2ce6e0,0xa3014314,0x4e0811a1,0xf7537e82,0xbd3af235,0x2ad7d2bb,0xeb86d391 };
const uint32_t MD5::R[64] = {
7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22, 5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,
4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23, 6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21 };
} // namespace md5impl
static std::string slurp(const fs::path& p) {
std::ifstream f(p, std::ios::binary);
if (!f) { std::fprintf(stderr, "compat.opencv build.mcpp: cannot read %s\n", p.string().c_str()); std::exit(1); }
std::ostringstream ss; ss << f.rdbuf(); return ss.str();
}
static void spew(const fs::path& p, const std::string& content) {
fs::create_directories(p.parent_path());
// only rewrite when changed: keeps ninja restat-friendly timestamps
if (fs::exists(p)) {
std::ifstream f(p, std::ios::binary); std::ostringstream ss; ss << f.rdbuf();
if (ss.str() == content) return;
}
std::ofstream f(p, std::ios::binary);
f << content;
if (!f) { std::fprintf(stderr, "compat.opencv build.mcpp: cannot write %s\n", p.string().c_str()); std::exit(1); }
}
// ── gunzip (raw inflate over the vendored zlib? not available here) ─────
// The .ttf.gz blobs are embedded AS-IS: cmake's ocv_blob2hdr hex-dumps the
// *compressed* file bytes (OpenCV decompresses at runtime via its zlib), so
// no inflate is needed here — just a hex dump.
static void blob2hdr(const fs::path& blob, const fs::path& hdr, const std::string& var) {
// byte-faithful port of cmake ocv_blob2hdr: 16 bytes per line, ", "
// separators, the very last ", " trimmed.
std::string data = slurp(blob);
std::ostringstream out;
out << "// Auto generated file.\nstatic const unsigned char " << var << "[] =\n{\n";
char buf[8];
for (size_t i = 0; i < data.size(); i++) {
std::snprintf(buf, sizeof buf, "0x%02x", (unsigned char)data[i]);
out << buf;
if (i + 1 != data.size()) out << ", ";
if (i % 16 == 15 && i + 1 != data.size()) out << "\n";
}
out << "\n};\n";
spew(hdr, out.str());
}
// ── cl2cpp (faithful port of cmake/cl2cpp.cmake) ────────────────────────
static std::string cl_escape(std::string lines) {
std::string t;
// \r removal + trailing \n + tabs→2 spaces
for (char c : lines) if (c != '\r') t.push_back(c);
t.push_back('\n');
std::string u;
for (char c : t) { if (c == '\t') u += " "; else u.push_back(c); }
// strip /* */ comments (non-greedy scan)
std::string v; v.reserve(u.size());
for (size_t i = 0; i < u.size();) {
if (i + 1 < u.size() && u[i] == '/' && u[i+1] == '*') {
size_t e = u.find("*/", i + 2);
i = (e == std::string::npos) ? u.size() : e + 2;
} else v.push_back(u[i++]);
}
// strip // comments (with leading spaces)
std::string w; w.reserve(v.size());
for (size_t i = 0; i < v.size();) {
if (i + 1 < v.size() && v[i] == '/' && v[i+1] == '/') {
while (!w.empty() && w.back() == ' ') w.pop_back();
size_t e = v.find('\n', i);
i = (e == std::string::npos) ? v.size() : e; // keep the newline
} else w.push_back(v[i++]);
}
// collapse empty lines + leading whitespace per line
std::string x; x.reserve(w.size());
for (size_t i = 0; i < w.size();) {
if (w[i] == '\n') {
x.push_back('\n');
size_t j = i + 1;
while (j < w.size() && (w[j] == ' ' || w[j] == '\n')) {
if (w[j] == '\n') { i = j; }
j++;
}
// re-scan: skip spaces directly after newline, and fold newline runs
size_t k = i + 1;
while (k < w.size() && w[k] == ' ') k++;
while (k < w.size() && w[k] == '\n') { k++; i = k - 1;
while (k < w.size() && w[k] == ' ') k++; }
i = k;
} else x.push_back(w[i++]);
}
if (!x.empty() && x.front() == '\n') x.erase(0, 1);
// escape backslash, quote; newline → \n" <newline> "
std::string y;
for (char c : x) {
if (c == '\\') y += "\\\\";
else if (c == '"') y += "\\\"";
else if (c == '\n') y += "\\n\"\n\"";
else y.push_back(c);
}
// drop unneeded trailing quote opener
if (y.size() >= 1 && y.back() == '"') y.pop_back();
return y;
}
static void cl2cpp(const fs::path& cl_dir, const fs::path& out_cpp, const fs::path& out_hpp,
const std::string& module_name) {
std::vector<fs::path> cls;
for (auto& e : fs::directory_iterator(cl_dir))
if (e.path().extension() == ".cl") cls.push_back(e.path());
std::sort(cls.begin(), cls.end());
std::string ns = module_name;
if (!ns.empty() && ns[0] >= '0' && ns[0] <= '9') ns = "_" + ns;
std::ostringstream cpp, hpp;
cpp << "// This file is auto-generated. Do not edit!\n\n#include \"opencv2/core.hpp\"\n"
<< "#include \"cvconfig.h\"\n#include \"" << out_hpp.filename().string() << "\"\n\n"
<< "#ifdef HAVE_OPENCL\n\nnamespace cv\n{\nnamespace ocl\n{\nnamespace " << ns
<< "\n{\n\nstatic const char* const moduleName = \"" << module_name << "\";\n\n";
hpp << "// This file is auto-generated. Do not edit!\n\n#include \"opencv2/core/ocl.hpp\"\n"
<< "#include \"opencv2/core/ocl_genbase.hpp\"\n#include \"opencv2/core/opencl/ocl_defs.hpp\"\n\n"
<< "#ifdef HAVE_OPENCL\n\nnamespace cv\n{\nnamespace ocl\n{\nnamespace " << ns << "\n{\n\n";
for (auto& cl : cls) {
std::string name = cl.stem().string();
std::string body = cl_escape(slurp(cl));
std::string hash = md5impl::MD5::hex(body);
cpp << "struct cv::ocl::internal::ProgramEntry " << name << "_oclsrc={moduleName, \"" << name
<< "\",\n\"" << body << ", \"" << hash << "\", NULL};\n";
hpp << "extern struct cv::ocl::internal::ProgramEntry " << name << "_oclsrc;\n";
}
cpp << "\n}}}\n#endif\n";
hpp << "\n}}}\n#endif\n";
spew(out_cpp, cpp.str());
spew(out_hpp, hpp.str());
}
int main() {
const char* man_env = std::getenv("MCPP_MANIFEST_DIR");
const char* out_env = std::getenv("MCPP_OUT_DIR");
fs::path man = man_env ? man_env : ".";
if (!out_env) { std::fprintf(stderr, "compat.opencv build.mcpp: MCPP_OUT_DIR unset (mcpp >= 0.0.95 required)\n"); return 1; }
fs::path out = out_env;
fs::path gen = man / "mcpp_generated";
// the extracted official tarball wrap dir (opencv-<version>/)
fs::path wrap;
for (auto& e : fs::directory_iterator(man)) {
if (e.is_directory() && e.path().filename().string().rfind("opencv-", 0) == 0
&& fs::exists(e.path() / "modules")) { wrap = e.path(); break; }
}
if (wrap.empty()) { std::fprintf(stderr, "compat.opencv build.mcpp: opencv-* source dir not found under %s\n", man.string().c_str()); return 1; }
// 1. fonts
blob2hdr(wrap / "modules/imgproc/fonts/Rubik.ttf.gz", out / "builtin_font_sans.h", "OcvBuiltinFontSans");
blob2hdr(wrap / "modules/imgproc/fonts/Rubik-Italic.ttf.gz", out / "builtin_font_italic.h", "OcvBuiltinFontItalic");
// 1b. unifont feature: hex-embed the CJK font pulled in by the
// compat.opencv-unifont dependency. Its raw .gz payload is parked by
// the installer in a shared runtimedir whose location relative to any
// one package shifted across xlings store layouts (0.4.62 -> 0.4.67,
// mcpp 0.0.99), which is why a fixed `<data>/xpkgs/<pkg>/<ver> ->
// <data>/runtimedir` hop broke. Anchor instead on the authoritative
// per-dep dir contract (mcpp#241: MCPP_DEP_<NAME>_DIR, emitted under
// both the canonical name and the namespace-stripped short name) and
// walk up probing runtimedir/ at every level; fall back to this
// package's own store location + a bounded search so older mcpp
// (pre-#241) and future layout shifts still resolve.
if (std::getenv("MCPP_FEATURE_UNIFONT")) {
const char* fname = "WenQuanYiMicroHei.ttf.gz";
fs::path font;
std::error_code ec;
auto probe = [&](const fs::path& base) -> fs::path {
if (base.empty()) return {};
for (const fs::path& c : { base / fname,
base / "runtimedir" / fname,
base / "data" / "runtimedir" / fname })
if (fs::exists(c)) return c;
return {};
};
std::vector<fs::path> anchors;
if (const char* d = std::getenv("MCPP_DEP_COMPAT_OPENCV_UNIFONT_DIR")) anchors.emplace_back(d);
if (const char* d = std::getenv("MCPP_DEP_OPENCV_UNIFONT_DIR")) anchors.emplace_back(d);
anchors.push_back(man);
if (const char* d = std::getenv("MCPP_OUT_DIR")) anchors.emplace_back(d);
// walk up from each anchor, probing runtimedir/ at every level
for (const auto& a : anchors) {
for (fs::path p = a; !p.empty(); p = p.parent_path()) {
if (auto hit = probe(p); !hit.empty()) { font = hit; break; }
if (p == p.root_path()) break;
}
if (!font.empty()) break;
}
// fallback: sweep any opencv-unifont verdir near this package's store dir
if (font.empty()) {
for (auto& e : fs::directory_iterator(man.parent_path().parent_path(), ec)) {
if (e.path().filename().string().find("opencv-unifont") == std::string::npos) continue;
for (auto& v : fs::recursive_directory_iterator(e.path(), ec))
if (v.path().filename() == fname) { font = v.path(); break; }
if (!font.empty()) break;
}
}
// last resort: bounded recursive search from the nearest store root
if (font.empty()) {
for (const auto& a : anchors) {
fs::path root = a;
for (int up = 0; up < 8 && root.has_parent_path(); ++up) {
if (fs::exists(root / "runtimedir") || fs::exists(root / "xpkgs")
|| root.filename() == "data") break;
root = root.parent_path();
}
long budget = 400000;
for (auto it = fs::recursive_directory_iterator(root,
fs::directory_options::skip_permission_denied, ec);
it != fs::recursive_directory_iterator() && budget-- > 0; it.increment(ec)) {
if (ec) { ec.clear(); continue; }
if (it->path().filename() == fname) { font = it->path(); break; }
}
if (!font.empty()) break;
}
}
if (font.empty()) {
const char* e1 = std::getenv("MCPP_DEP_COMPAT_OPENCV_UNIFONT_DIR");
const char* e2 = std::getenv("MCPP_DEP_OPENCV_UNIFONT_DIR");
const char* e3 = std::getenv("MCPP_OUT_DIR");
std::fprintf(stderr, "compat.opencv build.mcpp: unifont feature on but %s not found.\n"
" MCPP_MANIFEST_DIR=%s\n MCPP_DEP_COMPAT_OPENCV_UNIFONT_DIR=%s\n"
" MCPP_DEP_OPENCV_UNIFONT_DIR=%s\n MCPP_OUT_DIR=%s\n",
fname, man.string().c_str(),
e1 ? e1 : "(unset)", e2 ? e2 : "(unset)", e3 ? e3 : "(unset)");
return 1;
}
blob2hdr(font, out / "builtin_font_uni.h", "OcvBuiltinFontUni");
std::printf("compat.opencv build.mcpp: unifont embedded from %s\n", font.string().c_str());
}
// 2. OpenCL kernel embeddings (inert under this profile, byte-faithful)
for (std::string m : { "core", "imgproc", "geometry" }) {
fs::path cl_dir = wrap / "modules" / m / "src" / "opencl";
if (fs::exists(cl_dir))
cl2cpp(cl_dir, out / ("clsrc/opencl_kernels_" + m + ".cpp"),
out / ("opencl_kernels_" + m + ".hpp"), m);
}
// 3. jpeg12/jpeg16 re-compile stubs from the manifest
// line grammar: [?<feature><TAB>]<group><TAB><include-target>
// (group-prefixed filename => unique basenames across groups; a
// leading ?<feature> guard skips the stub unless MCPP_FEATURE_<F>=1)
std::ifstream mf(gen / "tu_manifest.txt");
if (!mf) { std::fprintf(stderr, "compat.opencv build.mcpp: mcpp_generated/tu_manifest.txt missing\n"); return 1; }
std::string line;
int stubs = 0;
while (std::getline(mf, line)) {
if (line.empty() || line[0] == '#') continue;
if (line[0] == '?') {
size_t g = line.find('\t');
if (g == std::string::npos) continue;
std::string feat = line.substr(1, g - 1);
for (char& c : feat) c = (c >= 'a' && c <= 'z') ? char(c - 32) : c;
if (!std::getenv(("MCPP_FEATURE_" + feat).c_str())) continue;
line = line.substr(g + 1);
}
size_t t = line.find('\t');
if (t == std::string::npos) continue;
std::string grp = line.substr(0, t);
std::string target = line.substr(t + 1);
std::string mangled = grp + "_" + target;
for (char& c : mangled) if (c == '/') c = '_';
fs::path stub = out / "tu" / grp / mangled;
std::string content = "/* compat.opencv " + grp + " re-compile TU */\n"
"#include \"" + target + "\"\n";
spew(stub, content);
std::printf("mcpp:generated=%s\n", stub.string().c_str());
stubs++;
}
// out/ carries builtin_font_*.h, opencl_kernels_*.hpp, clsrc/ includes
std::printf("mcpp:cxxflag=-I%s\n", out.string().c_str());
std::printf("mcpp:cflag=-I%s\n", out.string().c_str());
std::printf("mcpp:rerun-if-changed=%s\n", (gen / "tu_manifest.txt").string().c_str());
// diagnostics as a non-directive stdout line: stderr writes can interleave
// into the (buffered) stdout directive stream and corrupt a directive.
std::printf("compat.opencv build.mcpp: %d jpeg12/16 stubs, fonts + CL kernels synthesized\n", stubs);
std::fflush(stdout);
return 0;
}
]==],
["mcpp_generated/tu_manifest.txt"] = [==[
jpeg12 3rdparty/libjpeg-turbo/src/jcapistd.c
jpeg12 3rdparty/libjpeg-turbo/src/jccolor.c
jpeg12 3rdparty/libjpeg-turbo/src/jcdiffct.c
jpeg12 3rdparty/libjpeg-turbo/src/jclossls.c
jpeg12 3rdparty/libjpeg-turbo/src/jcmainct.c
jpeg12 3rdparty/libjpeg-turbo/src/jcprepct.c
jpeg12 3rdparty/libjpeg-turbo/src/jcsample.c
jpeg12 3rdparty/libjpeg-turbo/src/jdapistd.c
jpeg12 3rdparty/libjpeg-turbo/src/jdcolor.c
jpeg12 3rdparty/libjpeg-turbo/src/jddiffct.c
jpeg12 3rdparty/libjpeg-turbo/src/jdlossls.c
jpeg12 3rdparty/libjpeg-turbo/src/jdmainct.c
jpeg12 3rdparty/libjpeg-turbo/src/jdpostct.c
jpeg12 3rdparty/libjpeg-turbo/src/jdsample.c
jpeg12 3rdparty/libjpeg-turbo/src/jutils.c
jpeg12 3rdparty/libjpeg-turbo/src/jccoefct.c
jpeg12 3rdparty/libjpeg-turbo/src/jcdctmgr.c
jpeg12 3rdparty/libjpeg-turbo/src/jdcoefct.c
jpeg12 3rdparty/libjpeg-turbo/src/jddctmgr.c
jpeg12 3rdparty/libjpeg-turbo/src/jdmerge.c
jpeg12 3rdparty/libjpeg-turbo/src/jfdctfst.c
jpeg12 3rdparty/libjpeg-turbo/src/jfdctint.c
jpeg12 3rdparty/libjpeg-turbo/src/jidctflt.c
jpeg12 3rdparty/libjpeg-turbo/src/jidctfst.c
jpeg12 3rdparty/libjpeg-turbo/src/jidctint.c
jpeg12 3rdparty/libjpeg-turbo/src/jidctred.c
jpeg12 3rdparty/libjpeg-turbo/src/jquant1.c
jpeg12 3rdparty/libjpeg-turbo/src/jquant2.c
jpeg16 3rdparty/libjpeg-turbo/src/jcapistd.c
jpeg16 3rdparty/libjpeg-turbo/src/jccolor.c
jpeg16 3rdparty/libjpeg-turbo/src/jcdiffct.c
jpeg16 3rdparty/libjpeg-turbo/src/jclossls.c
jpeg16 3rdparty/libjpeg-turbo/src/jcmainct.c
jpeg16 3rdparty/libjpeg-turbo/src/jcprepct.c
jpeg16 3rdparty/libjpeg-turbo/src/jcsample.c
jpeg16 3rdparty/libjpeg-turbo/src/jdapistd.c
jpeg16 3rdparty/libjpeg-turbo/src/jdcolor.c
jpeg16 3rdparty/libjpeg-turbo/src/jddiffct.c
jpeg16 3rdparty/libjpeg-turbo/src/jdlossls.c
jpeg16 3rdparty/libjpeg-turbo/src/jdmainct.c
jpeg16 3rdparty/libjpeg-turbo/src/jdpostct.c
jpeg16 3rdparty/libjpeg-turbo/src/jdsample.c
jpeg16 3rdparty/libjpeg-turbo/src/jutils.c
?dnn mlasgemm modules/dnn/src/layers/cpu_kernels/mlas_threading.cpp
]==],
["mcpp_generated/3rdparty/libjpeg-turbo/jconfig.h"] = [==[
/* Version ID for the JPEG library.
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
*/
#define JPEG_LIB_VERSION 70
/* libjpeg-turbo version */
#define LIBJPEG_TURBO_VERSION 3.1.2
/* libjpeg-turbo version in integer form */
#define LIBJPEG_TURBO_VERSION_NUMBER 3001002
/* Support arithmetic encoding when using 8-bit samples */
#define C_ARITH_CODING_SUPPORTED 1
/* Support arithmetic decoding when using 8-bit samples */
#define D_ARITH_CODING_SUPPORTED 1
/* Support in-memory source/destination managers */
#define MEM_SRCDST_SUPPORTED 1
/* Use accelerated SIMD routines when using 8-bit samples */
#define WITH_SIMD 1
/* This version of libjpeg-turbo supports run-time selection of data precision,
* so BITS_IN_JSAMPLE is no longer used to specify the data precision at build
* time. However, some downstream software expects the macro to be defined.
* Since 12-bit data precision is an opt-in feature that requires explicitly
* calling 12-bit-specific libjpeg API functions and using 12-bit-specific data
* types, the unmodified portion of the libjpeg API still behaves as if it were
* built for 8-bit precision, and JSAMPLE is still literally an 8-bit data
* type. Thus, it is correct to define BITS_IN_JSAMPLE to 8 here.
*/
#ifndef BITS_IN_JSAMPLE
#define BITS_IN_JSAMPLE 8
#endif
#ifdef _WIN32
#undef RIGHT_SHIFT_IS_UNSIGNED
/* Define "boolean" as unsigned char, not int, per Windows custom */
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
/* Define "INT32" as int, not long, per Windows custom */
#if !(defined(_BASETSD_H_) || defined(_BASETSD_H)) /* don't conflict if basetsd.h already read */
typedef short INT16;
typedef signed int INT32;
#endif
#define XMD_H /* prevent jmorecfg.h from redefining it */
#else
/* Define if your (broken) compiler shifts signed values as if they were
unsigned. */
/* #undef RIGHT_SHIFT_IS_UNSIGNED */
#endif
]==],
["mcpp_generated/3rdparty/libjpeg-turbo/jconfigint.h"] = [==[
/* libjpeg-turbo build number */
#define BUILD "opencv-5.0.0-libjpeg-turbo"
/* How to hide global symbols. */
#define HIDDEN
/* Compiler's inline keyword */
#undef inline
/* How to obtain function inlining. */
#define INLINE
/* How to obtain thread-local storage */
#define THREAD_LOCAL
/* Define to the full name of this package. */
#define PACKAGE_NAME "OpenCV"
/* Version number of package */
#define VERSION "3.1.2"
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 8
/* Define if your compiler has __builtin_ctzl() and sizeof(unsigned long) == sizeof(size_t). */
/* #undef HAVE_BUILTIN_CTZL */
/* Define to 1 if you have the <intrin.h> header file. */
/* #undef HAVE_INTRIN_H */
#if defined(_MSC_VER) && defined(HAVE_INTRIN_H)
#if (SIZEOF_SIZE_T == 8)
#define HAVE_BITSCANFORWARD64
#elif (SIZEOF_SIZE_T == 4)
#define HAVE_BITSCANFORWARD
#endif
#endif
#if defined(__has_attribute)
#if __has_attribute(fallthrough)
#define FALLTHROUGH __attribute__((fallthrough));
#else
#define FALLTHROUGH
#endif
#else
#define FALLTHROUGH
#endif
/*
* Define BITS_IN_JSAMPLE as either
* 8 for 8-bit sample values (the usual setting)
* 12 for 12-bit sample values
* Only 8 and 12 are legal data precisions for lossy JPEG according to the
* JPEG standard, and the IJG code does not support anything else!
*/
#ifndef BITS_IN_JSAMPLE
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
#endif
#undef C_ARITH_CODING_SUPPORTED
#undef D_ARITH_CODING_SUPPORTED
#undef WITH_SIMD
#if BITS_IN_JSAMPLE == 8
/* Support arithmetic encoding */
#define C_ARITH_CODING_SUPPORTED 1
/* Support arithmetic decoding */
#define D_ARITH_CODING_SUPPORTED 1
/* Use accelerated SIMD routines. */
#define WITH_SIMD 1
#endif
]==],
["mcpp_generated/3rdparty/libjpeg-turbo/jversion.h"] = [==[
/*
* jversion.h
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2010, 2012-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains software version identification.
*/
#if JPEG_LIB_VERSION >= 80
#define JVERSION "8d 15-Jan-2012"
#elif JPEG_LIB_VERSION >= 70
#define JVERSION "7 27-Jun-2009"
#else
#define JVERSION "6b 27-Mar-1998"
#endif
/*
* NOTE: It is our convention to place the authors in the following order:
* - libjpeg-turbo authors (2009-) in descending order of the date of their
* most recent contribution to the project, then in ascending order of the
* date of their first contribution to the project, then in alphabetical
* order
* - Upstream authors in descending order of the date of the first inclusion of
* their code
*/
#define JCOPYRIGHT1 \
"Copyright (C) 2009-2024 D. R. Commander\n" \
"Copyright (C) 2015, 2020 Google, Inc.\n" \
"Copyright (C) 2019-2020 Arm Limited\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
"Copyright (C) 2015 Intel Corporation\n"
#define JCOPYRIGHT2 \
"Copyright (C) 2013-2014 Linaro Limited\n" \
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
"Copyright (C) 1999 Ken Murchison\n" \
"Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding\n"
#define JCOPYRIGHT_SHORT \
"Copyright (C) 1991-2025 The libjpeg-turbo Project and many others"
]==],
["mcpp_generated/3rdparty/zlib/zconf.h"] = [==[
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#ifndef ZCONF_H
#define ZCONF_H
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
* Even better than compiling with -DZ_PREFIX would be to use configure to set
* this permanently in zconf.h using "./configure --zprefix".
*/
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
/* all linked symbols and init macros */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
# define _tr_flush_bits z__tr_flush_bits
# define _tr_flush_block z__tr_flush_block
# define _tr_init z__tr_init
# define _tr_stored_block z__tr_stored_block
# define _tr_tally z__tr_tally
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
# define adler32_z z_adler32_z
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
# define compress_z z_compress_z
# define compress2_z z_compress2_z
# define compressBound z_compressBound
# define compressBound_z z_compressBound_z
# endif
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
# define crc32_combine_gen z_crc32_combine_gen
# define crc32_combine_gen64 z_crc32_combine_gen64
# define crc32_combine_op z_crc32_combine_op
# define crc32_z z_crc32_z
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateBound_z z_deflateBound_z
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
# define deflateGetDictionary z_deflateGetDictionary
# define deflateInit z_deflateInit
# define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
# define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset
# define deflateResetKeep z_deflateResetKeep
# define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune
# define deflateUsed z_deflateUsed
# define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table
# ifndef Z_SOLO
# define gz_error z_gz_error
# define gz_intmax z_gz_intmax
# define gz_strwinerror z_gz_strwinerror
# define gzbuffer z_gzbuffer
# define gzclearerr z_gzclearerr
# define gzclose z_gzclose
# define gzclose_r z_gzclose_r
# define gzclose_w z_gzclose_w
# define gzdirect z_gzdirect
# define gzdopen z_gzdopen
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
# define gzfread z_gzfread
# define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
# define gzoffset z_gzoffset
# define gzoffset64 z_gzoffset64
# define gzopen z_gzopen
# define gzopen64 z_gzopen64
# ifdef _WIN32
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
# define gzrewind z_gzrewind
# define gzseek z_gzseek
# define gzseek64 z_gzseek64
# define gzsetparams z_gzsetparams
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
# define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
# define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_
# define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
# define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader
# define inflateInit z_inflateInit
# define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
# define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
# define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# define inflate_fixed z_inflate_fixed
# ifndef Z_SOLO
# define uncompress z_uncompress
# define uncompress2 z_uncompress2
# define uncompress_z z_uncompress_z
# define uncompress2_z z_uncompress2_z
# endif
# define zError z_zError
# ifndef Z_SOLO
# define zcalloc z_zcalloc
# define zcfree z_zcfree
# endif
# define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion
/* all zlib typedefs in zlib.h and zconf.h */
# define Byte z_Byte
# define Bytef z_Bytef
# define alloc_func z_alloc_func
# define charf z_charf
# define free_func z_free_func
# ifndef Z_SOLO
# define gzFile z_gzFile
# endif
# define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# define in_func z_in_func
# define intf z_intf
# define out_func z_out_func
# define uInt z_uInt
# define uIntf z_uIntf
# define uLong z_uLong
# define uLongf z_uLongf
# define voidp z_voidp
# define voidpc z_voidpc
# define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s
# define internal_state z_internal_state
#endif
#if defined(__MSDOS__) && !defined(MSDOS)