support build_id on Python package building (#281)

* support buildid in package building

* undo the change on build.sh

* build.sh issue on macos
This commit is contained in:
Wenbing Li 2022-08-24 14:39:33 -07:00 коммит произвёл GitHub
Родитель 134f882e64
Коммит f7151e3ae0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -4,13 +4,16 @@
set -e -x -u set -e -x -u
OSNAME=$(uname -s) OSNAME=$(uname -s)
if [[ "$OSNAME" == "Darwin" ]]; then if [ -z ${CPU_NUMBER+x} ]; then
alias nproc="sysctl -n hw.logicalcpu" if [[ "$OSNAME" == "Darwin" ]]; then
CPU_NUMBER=$(sysctl -n hw.logicalcpu)
else
CPU_NUMBER=$(nproc)
fi
fi fi
BUILD_FLAVOR=RelWithDebInfo BUILD_FLAVOR=RelWithDebInfo
target_dir=out/$OSNAME/$BUILD_FLAVOR target_dir=out/$OSNAME/$BUILD_FLAVOR
mkdir -p "$target_dir" && cd "$target_dir" mkdir -p "$target_dir" && cd "$target_dir"
if [ -z ${CPU_NUMBER+x} ]; then CPU_NUMBER=$(nproc); fi
# it looks the parallel build on CI pipeline machine causes crashes. # it looks the parallel build on CI pipeline machine causes crashes.
cmake "$@" ../../.. && cmake --build . --config $BUILD_FLAVOR --parallel "${CPU_NUMBER}" cmake "$@" ../../.. && cmake --build . --config $BUILD_FLAVOR --parallel "${CPU_NUMBER}"

Просмотреть файл

@ -126,10 +126,14 @@ def read_version():
version_str = line[0].split('=')[1].strip('" \n\r') version_str = line[0].split('=')[1].strip('" \n\r')
# is it a dev build or release? # is it a dev build or release?
if os.path.isdir(os.path.join(TOP_DIR, '.git')): build_id = os.getenv('BUILD_BUILDID', None)
rel_br, cid = read_git_refs() if build_id is not None:
if not rel_br: version_str += '.{}'.format(build_id)
version_str += '+' + cid[:7] else:
if os.path.isdir(os.path.join(TOP_DIR, '.git')):
rel_br, cid = read_git_refs()
if not rel_br:
version_str += '+' + cid[:7]
return version_str return version_str