### Install Brotli via Vcpkg Source: https://github.com/google/brotli/blob/master/README.md Use the vcpkg dependency manager to download and install the Brotli library. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install brotli ``` -------------------------------- ### Install Build Tools and Clone Brotli Source: https://github.com/google/brotli/wiki/Running-Coverity-Scan Installs necessary build tools and clones the Brotli repository within a Docker container. Ensure build-essential and git are installed. ```bash apt-get update && apt-get -y install build-essential git git clone http://github.com/google/brotli cd brotli ``` -------------------------------- ### Install Brotli from Source Source: https://github.com/google/brotli/blob/master/python/README.md Install the Python brotli module directly from the source code by running this command from the project directory. ```bash make install ``` -------------------------------- ### Install pkg-config Files Source: https://github.com/google/brotli/blob/master/CMakeLists.txt Installs the generated pkg-config files to the appropriate directory if Brotli is not in bundled mode. ```cmake if (NOT BROTLI_BUNDLED_MODE) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlidec.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() # BROTLI_BUNDLED_MODE ``` -------------------------------- ### Install Brotli API Man Pages Source: https://github.com/google/brotli/blob/master/CMakeLists.txt Installs the man pages for Brotli API functions. ```cmake install(FILES docs/constants.h.3 docs/decode.h.3 docs/encode.h.3 docs/types.h.3 DESTINATION "${CMAKE_INSTALL_MANDIR}/man3") ``` -------------------------------- ### Install Brotli Man Page Source: https://github.com/google/brotli/blob/master/CMakeLists.txt Installs the Brotli man page if Brotli build tools are enabled. ```cmake if (BROTLI_BUILD_TOOLS) install(FILES "docs/brotli.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") endif() ``` -------------------------------- ### Install Brotli in Development Mode Source: https://github.com/google/brotli/blob/master/python/README.md Install the Python brotli module in 'development mode' using setuptools, allowing for live source file editing. ```bash make develop ``` -------------------------------- ### Install Brotli with System Library Source: https://github.com/google/brotli/blob/master/python/README.md Install the Python brotli module using a system-provided Brotli library by setting the USE_SYSTEM_BROTLI environment variable. ```bash USE_SYSTEM_BROTLI=1 pip install brotli --no-binary brotli ``` -------------------------------- ### Install Brotli from PyPI Source: https://github.com/google/brotli/blob/master/python/README.md Use this command to install the latest release of the Python brotli module from PyPI. ```bash pip install brotli ``` -------------------------------- ### Install Brotli Python Module Source: https://github.com/google/brotli/blob/master/README.md Commands to install the Brotli Python module from PyPI or directly from the source repository. ```bash $ pip install brotli ``` ```bash $ pip install --upgrade git+https://github.com/google/brotli ``` -------------------------------- ### Build Brotli with CMake Source: https://github.com/google/brotli/blob/master/README.md Standard commands to configure, build, and install Brotli using CMake. ```bash $ mkdir out && cd out $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed .. $ cmake --build . --config Release --target install ``` -------------------------------- ### Install YAPF for Code Formatting Source: https://github.com/google/brotli/blob/master/python/README.md Install the YAPF code formatter, which is used to automatically format the Brotli project's code. ```bash pip install yapf ``` -------------------------------- ### Read from .dist file Source: https://github.com/google/brotli/blob/master/research/README.md Example of iterating through backward references using the ReadBackwardReference helper. ```c++ #include "read_dist.h" FILE* f; int copy, pos, dist; while (ReadBackwardReference(fin, ©, &pos, &dist)) { ... } ``` -------------------------------- ### Setup Coverage Target Source: https://github.com/google/brotli/blob/master/CMakeLists.txt Configures a target for code coverage analysis if coverage is enabled. ```cmake if (ENABLE_COVERAGE STREQUAL "yes") setup_target_for_coverage(coverage test coverage) endif() ``` -------------------------------- ### Build Brotli for Windows via Docker Source: https://github.com/google/brotli/wiki/Building-Windows-Artifacts This bash script sets up CMake toolchains, compiles the Brotli source, and packages the resulting executables and DLLs into ZIP files. ```bash #!/bin/bash rm -rf out && mkdir out BROTLI_TAG="vX.Y.Z" # <-------- specify desired tag / commit has here function create_toolchain { BROTLI_TOOLCHAIN=$1 cat >>out/toolchain-${BROTLI_TOOLCHAIN}.cmake << EOF SET(CMAKE_SYSTEM_NAME Windows) set(COMPILER_PREFIX "${BROTLI_TOOLCHAIN}-w64-mingw32") find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres) find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc) find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++) SET(USER_ROOT_PATH /home/win-dev-${BROTLI_TOOLCHAIN}) SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} ${USER_ROOT_PATH}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) EOF } function create_artifact { BROTLI_TOOLCHAIN=$1 cat >>out/script-${BROTLI_TOOLCHAIN}.sh << EOF mkdir out-${BROTLI_TOOLCHAIN} cd out-${BROTLI_TOOLCHAIN} cmake \ -DCMAKE_TOOLCHAIN_FILE=/out/toolchain-${BROTLI_TOOLCHAIN}.cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_FLAGS="-s" \ .. make advzip -a4 -i 1 brotli.zip \ brotli.exe cp -f brotli.zip /out/brotli-${BROTLI_TAG}-win_${BROTLI_TOOLCHAIN}.zip advzip -a4 -i 1 brotli_dll.zip \ libbrotlicommon.dll libbrotlidec.dll libbrotlienc.dll cp -f brotli_dll.zip /out/brotli_dll-${BROTLI_TAG}-win_${BROTLI_TOOLCHAIN}.zip cd .. EOF } create_toolchain "i686" create_artifact "i686" create_toolchain "x86_64" create_artifact "x86_64" cat >>out/script.sh << EOF apt-get update apt-get -y install \ advancecomp cmake git mingw-w64 git clone https://github.com/google/brotli cd brotli git checkout $BROTLI_TAG ../script-i686.sh ../script-x86_64.sh EOF docker run -it -v `pwd`/out:/out debian:testing /bin/bash -c \ "cd home; cp /out/script*.sh ./; chmod +x ./script*.sh; ./script.sh" ``` -------------------------------- ### Install Brotli Development Package on Fedora Source: https://github.com/google/brotli/blob/master/python/README.md Install the necessary Brotli development packages on Fedora using dnf. This ensures all components (brotlicommon, brotlienc, brotlidec) are available. ```bash dnf install brotli brotli-devel ```