Skip to content

Commit ee6ed34

Browse files
author
Chris Maunder
committed
Moving scripts into devops / downloads into root
1 parent d43bd6b commit ee6ed34

11 files changed

Lines changed: 162 additions & 176 deletions

File tree

‎.gitignore‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,16 @@ MigrationBackup/
308308
wget-log*
309309

310310
# keep the folder structure but don't git commit the cached downloads
311-
!/src/downloads
312-
/src/downloads/*
311+
!/downloads
312+
/downloads/*
313313

314-
!/src/downloads/modules
315-
/src/downloads/modules/*
316-
!/src/downloads/modules/readme.txt
314+
!/downloads/modules
315+
/downloads/modules/*
316+
!/downloads/modules/readme.txt
317317

318-
!/src/downloads/models
319-
/src/downloads/models/*
320-
!/src/downloads/models/models.json
318+
!/downloads/models
319+
/downloads/models/*
320+
!/downloads/models/models.json
321321

322322

323323
# Downloaded assets and libraries for modules
Lines changed: 34 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,45 @@ set verbosity=quiet
1616
:: Show output in wild, crazy colours
1717
set useColor=true
1818

19+
:: Whether or not to use the jq utility for JSON parsing
20+
set useJq=false
21+
1922
:: Set this to false (or call script with --no-dotnet) to exclude .NET packages
2023
:: This saves time to allow for quick packaging of the easier, non-compiled modules
2124
set includeDotNet=true
2225

23-
:: Basic locations
24-
25-
:: The path to the directory containing the setup script. Will end in "\"
26-
set setupScriptDirPath=%~dp0
26+
:: Width of lines
27+
set lineWidth=70
2728

28-
:: The path to the application root dir. This is 'src' in dev, or / in production
29-
:: This setup script always lives in the app root
30-
set appRootDirPath=!setupScriptDirPath!
3129

32-
:: The name of the source directory
33-
set srcDirName=src
30+
:: Basic locations
3431

3532
:: The name of the dir, within the current directory, where install assets will
3633
:: be downloaded
3734
set downloadDir=downloads
3835

36+
:: The name of the dir holding the source code
37+
set srcDir=src
38+
39+
:: The name of the dir holding the SDK
40+
set sdkDir=SDK
41+
3942
:: The name of the dir holding the downloaded/sideloaded modules
4043
set modulesDir=modules
4144

4245
:: The name of the dir holding the external modules
4346
set externalModulesDir=CodeProject.AI-Modules
4447

45-
set sdkPath=!appRootDirPath!SDK
4648

47-
:: Whether or not to use the jq utility for JSON parsing
48-
set useJq=false
49+
:: The path to the directory containing this script. Will end in "\"
50+
set thisScriptDirPath=%~dp0
51+
52+
:: We're assuming this script lives in /devops/build
53+
pushd %thisScriptDirPath%..\..
54+
set rootDirPath=%cd%
55+
popd
56+
set sdkDirPath=%rootDirPath%\%srcDir%\%sdkDir%
57+
set sdkScriptsDirPath=%sdkDirPath%\Scripts
4958

5059

5160
:: Override some values via parameters ::::::::::::::::::::::::::::::::::::::::
@@ -56,10 +65,13 @@ set useJq=false
5665
if not "!arg_name!" == "" (
5766
if not "!arg_name:--no-color=!" == "!arg_name!" set useColor=false
5867
if not "!arg_name:--no-dotnet=!" == "!arg_name!" set includeDotNet=false
59-
if not "!arg_name:--path-to-setup=!" == "!arg_name!" (
60-
set setupScriptDirPath=!arg_value!
61-
shift
62-
)
68+
69+
REM No longer supporting this scenario
70+
REM if not "!arg_name:--path-to-setup=!" == "!arg_name!" (
71+
REM set setupScriptDirPath=!arg_value!
72+
REM shift
73+
REM )
74+
6375
if not "!arg_name:--verbosity=!" == "!arg_name!" (
6476
set verbosity=!arg_value!
6577
shift
@@ -69,58 +81,18 @@ set useJq=false
6981
if not "!arg_name!"=="" goto param_loop
7082

7183

72-
:: This can be x86 (32-bit), AMD64 (Intel/AMD 64bit), ARM64 (Arm 64bit)
73-
set architecture=%PROCESSOR_ARCHITECTURE%
74-
75-
:: A NOTE ON PLATFORM.
76-
:: We use the full "x86_64" for architecture, but follow the common convention
77-
:: of abbreviating this to "x64" when used in conjuntion with OS. So windows-x64
78-
:: rather than windows-x86_64. To simplify further, if the platform value doesn't
79-
:: have a suffix then it's assumed to be -x64. This may change in the future.
80-
if /i "!architecture!" == "amd64" set architecture=x86_64
81-
if /i "!architecture!" == "ARM64" set architecture=arm64
82-
83-
:: In Development, this script is in the /src folder. In Production there is no
84-
:: /src folder; everything is in the root folder. So: go to the folder
85-
:: containing this script and check the name of the parent folder to see if
86-
:: we're in dev or production.
87-
pushd "!setupScriptDirPath!"
88-
for /f "delims=\" %%a in ("%cd%") do @set setupScriptDirName=%%~nxa
89-
popd
90-
91-
set executionEnvironment=Production
92-
if /i "%setupScriptDirName%" == "%srcDirName%" set executionEnvironment=Development
93-
94-
:: The absolute path to the setup script and the root directory. Note that
95-
:: this script (and the SDK folder) is either in the /src dir or the root dir
96-
pushd "!setupScriptDirPath!"
97-
set sdkScriptsDirPath=%cd%\SDK\Scripts
98-
if /i "%executionEnvironment%" == "Development" cd ..
99-
set rootDirPath=%cd%
100-
popd
101-
102-
set appRootDirPath=!setupScriptDirPath!
103-
104-
:: Platform can define where things are located :::::::::::::::::::::::::::::::
105-
10684
:: The location of directories relative to the root of the solution directory
107-
set modulesDirPath=!appRootDirPath!!modulesDir!
108-
set externalModulesDirPath=!appRootDirPath!\..\!externalModulesDir!
109-
set downloadDirPath=!appRootDirPath!!downloadDir!
85+
set modulesDirPath=!rootDirPath!\%srcDir%\!modulesDir!
86+
set externalModulesDirPath=!rootDirPath!\..\!externalModulesDir!
87+
set downloadDirPath=!rootDirPath!\!downloadDir!
11088

11189
:: Let's go
11290
if /i "!useColor!" == "true" call "!sdkScriptsDirPath!\utils.bat" setESC
113-
if /i "!executionEnvironment!" == "Development" (
114-
set scriptTitle= Creating CodeProject.AI Module Downloads
115-
) else (
116-
writeLine "Can't run in Production. Exiting" "Red"
117-
goto:eof
118-
)
11991

12092
set lineWidth=70
12193

12294
call "!sdkScriptsDirPath!\utils.bat" WriteLine
123-
call "!sdkScriptsDirPath!\utils.bat" WriteLine "!scriptTitle!" "DarkYellow" "Default" !lineWidth!
95+
call "!sdkScriptsDirPath!\utils.bat" WriteLine "Creating CodeProject.AI Module Downloads" "DarkYellow" "Default" !lineWidth!
12496
call "!sdkScriptsDirPath!\utils.bat" WriteLine
12597
call "!sdkScriptsDirPath!\utils.bat" WriteLine "========================================================================" "DarkGreen"
12698
call "!sdkScriptsDirPath!\utils.bat" WriteLine
@@ -132,8 +104,7 @@ call "!sdkScriptsDirPath!\utils.bat" WriteLine
132104

133105
if /i "%verbosity%" neq "quiet" (
134106
call "!sdkScriptsDirPath!\utils.bat" WriteLine
135-
call "!sdkScriptsDirPath!\utils.bat" WriteLine "executionEnvironment = !executionEnvironment!" !color_mute!
136-
call "!sdkScriptsDirPath!\utils.bat" WriteLine "appRootDirPath = !appRootDirPath!" !color_mute!
107+
call "!sdkScriptsDirPath!\utils.bat" WriteLine "rootDirPath = !rootDirPath!" !color_mute!
137108
call "!sdkScriptsDirPath!\utils.bat" WriteLine "setupScriptDirPath = !setupScriptDirPath!" !color_mute!
138109
call "!sdkScriptsDirPath!\utils.bat" WriteLine "sdkScriptsDirPath = !sdkScriptsDirPath!" !color_mute!
139110
call "!sdkScriptsDirPath!\utils.bat" WriteLine "modulesDirPath = !modulesDirPath!" !color_mute!
@@ -145,7 +116,7 @@ if /i "%verbosity%" neq "quiet" (
145116

146117
set success=true
147118

148-
pushd SDK\Utilities\ParseJSON
119+
pushd %sdkDirPath%\Utilities\ParseJSON
149120
if not exist ParseJSON.exe (
150121
dotnet build /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary -c Release >NUL
151122
if exist .\bin\Release\net7.0\ move .\bin\Release\net7.0\* . >nul
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ lineWidth=70
2929

3030
# Basic locations
3131

32-
# The path to the directory containing the setup scripts
33-
#setupScriptDirPath=$(dirname "$0")
34-
setupScriptDirPath="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
32+
# The name of the dir, within the current directory, where install assets will
33+
# be downloaded
34+
downloadDir='downloads'
3535

3636
# The name of the source directory (in development)
3737
srcDirName='src'
3838

39-
# The name of the dir, within the current directory, where install assets will
40-
# be downloaded
41-
downloadDir='downloads'
39+
# The name of the dir holing the SDK
40+
sdkDir='SDK'
4241

4342
# The name of the dir holding the downloaded/sideloaded backend analysis services
4443
modulesDir="modules"
@@ -47,37 +46,41 @@ modulesDir="modules"
4746
externalModulesDir="CodeProject.AI-Modules"
4847

4948

50-
# Override some values via parameters ::::::::::::::::::::::::::::::::::::::::::
51-
for i in "$@"; do
52-
case $i in
53-
--no-dotnet) includeDotNet=false ;;
54-
--no-color) useColor=false ;;
55-
-*|--*) echo "Unknown option $i" ;;
56-
*) ;;
57-
esac
58-
done
59-
60-
# In Development, this script is in the /src folder. In Production there is no
61-
# /src folder; everything is in the root folder. So: go to the folder
62-
# containing this script and check the name of the parent folder to see if
63-
# we're in dev or production.
64-
pushd "$setupScriptDirPath" >/dev/null
65-
setupScriptDirName="$(basename ${setupScriptDirPath})"
66-
setupScriptDirName=${setupScriptDirName:-/} # correct for the case where pwd=/
67-
popd >/dev/null
68-
69-
executionEnvironment='Production'
70-
if [ "$setupScriptDirName" == "$srcDirName" ]; then executionEnvironment='Development'; fi
49+
# The path to the directory containing this script
50+
#thisScriptDirPath=$(dirname "$0")
51+
thisScriptDirPath="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
7152

72-
# The absolute path to the installer script and the root directory. Note that
73-
# this script (and the SDK folder) is either in the /src dir or the root dir
74-
sdkScriptsDirPath="${setupScriptDirPath}/SDK/Scripts"
75-
pushd "$setupScriptDirPath" >/dev/null
76-
if [ "$executionEnvironment" == 'Development' ]; then cd ..; fi
53+
# We're assuming this script lives in /devops/build
54+
pushd "${thisScriptDirPath}/../.." >/dev/null
7755
rootDirPath="$(pwd)"
7856
popd >/dev/null
57+
sdkDirPath="${rootDirPath}/${srcDirName}/${sdkDir}"
58+
sdkScriptsDirPath="${sdkDirPath}/Scripts"
59+
60+
# Override some values via parameters ::::::::::::::::::::::::::::::::::::::::::
7961

80-
appRootDirPath="${setupScriptDirPath}"
62+
while [[ $# -gt 0 ]]; do
63+
param=$(echo $1 | tr '[:upper:]' '[:lower:]')
64+
65+
if [ "$param" = "--no-dotnet" ]; then includeDotNet=false; fi
66+
if [ "$param" = "--no-color" ]; then useColor=false; fi
67+
if [ "$param" = "--verbosity" ]; then
68+
shift
69+
if [[ $# -gt 0 ]]; then
70+
param_value=$(echo $1 | tr '[:upper:]' '[:lower:]')
71+
if [[ "$param_value" =~ ^(quiet|info|loud)$ ]]; then
72+
# echo "Verbosity is $1 -> ${param_value}"
73+
verbosity="$param_value"
74+
echo "Setting verbosity to ${verbosity}"
75+
else
76+
echo "No Verbosity value provided"
77+
fi
78+
else
79+
echo "Verbosity does not match the expected values quiet|info|loud"
80+
fi
81+
fi
82+
shift
83+
done
8184

8285
# Standard output may be used as a return value in the functions. Expose stream
8386
# 3 so we can do 'echo "Hello, World!" >&3' within these functions for debugging
@@ -173,12 +176,10 @@ function doModulePackage () {
173176
}
174177

175178

176-
# Platform can define where things are located :::::::::::::::::::::::::::::::
177-
178179
# The location of directories relative to the root of the solution directory
179-
modulesDirPath="${appRootDirPath}/${modulesDir}"
180-
externalModulesDirPath="${appRootDirPath}/../../${externalModulesDir}"
181-
downloadDirPath="${appRootDirPath}/${downloadDir}"
180+
modulesDirPath="${rootDirPath}/${srcDirName}/${modulesDir}"
181+
externalModulesDirPath="${rootDirPath}/../${externalModulesDir}"
182+
downloadDirPath="${rootDirPath}/${downloadDir}"
182183

183184
# Let's go
184185

@@ -196,9 +197,8 @@ writeLine
196197

197198
if [ "$verbosity" != "quiet" ]; then
198199
writeLine
199-
writeLine "executionEnvironment = ${executionEnvironment}" $color_mute
200-
writeLine "appRootDirPath = ${appRootDirPath}" $color_mute
201-
writeLine "setupScriptDirPath = ${setupScriptDirPath}" $color_mute
200+
writeLine "rootDirPath = ${rootDirPath}" $color_mute
201+
writeLine "thisScriptDirPath = ${thisScriptDirPath}" $color_mute
202202
writeLine "sdkScriptsDirPath = ${sdkScriptsDirPath}" $color_mute
203203
writeLine "modulesDirPath = ${modulesDirPath}" $color_mute
204204
writeLine "externalModulesDirPath = ${externalModulesDirPath}" $color_mute
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ if /i "%cleanUserData%" == "true" (
171171
call "!sdkDir!\utils.bat" WriteLine "Cleaning User data" "White" "Blue" !lineWidth!
172172
call "!sdkDir!\utils.bat" WriteLine
173173

174-
call :RemoveDir "!rootDir!\src\modules\FaceProcessing\datastore"
174+
call :RemoveDir "!externalModulesDir!\CodeProject.AI-FaceProcessing\datastore"
175175
)
176176

177177
if /i "%cleanInstallAll%" == "true" (
@@ -247,15 +247,15 @@ if /i "%cleanDownloadCache%" == "true" (
247247
call "!sdkDir!\utils.bat" WriteLine
248248

249249
rem delete downloads for each module
250-
FOR /d %%a IN ("%rootDir%\src\downloads\*") DO (
250+
FOR /d %%a IN ("%rootDir%\downloads\*") DO (
251251
IF /i NOT "%%~nxa"=="modules" IF /i NOT "%%~nxa"=="models" call :RemoveDir "%%a"
252252
)
253253
rem delete module packages downloads
254-
FOR %%a IN ("%rootDir%\src\downloads\modules\*") DO (
254+
FOR %%a IN ("%rootDir%\downloads\modules\*") DO (
255255
IF /i NOT "%%~nxa"=="readme.txt" call :RemoveFile "%%a"
256256
)
257257
rem delete model packages downloads
258-
FOR %%a IN ("%rootDir%\src\downloads\models\*") DO (
258+
FOR %%a IN ("%rootDir%\downloads\models\*") DO (
259259
IF /i NOT "%%~nxa"=="models.json" call :RemoveFile "%%a"
260260
)
261261
)

0 commit comments

Comments
 (0)