Update build system. Now libraries are produced as build artifacts.

There are currently 3 ways to build:
* Easy: `./configure; make`
* Simple: use Bazel
* Portable: use premake5 to generate XCode / MSVS projects
This commit is contained in:
Eugene Kliuchnikov 2016-06-16 10:52:57 +02:00
parent 4a8bb6a2b8
commit 378485b097
13 changed files with 233 additions and 83 deletions

148
BUILD Normal file
View File

@ -0,0 +1,148 @@
# Description:
# Brotli is a generic-purpose lossless compression algorithm.
package(
default_visibility = ["//visibility:public"],
)
licenses(["notice"]) # MIT
STRICT_COMPILER_OPTIONS = [
"--pedantic-errors",
"-Wall",
"-Wconversion",
"-Werror",
"-Wextra",
"-Wlong-long",
"-Wmissing-declarations",
"-Wno-strict-aliasing",
"-Wshadow",
"-Wsign-compare",
]
STRICT_C_OPTIONS = STRICT_COMPILER_OPTIONS + [
"-Wmissing-prototypes",
]
COMMON_HEADERS = [
"common/constants.h",
"common/dictionary.h",
"common/port.h",
"common/types.h",
]
COMMON_SOURCES = [
"common/dictionary.c",
]
DEC_HEADERS = [
"dec/bit_reader.h",
"dec/context.h",
"dec/decode.h",
"dec/huffman.h",
"dec/port.h",
"dec/prefix.h",
"dec/state.h",
"dec/transform.h",
]
DEC_SOURCES = [
"dec/bit_reader.c",
"dec/decode.c",
"dec/huffman.c",
"dec/state.c",
]
ENC_HEADERS = [
"enc/backward_references.h",
"enc/backward_references_inc.h",
"enc/bit_cost.h",
"enc/bit_cost_inc.h",
"enc/block_encoder_inc.h",
"enc/block_splitter.h",
"enc/block_splitter_inc.h",
"enc/brotli_bit_stream.h",
"enc/cluster.h",
"enc/cluster_inc.h",
"enc/command.h",
"enc/compress_fragment.h",
"enc/compress_fragment_two_pass.h",
"enc/context.h",
"enc/dictionary_hash.h",
"enc/encode.h",
"enc/entropy_encode.h",
"enc/entropy_encode_static.h",
"enc/fast_log.h",
"enc/find_match_length.h",
"enc/hash.h",
"enc/hash_longest_match_inc.h",
"enc/hash_longest_match_quickly_inc.h",
"enc/histogram.h",
"enc/histogram_inc.h",
"enc/literal_cost.h",
"enc/memory.h",
"enc/metablock.h",
"enc/metablock_inc.h",
"enc/port.h",
"enc/prefix.h",
"enc/ringbuffer.h",
"enc/static_dict.h",
"enc/static_dict_lut.h",
"enc/utf8_util.h",
"enc/write_bits.h",
]
ENC_SOURCES = [
"enc/backward_references.c",
"enc/bit_cost.c",
"enc/block_splitter.c",
"enc/brotli_bit_stream.c",
"enc/cluster.c",
"enc/compress_fragment.c",
"enc/compress_fragment_two_pass.c",
"enc/encode.c",
"enc/entropy_encode.c",
"enc/histogram.c",
"enc/literal_cost.c",
"enc/memory.c",
"enc/metablock.c",
"enc/static_dict.c",
"enc/utf8_util.c",
]
cc_library(
name = "brotli_common",
srcs = COMMON_SOURCES,
hdrs = COMMON_HEADERS,
copts = STRICT_C_OPTIONS,
)
cc_library(
name = "brotli_dec",
srcs = DEC_SOURCES,
hdrs = DEC_HEADERS,
copts = STRICT_C_OPTIONS,
deps = [
":brotli_common",
],
)
cc_library(
name = "brotli_enc",
srcs = ENC_SOURCES,
hdrs = ENC_HEADERS,
copts = STRICT_C_OPTIONS,
deps = [
":brotli_common",
],
)
cc_binary(
name = "bro",
srcs = ["tools/bro.cc"],
copts = STRICT_COMPILER_OPTIONS,
deps = [
":brotli_dec",
":brotli_enc",
],
)

12
Makefile Normal file
View File

@ -0,0 +1,12 @@
include build/gmake/config.make
TARGETS=all clean brotli_common brotli_dec brotli_enc bro help
.PHONY: $(TARGETS) install
$(TARGETS):
@${MAKE} -C build/gmake $@
install:
@echo "copy include and libraries to $(prefix)"
$(error Installation is not implemented yet)

4
WORKSPACE Normal file
View File

@ -0,0 +1,4 @@
# Description:
# Bazel workspace file for Brotli.
workspace(name = "io_brotli")

View File

@ -1,12 +0,0 @@
#brotli/common
include ../shared.mk
CFLAGS += -Wall
OBJS = dictionary.o
all : $(OBJS)
clean :
rm -f $(OBJS)

19
configure vendored Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
PREFIX=/usr/local
VERSION=`cat tools/version.h | grep BROTLI_VERSION | grep -o \".*\"`
VERSION=${VERSION:1:${#VERSION}-2}
for i in "$@"
do
case $i in
-p=*|--prefix=*)
PREFIX="${i#*=}"
;;
esac
done
echo -e "prefix=$PREFIX" > ./build/gmake/config.make
echo -e "version=$VERSION" >> ./build/gmake/config.make

View File

@ -1,12 +0,0 @@
#brotli/dec
include ../shared.mk
CFLAGS += -Wall
OBJS = bit_reader.o decode.o huffman.o state.o
all : $(OBJS)
clean :
rm -f $(OBJS)

View File

@ -1,13 +0,0 @@
#brotli/enc
include ../shared.mk
OBJS = backward_references.o bit_cost.o block_splitter.o brotli_bit_stream.o \
cluster.o compress_fragment.o compress_fragment_two_pass.o compressor.o \
encode.o encode_parallel.o entropy_encode.o histogram.o literal_cost.o \
memory.o metablock.o static_dict.o streams.o utf8_util.o
all : $(OBJS)
clean :
rm -f $(OBJS) $(SO)

47
premake5.lua Normal file
View File

@ -0,0 +1,47 @@
-- A solution contains projects, and defines the available configurations
solution "brotli"
configurations { "Release", "Debug" }
platforms { "Static", "Shared" }
targetdir "bin"
location "build"
flags "RelativeLinks"
filter "configurations:Release"
optimize "Speed"
flags { "StaticRuntime" }
filter "configurations:Debug"
flags { "Symbols" }
filter { "platforms:Static" }
kind "StaticLib"
filter { "platforms:Shared" }
kind "SharedLib"
configuration { "gmake" }
buildoptions { "-Wall -fno-omit-frame-pointer" }
location "build/gmake"
configuration { "macosx" }
defines { "DOS_MACOSX" }
project "brotli_common"
language "C"
files { "common/**.h", "common/**.c" }
project "brotli_dec"
language "C"
files { "dec/**.h", "dec/**.c" }
links "brotli_common"
project "brotli_enc"
language "C"
files { "enc/**.h", "enc/**.c" }
links "brotli_common"
project "bro"
kind "ConsoleApp"
language "C++"
files { "tools/bro.cc" }
links { "brotli_common", "brotli_dec", "brotli_enc" }

View File

@ -1,13 +0,0 @@
OS := $(shell uname)
CC ?= gcc
CXX ?= g++
COMMON_FLAGS = -fno-omit-frame-pointer -no-canonical-prefixes -O2
ifeq ($(OS), Darwin)
CPPFLAGS += -DOS_MACOSX
endif
CFLAGS += $(COMMON_FLAGS) -Wmissing-prototypes
CXXFLAGS += $(COMMON_FLAGS) -Wmissing-declarations

View File

@ -1,7 +1,5 @@
#brotli/tests
include ../shared.mk
BROTLI = ..
all: test
@ -11,7 +9,7 @@ test: deps
./roundtrip_test.sh
deps :
$(MAKE) -C $(BROTLI)/tools
$(MAKE) -C $(BROTLI) bro
clean :
rm -f testdata/*.{bro,unbro,uncompressed}

View File

@ -5,7 +5,7 @@
set -o errexit
BRO=../tools/bro
BRO=../bin/bro
for file in testdata/*.compressed*; do
echo "Testing decompression of file $file"

View File

@ -4,7 +4,7 @@
set -o errexit
BRO=../tools/bro
BRO=../bin/bro
INPUTS="""
testdata/alice29.txt
testdata/asyoulik.txt

View File

@ -1,28 +0,0 @@
#brotli/tools
include ../shared.mk
BROTLI = ..
COMMONOBJ = $(BROTLI)/common/*.o
DECOBJ = $(BROTLI)/dec/*.o
ENCOBJ = $(BROTLI)/enc/*.o
EXECUTABLES=bro
EXE_OBJS=$(patsubst %, %.o, $(EXECUTABLES))
all : $(EXECUTABLES)
$(EXECUTABLES) : $(EXE_OBJS) deps
$(CXX) $(LDFLAGS) $(COMMONOBJ) $(ENCOBJ) $(DECOBJ) $@.o -o $@
deps :
$(MAKE) -C $(BROTLI)/common
$(MAKE) -C $(BROTLI)/dec
$(MAKE) -C $(BROTLI)/enc
clean :
rm -f $(OBJS) $(EXE_OBJS) $(EXECUTABLES)
$(MAKE) -C $(BROTLI)/common clean
$(MAKE) -C $(BROTLI)/dec clean
$(MAKE) -C $(BROTLI)/enc clean