77#
88# supported antibot repo formats:
99#
10- # - standalone built from source (recommended)
11- # the repository is expected to contain a Makefile
10+ # - standalone make/cmake built from source (recommended)
11+ # the repository is expected to contain a Makefile or CMakeLists.txt
1212# and be able to compile on its own
1313# the resulting libantibot.so is then copied to the runtime path
1414# have a look at antibob for an example of such a repository
@@ -36,10 +36,14 @@ function update_antibot() {
3636 git_save_pull
3737 ) || exit 1
3838
39- if [ -f " $CFG_GITPATH_ANTIBOT /Makefile " ]
39+ if [ -f " $CFG_GITPATH_ANTIBOT /CMakeLists.txt " ]
4040 then
41- log " detected antibot format: standalone"
42- _antibot_format_standalone
41+ log " detected antibot format: standalone cmake"
42+ _antibot_format_standalone_cmake
43+ elif [ -f " $CFG_GITPATH_ANTIBOT /Makefile" ]
44+ then
45+ log " detected antibot format: standalone make"
46+ _antibot_format_standalone_make
4347 elif compgen -G " $CFG_GITPATH_ANTIBOT /*.{h,cpp}" > /dev/null
4448 then
4549 log " detected antibot format: source patches"
@@ -50,7 +54,55 @@ function update_antibot() {
5054 fi
5155}
5256
53- function _antibot_format_standalone() {
57+ function _antibot_format_standalone_cmake() {
58+ (
59+ cd " $CFG_GITPATH_ANTIBOT " || exit 1
60+ log -n " compiling standalone antibot with cmake "
61+
62+ build_log=" /tmp/${USER} _ddpp_antibot_build_$$ .log"
63+ :> " $build_log "
64+
65+ function __run_build_cmd() {
66+ local cmd=" $1 "
67+ printf ' $ %s\n' " $cmd " >> " $build_log "
68+ if ! $cmd & >> " $build_log "
69+ then
70+ log_status_error
71+ cat " $build_log "
72+ rm " $build_log "
73+ err " Error: building antibot with make failed, failed command: $cmd "
74+ exit 1
75+ fi
76+ printf ' .'
77+ }
78+
79+ __run_build_cmd ' mkdir -p build'
80+ __run_build_cmd ' cd build'
81+ __run_build_cmd ' cmake ..'
82+ __run_build_cmd ' make'
83+
84+ rm " $build_log "
85+ printf ' '
86+ log_status_ok
87+
88+ if [ ! -f " $CFG_GITPATH_ANTIBOT " /build/libantibot.so ]
89+ then
90+ err " Error: antibot cmake passed but did not produce a libantibot.so file"
91+ exit 1
92+ fi
93+
94+ # TODO: remove this backcompat layer once cmake antibob rolled out everywhere
95+ if [ -f " $CFG_GITPATH_ANTIBOT " /libantibot.so ]
96+ then
97+ # this avoids having libantibot.so and build/libantibot.so
98+ # in the antibot git repo when transitioning from antibob Makefile to cmake
99+ log " cleaning up legacy Makefile antibot at $CFG_GITPATH_ANTIBOT /libantibot.so"
100+ rm " $CFG_GITPATH_ANTIBOT " /libantibot.so
101+ fi
102+ ) || exit 1
103+ }
104+
105+ function _antibot_format_standalone_make() {
54106 (
55107 cd " $CFG_GITPATH_ANTIBOT " || exit 1
56108 log -n " compiling standalone antibot with make .. "
0 commit comments