add autoscaler and build for go code
This commit is contained in:
parent
7912242231
commit
cf1dbdc07a
4 changed files with 144 additions and 0 deletions
|
|
@ -22,3 +22,5 @@ libscaler = static_library('scaler',
|
||||||
include_directories: [incdir],
|
include_directories: [incdir],
|
||||||
dependencies: libscaler_deps,
|
dependencies: libscaler_deps,
|
||||||
install: true)
|
install: true)
|
||||||
|
|
||||||
|
subdir('providers')
|
||||||
|
|
|
||||||
34
src/autoscaler/providers/meson.build
Normal file
34
src/autoscaler/providers/meson.build
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
go_env = environment()
|
||||||
|
go_env.set('BUILDTYPE', get_option('buildtype'))
|
||||||
|
go_env.set('FIX_ENVARS','CGO_CFLAGS CGO_LDFLAGS')
|
||||||
|
go_env.set('DEPENDENCIES','thread math')
|
||||||
|
go_env.set('ENVARS', 'CURRENT_SOURCE_DIR BUILD_ROOT')
|
||||||
|
|
||||||
|
apiserver = custom_target('bcctool',
|
||||||
|
input: 'baidu/src/bcctool/main.go',
|
||||||
|
output: 'bcctool',
|
||||||
|
command: [env_program,
|
||||||
|
'CURRENT_SOURCE_DIR="@CURRENT_SOURCE_DIR@"',
|
||||||
|
'BUILD_ROOT="@BUILD_ROOT@"',
|
||||||
|
go_build_program,
|
||||||
|
'@INPUT@', '@OUTPUT@'],
|
||||||
|
env: go_env,
|
||||||
|
install: true,
|
||||||
|
install_dir: get_option('prefix') / 'bin')
|
||||||
|
|
||||||
|
scripts = [
|
||||||
|
'./baidu/scripts/getReturnRequests.sh',
|
||||||
|
'./baidu/scripts/getAvailableTemplates.sh',
|
||||||
|
'./baidu/scripts/getRequestStatus.sh',
|
||||||
|
'./baidu/scripts/requestReturnMachines.sh',
|
||||||
|
'./baidu/scripts/getAvailableMachines.sh',
|
||||||
|
'./baidu/scripts/requestMachines.sh',
|
||||||
|
'./baidu/postprovision/lsf/example_user_data.sh',
|
||||||
|
]
|
||||||
|
|
||||||
|
install_data(scripts,
|
||||||
|
install_dir: 'share/bcctool/scripts')
|
||||||
|
|
||||||
|
# FIXME: support installation of configuration
|
||||||
|
# file later
|
||||||
|
|
@ -31,6 +31,12 @@ else
|
||||||
wrap_link_args = []
|
wrap_link_args = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
go_compiler = find_program('go')
|
||||||
|
pkgconfig = find_program('pkg-config')
|
||||||
|
go_build = files('tools/go_build')
|
||||||
|
go_build_program = find_program('go_build', go_build)
|
||||||
|
env_program = find_program('env')
|
||||||
|
|
||||||
include_dir = include_directories('include', 'include/xce')
|
include_dir = include_directories('include', 'include/xce')
|
||||||
|
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
|
|
|
||||||
102
src/tools/go_build
Executable file
102
src/tools/go_build
Executable file
|
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "x$DEBUG" = "x" ]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$BUILDTYPE" = "xdebug" ]; then
|
||||||
|
CGO_CFLAGS="$CGO_CFLAGS -DWITH_DEBUG=1 -Og -ggdb "
|
||||||
|
CGO_LDFLAGS="$CGO_LDFLAGS -Og -ggdb "
|
||||||
|
GO_FLAGS=' -gcflags "all=-N -l"'
|
||||||
|
|
||||||
|
export CGO_CFLAGS CGO_LDFLAGS GO_FLAGS
|
||||||
|
fi
|
||||||
|
|
||||||
|
fix_env() {
|
||||||
|
local _n _x _cmd _v
|
||||||
|
|
||||||
|
_n="$1"
|
||||||
|
shift
|
||||||
|
_cmd="sed "
|
||||||
|
for _x in $*; do
|
||||||
|
_v=$(eval $(echo "echo \$$_x") | sed -s 's@"@@g')
|
||||||
|
_cmd="$_cmd -e s|@$_x@|$_v|g "
|
||||||
|
done
|
||||||
|
_v=$(eval $(echo "echo \$$_n"))
|
||||||
|
_cmd="$_n=\"$(echo $_v | $_cmd)\"; export $_n"
|
||||||
|
eval "$_cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
# fix value of environment variable by realpath
|
||||||
|
# of it
|
||||||
|
fix_input_envs() {
|
||||||
|
local _n _v _cmd
|
||||||
|
|
||||||
|
for _n in CURRENT_SOURCE_DIR BUILD_ROOT; do
|
||||||
|
_v=$(eval $(echo "echo \$$_n") | sed -e 's@"@@g')
|
||||||
|
_v=$(realpath $_v)
|
||||||
|
_cmd="$_n=$_v; export $_n"
|
||||||
|
eval "$_cmd"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# fix dependencies, by:
|
||||||
|
# for math just add -lmath
|
||||||
|
# for thread by add -pthread
|
||||||
|
# otherwise using
|
||||||
|
# pkg-config --cflags/ pkg-config --libs
|
||||||
|
fix_dependencies() {
|
||||||
|
local _x _cflags _ldflags
|
||||||
|
|
||||||
|
for _x in $DEPENDENCIES; do
|
||||||
|
case "$_x" in
|
||||||
|
math)
|
||||||
|
_cflags=""
|
||||||
|
_ldflags="-lm"
|
||||||
|
;;
|
||||||
|
thread)
|
||||||
|
_cflags="-pthread"
|
||||||
|
_ldflags="-pthread"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_cflags=$(pkg-config --cflags "$_x")
|
||||||
|
_ldflags=$(pkg-config --libs "$_x")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CGO_CFLAGS="$CGO_CFLAGS $_cflags"
|
||||||
|
CGO_LDFLAGS="$CGO_LDFLAGS $_ldflags"
|
||||||
|
done
|
||||||
|
|
||||||
|
export CGO_CFLAGS CGO_LDFLAGS
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 2 ]; then
|
||||||
|
echo go_build sfile dest
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_sfile=$(realpath "$1")
|
||||||
|
_sdir=$(dirname "$_sfile")
|
||||||
|
_dfile=$(realpath "$2")
|
||||||
|
|
||||||
|
fix_input_envs
|
||||||
|
fix_dependencies
|
||||||
|
|
||||||
|
if [ -z "$HOME" -o ! -w "$HOME" ]; then
|
||||||
|
HOME=$TMPDIR
|
||||||
|
export HOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
export GOCACHE=$TMPDIR/go-cache
|
||||||
|
export GOPATH="$TMPDIR/go"
|
||||||
|
|
||||||
|
for _n in $FIX_ENVARS; do
|
||||||
|
fix_env $_n $ENVARS;
|
||||||
|
done
|
||||||
|
|
||||||
|
export GOPROXY=https://goproxy.cn
|
||||||
|
|
||||||
|
(cd $_sdir; go build -gcflags "all=-N -l" -o "$_dfile" "$_sfile")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue