tools/release: Cleanup scripts
This commit is contained in:
@@ -41,37 +41,7 @@ function assert_defined(){
|
||||
fi
|
||||
}
|
||||
|
||||
function build_cxx() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/cxx_build" -; then
|
||||
echo "build C++ up to date!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check all prerequisite
|
||||
command -v gcc | xargs echo "gcc: " | tee -a build.log
|
||||
command -v cmake | xargs echo "cmake: " | tee -a build.log
|
||||
command -v make | xargs echo "make: " | tee -a build.log
|
||||
|
||||
# Clean everything
|
||||
cd "${ROOT_DIR}" || exit 2
|
||||
make clean
|
||||
make clean_third_party
|
||||
|
||||
# Build Third Party
|
||||
echo -n "Build Third Party..." | tee -a build.log
|
||||
make third_party UNIX_PYTHON_VER=3
|
||||
echo "DONE" | tee -a build.log
|
||||
|
||||
echo -n "Build C++..." | tee -a build.log
|
||||
make cc -l 4 UNIX_PYTHON_VER=3
|
||||
echo "DONE" | tee -a build.log
|
||||
#make test_cc -l 4 UNIX_PYTHON_VER=3
|
||||
#echo "make test_cc: DONE" | tee -a build.log
|
||||
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/cxx_build"
|
||||
}
|
||||
|
||||
# Net build
|
||||
# .Net build
|
||||
function build_dotnet() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/dotnet_build" -; then
|
||||
echo "build .Net up to date!"
|
||||
@@ -180,22 +150,34 @@ function build_java() {
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/java_build"
|
||||
}
|
||||
|
||||
function build_fz() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/fz_build" -; then
|
||||
echo "build Flatzinc up to date!" | tee -a build.log
|
||||
# Python 3
|
||||
# todo(mizux) Use `make --directory tools/docker python` instead
|
||||
function build_python() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/python_build" -; then
|
||||
echo "build python up to date!" | tee -a build.log
|
||||
return 0
|
||||
fi
|
||||
build_cxx
|
||||
|
||||
# Clean fz
|
||||
cd "${ROOT_DIR}" || exit 2
|
||||
make clean_fz
|
||||
command -v swig
|
||||
command -v swig | xargs echo "swig: " | tee -a build.log
|
||||
command -v python3 | xargs echo "python3: " | tee -a build.log
|
||||
command -v protoc-gen-mypy | xargs echo "protoc-gen-mypy: " | tee -a build.log
|
||||
protoc-gen-mypy --version | xargs echo "protoc-gen-mypy version: " | tee -a build.log
|
||||
protoc-gen-mypy --version | grep "3\.2\.0"
|
||||
|
||||
echo -n "Build flatzinc..." | tee -a build.log
|
||||
make fz -l 4 UNIX_PYTHON_VER=3
|
||||
echo -n "Cleaning Python 3..." | tee -a build.log
|
||||
rm -rf temp_python
|
||||
echo "DONE" | tee -a build.log
|
||||
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/fz_build"
|
||||
echo -n "Build Python 3..." | tee -a build.log
|
||||
cmake -S . -B temp_python -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON
|
||||
cmake --build temp_python -j8 -v
|
||||
echo "DONE" | tee -a build.log
|
||||
#cmake --build test_python --target test
|
||||
#echo "cmake test_python: DONE" | tee -a build.log
|
||||
|
||||
cp temp_python/python/dist/*.whl export/
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/python_build"
|
||||
}
|
||||
|
||||
# Create Archive
|
||||
@@ -204,7 +186,6 @@ function build_archive() {
|
||||
echo "build archive up to date!" | tee -a build.log
|
||||
return 0
|
||||
fi
|
||||
build_fz
|
||||
|
||||
# Clean archive
|
||||
cd "${ROOT_DIR}" || exit 2
|
||||
@@ -253,36 +234,6 @@ function build_examples() {
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/examples_build"
|
||||
}
|
||||
|
||||
# Python 3
|
||||
# todo(mizux) Use `make --directory tools/docker python` instead
|
||||
function build_python() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/python_build" -; then
|
||||
echo "build python up to date!" | tee -a build.log
|
||||
return 0
|
||||
fi
|
||||
|
||||
command -v swig
|
||||
command -v swig | xargs echo "swig: " | tee -a build.log
|
||||
command -v python3 | xargs echo "python3: " | tee -a build.log
|
||||
command -v protoc-gen-mypy | xargs echo "protoc-gen-mypy: " | tee -a build.log
|
||||
protoc-gen-mypy --version | xargs echo "protoc-gen-mypy version: " | tee -a build.log
|
||||
protoc-gen-mypy --version | grep "3\.2\.0"
|
||||
|
||||
echo -n "Cleaning Python 3..." | tee -a build.log
|
||||
rm -rf temp_python
|
||||
echo "DONE" | tee -a build.log
|
||||
|
||||
echo -n "Build Python 3..." | tee -a build.log
|
||||
cmake -S . -B temp_python -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON
|
||||
cmake --build temp_python -j8 -v
|
||||
echo "DONE" | tee -a build.log
|
||||
#cmake --build test_python --target test
|
||||
#echo "cmake test_python: DONE" | tee -a build.log
|
||||
|
||||
cp temp_python/python/dist/*.whl export/
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/python_build"
|
||||
}
|
||||
|
||||
# Main
|
||||
function main() {
|
||||
case ${1} in
|
||||
@@ -305,7 +256,7 @@ function main() {
|
||||
mkdir -p export
|
||||
|
||||
case ${1} in
|
||||
cxx|dotnet|java|python|archive|examples)
|
||||
dotnet|java|python|archive|examples)
|
||||
"build_$1"
|
||||
exit ;;
|
||||
all)
|
||||
|
||||
@@ -42,39 +42,6 @@ function assert_defined(){
|
||||
fi
|
||||
}
|
||||
|
||||
function build_cxx() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/cxx_build" -; then
|
||||
echo "build C++ up to date!" | tee -a build.log
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check all prerequisite
|
||||
command -v clang
|
||||
command -v clang | xargs echo "clang: " | tee -a build.log
|
||||
command -v cmake
|
||||
command -v cmake | xargs echo "cmake: " | tee -a build.log
|
||||
command -v make
|
||||
command -v make | xargs echo "make: " | tee -a build.log
|
||||
|
||||
# Clean everything
|
||||
cd "${ROOT_DIR}" || exit 2
|
||||
make clean
|
||||
make clean_third_party
|
||||
|
||||
# Build Third Party
|
||||
echo -n "Build Third Party..." | tee -a build.log
|
||||
make third_party UNIX_PYTHON_VER=3.9
|
||||
echo "DONE" | tee -a build.log
|
||||
|
||||
echo -n "Build C++..." | tee -a build.log
|
||||
make cc -l 4 UNIX_PYTHON_VER=3.9
|
||||
echo "DONE" | tee -a build.log
|
||||
#make test_cc -l 4 UNIX_PYTHON_VER=3.9
|
||||
#echo "make test_cc: DONE" | tee -a build.log
|
||||
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/cxx_build"
|
||||
}
|
||||
|
||||
# .Net build
|
||||
function build_dotnet() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/dotnet_build" -; then
|
||||
@@ -177,22 +144,48 @@ function build_java() {
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/java_build"
|
||||
}
|
||||
|
||||
function build_fz() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/fz_build" -; then
|
||||
echo "build Flatzinc up to date!" | tee -a build.log
|
||||
# Python 3
|
||||
# todo(mizux) Use `make --directory tools/docker python` instead
|
||||
function build_python() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/python_build" -; then
|
||||
echo "build python up to date!" | tee -a build.log
|
||||
return 0
|
||||
fi
|
||||
build_cxx
|
||||
|
||||
# Clean fz
|
||||
cd "${ROOT_DIR}" || exit 2
|
||||
make clean_fz
|
||||
command -v swig
|
||||
command -v swig | xargs echo "swig: " | tee -a build.log
|
||||
PY=(3.6 3.7 3.8 3.9 3.10)
|
||||
for i in "${PY[@]}"; do
|
||||
command -v "python$i"
|
||||
command -v "python$i" | xargs echo "python$i: " | tee -a build.log
|
||||
"python$i" -c "import distutils.util as u; print(u.get_platform())" | tee -a build.log
|
||||
"python$i" -m pip install --upgrade --user wheel absl-py mypy-protobuf virtualenv
|
||||
done
|
||||
command -v protoc-gen-mypy | xargs echo "protoc-gen-mypy: " | tee -a build.log
|
||||
protoc-gen-mypy --version | xargs echo "protoc-gen-mypy version: " | tee -a build.log
|
||||
protoc-gen-mypy --version | grep "3\.2\.0"
|
||||
|
||||
echo -n "Build flatzinc..." | tee -a build.log
|
||||
make fz -l 4 UNIX_PYTHON_VER=3.9
|
||||
echo "DONE" | tee -a build.log
|
||||
for i in "${PY[@]}"; do
|
||||
echo -n "Cleaning Python $i..." | tee -a build.log
|
||||
rm -rf "temp_python$i"
|
||||
echo "DONE" | tee -a build.log
|
||||
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/fz_build"
|
||||
PY_PATH="/Library/Frameworks/Python.framework/Versions/$i"
|
||||
if [[ ! -d "$PY_PATH" ]]; then
|
||||
echo "Error: Python $i is not found (${PY_PATH})." | tee -a build.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "Build Python $i..." | tee -a build.log
|
||||
cmake -S. -B"temp_python$i" -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON -DPython3_ROOT_DIR="$PY_PATH"
|
||||
cmake --build "temp_python$i" -j8 -v
|
||||
echo "DONE" | tee -a build.log
|
||||
#cmake --build temp_python$i --target test
|
||||
#echo "cmake test_python$i: DONE" | tee -a build.log
|
||||
|
||||
cp "temp_python$i"/python/dist/*.whl export/
|
||||
done
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/python_build"
|
||||
}
|
||||
|
||||
# Create Archive
|
||||
@@ -201,7 +194,6 @@ function build_archive() {
|
||||
echo "build archive up to date!" | tee -a build.log
|
||||
return 0
|
||||
fi
|
||||
build_fz
|
||||
|
||||
# Clean archive
|
||||
cd "${ROOT_DIR}" || exit 2
|
||||
@@ -250,50 +242,6 @@ function build_examples() {
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/examples_build"
|
||||
}
|
||||
|
||||
# Python 3
|
||||
# todo(mizux) Use `make --directory tools/docker python` instead
|
||||
function build_python() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/python_build" -; then
|
||||
echo "build python up to date!" | tee -a build.log
|
||||
return 0
|
||||
fi
|
||||
|
||||
command -v swig
|
||||
command -v swig | xargs echo "swig: " | tee -a build.log
|
||||
PY=(3.6 3.7 3.8 3.9 3.10)
|
||||
for i in "${PY[@]}"; do
|
||||
command -v "python$i"
|
||||
command -v "python$i" | xargs echo "python$i: " | tee -a build.log
|
||||
"python$i" -c "import distutils.util as u; print(u.get_platform())" | tee -a build.log
|
||||
"python$i" -m pip install --upgrade --user wheel absl-py mypy-protobuf virtualenv
|
||||
done
|
||||
command -v protoc-gen-mypy | xargs echo "protoc-gen-mypy: " | tee -a build.log
|
||||
protoc-gen-mypy --version | xargs echo "protoc-gen-mypy version: " | tee -a build.log
|
||||
protoc-gen-mypy --version | grep "3\.2\.0"
|
||||
|
||||
for i in "${PY[@]}"; do
|
||||
echo -n "Cleaning Python $i..." | tee -a build.log
|
||||
rm -rf "temp_python$i"
|
||||
echo "DONE" | tee -a build.log
|
||||
|
||||
PY_PATH="/Library/Frameworks/Python.framework/Versions/$i"
|
||||
if [[ ! -d "$PY_PATH" ]]; then
|
||||
echo "Error: Python $i is not found (${PY_PATH})." | tee -a build.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "Build Python $i..." | tee -a build.log
|
||||
cmake -S. -B"temp_python$i" -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON -DPython3_ROOT_DIR="$PY_PATH"
|
||||
cmake --build "temp_python$i" -j8 -v
|
||||
echo "DONE" | tee -a build.log
|
||||
#cmake --build temp_python$i --target test
|
||||
#echo "cmake test_python$i: DONE" | tee -a build.log
|
||||
|
||||
cp "temp_python$i"/python/dist/*.whl export/
|
||||
done
|
||||
echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" > "${ROOT_DIR}/export/python_build"
|
||||
}
|
||||
|
||||
# Main
|
||||
function main() {
|
||||
case ${1} in
|
||||
@@ -316,7 +264,7 @@ function main() {
|
||||
|
||||
mkdir -p export
|
||||
case ${1} in
|
||||
cxx|dotnet|java|python|archive|examples)
|
||||
dotnet|java|python|archive|examples)
|
||||
"build_$1"
|
||||
exit ;;
|
||||
all)
|
||||
|
||||
@@ -42,32 +42,6 @@ function assert_defined(){
|
||||
fi
|
||||
}
|
||||
|
||||
function build_devel() {
|
||||
# Check all prerequisite
|
||||
command -v docker
|
||||
|
||||
# Clean
|
||||
#docker image rm -f ortools:linux_devel 2>/dev/null
|
||||
#docker image rm -f ortools:linux_env 2>/dev/null
|
||||
|
||||
cd "${RELEASE_DIR}" || exit 2
|
||||
|
||||
# Build env
|
||||
docker build --tag ortools:linux_env \
|
||||
--target=env \
|
||||
-f "${RELEASE_DIR}/Dockerfile" "${RELEASE_DIR}"
|
||||
|
||||
# Build devel
|
||||
assert_defined ORTOOLS_BRANCH
|
||||
assert_defined ORTOOLS_SHA1
|
||||
|
||||
docker build --tag ortools:linux_devel \
|
||||
--build-arg ORTOOLS_GIT_BRANCH="${ORTOOLS_BRANCH}" \
|
||||
--build-arg ORTOOLS_GIT_SHA1="${ORTOOLS_SHA1}" \
|
||||
--target=devel \
|
||||
-f Dockerfile .
|
||||
}
|
||||
|
||||
function build_delivery() {
|
||||
assert_defined ORTOOLS_BRANCH
|
||||
assert_defined ORTOOLS_SHA1
|
||||
@@ -103,11 +77,7 @@ function build_delivery() {
|
||||
-f Dockerfile .
|
||||
}
|
||||
|
||||
function build_examples() {
|
||||
local -r ORTOOLS_DELIVERY=examples
|
||||
build_delivery
|
||||
}
|
||||
|
||||
# .Net build
|
||||
function build_dotnet() {
|
||||
local -r ORTOOLS_DELIVERY=dotnet
|
||||
build_delivery
|
||||
@@ -129,13 +99,19 @@ function build_java() {
|
||||
-t ortools/linux_delivery:java "cp export/*.jar* /export/"
|
||||
}
|
||||
|
||||
# Python build
|
||||
function build_python() {
|
||||
local -r ORTOOLS_DELIVERY=python
|
||||
build_delivery
|
||||
}
|
||||
|
||||
function build_archive() {
|
||||
local -r ORTOOLS_DELIVERY=archive
|
||||
build_delivery
|
||||
}
|
||||
|
||||
function build_python() {
|
||||
local -r ORTOOLS_DELIVERY=python
|
||||
function build_examples() {
|
||||
local -r ORTOOLS_DELIVERY=examples
|
||||
build_delivery
|
||||
}
|
||||
|
||||
@@ -157,11 +133,10 @@ function main() {
|
||||
|
||||
local -r ORTOOLS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
local -r ORTOOLS_SHA1=$(git rev-parse --verify HEAD)
|
||||
build_devel
|
||||
|
||||
mkdir -p export
|
||||
case ${1} in
|
||||
cxx|dotnet|java|python|archive|examples)
|
||||
dotnet|java|python|archive|examples)
|
||||
"build_$1"
|
||||
exit ;;
|
||||
all)
|
||||
|
||||
@@ -71,7 +71,6 @@ exit /B %ERRORLEVEL%
|
||||
if "%1"=="reset" (
|
||||
echo clean everything... | tee.exe -a build.log
|
||||
make.exe clean || exit 1
|
||||
make.exe clean_third_party || exit 1
|
||||
rm.exe -rf temp_dotnet
|
||||
rm.exe -rf temp_java
|
||||
for %%v in (6 7 8 9 10) do (
|
||||
@@ -114,43 +113,7 @@ echo cmd /c %PRG%
|
||||
exit /B 0
|
||||
|
||||
|
||||
:BUILD_CXX
|
||||
title Build C++
|
||||
set HASH=
|
||||
for /F "tokens=* delims=" %%x in (build_cxx.log) do (set HASH=%%x)
|
||||
if "%HASH%"=="%BRANCH% %SHA1%" (
|
||||
echo C++ build seems up to date, skipping
|
||||
exit /B 0
|
||||
)
|
||||
|
||||
REM Check C++
|
||||
which.exe cmake || exit 1
|
||||
which.exe cmake | tee.exe -a build.log
|
||||
|
||||
REM clean everything
|
||||
echo clean everything... | tee.exe -a build.log
|
||||
make.exe clean_third_party || exit 1
|
||||
make.exe clean || exit 1
|
||||
|
||||
REM THIRD PARTY
|
||||
echo make third_party: ... | tee.exe -a build.log
|
||||
make.exe third_party WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
|
||||
echo make third_party: DONE | tee.exe -a build.log
|
||||
|
||||
echo make cc: ... | tee.exe -a build.log
|
||||
make.exe cc WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
|
||||
echo make cc: DONE | tee.exe -a build.log
|
||||
REM make.exe test_cc WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
|
||||
REM echo make test_cc: DONE | tee.exe -a build.log
|
||||
|
||||
echo make fz: ... | tee.exe -a build.log
|
||||
make.exe fz WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
|
||||
echo make fz: DONE | tee.exe -a build.log
|
||||
|
||||
echo %BRANCH% %SHA1%>build_cxx.log
|
||||
exit /B 0
|
||||
|
||||
|
||||
REM Build .Net
|
||||
:BUILD_DOTNET
|
||||
title Build .Net
|
||||
set HASH=
|
||||
@@ -189,6 +152,7 @@ echo %BRANCH% %SHA1%>build_dotnet.log
|
||||
exit /B 0
|
||||
|
||||
|
||||
REM Build Java
|
||||
:BUILD_JAVA
|
||||
title Build Java
|
||||
set HASH=
|
||||
|
||||
Reference in New Issue
Block a user