-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdependency.cmd
More file actions
122 lines (105 loc) · 3.32 KB
/
Copy pathdependency.cmd
File metadata and controls
122 lines (105 loc) · 3.32 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
@echo off
setlocal
:: ============================================================
:: Universal build script for a single Lazarus dependency
:: Usage: build_dependency.cmd <Name> <SubtreePath> <RepoURL> <Branch> <LpkFile> [RevertFile] [DoPull]
:: 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.
:: ----- Decide whether to update submodule -----
if /i not "%DO_PULL%"=="true" (
echo Getting current %DEP_NAME% submodule version
git submodule update --init -- %DEP_PATH%
if errorlevel 1 (
echo WARNING: Failed to get current %DEP_NAME% submodule version
)
goto process_lpk
)
echo Checking %DEP_NAME% submodule state
:: Check for local changes in the submodule
git -C %DEP_PATH% diff --quiet
if errorlevel 1 (
echo WARNING: %DEP_NAME% has unstaged changes, skipping submodule update
goto process_lpk
)
:: Check for staged changes in the submodule
git -C %DEP_PATH% diff --cached --quiet
if errorlevel 1 (
echo WARNING: %DEP_NAME% has staged changes, skipping submodule update
goto process_lpk
)
:: No local changes – safe to update to the latest branch commit
echo Updating %DEP_NAME% submodule
git submodule update --init --remote -- %DEP_PATH%
if errorlevel 1 (
echo WARNING: %DEP_NAME% submodule update failed, continuing with existing version
) else (
echo %DEP_NAME% submodule updated successfully
)
goto process_lpk
:skip_update
echo Skipping %DEP_NAME% subtree update due to local changes or DO_PULL policy.
:process_lpk
:: ----- Decide whether to attempt build lpk -----
if /i not "%DO_BUILD%"=="true" (
echo Skipping %DEP_NAME% build because DO_BUILD is not "true".
goto skip_build
)
echo Processing Lazarus package
if exist "%DEP_LPK%" (
echo Building %DEP_LPK%
"%LAZBUILD%" "%DEP_LPK%" %LAZBUILD_OPTS% -q -q
if errorlevel 1 (
echo ERROR: %DEP_NAME% LPK build failed
pause
exit /b %errorlevel%
)
echo %DEP_NAME% LPK processed successfully
:: Revert auto-generated changes if a revert file is specified
if not "%DEP_REVERT%"=="" (
if exist "%DEP_PATH%\%DEP_REVERT%" (
git checkout -- "%DEP_PATH%\%DEP_REVERT%"
if not errorlevel 1 (
echo Reverted auto-changes in %DEP_REVERT%
)
)
)
) else (
echo WARNING: %DEP_LPK% not found, skipping
)
goto fin
:skip_build
echo Skipping %DEP_NAME% build lpk due to local changes or DO_BUILD policy.
:fin
exit /b 0