Repository navigation
Expand file tree
/
Copy pathdependency.cmd
More file actions
110 lines (99 loc) · 3.29 KB
/
Copy pathdependency.cmd
File metadata and controls
110 lines (99 loc) · 3.29 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
@echo off
setlocal
:: ============================================================
:: Universal build script for a single Lazarus dependency
:: Usage: build_dependency.cmd <Name> <SubtreePath> <RepoURL> <Branch> <LpkFileList> [RevertFile] [DoPull] [DoBuild]
:: LpkFileList - comma-separated list of .lpk files relative to <SubtreePath>
:: DoPull - set to "true" (case insensitive) to perform git subtree pull;
:: any other value, empty or "false" skips the pull.
:: Expects LAZBUILD to point to lazbuild.exe
:: Optionally uses LAZBUILD_OPTS for additional flags (e.g. 32-bit target)
:: ============================================================
set "DEP_NAME=%~1"
set "DEP_PATH=%~2"
set "DEP_REPO=%~3"
set "DEP_BRANCH=%~4"
set "DEP_LPK=%~5"
set "DEP_REVERT=%~6"
set "DO_PULL=%~7"
set "DO_BUILD=%~8"
if "%DEP_NAME%"=="" (
echo ERROR: Missing dependency name
exit /b 1
)
if "%DEP_BRANCH%"=="" (
echo ERROR: Missing dependency branch
exit /b 1
)
if "%DEP_PATH%"=="" (
echo ERROR: Missing subtree path
exit /b 1
)
if "%DEP_REPO%"=="" (
echo ERROR: Missing repo URL
exit /b 1
)
echo.
echo ############################################################
echo Build %DEP_NAME% (%ARCH_LABEL%)
echo ############################################################
echo.
:: ----- Always ensure submodule exists and is cleanly checked out -----
echo Syncing %DEP_NAME% submodule (committed version)
git submodule update --init -- %DEP_PATH%
if not errorlevel 1 goto :submodule_ok
echo WARNING: Failed to initialize/update %DEP_NAME% submodule.
echo Possibly local changes exist or network error.
goto :process_lpk
:submodule_ok
:: ----- If pulling requested, move to the latest branch commit -----
if /i "%DO_PULL%"=="true" (
echo Pulling latest %DEP_NAME% from branch %DEP_BRANCH%
git submodule update --remote -- %DEP_PATH%
if errorlevel 1 (
echo WARNING: Failed to update %DEP_NAME% to latest remote commit.
) else (
echo %DEP_NAME% submodule updated to latest commit successfully.
)
)
:process_lpk
:: Skip build if requested
if /i not "%DO_BUILD%"=="true" (
echo Skipping %DEP_NAME% build because DO_BUILD is not "true".
goto :fin
)
if "%DEP_LPK%"=="" (
echo WARNING: no LPK files specified for %DEP_NAME%, skipping.
goto :fin
)
echo Processing Lazarus packages
for %%L in (%DEP_LPK%) do (
if exist "%DEP_PATH%\%%L" (
echo Building "%DEP_PATH%\%%L"
"%LAZBUILD%" "%DEP_PATH%\%%L" %LAZBUILD_OPTS% -q -q
if errorlevel 1 (
echo ERROR: %DEP_NAME% LPK build failed for "%DEP_PATH%\%%L"
if not defined CI pause
exit /b 1
)
echo %DEP_NAME% LPK processed successfully: "%DEP_PATH%\%%L"
) else (
echo WARNING: "%DEP_PATH%\%%L" not found, skipping
)
)
:: Revert auto-generated changes if a revert file is specified
if not "%DEP_REVERT%"=="" (
if exist "%DEP_PATH%\%DEP_REVERT%" (
git ls-files --error-unmatch "%DEP_PATH%/%DEP_REVERT%" >nul 2>&1
if not errorlevel 1 (
git checkout -- "%DEP_PATH%/%DEP_REVERT%"
if not errorlevel 1 (
echo Reverted auto-changes in %DEP_REVERT%
)
) else (
echo NOTE: %DEP_REVERT% is not tracked by git, skipping revert.
)
)
)
:fin
exit /b 0