Unverified Commit 2e1b39ba authored by Josh Maxwell's avatar Josh Maxwell Committed by GitHub
Browse files

[R-package] Suppresses unknown pragma warnings during CRAN build (#3460)



* Modified script to also remove pragma warnings.

This also includes modifying the scope of the pragma removal.
Previously this script only searched inside the ./src/include/LightGMB directory.
This was not inclusive enough to remove the warnings in files shown in the ticket.

* Adds CI test that exits if unknown pragma warnings are present.

* Expanding pragma removal to cpp and hpp files.

* Update .ci/test_r_package.sh

Removing unneeded conditions since this script will only run on Linux and Mac builds anyway.
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* Update .ci/test_r_package.sh

Fixes typo
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>

* replacing double quotes with single quotes

* Using a more portable find syntax so it works on macOS and Linux
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>
parent 0c1c36cd
...@@ -216,3 +216,17 @@ if [[ $OS_NAME == "macos" ]] && [[ $R_BUILD_TYPE == "cran" ]]; then ...@@ -216,3 +216,17 @@ if [[ $OS_NAME == "macos" ]] && [[ $R_BUILD_TYPE == "cran" ]]; then
exit -1 exit -1
fi fi
fi fi
# this check makes sure that no "warning: unknown pragma ignored" logs
# reach the user leading them to believe that something went wrong
if [[ $R_BUILD_TYPE == "cran" ]]; then
pragma_warning_present=$(
cat $BUILD_LOG_FILE \
| grep -E "warning: unknown pragma ignored" \
| wc -l
)
if [[ $pragma_warning_present -ne 0 ]]; then
echo "Unknown pragma warning is present, pragmas should have been removed before build"
exit -1
fi
fi
...@@ -50,19 +50,20 @@ cd ${TEMP_R_DIR} ...@@ -50,19 +50,20 @@ cd ${TEMP_R_DIR}
sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" DESCRIPTION sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" DESCRIPTION
sed -i.bak -e "s/~~DATE~~/${CURRENT_DATE}/" DESCRIPTION sed -i.bak -e "s/~~DATE~~/${CURRENT_DATE}/" DESCRIPTION
# Remove 'region' and 'endregion' pragmas. This won't change # Remove 'region', 'endregion', and 'warning' pragmas.
# the correctness of the code. CRAN does not allow you # This won't change the correctness of the code. CRAN does
# to use compiler flag '-Wno-unknown-pragmas' or # not allow you to use compiler flag '-Wno-unknown-pragmas' or
# pragmas that suppress warnings. # pragmas that suppress warnings.
echo "Removing unknown pragmas in headers" echo "Removing unknown pragmas in headers"
for file in src/include/LightGBM/*.h; do for file in $(find . -name '*.h' -o -name '*.hpp' -o -name '*.cpp'); do
sed \ sed \
-i.bak \ -i.bak \
-e 's/^.*#pragma region.*$//' \ -e 's/^.*#pragma region.*$//' \
-e 's/^.*#pragma endregion.*$//' \ -e 's/^.*#pragma endregion.*$//' \
-e 's/^.*#pragma warning.*$//' \
"${file}" "${file}"
done done
rm src/include/LightGBM/*.h.bak find . -name '*.h.bak' -o -name '*.hpp.bak' -o -name '*.cpp.bak' -exec rm {} \;
# When building an R package with 'configure', it seems # When building an R package with 'configure', it seems
# you're guaranteed to get a shared library called # you're guaranteed to get a shared library called
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment