incubator-pagespeed-mod icon indicating copy to clipboard operation
incubator-pagespeed-mod copied to clipboard

bazel build / psol

Open eilandert opened this issue 4 years ago • 7 comments

@oschaaf or whoever knows how to do this ... :-)

First, when I build with bazel I need to add #include <cstdarg> to pagespeed/kernel/base/string.h or else bazel build will fail.

When I build with bazel I get a pagespeed_automatic.a which is 3mb big and not recognized by nginx configure. Is this size normal?

I tried a lot of things, I ended up with the following:

cd /usr/src/master
bazel build -c opt //pagespeed/automatic:automatic
cd /usr/src/master/pagespeed/automatic
ADIR="/usr/src/master/bazel-bin"
ALIST=$(find -L $ADIR -name "*.a" | grep -v main | grep -v copy | sed -e s/"^\."/"\/root"/g | xargs echo)

echo "merging libs"
./merge_libraries.sh ~/pagespeed_automatic.a.dirty $ALIST > merge.log
./rename_c_symbols.sh ~/pagespeed_automatic.a.dirty ~/pagespeed_automatic.a > symbol-rename.log
cd /usr/src/master
mkdir -p psol/include

if [ "$(uname -m)" = x86_64 ]; then
  bit_size_name=x64
else
  bit_size_name=ia32
fi

bindir="psol/lib/Release/linux/$bit_size_name"
mkdir -p "$bindir"
echo Copying files to psol directory...
cp -f ~/pagespeed_automatic.a $bindir/

rsync -arz "." "psol/include/" --prune-empty-dirs \
  --exclude=".svn" \
  --exclude=".git" \
  --include='*.h' \
  --include='*/' \
  --include="apr_thread_compatible_pool.cc" \
  --include="serf_url_async_fetcher.cc" \
  --include="apr_mem_cache.cc" \
  --include="key_value_codec.cc" \
  --include="apr_memcache2.c" \
  --include="loopback_route_fetcher.cc" \
  --include="add_headers_fetcher.cc" \
  --include="console_css_out.cc" \
  --include="console_out.cc" \
  --include="dense_hash_map" \
  --include="dense_hash_set" \
  --include="sparse_hash_map" \
  --include="sparse_hash_set" \
  --include="sparsetable" \
  --include="mod_pagespeed_console_out.cc" \
  --include="mod_pagespeed_console_css_out.cc" \
  --include="mod_pagespeed_console_html_out.cc" \
  --exclude='*'

cd /usr/src/master
tar czf /usr/src/psol.tar.gz psol

Any idea's or pointers?

eilandert avatar Oct 18 '21 16:10 eilandert

What do you need to add that #include into?

pagespeed_automatic.a is an intermediate library which can be used to build the Apache or nginx versions.

jmarantz avatar Oct 18 '21 17:10 jmarantz

What do you need to add that #include into?

pagespeed_automatic.a is an intermediate library which can be used to build the Apache or nginx versions.

Sorry, there was a part github was not showing. updated my post. I need to add #include <cstdarg> in pagespeed/kernel/base/string.h or I get build errors about va_copy

My goal is to build a working PSOL from the master tree with bazel

eilandert avatar Oct 18 '21 17:10 eilandert

I don't think I ever really got to producing/testing a standalone pagespeed_automatic.a.

Checking I did find this script, but unfortunately I left no context or notes: https://github.com/apache/incubator-pagespeed-mod/blob/master/pagespeed/automatic/bazel_merge.sh

At a glance this script doesn't seem to be that different from what you are doing above (in fact it does less it seems) .. so I am pessimistic that it will produce a better pagespeed_automatic.a.

I do remember that at the time I was hoping for an a NGINX version that would support bazel builds. Because then we could probably add that and this repo as native dependencies in ngx_pagespeed. https://github.com/S8Cloud/nginx-bazel is an example of that but it seems the effort stalled and it no longer gets any updates.

oschaaf avatar Oct 18 '21 18:10 oschaaf

@oschaaf Does that mean we are doomed to use the latest-stable tag?

I am trying to cook some things up with docker ( https://github.com/eilandert/psol-bazel ) but right now I get some 403 errors on some bazel stuff so I have to delay my attempts...

And yes, if I can build this I will try to use it with nginx/ngx_pagespeed ;-)

eilandert avatar Oct 18 '21 19:10 eilandert

I wouldn't say doomed.. but it will require some effort to get ngx_pagespeed to work with the bleeding edge / bazel build system. The path of least resistance is probably producing a working pagespeed_automatic.a plus a set of headers, like you are currently attempting.

oschaaf avatar Oct 18 '21 19:10 oschaaf

I am stuck now at src/incubator-pagespeed-ngx/psol/include/base/logging.h:22:10: fatal error: glog/logging.h: No such file or directory

Will investigate later

eilandert avatar Oct 19 '21 21:10 eilandert

@eilandert Maybe is the same issue related here: https://github.com/apache/incubator-pagespeed-mod/issues/2069#issuecomment-858151770

"File "base/logging.h" contains "include glog/logging.h" I had error about "glog" until I've added path to "glog/logging.h" to list of "include"-paths for CC-command in ngx/config:$pagespeed_include"

Lofesa avatar Oct 20 '21 06:10 Lofesa