1.安装bazel 首先,需要安装bazel构建工具。根据不同平台选择安装方式,可以从bazel官网上下载。
2.配置BUILD文件 在uWSGI源码根目录下新建BUILD文件,用于bazel构建uWSGI。
cc_binary( name = "uwsgi", srcs = glob([ ".c", ".cc", ".cpp", ".cxx" ]), includes = [ ".", "./src", "./proto" ], copts = [ "-fPIC", "-O2", "-Wall", "-Werror", "-Wstrict-aliasing", "-Wconversion", "-Wunused-function", "-Wunused-variable", "-Wunused-result" ], linkopts = [ "-lpthread", "-ldl" ], visibility = ["//visibility:public"] )
3.运行bazel 在终端中进入uWSGI根目录,执行:
bazel build :uwsgi
执行完成,得到二进制文件bazel-bin/uwsgi。
4.运行uWSGI 在终端中进入二进制文件所在目录,执行:
./uwsgi --http :8080 --wsgi-file hello.py
其中,hello.py为一个简单的wsgi应用程序。
这样,就能成功使用bazel构建uWSGI。