Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

cleanup glog build file #1636

Merged
merged 4 commits into from
Dec 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 41 additions & 37 deletions third_party/glog/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,41 @@ package_version = "0.3.4"
package_file = package_name + "-" + package_version + ".tar.gz"
package_dir = package_name + "-" + package_version

COMMON_EXECUTE = [
"export UNWIND_DIR=$$(pwd)/$(GENDIR)/third_party/libunwind",
"export INSTALL_DIR=$$(pwd)/$(@D)",
"export TMP_DIR=$$(mktemp -d -t glog.XXXXX)",
"mkdir -p $$TMP_DIR",
"cp -R $(SRCS) $$TMP_DIR",
"cd $$TMP_DIR",
"tar xfz " + package_file,
"cd " + package_dir,
include_files = [
"include/glog/log_severity.h",
"include/glog/logging.h",
"include/glog/raw_logging.h",
"include/glog/stl_logging.h",
"include/glog/vlog_is_on.h",
]

DARWIN_EXECUTE = "\n".join(COMMON_EXECUTE + [
"./configure --prefix=$$INSTALL_DIR --enable-shared=no",
"make install",
"rm -rf $$TMP_DIR",
lib_files = [
"lib/libglog.a",
]

common_script = [
'export UNWIND_DIR=$$(pwd)/$(GENDIR)/third_party/libunwind',
'export INSTALL_DIR=$$(pwd)/$(@D)',
'export TMP_DIR=$$(mktemp -d -t glog.XXXXX)',
'mkdir -p $$TMP_DIR',
'cp -R $(SRCS) $$TMP_DIR',
'cd $$TMP_DIR',
'tar xfz ' + package_file,
'cd ' + package_dir,
]

mac_script = "\n".join(common_script + [
'./configure --prefix=$$INSTALL_DIR --enable-shared=no',
'make install',
'rm -rf $$TMP_DIR',
])

LINUX_EXECUTE = "\n".join(COMMON_EXECUTE + [
'./configure --prefix=$$INSTALL_DIR --enable-shared=no LIBS="-Wl,--rpath -Wl,$$UNWIND_DIR/lib -L$$UNWIND_DIR/lib" CPPFLAGS=-I$$UNWIND_DIR/include LDFLAGS=-L$$UNWIND_DIR/lib',
'make install LIBS="-Wl,--rpath -Wl,$$UNWIND_DIR/lib -L$$UNWIND_DIR/lib" CPPFLAGS=-I$$UNWIND_DIR/include LDFLAGS=-L$$UNWIND_DIR/lib',
linux_script = "\n".join(common_script + [
'export VAR_LIBS="-Wl,--rpath -Wl,$$UNWIND_DIR/lib -L$$UNWIND_DIR/lib"',
'export VAR_INCL="-I$$UNWIND_DIR/include"',
'export VAR_LD="-L$$UNWIND_DIR/lib"',
'./configure --prefix=$$INSTALL_DIR --enable-shared=no LIBS="$$VAR_LIBS" CPPFLAGS="$$VAR_INCL" LDFLAGS="$$VAR_LD"',
'make install LIBS="$$VAR_LIBS" CPPFLAGS="$$VAR_INCL" LDFLAGS="$$VAR_LD"',
'rm -rf $$TMP_DIR',
])

Expand All @@ -40,36 +55,20 @@ genrule(
"//third_party/libunwind:libunwind-files",
]
}),
outs = [
"include/glog/log_severity.h",
"include/glog/logging.h",
"include/glog/raw_logging.h",
"include/glog/stl_logging.h",
"include/glog/vlog_is_on.h",
"lib/libglog.a",
],
outs = include_files + lib_files,
cmd = select({
"//tools/platform:darwin": DARWIN_EXECUTE,
"//conditions:default": LINUX_EXECUTE,
"//tools/platform:darwin": mac_script,
"//conditions:default": linux_script,
}),
)

cc_library(
name = "glog-cxx",
srcs = [
"empty.cc",
"lib/libglog.a",
"include/glog/log_severity.h",
"include/glog/raw_logging.h",
"include/glog/stl_logging.h",
"include/glog/vlog_is_on.h",
],
srcs = ["empty.cc"] + lib_files,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also + include_files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The include files are in the hdrs now. Realized this is not needed in the srcs actually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk, LGTM

deps = [
"//third_party/gflags:gflags-cxx",
],
hdrs = [
"include/glog/logging.h",
],
hdrs = include_files,
includes = [
"include",
],
Expand All @@ -82,3 +81,8 @@ filegroup(
":glog-cxx",
]
)

filegroup(
name = "glog-files",
srcs = include_files + lib_files
)