Skip to content

Commit 31c9290

Browse files
rcsanchez97kevinAlbs
authored andcommitted
CDRIVER-2849 name uninstall program based on components built
also make generation of uninstall optional with default to ON
1 parent 5a7090e commit 31c9290

File tree

6 files changed

+86
-26
lines changed

6 files changed

+86
-26
lines changed

.evergreen/install-uninstall-check-windows.cmd

+33-6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ echo.%CC%| findstr /I "gcc">Nul && (
5454
if errorlevel 1 (
5555
exit /B 1
5656
)
57+
58+
echo > %INSTALL_DIR%\lib\canary.txt
59+
60+
dir %INSTALL_DIR%\share\mongo-c-driver
61+
62+
%CMAKE_MAKE_PROGRAM% uninstall
63+
if errorlevel 1 (
64+
exit /B 1
65+
)
5766
) || (
5867
%CMAKE% -G "%CC%" "-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR%" "-DCMAKE_BUILD_TYPE=Debug" %BSON_ONLY_OPTION% .
5968
MSBuild.exe /m ALL_BUILD.vcxproj
@@ -64,15 +73,15 @@ echo.%CC%| findstr /I "gcc">Nul && (
6473
if errorlevel 1 (
6574
exit /B 1
6675
)
67-
)
6876

69-
echo > %INSTALL_DIR%\lib\canary.txt
77+
echo > %INSTALL_DIR%\lib\canary.txt
7078

71-
dir %INSTALL_DIR%\share\mongo-c-driver
79+
dir %INSTALL_DIR%\share\mongo-c-driver
7280

73-
call %INSTALL_DIR%\share\mongo-c-driver\uninstall.cmd
74-
if errorlevel 1 (
75-
exit /B 1
81+
MSBuild.exe /m generate_uninstall\uninstall.vcxproj
82+
if errorlevel 1 (
83+
exit /B 1
84+
)
7685
)
7786

7887
if exist %INSTALL_DIR%\lib\pkgconfig\libbson-1.0.pc (
@@ -163,6 +172,24 @@ if "%BSON_ONLY%" NEQ "1" (
163172
echo $INSTALL_DIR\include\libmongoc-1.0 check ok
164173
)
165174
)
175+
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall-bson.cmd (
176+
echo uninstall-bson.cmd found!
177+
exit /B 1
178+
) else (
179+
echo uninstall-bson.cmd check ok
180+
)
181+
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall.cmd (
182+
echo uninstall.cmd found!
183+
exit /B 1
184+
) else (
185+
echo uninstall.cmd check ok
186+
)
187+
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall-bson.sh (
188+
echo uninstall-bson.sh found!
189+
exit /B 1
190+
) else (
191+
echo uninstall-bson.sh check ok
192+
)
166193
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall.sh (
167194
echo uninstall.sh found!
168195
exit /B 1

.evergreen/install-uninstall-check.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ touch $INSTALL_DIR/lib/canary.txt
5858

5959
ls -l $INSTALL_DIR/share/mongo-c-driver
6060

61-
$INSTALL_DIR/share/mongo-c-driver/uninstall.sh
61+
make uninstall
6262

6363
set +o xtrace
6464

@@ -150,6 +150,12 @@ if [ -z "$BSON_ONLY" ]; then
150150
echo "$INSTALL_DIR/include/libmongoc-1.0 check ok"
151151
fi
152152
fi
153+
if test -f $INSTALL_DIR/share/mongo-c-driver/uninstall-bson.sh; then
154+
echo "uninstall-bson.sh found!"
155+
exit 1
156+
else
157+
echo "uninstall-bson.sh check ok"
158+
fi
153159
if test -f $INSTALL_DIR/share/mongo-c-driver/uninstall.sh; then
154160
echo "uninstall.sh found!"
155161
exit 1

CMakeLists.txt

+22-11
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ option (ENABLE_RDTSCP
5050
)
5151
option (ENABLE_APPLE_FRAMEWORK "Build libraries as frameworks on darwin platforms" OFF)
5252
set (ENABLE_ICU AUTO CACHE STRING "Enable ICU support, necessary to use non-ASCII usernames or passwords, default AUTO.")
53+
option (ENABLE_UNINSTALL "Enable creation of uninstall script and associate uninstall build target." ON)
5354

5455
project (mongo-c-driver C)
5556

@@ -336,15 +337,25 @@ if (ENABLE_MONGOC)
336337

337338
endif ()
338339

339-
if (WIN32)
340-
set (UNINSTALL_PROG "uninstall.cmd")
341-
else ()
342-
set (UNINSTALL_PROG "uninstall.sh")
343-
endif ()
344-
set (UNINSTALL_PROG_DIR "${CMAKE_INSTALL_DATADIR}/mongo-c-driver")
340+
if (ENABLE_UNINSTALL)
341+
if (WIN32)
342+
if (ENABLE_MONGOC)
343+
set (UNINSTALL_PROG "uninstall.cmd")
344+
else ()
345+
set (UNINSTALL_PROG "uninstall-bson.cmd")
346+
endif ()
347+
else ()
348+
if (ENABLE_MONGOC)
349+
set (UNINSTALL_PROG "uninstall.sh")
350+
else ()
351+
set (UNINSTALL_PROG "uninstall-bson.sh")
352+
endif ()
353+
endif ()
354+
set (UNINSTALL_PROG_DIR "${CMAKE_INSTALL_DATADIR}/mongo-c-driver")
345355

346-
# Create uninstall program and associated uninstall target
347-
#
348-
# This needs to be last (after all other add_subdirectory calls) to ensure that
349-
# the generated uninstall program is complete and correct
350-
add_subdirectory (generate_uninstall)
356+
# Create uninstall program and associated uninstall target
357+
#
358+
# This needs to be last (after all other add_subdirectory calls) to ensure that
359+
# the generated uninstall program is complete and correct
360+
add_subdirectory (generate_uninstall)
361+
endif ()

build/generate-uninstall.cmd

+7-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ for /f "usebackq delims=" %%a in ("%manifest%") do (
8484
echo.del !suffix! ^|^| echo ... not removed
8585
)
8686

87-
echo.echo Removing file share\mongo-c-driver\uninstall.cmd
88-
echo.del share\mongo-c-driver\uninstall.cmd ^|^| echo ... not removed
87+
if "%ENABLE_MONGOC%"=="ON" (
88+
echo.echo Removing file share\mongo-c-driver\uninstall.cmd
89+
echo.del share\mongo-c-driver\uninstall.cmd ^|^| echo ... not removed
90+
) else (
91+
echo.echo Removing file share\mongo-c-driver\uninstall-bson.cmd
92+
echo.del share\mongo-c-driver\uninstall-bson.cmd ^|^| echo ... not removed
93+
)
8994
call :save_dirs "share\mongo-c-driver"
9095

9196
for /f "tokens=2 delims=[]" %%a in ('set dirs[') do (

build/generate-uninstall.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,13 @@ while IFS= read -r line || [ -n "${line}" ]; do
9393
printf "(rm -f \"%s\" && printf \"\\\n\") || printf \" ... not removed\\\n\"\n" "${suffix}"
9494
done < "${manifest}"
9595

96-
printf "printf \"Removing file \\\"share/mongo-c-driver/uninstall.sh\\\"\"\n"
97-
printf "(rm -f \"share/mongo-c-driver/uninstall.sh\" && printf \"\\\n\") || printf \" ... not removed\\\n\"\n"
96+
if [ "${ENABLE_MONGOC}" = "ON" ]; then
97+
printf "printf \"Removing file \\\"share/mongo-c-driver/uninstall.sh\\\"\"\n"
98+
printf "(rm -f \"share/mongo-c-driver/uninstall.sh\" && printf \"\\\n\") || printf \" ... not removed\\\n\"\n"
99+
else
100+
printf "printf \"Removing file \\\"share/mongo-c-driver/uninstall-bson.sh\\\"\"\n"
101+
printf "(rm -f \"share/mongo-c-driver/uninstall-bson.sh\" && printf \"\\\n\") || printf \" ... not removed\\\n\"\n"
102+
fi
98103
dirs="${dirs}share/mongo-c-driver\nshare\n"
99104

100105
echo "${dirs}" | sort -ru | while IFS= read -r dir; do

generate_uninstall/CMakeLists.txt

+10-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ if (WIN32)
1717
execute_process (
1818
COMMAND
1919
${CMAKE_COMMAND} -E env
20+
ENABLE_MONGOC=${ENABLE_MONGOC}
2021
cmd.exe /c
2122
\"${PROJECT_SOURCE_DIR}/build/generate-uninstall.cmd\"
2223
mongoc_install_manifest.txt
@@ -26,6 +27,10 @@ if (WIN32)
2627
)
2728
")
2829
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" DESTINATION "${UNINSTALL_PROG_DIR}" PERMISSIONS ${UNINSTALL_PERMISSIONS})
30+
31+
add_custom_target (uninstall
32+
COMMAND call "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}"
33+
)
2934
else ()
3035
install (CODE "
3136
string(REPLACE \";\" \"\\n\" MONGOC_INSTALL_MANIFEST_CONTENT
@@ -35,6 +40,7 @@ else ()
3540
execute_process (
3641
COMMAND
3742
${CMAKE_COMMAND} -E env
43+
ENABLE_MONGOC=${ENABLE_MONGOC}
3844
\"${PROJECT_SOURCE_DIR}/build/generate-uninstall.sh\"
3945
mongoc_install_manifest.txt
4046
${CMAKE_INSTALL_PREFIX}
@@ -43,8 +49,8 @@ else ()
4349
)
4450
")
4551
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}" DESTINATION "${UNINSTALL_PROG_DIR}" PERMISSIONS ${UNINSTALL_PERMISSIONS})
46-
endif ()
4752

48-
add_custom_target (uninstall
49-
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}"
50-
)
53+
add_custom_target (uninstall
54+
COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/${UNINSTALL_PROG}"
55+
)
56+
endif ()

0 commit comments

Comments
 (0)