-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_cmd_app.bat
More file actions
1045 lines (892 loc) · 35.3 KB
/
Copy pathbuild_cmd_app.bat
File metadata and controls
1045 lines (892 loc) · 35.3 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
@rem set VSCMD_DEBUG=2
call :DetectVsPath VisualStudioCmd
call :DetectProgramDir ProgramDir
call :DetectQtDir QtEnvBat QtMsvcPath
echo ProgramDir=%ProgramDir%
@rem copy compiler\mr_helper.mrp compiler\mr_helpere.mrp
set CurDir=%~dp0
set ProjDir=%CurDir:~0,-1%
set old_sys_include="%include%"
set old_sys_lib="%lib%"
set old_sys_path="%path%"
set PERL5LIB=%PERL5LIB%
set PerlPath=%ProgramDir%\Perl\bin
set NASMPath=%ProgramDir%\nasm\bin
set YASMPath=%ProgramDir%\yasm\bin
set GPERFPath=%ProgramDir%\gperf\bin
set CMakePath=%ProgramDir%\cmake\bin
set PythonHome=%ProgramDir%\python\Python312
set PYTHONPATH=%PYTHONHOME%\lib;%PythonHome%;
set PATH=%NASMPath%;%YASMPath%;%GPERFPath%;%PerlPath%;%CMakePath%;%PythonHome%;%PythonHome%\Scripts;%PATH%
set CurDir=%~dp0
set ProjDir=%CurDir:~0,-1%
echo ProjDir %ProjDir%
set software_dir="%ProjDir%\thirdparty"
set HomeDir=%ProjDir%\out\windows
@rem set HomeDir=%ProgramDir%
call :SetProjEnv "%software_dir%" "%CurDir%" include lib path CMAKE_INCLUDE_PATH CMAKE_LIBRARY_PATH CMAKE_MODULE_PATH
call :ShowProjEnv
set SystemBinDir=.\
@rem x86 or x64
call "%VisualStudioCmd%" x64
call "%QtEnvBat%"
pushd %CurDir%
@rem Win32 or x64
set ArchType=x64
set BuildType=Release
set ProjName=
set all_srcs=src\main.c
call :GetSrcFileList "src" "*.c*" all_srcs
set objs_dir=out
call :CompileAllSrcs "%all_srcs%" "%objs_dir%"
set lib_root_dir=out\windows\pcre-8.42
set lib_dir=%lib_root_dir%\lib
set inc_dir=%lib_root_dir%\include
set lib_name=%lib_dir%\pcred.lib
set obj_name=main.obj
set func_name=pcre_config
call :search_func_in_lib "%lib_name%" "%func_name%"
call :search_func_in_lib "%obj_name%" "%func_name%"
call :GetSrcFileList "src" "*.ui*" AllQtUis
call :ProcQtUis "%AllQtUis%"
call :GetSrcFileList "src" "*.qrc*" AllQtRcs
call :ProcQtRcs "%AllQtRcs%"
set ProjDepDefs= -DWIN32 -DUNICODE -D_UNICODE -D_WIN64 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DLUA_STATIC
set QtDepDefs= -DQT_CONCURRENT_LIB -DQT_CORE5COMPAT_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_OPENGL_LIB
set QtDepDefs=%QtDepDefs% -DQT_PRINTSUPPORT_LIB -DQT_QMLINTEGRATION_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICK_LIB -DQT_WEBCHANNEL_LIB
set QtDepDefs=%QtDepDefs% -DQT_WEBENGINECORE_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DQT_POSITIONING_LIB
set QtIncFlag=1
call :GenQtIncDirOpts "%QtMsvcPath%" "%QtIncFlag%" QtIncDirs
call :GetSrcFileList "src" "*.h*" AllQtHdrs
call :ProcQtHdrs "%ProjDepDefs%" "%QtDepDefs%" "%ProjIncDirs%" "%QtIncDirs%" "%AllQtHdrs%"
set ProjDepDefs= /D WIN64 /D _WIN64 /D UNICODE /D _UNICODE /D WIN32 /D _WINDOWS
set ProjDepDefs=%ProjDepDefs% /D _ENABLE_EXTENDED_ALIGNED_STORAGE /D LUA_STATIC
set QtDepDefs= /D QT_CORE_LIB /D QT_CORE5COMPAT_LIB /D QT_PRINTSUPPORT_LIB /D QT_POSITIONING_LIB
set QtDepDefs=%QtDepDefs% /D QT_GUI_LIB /D QT_WIDGETS_LIB /D QT_CONCURRENT_LIB /D QT_NETWORK_LIB
set QtDepDefs=%QtDepDefs% /D QT_XML_LIB /D QT_WEBENGINECORE_LIB /D QT_QUICK_LIB /D QT_QMLINTEGRATION_LIB
set QtDepDefs=%QtDepDefs% /D QT_QML_LIB /D QT_QMLMODELS_LIB /D QT_OPENGL_LIB /D QT_WEBCHANNEL_LIB
@rem set QtDepDefs=%QtDepDefs% /D "CMAKE_INTDIR=\"Debug\""
set QtIncFlag=2
call :GenQtIncDirOpts "%QtMsvcPath%" "%QtIncFlag%" QtExtIncDirs
call :GetSrcFileList "src" "*.c*" ProjAllSrcs
call :CompileQtSrcs "%ProjIncDirs%" "%ProjDepDefs%" "%QtDepDefs%" "%QtIncDirs%" "%ProjAllSrcs%"
call :GetSrcFileList "out\Debug" "*.c*" ProjAllSrcs
call :CompileQtSrcs "%ProjIncDirs%" "%ProjDepDefs%" "%QtDepDefs%" "%QtExtIncDirs%" "%ProjAllSrcs%"
call :GenThirdpartyLibDir "%HomeDir%" ProjDepLibDirs
call :GenQtDepLibs "%QtMsvcPath%" QtDepLibs
set DepSysLibs=comdlg32.lib winspool.lib d3d11.lib dxgi.lib dxguid.lib dcomp.lib user32.lib
set DepSysLibs=%DepSysLibs% ws2_32.lib shell32.lib mpr.lib userenv.lib kernel32.lib user32.lib gdi32.lib
set DepSysLibs=%DepSysLibs% winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
call :GetSrcFileList "out\Debug" "*.obj" ProjAllObjs
call :LinkQtObjs "%ProjDepLibDirs%" "%QtDepLibs%" "%DepSysLibs%" "%ProjAllObjs%" "%ProjDepLibs% " "%ProjName%"
pause
goto :eof
:CheckSrcFileFilter
setlocal EnableDelayedExpansion
set srcFileName=%~1
call :color_text 2f " +++++++++++++++++++ CheckSrcFileFilter +++++++++++++++++++++++ "
set SrcFileFilter=%SrcFileFilter%
set SrcFileFilter=%SrcFileFilter% smp_calendar.c smp_combobox.c smp_datepicker.c smp_spin.c smp_tabwindow.c
echo SrcFileFilter=%SrcFileFilter%
set IsExist=no
@rem call :get_path_by_file "!srcFile!"
for %%k in (%SrcFileFilter%) do (
echo k=%%k srcFileName=!srcFileName!
if "%%k"=="!srcFileName!" (
call :color_text 4f " ============= CheckSrcFileFilter ============== "
echo srcFileName=!srcFileName!
set IsExist=yes
goto :intercept_src_file_list
)
)
:intercept_src_file_list
call :color_text 2f " ------------------- CheckSrcFileFilter ----------------------- "
endlocal & set %~2="%IsExist%"
goto :eof
:GetSrcFileList
setlocal EnableDelayedExpansion
call :color_text 2f " +++++++++++++++++++ GetSrcFileList +++++++++++++++++++++++ "
set SrcFileDir="%~1"
set SrcFileFilterKey=%~2
if not exist "%SrcFileDir%" (
echo SrcFileDir %SrcFileDir%
goto :eof
) else (
echo SrcFileDir %SrcFileDir%
)
pushd %SrcFileDir%
echo SrcFileFilter=%SrcFileFilter%
set AllSrcFile=
for /f %%i in ('dir /s /b "%SrcFileFilterKey%"') do (
set /a idx+=1
set srcFile=%%i
set ext=%%~xi
set srcFileName=%%~nxi
echo [!idx!] srcFile=!srcFile! srcFileName=!srcFileName!
call :CheckSrcFileFilter "!srcFileName!" IsExist
if !IsExist!=="yes" (
echo skip !srcFileName!
) else (
set AllSrcFile=!AllSrcFile! !srcFile!
)
)
popd
call :color_text 2f " -------------- GetSrcFileList -------------- "
endlocal & set %~3=%AllSrcFile%
goto :eof
:GenThirdpartyLibs
setlocal ENABLEDELAYEDEXPANSION
set thirdparty_dir=%1
set ProjDepLibs=
call:color_text 2f " ++++++++++++++ GenThirdpartyLibs ++++++++++++++ "
set idx=0
pushd %thirdparty_dir%
for /f %%i in (' dir /s /b *.lib ') do (
set /a idx+=1
set lib_path_name=%%i
echo [!idx!] lib:!lib_path_name!
echo "!lib_path_name!" | findstr /C:Debug >nul
if !errorlevel! equ 0 (
echo "!lib_path_name!" "Debug"
) else (
echo "!lib_path_name!" "Release"
)
set CurDepLib=!lib_path_name!
set ProjDepLibs=!ProjDepLibs! !CurDepLib!
echo [!idx!] CurDepLib : !CurDepLib!
)
popd
call:color_text 9f " -------------- GenThirdpartyLibs -------------- "
endlocal & set %~2=%ProjDepLibs%
goto :eof
:GenThirdpartyLibDir
setlocal ENABLEDELAYEDEXPANSION
set thirdparty_dir=%1
set ProjDepLibDirs=
call:color_text 2f " ++++++++++++++ GenThirdpartyLibDir ++++++++++++++ "
set OptLibFlag= /LIBPATH:
set idx=0
pushd %thirdparty_dir%
for /f %%i in (' dir /s /b *.lib ') do (
set /a idx+=1
set lib_path_name=%%i
echo [!idx!] lib:!lib_path_name!
call :get_path_by_file "!lib_path_name!" cur_lib_path cur_lib_name cur_lib_ext
set ProjDepLibDirs=!ProjDepLibDirs! !OptLibFlag!!cur_lib_path!
echo [!idx!] cur_lib_path : !cur_lib_path!
)
popd
call:color_text 9f " -------------- GenThirdpartyLibDir -------------- "
endlocal & set %~2=%ProjDepLibDirs%
goto :eof
:GenThirdpartyIncDir
setlocal ENABLEDELAYEDEXPANSION
set thirdparty_dir=%~1
set ProjDepIncDir=
call:color_text 2f " ++++++++++++++ GenThirdpartyIncDir ++++++++++++++ "
set OptIncFlag=-I
set idx=0
pushd %thirdparty_dir%
for /f %%i in (' dir /ad /b ') do (
set /a idx+=1
set inc_dir_name=%%i
set CurDepIncDir=!thirdparty_dir!\!inc_dir_name!\include
set ProjDepIncDir=!ProjDepIncDir! !OptIncFlag! !CurDepIncDir!
echo [!idx!] CurDepIncDir : !CurDepIncDir!
)
popd
call:color_text 9f " -------------- GenThirdpartyIncDir -------------- "
endlocal & set %~2=%ProjDepIncDir%
goto :eof
:CopyThirdpartyLib
setlocal ENABLEDELAYEDEXPANSION
set thirdparty_dir=%1
set BuildType=%~2
set TargetDir=%~3
call:color_text 2f " ++++++++++++++ CopyThirdpartyLib ++++++++++++++ "
echo TargetDir=%TargetDir%
set idx=0
pushd %thirdparty_dir%
for /f %%i in (' dir /s /b *.lib ') do (
set /a idx+=1
set cur_lib_file=%%i
echo [!idx!] BuildType=!BuildType! cur_lib_file:!cur_lib_file!
echo "!cur_lib_file!" | findstr /C:!BuildType! >nul
if !errorlevel! equ 0 (
copy !cur_lib_file! !TargetDir!\lib\
if !errorlevel! equ 0 (
echo "copy succ"
) else (
echo "copy !cur_lib_file! !TargetDir!\lib\"
)
) else (
echo "!BuildType!---!cur_lib_file!"
pause
)
)
popd
call:color_text 9f " -------------- CopyThirdpartyLib -------------- "
endlocal
goto :eof
:CheckDepTypeByDir
setlocal EnableDelayedExpansion
set LibTopDir=%~1
call :color_text 2f " +++++++++++++++++++ CheckDepTypeByDir +++++++++++++++++++ "
echo LibTopDir:%LibTopDir%
set idx=0
for /f %%i in ('dir /s /b "%LibTopDir%\*.lib"') do (
set /a idx+=1
set lib_file=%%i
echo [!idx!] dumpbin /DIRECTIVES !cur_lib_file!
dumpbin /DIRECTIVES !cur_lib_file! | findstr "DEFAULTLIB"
echo dumpbin /DIRECTIVES !cur_lib_file!
pause
)
call :color_text 2f " -------------------- CheckDepTypeByDir ----------------------- "
endlocal
goto :eof
:StaticLibCheckMTorMD
setlocal EnableDelayedExpansion
set LibTopDir=%~1
call :color_text 2f " +++++++++++++++++++ StaticLibCheckMTorMD +++++++++++++++++++ "
set idx=0
for /f %%i in ('dir /s /b "%LibTopDir%\*.lib"') do (
set /a idx+=1
set cur_lib_file=%%i
echo [!idx!] dumpbin /directives !cur_lib_file!
dumpbin /HEADERS !cur_lib_file! | grep "machine"
dumpbin /directives !cur_lib_file! | grep "MSVCRT"
dumpbin /directives !cur_lib_file! | grep "RuntimeLibrary"
@rem lib /list !cur_lib_file!
pause
)
call :color_text 2f " -------------------- StaticLibCheckMTorMD ----------------------- "
endlocal
goto :eof
:DynamicLibCheckMTorMD
setlocal EnableDelayedExpansion
set LibTopDir=%~1
call :color_text 2f " +++++++++++++++++++ DynamicLibCheckMTorMD +++++++++++++++++++ "
set idx=0
for /f %%i in ('dir /s /b "%LibTopDir%\*.dll"') do (
set /a idx+=1
set cur_lib_file=%%i
echo [!idx!] dumpbin /dependents !cur_lib_file!
dumpbin /HEADERS !cur_lib_file! | grep "machine"
dumpbin /dependents !cur_lib_file! | grep "MSVCRT"
pause
)
call :color_text 2f " -------------------- DynamicLibCheckMTorMD ----------------------- "
endlocal
goto :eof
:CheckLibType
setlocal EnableDelayedExpansion
set LibFile=%~1
call :color_text 2f " +++++++++++++++++++ CheckLibType +++++++++++++++++++ "
echo LibFile:%LibFile%
lib /list %LibFile%
call :color_text 2f " -------------------- CheckLibType ----------------------- "
endlocal
goto :eof
:Copy3rdLibCMakeList
setlocal EnableDelayedExpansion
set lib_dir="%~1"
call :color_text 2f "++++++++++++++ Copy3rdLibCMakeList ++++++++++++++"
@rem pushd %lib_dir%
set idx=0
for /f %%i in ( 'dir /b /ad %lib_dir%' ) do (
set /a idx+=1
set cur_lib_name=%%i
set cur_lib_dir=!lib_dir!\%%i
set cur_lib_cmake=!cur_lib_dir!\CMakeLists.txt
set dst_lib_cmake=!cur_lib_name!CMakeLists.txt
echo [!idx!] !cur_lib_dir!, cur_cmake:!cur_lib_cmake!, dst_cmake:!dst_lib_cmake!
if exist "!cur_lib_cmake!" (
copy !cur_lib_cmake! !dst_lib_cmake!
) else (
echo file !cur_lib_cmake! does not exist.
)
)
@rem popd
call :color_text 2f " -------------- Copy3rdLibCMakeList --------------- "
endlocal
goto :eof
:del_lib_cacke_dir
setlocal EnableDelayedExpansion
set lib_dir="%~1"
set home_dir="%~2"
call :color_text 2f " ++++++++++++++ del_lib_cacke_dir ++++++++++++++ "
pushd %lib_dir%
set idx=0
for /f %%i in ( 'dir /b /ad ' ) do (
set /a idx+=1
set cur_lib_name=%%i
echo [!idx!] !cur_lib_name!
if exist !cur_lib_name!\dyzbuild (
echo !cur_lib_name!\dyzbuild does exist
pause
)
if exist !cur_lib_name!\SMP\.vs (
echo !cur_lib_name!\SMP\.vs does exist
pause
)
if exist !cur_lib_name!\SMP\obj (
echo !cur_lib_name!\SMP\obj does exist
pause
)
tar -caf !cur_lib_name!.tar.gz !cur_lib_name!
)
popd
call :color_text 2f " -------------- del_lib_cacke_dir --------------- "
endlocal
goto :eof
:TaskKillSpecProcess
setlocal EnableDelayedExpansion
set ProcName=%~1
call :color_text 2f " +++++++++++++++++++ TaskKillSpecProcess +++++++++++++++++++ "
tasklist | grep "%ProcName%"
taskkill /f /im "%ProcName%"
call :color_text 2f " ------------------- TaskKillSpecProcess ------------------- "
endlocal
goto :eof
:upgrade_python_pip
setlocal EnableDelayedExpansion
call :color_text 2f " +++++++++++++++++++ upgrade_python_pip +++++++++++++++++++ "
python -m ensurepip
python -m pip install --upgrade pip
pip3 install Jinja2
call :color_text 2f " ------------------- upgrade_python_pip ------------------- "
endlocal
goto :eof
:DetectQtDir
setlocal EnableDelayedExpansion
@rem call "C:\Qt\6.5.2\msvc2019_64\bin\qtenv2.bat"
@rem call "C:\Qt\6.6.0\msvc2019_64\bin\qtenv2.bat"
@rem call "C:\Qt\6.9.0\msvc2022_64\bin\qtenv2.bat"
@rem call "D:/Qt/Qt5.12.0/5.12.0/msvc2017_64/bin/qtenv2.bat"
@rem call "D:\Qt\Qt5.14.2\5.14.2\msvc2017_64\bin\qtenv2.bat"
set VsBatFileVar=%~1
call :color_text 2f " ++++++++++++++++++ DetectQtDir +++++++++++++++++++++++ "
set VSDiskSet=C;D;E;F;G;
set QtPathSet="Qt"
set QtVerSet=%QtVerSet%;"6.5.2"
set QtVerSet=%QtVerSet%;"6.6.0"
set QtVerSet=%QtVerSet%;"6.9.0"
set QtVerSet=%QtVerSet%;"Qt5.12.0\5.12.0"
set QtVerSet=%QtVerSet%;"Qt5.14.2\5.14.2"
set QtMsvcSet=%QtMsvcSet%;"msvc2017_64"
set QtMsvcSet=%QtMsvcSet%;"msvc2019_64"
set QtMsvcSet=%QtMsvcSet%;"msvc2022_64"
set idx_a=0
for %%A in (!VSDiskSet!) do (
set /a idx_a+=1
set idx_b=0
for %%B in (!QtPathSet!) do (
set /a idx_b+=1
set idx_c=0
for %%C in (!QtVerSet!) do (
set /a idx_c+=1
for %%D in (!QtMsvcSet!) do (
set /a idx_d+=1
set CurQtEnvBatFile=%%A:\%%~B\%%~C\%%~D\bin\qtenv2.bat
echo [!idx_a!][!idx_b!][!idx_c!][!idx_d!] !CurQtEnvBatFile!
if exist !CurQtEnvBatFile! (
set QtEnvBatFile=!CurQtEnvBatFile!
set QtMsvcPath=%%A:\%%~B\%%~C\%%~D
goto :DetectQtEnvPathBreak
)
)
)
)
)
:DetectQtEnvPathBreak
echo Use:%QtEnvBatFile%
call :color_text 2f " ------------------ DetectQtDir ----------------------- "
endlocal & set "%~1=%QtEnvBatFile%"& set "%~2=%QtMsvcPath%"
goto :eof
:GenQtIncDirOpts
setlocal EnableDelayedExpansion
set QtMsvcPath=%~1
set OptIncFlag=%~2
call :color_text 2f " ++++++++++++++++++ GenQtIncDirOpts +++++++++++++++++++++++ "
set QtMsvcSet=%QtMsvcSet%;"msvc2017_64"
set QtMsvcSet=%QtMsvcSet%;"msvc2019_64"
set QtMsvcSet=%QtMsvcSet%;"msvc2022_64"
if "%OptIncFlag%"=="1" (
set OptIncFlag=-I
) else (
set OptIncFlag=/external:I
)
set QtMsvcIncDirs=%QtMsvcIncDirs% %OptIncFlag% %QtMsvcPath%/include
set QtMsvcIncDirs=%QtMsvcIncDirs% %OptIncFlag% %QtMsvcPath%/mkspecs/win32-msvc
set QtModDirs=%QtModDirs% QtCore
set QtModDirs=%QtModDirs% QtCore5Compat
set QtModDirs=%QtModDirs% QtGui
set QtModDirs=%QtModDirs% QtWidgets
set QtModDirs=%QtModDirs% QtConcurrent
set QtModDirs=%QtModDirs% QtNetwork
set QtModDirs=%QtModDirs% QtPrintSupport
set QtModDirs=%QtModDirs% QtXml
set QtModDirs=%QtModDirs% QtWebEngineCore
set QtModDirs=%QtModDirs% QtQuick
set QtModDirs=%QtModDirs% QtQml
set QtModDirs=%QtModDirs% QtQmlIntegration
set QtModDirs=%QtModDirs% QtQmlModels
set QtModDirs=%QtModDirs% QtOpenGL
set QtModDirs=%QtModDirs% QtWebChannel
set QtModDirs=%QtModDirs% QtPositioning
set idx_a=0
for %%A in (!QtMsvcPath!) do (
set /a idx_a+=1
set idx_b=0
for %%B in (!QtModDirs!) do (
set /a idx_b+=1
set CurQtMsvcModIncDirs=!OptIncFlag! %%A\include\%%~B
set QtMsvcIncDirs=!QtMsvcIncDirs! !CurQtMsvcModIncDirs!
echo [!idx_a!][!idx_b!] !CurQtMsvcModIncDirs!
)
)
call :color_text 2f " ------------------ GenQtIncDirOpts ----------------------- "
endlocal & set "%~3=%QtMsvcIncDirs%"
goto :eof
:GenQtDepLibs
setlocal EnableDelayedExpansion
set QtMsvcPath=%~1
set OptLinkFlag=
call :color_text 2f " ++++++++++++++++++ GenQtDepLibs +++++++++++++++++++++++ "
set QtMsvcSet=%QtMsvcSet%;"msvc2017_64"
set QtMsvcSet=%QtMsvcSet%;"msvc2019_64"
set QtMsvcSet=%QtMsvcSet%;"msvc2022_64"
set QtMsvcDepLibs=
set QtModLibs=%QtModLibs% QtCore
set QtModLibs=%QtModLibs% QtCore5Compat
set QtModLibs=%QtModLibs% QtGui
set QtModLibs=%QtModLibs% QtWidgets
set QtModLibs=%QtModLibs% QtConcurrent
set QtModLibs=%QtModLibs% QtNetwork
set QtModLibs=%QtModLibs% QtPrintSupport
set QtModLibs=%QtModLibs% QtXml
set QtModLibs=%QtModLibs% QtWebEngineCore
set QtModLibs=%QtModLibs% QtQuick
set QtModLibs=%QtModLibs% QtQml
set QtModLibs=%QtModLibs% QtQmlIntegration
set QtModLibs=%QtModLibs% QtQmlModels
set QtModLibs=%QtModLibs% QtOpenGL
set QtModLibs=%QtModLibs% QtWebChannel
set QtModLibs=%QtModLibs% QtPositioning
set idx_a=0
for %%A in (!QtMsvcPath!) do (
set /a idx_a+=1
set idx_b=0
for %%B in (!QtModLibs!) do (
set /a idx_b+=1
set CurQtMsvcModLib=!OptLinkFlag! %%A\lib\%%~B.lib
set QtMsvcDepLibs=!QtMsvcDepLibs! !CurQtMsvcModLib!
echo [!idx_a!][!idx_b!] !CurQtMsvcModLib!
)
)
call :color_text 2f " ------------------ GenQtDepLibs ----------------------- "
endlocal & set "%~2=%QtMsvcDepLibs%"
goto :eof
:DetectProgramDir
setlocal EnableDelayedExpansion
@rem SkySdk\VS2005\VC
set ToolDir=SkySdk
set SkySdkDiskSet=C;D;E;F;G;
set CurProgramDir=
set idx=0
call :color_text 2f " +++++++++++++++++++ DetectProgramDir +++++++++++++++++++++++ "
for %%i in (!SkySdkDiskSet!) do (
set /a idx+=1
for /f "tokens=1-2 delims=|" %%B in ("programs|program") do (
set CurProgramDir=%%i:\%%B
echo [!idx!] !CurProgramDir!
if exist !CurProgramDir!\!ToolDir! (
set ProgramDir=!CurProgramDir!
goto :DetectProgramDirBreak
)
set CurProgramDir=%%i:\%%C
echo [!idx!] !CurProgramDir!
if exist !CurProgramDir!\!ToolDir! (
set ProgramDir=!CurProgramDir!
goto :DetectProgramDirBreak
)
)
)
:DetectProgramDirBreak
echo Use:%ProgramDir%
call :color_text 2f " ------------------- DetectProgramDir ----------------------- "
endlocal & set %~1=%ProgramDir%
goto :eof
:CopyDynamicLibsForVS2005
setlocal EnableDelayedExpansion
set SpecLibDir=%~1
call :color_text 2f " +++++++++++++++++++ CopyDynamicLibsForVS2005 +++++++++++++++++++++++ "
call :DetectProgramDir ProgramDir
set VCInstallDir=%ProgramDir%\SkySdk\VS2005\VC
set RedistDir=%VCInstallDir%\redist\Debug_NonRedist\x86
mkdir %SpecLibDir%\lib
xcopy %RedistDir% "%SpecLibDir%\" /y /s /e
xcopy %RedistDir% "%SpecLibDir%\lib\" /y /s /e
call :color_text 2f " ------------------- CopyDynamicLibsForVS2005 ----------------------- "
endlocal
goto :eof
:CopyStaticLibsForVS2005
setlocal EnableDelayedExpansion
set ProjDir=%~1
call :color_text 2f " +++++++++++++++++++ CopyStaticLibsForVS2005 +++++++++++++++++++++++ "
@rem call :DetectVS2005VcDir VCInstallDir
call :DetectProgramDir ProgramDir
set VCInstallDir=%ProgramDir%\SkySdk\VS2005\VC
set VscLib=msvcmrtd.lib;msvcrtd.lib;
set VscDir=%VCInstallDir%\lib
set VsAtlmfcLib=mfcs80d.lib atlsd.lib mfc80d.lib
set VsAtlmfcDir=%VCInstallDir%\atlmfc\lib
set FrameworkLib=kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;WS2_32.lib;winmm.lib;vfw32.lib;
set FrameworkDir=%VCInstallDir%\PlatformSDK\lib
set SkySdkLib=dsound.lib;dxguid.lib;simulator.lib;simlib.lib;jpeg_sim.lib;SIM_mr_helperexb.lib;data_codec_sim.lib;SIM_mr_helperexbnp.lib;
call :CopyStaticLibToSpecDir "%VscLib%" "%VscDir%" "%ProjDir%"
call :CopyStaticLibToSpecDir "%VsAtlmfcLib%" "%VsAtlmfcDir%" "%ProjDir%"
@rem call :CopyStaticLibToSpecDir "%FrameworkLib%" "%FrameworkDir%" "%ProjDir%"
@rem call :CopyStaticLibToSpecDir "%SkySdkLib%" "%SkySdkDir%\Simulator\lib" "%ProjDir%"
call :color_text 2f " -------------------- CopyStaticLibsForVS2005 ----------------------- "
endlocal
goto :eof
:CopyStaticLibToSpecDir
setlocal EnableDelayedExpansion
set Libs=%~1
set LibDir="%~2"
set ProjDir=%~3
set MyPlatformSDK=%ProjDir%\lib
if not exist "%MyPlatformSDK%" (
mkdir %MyPlatformSDK%
)
call :color_text 2f " +++++++++++++++++++ CopyStaticLibToSpecDir +++++++++++++++++++++++ "
echo LibDir %LibDir%
if not exist %LibDir% (
call :color_text 4f " -------------------- CopyStaticLibToSpecDir ----------------------- "
echo '%LibDir%' does not exist...
goto :eof
)
pushd %LibDir%
set idx=0
for %%i in (%Libs%) do (
set /a idx+=1
set CurLib=%%i
echo [!idx!] !LibDir!\!CurLib!
if not exist !LibDir!\!CurLib! (
echo !LibDir!\!CurLib!
) else (
copy !LibDir!\!CurLib! !MyPlatformSDK!
)
)
popd
call :color_text 2f " -------------------- CopyStaticLibToSpecDir ----------------------- "
endlocal
goto :eof
:DetectVsPath
setlocal EnableDelayedExpansion
set VsBatFileVar=%~1
call :color_text 2f " ++++++++++++++++++ DetectVsPath +++++++++++++++++++++++ "
set VSDiskSet=C;D;E;F;G;
set AllProgramsPathSet="program"
set AllProgramsPathSet=%AllProgramsPathSet%;"programs"
set AllProgramsPathSet=%AllProgramsPathSet%;"Program Files"
set AllProgramsPathSet=%AllProgramsPathSet%;"Program Files (x86)"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build"
set VCPathSet=%VCPathSet%;"VS2022\VC\Auxiliary\Build"
set VCPathSet=%VCPathSet%;"SkySdk\VS2005\VC"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio 8\VC"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio 12.0\VC\bin"
set VCPathSet=%VCPathSet%;"Microsoft Visual Studio 14.0\VC\bin"
set idx_a=0
for %%C in (!VCPathSet!) do (
set /a idx_a+=1
set idx_b=0
for %%B in (!AllProgramsPathSet!) do (
set /a idx_b+=1
set idx_c=0
for %%A in (!VSDiskSet!) do (
set /a idx_c+=1
set CurBatFile=%%A:\%%~B\%%~C\vcvarsall.bat
echo [!idx_a!][!idx_b!][!idx_c!] !CurBatFile!
if exist !CurBatFile! (
set VsVcBatFile=!CurBatFile!
goto :DetectVsPathBreak
)
)
)
)
:DetectVsPathBreak
echo Use:%VsVcBatFile%
call :color_text 2f " -------------------- DetectVsPath ----------------------- "
endlocal & set "%~1=%VsVcBatFile%"
goto :eof
:DetectWinSdk
setlocal EnableDelayedExpansion
set VsBatFileVar=%~1
set VS_ARCH=%~1
call :color_text 2f " ++++++++++++++++++ DetectWinSdk +++++++++++++++++++++++ "
set WindowsSdkVersion=10.0.22621.0
set VSDiskSet=C;D;E;F;G;
set AllProgramsPathSet=program
set AllProgramsPathSet=%AllProgramsPathSet%;programs
set VCPathSet=%VCPathSet%;"VS2022\Windows Kits\10"
set VCPathSet=%VCPathSet%;"SkySdk\VS2005\SDK\v2.0"
set idx_a=0
for %%C in (!VCPathSet!) do (
set /a idx_a+=1
set idx_b=0
for %%B in (!AllProgramsPathSet!) do (
set /a idx_b+=1
set idx_c=0
for %%A in (!VSDiskSet!) do (
set /a idx_c+=1
set CurWinSdkDirName=%%A:\%%B\%%~C
echo [!idx_a!][!idx_b!][!idx_c!] !CurWinSdkDirName!
if exist !CurWinSdkDirName! (
set WindowsSdkDirName=!CurWinSdkDirName!
set WIN_SDK_BIN=!WindowsSdkDirName!\bin\!WindowsSdkVersion!\!VS_ARCH!;
set WIN_SDK_INC=!WIN_SDK_INC!;!WindowsSdkDirName!\Include\!WindowsSdkVersion!\um;
set WIN_SDK_INC=!WIN_SDK_INC!;!WindowsSdkDirName!\Include\!WindowsSdkVersion!\ucrt;
set WIN_SDK_INC=!WIN_SDK_INC!;!WindowsSdkDirName!\Include\!WindowsSdkVersion!\shared;
set WIN_SDK_LIB=!WIN_SDK_LIB!;!WindowsSdkDirName!\Lib\!WindowsSdkVersion!\um\!VS_ARCH!;
set WIN_SDK_LIB=!WIN_SDK_LIB!;!WindowsSdkDirName!\Lib\!WindowsSdkVersion!\ucrt\!VS_ARCH!;
goto :DetectWinSdkBreak
)
)
)
)
:DetectWinSdkBreak
echo Use:%WindowsSdkDirName%
call :color_text 2f " ------------------ DetectWinSdk ----------------------- "
endlocal & set "%~2=%WindowsSdkDirName%" & set %~3=%WIN_SDK_BIN% & set %~4=%WIN_SDK_INC% & set %~5=%WIN_SDK_LIB%
goto :eof
@rem call :ProcQtUis "%AllQtUis%"
:ProcQtUis
setlocal EnableDelayedExpansion
set AllQtUis=%~1
call :color_text 2f " +++++++++++++++++ ProcQtUis ++++++++++++++++ "
set OutDir=out\Debug
if not exist %OutDir% (
mkdir %OutDir%
)
set idx=0
set AllUiHdrs=
for %%i in (%AllQtUis%) do (
set /a idx+=1
set QtUiFile=%%i
set QtUiHdr=!OutDir!\ui_%%~ni.h
set ext=%%~xi
echo [!idx!] !QtUiFile! !QtUiHdr!
set AllUiHdrs=!AllUiHdrs! !QtUiHdr!
uic.exe -o !QtUiHdr! !QtUiFile!
)
call :color_text 2f " ----------------- ProcQtUis ---------------- "
endlocal
goto :eof
@rem call :ProcQtRcs "%AllQtRcs%"
:ProcQtRcs
setlocal EnableDelayedExpansion
set AllQtRcs=%~1
call :color_text 2f " +++++++++++++++++ ProcQtRcs ++++++++++++++++ "
set OutDir=out\Debug
if not exist %OutDir% (
mkdir %OutDir%
)
set idx=0
set AllQtCpps=
for %%i in (%AllQtRcs%) do (
set /a idx+=1
set QrcFile=%%i
set FileName=%%~ni
set CppFile=!OutDir!\qrc_!FileName!_CMKE_.cpp
set ext=%%~xi
echo [!idx!] !QrcFile! !CppFile!
set AllQtCpps=!AllQtCpps! !CppFile!
rcc.exe -name !FileName! -o !CppFile! !QrcFile!
)
call :color_text 2f " ----------------- ProcQtRcs ---------------- "
endlocal
goto :eof
@rem call :ProcQtHdrs "%ProjDepDefs%" "%QtDepDefs%" "%ProjIncDirs%" "%QtIncDirs%" "%AllQtHdrs%"
:ProcQtHdrs
setlocal EnableDelayedExpansion
set ProjDepDefs=%~1
set QtDepDefs=%~2
set ProjIncDirs=%~3
set QtIncDirs=%~4
set AllQtHdrs=%~5
call :color_text 2f " +++++++++++++++++ ProcQtHdrs ++++++++++++++++ "
echo ProjDepDefs=%ProjDepDefs%
echo QtDepDefs=%QtDepDefs%
echo ProjIncDirs=%ProjIncDirs%
echo QtIncDirs=%QtIncDirs%
echo AllQtHdrs=%AllQtHdrs%
set OutDir=out\Debug
if not exist %OutDir% (
mkdir %OutDir%
)
set idx=0
set AllMocCpps=
for %%i in (%AllQtHdrs%) do (
set /a idx+=1
set QtHdrFile=%%i
set QtMocCpp=!OutDir!\moc_%%~ni.cpp
set ext=%%~xi
echo [!idx!] !QtHdrFile! !QtMocCpp!
set AllMocCpps=!AllMocCpps! !QtMocCpp!
moc.exe !ProjDepDefs! !QtDepDefs! !ProjIncDirs! !QtIncDirs! --output-dep-file -o !QtMocCpp! !QtHdrFile!
)
call :color_text 2f " ----------------- ProcQtHdrs ---------------- "
endlocal
goto :eof
@rem call :CompileQtSrcs "%ProjIncDirs%" "%ProjDepDefs%" "%QtDepDefs%" "%QtIncDirs%" "%ProjAllSrcs%"
:CompileQtSrcs
setlocal EnableDelayedExpansion
set ProjIncDirs=%~1
set ProjDepDefs=%~2
set QtDepDefs=%~3
set QtIncDirs=%~4
set ProjAllSrcs=%~5
call :color_text 2f " +++++++++++++++++ CompileQtSrcs ++++++++++++++++ "
echo ProjIncDirs=%ProjIncDirs%
echo ProjDepDefs=%ProjDepDefs%
echo QtDepDefs=%QtDepDefs%
echo QtIncDirs=%QtIncDirs%
echo ProjAllSrcs=%ProjAllSrcs%
set OutDir=out\Debug
set ZcOpts=/Zc:wchar_t /Zc:forScope /Zc:inline
set idx=0
set AllMocCpps=
for %%i in (%ProjAllSrcs%) do (
set /a idx+=1
set QtCppFile=%%i
set ObjFile=!OutDir!\%%~ni.obj
set ext=%%~xi
echo [!idx!] !QtCppFile! !ObjFile!
set AllObjFiles=!AllObjFiles! !ObjFile!
CL.exe /c /I"!OutDir!" !ProjIncDirs! /Z7 /nologo /W4 /WX- /diagnostics:column /Od /Ob0 !ProjDepDefs! !QtDepDefs! /Gm- /EHsc /RTC1 /MDd /GS /fp:precise !ZcOpts! /GR /std:c++17 /permissive- /Fo"!OutDir!\\" /Fd"!OutDir!\vc143.pdb" /external:W0 /Gd /TP /errorReport:queue !QtIncDirs! -Zc:__cplusplus -utf-8 !QtCppFile!
)
call :color_text 2f " ----------------- CompileQtSrcs ---------------- "
endlocal
goto :eof
@rem call :LinkQtObjs "%ProjLibDirs%" "%QtLibDirs%" "%DepSysLibs%" "%ProjAllObjs%"
:LinkQtObjs
setlocal EnableDelayedExpansion
set ProjLibDirs=%~1
set QtLibDirs=%~2
set DepSysLibs=%~3
set ProjAllObjs=%~4
set ProjDepLibs=%~5
set TargetName=%~6
call :color_text 2f " +++++++++++++++++ LinkQtObjs ++++++++++++++++ "
echo ProjLibDirs=%ProjLibDirs%
echo QtLibDirs=%QtLibDirs%
echo DepSysLibs=%DepSysLibs%
echo ProjAllObjs=%ProjAllObjs%
set OutDir=out\Debug
link.exe /ERRORREPORT:QUEUE /OUT:"%OutDir%\%TargetName%.exe" /INCREMENTAL /ILK:"%OutDir%\%TargetName%.ilk" /NOLOGO %ProjLibDirs% %QtLibDirs% %DepSysLibs% /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"%OutDir%/%TargetName%.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"%OutDir%/%TargetName%.lib" /MACHINE:X64 %ProjAllObjs% %ProjDepLibs%
if !errorlevel! equ 0 (
echo ok
) else (
call :color_text 4f " ==== LinkQtObjs ==== "
echo link.exe /ERRORREPORT:QUEUE /OUT:"%OutDir%\%TargetName%.exe" /INCREMENTAL /ILK:"%OutDir%\%TargetName%.ilk" /NOLOGO %ProjLibDirs% %QtLibDirs% %DepSysLibs% /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"%OutDir%/%TargetName%.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"%OutDir%/%TargetName%.lib" /MACHINE:X64 %ProjAllObjs% %ProjDepLibs%
pause
)
call :color_text 2f " ----------------- LinkQtObjs ---------------- "
endlocal
goto :eof
:CompileQtSln
setlocal EnableDelayedExpansion
set QtSln=%~1
call :color_text 2f " +++++++++++++++++ CompileQtSln ++++++++++++++++ "
set OutDir=out\Debug
call :color_text 2f " ----------------- CompileQtSln ---------------- "
endlocal
goto :eof
:CompileAllSrcs
setlocal EnableDelayedExpansion
set AllSrcs=%~1
set ObjsDir=%~2
set PcreDir=%HomeDir%\pcre-8.42
call :color_text 2f " ++++++++++++++++++ CompileAllSrcs ++++++++++++++++++++++++ "
set IncDir=/I .\inc /I .\src /I .\ /I .\include
set PcreDefs=/D PCRE_STATIC
set WinDefs=/D _WINDOWS /D WIN32 /D _NDEBUG /D NDEBUG
set AllDefs=%PcreDefs% /TC /MD
set OutDir=out
if not exist %OutDir% (
mkdir %OutDir%
)
set idx=0
set AllObjs=
for %%i in (%AllSrcs%) do (
set /a idx+=1
set srcFile=%%i
set objFile=!OutDir!\%%~ni.obj
set ext=%%~xi
echo [!idx!] !srcFile! !objFile!
set AllObjs=!AllObjs! !objFile!
echo cl !IncDir! !AllDefs! /Fo"!objFile!" /c !srcFile!
cl !IncDir! !AllDefs! /Fo"!objFile!" /c !srcFile!
)
set LibDir=/LIBPATH:.\ /LIBPATH:.\lib /LIBPATH:%PcreDir%\lib
set PcreOpts=pcred.lib
set WinOpts=/subsystem:windows /entry:WinMainCRTStartup
set ArmOpts=/SAFESEH:NO /NODEFAULTLIB:LIBCD.lib /NODEFAULTLIB:LIBC.lib /NODEFAULTLIB:LIBCMT.lib /NODEFAULTLIB:LIBCMTD.lib /INCLUDE:_sim_dummy MSCOREE.lib
set AllOpts=
echo link /link %LibDir% %AllOpts% %AllObjs% /OUT:%OutDir%\app.exe
link /link %LibDir% %AllOpts% %AllObjs% /OUT:%OutDir%\app.exe
call :color_text 2f " ----------------- CompileAllSrcs ----------------- "
endlocal
goto :eof
:search_func_in_lib
setlocal ENABLEDELAYEDEXPANSION