PR : nsync dep updates

Please approve this CL. It will be submitted automatically, and its GitHub pull request will be marked as merged.

Imported from GitHub PR 

A new version of nsync is released, this updates the workspace.bzl and adds nsync to the libs that can be unbundled. I've packaged nsync on Gentoo Linux and tested the full unbundled build.

The CMake build is also updated to the latest version, the patch is no longer required and is removed. I have tested the cmake build on my machine but the CI needs to test windows since I can't.

The last commits update ./configure to handle adding TF_SYSTEM_LIBS and an option to disable stripping.

@m3bm3b, can you review too?

Copybara import of the project:

  - 3d224b29fcf699b84cf538e2d16e3dd4e78e6a91 workspace: update nsync dep to 1.20.1 by Jason Zaman <jason@perfinion.com>
  - 34536b88bedc5a83ad939438a49a3cc53aea210c CMake: nsync: update to 1.20.1 by Jason Zaman <jason@perfinion.com>
  - f2444ba218ae280e03710f936b249b6b650ea3dd third_party: unbundle nsync by Jason Zaman <jason@perfinion.com>
  - 4386d8c4b01020ba1c979258e5102ac1947d2574 configure: Add TF_SYSTEM_LIBS handling by Jason Zaman <jason@perfinion.com>
  - f3fd1f110781cfb8cc941241a69eb41114787bfd Merge 4386d8c4b01020ba1c979258e5102ac1947d2574 into a05c7... by Jason Zaman <jasonzaman@gmail.com>

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/tensorflow/pull/21373 from perfinion:nsync 4386d8c4b01020ba1c979258e5102ac1947d2574
PiperOrigin-RevId: 209201545
This commit is contained in:
Yifei Feng 2018-08-17 13:53:06 -07:00 committed by TensorFlower Gardener
parent 3aed785822
commit 5198cb8b3d
6 changed files with 121 additions and 416 deletions
configure.py
tensorflow
contrib/cmake
external
patches/nsync
workspace.bzl
third_party/systemlibs

View File

@ -848,7 +848,7 @@ def set_tf_cuda_version(environ_cp):
cuda_toolkit_paths_full = [os.path.join(cuda_toolkit_path, x) for x in cuda_rt_lib_paths]
if any([os.path.exists(x) for x in cuda_toolkit_paths_full]):
break
break
# Reset and retry
print('Invalid path to CUDA %s toolkit. %s cannot be found' %
@ -1399,6 +1399,13 @@ def set_grpc_build_flags():
write_to_bazelrc('build --define grpc_no_ares=true')
def set_system_libs_flag(environ_cp):
syslibs = environ_cp.get('TF_SYSTEM_LIBS', '')
syslibs = ','.join(sorted(syslibs.split(',')))
if syslibs and syslibs != '':
write_action_env_to_bazelrc('TF_SYSTEM_LIBS', syslibs)
def set_windows_build_flags(environ_cp):
"""Set Windows specific build options."""
# The non-monolithic build is not supported yet
@ -1555,6 +1562,7 @@ def main():
set_grpc_build_flags()
set_cc_opt_flags(environ_cp)
set_system_libs_flag(environ_cp)
if is_windows():
set_windows_build_flags(environ_cp)

View File

@ -16,16 +16,16 @@ include (ExternalProject)
set(nsync_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/nsync/public)
set(nsync_URL https://github.com/google/nsync)
set(nsync_TAG 1.20.0)
set(nsync_TAG 1.20.1)
set(nsync_BUILD ${CMAKE_CURRENT_BINARY_DIR}/nsync/src/nsync)
set(nsync_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/nsync/install)
if(WIN32)
set(nsync_HEADERS "${nsync_BUILD}/public/*.h")
set(nsync_STATIC_LIBRARIES ${nsync_INSTALL}/lib/nsync.lib)
set(nsync_STATIC_LIBRARIES ${nsync_INSTALL}/lib/nsync_cpp.lib)
else()
set(nsync_HEADERS "${nsync_BUILD}/public/*.h")
set(nsync_STATIC_LIBRARIES ${nsync_INSTALL}/lib/libnsync.a)
set(nsync_STATIC_LIBRARIES ${nsync_INSTALL}/lib/libnsync_cpp.a)
endif()
ExternalProject_Add(nsync
@ -35,12 +35,12 @@ ExternalProject_Add(nsync
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${nsync_STATIC_LIBRARIES}
PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/patches/nsync/CMakeLists.txt ${nsync_BUILD}
INSTALL_DIR ${nsync_INSTALL}
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DCMAKE_INSTALL_PREFIX:STRING=${nsync_INSTALL}
-DCMAKE_INSTALL_LIBDIR:STRING=lib
-DNSYNC_LANGUAGE:STRING=c++11)
set(nsync_HEADERS

View File

@ -1,325 +0,0 @@
cmake_minimum_required (VERSION 2.8.12)
# nsync provides portable synchronization primitives, such as mutexes and
# condition variables.
project (nsync)
# Set variable NSYNC_LANGUAGE to "c++11" to build with C++11
# rather than C.
# Some builds need position-independent code.
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
# -----------------------------------------------------------------
# Platform dependencies
# Many platforms use these posix related sources; even Win32.
set (NSYNC_POSIX_SRC
"platform/posix/src/nsync_panic.c"
"platform/posix/src/per_thread_waiter.c"
"platform/posix/src/time_rep.c"
"platform/posix/src/yield.c"
)
if (WIN32)
# Suppress warnings to reduce build log size.
add_definitions(/wd4267 /wd4244 /wd4800 /wd4503 /wd4554 /wd4996 /wd4348 /wd4018)
add_definitions(/wd4099 /wd4146 /wd4267 /wd4305 /wd4307)
add_definitions(/wd4715 /wd4722 /wd4723 /wd4838 /wd4309 /wd4334)
add_definitions(/wd4003 /wd4244 /wd4267 /wd4503 /wd4506 /wd4800 /wd4996)
add_definitions(/wd8029)
endif()
# Many of the string matches below use a literal "X" suffix on both sides.
# This is because some versions of cmake treat (for example) "MSVC" (in quotes)
# as a reference to the variable MSVC, thus the expression
# "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC"
# is false when ${CMAKE_C_COMPILER_ID} has the value "MSVC"! See
# https://cmake.org/cmake/help/v3.1/policy/CMP0054.html
# Pick the include directory for the operating system.
if ("${NSYNC_LANGUAGE}X" STREQUAL "c++11X")
include_directories ("${PROJECT_SOURCE_DIR}/platform/c++11")
add_definitions ("-DNSYNC_USE_CPP11_TIMEPOINT -DNSYNC_ATOMIC_CPP11")
set (NSYNC_OS_CPP_SRC
"platform/c++11/src/per_thread_waiter.cc"
"platform/c++11/src/yield.cc"
"platform/c++11/src/time_rep_timespec.cc"
"platform/c++11/src/nsync_panic.cc"
)
if ("${CMAKE_SYSTEM_NAME}X" STREQUAL "WindowsX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/win32")
add_compile_options ("/TP")
set (NSYNC_OS_SRC
"platform/c++11/src/nsync_semaphore_mutex.cc"
"platform/win32/src/clock_gettime.c"
"platform/win32/src/pthread_key_win32.cc"
${NSYNC_OS_CPP_SRC}
)
set (NSYNC_TEST_OS_SRC
"platform/win32/src/start_thread.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "DarwinX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/macos")
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
# Some versions of MacOS, such as Sierra, require _DARWIN_C_SOURCE
# when including certin C++ standard header files, such as <mutex>.
add_definitions ("-D_DARWIN_C_SOURCE")
add_compile_options ("-std=c++11")
set (NSYNC_OS_SRC
${NSYNC_OS_CPP_SRC}
"platform/c++11/src/nsync_semaphore_mutex.cc"
"platform/posix/src/clock_gettime.c"
"platform/posix/src/nsync_semaphore_mutex.c"
)
set (NSYNC_TEST_OS_SRC
"platform/posix/src/start_thread.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "LinuxX")
include_directories (BEFORE "${PROJECT_SOURCE_DIR}/platform/c++11.futex")
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
add_compile_options ("-std=c++11")
set (NSYNC_OS_SRC
"platform/linux/src/nsync_semaphore_futex.c"
${NSYNC_OS_CPP_SRC}
)
set (NSYNC_TEST_OS_SRC
"platform/posix/src/start_thread.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "NetBSDX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
add_compile_options ("-std=c++11")
set (NSYNC_OS_SRC
"platform/c++11/src/nsync_semaphore_mutex.cc"
${NSYNC_OS_CPP_SRC}
)
set (NSYNC_TEST_OS_SRC
"platform/posix/src/start_thread.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "FreeBSDX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
add_compile_options ("-std=c++11")
set (NSYNC_OS_SRC
"platform/c++11/src/nsync_semaphore_mutex.cc"
${NSYNC_OS_CPP_SRC}
)
set (NSYNC_TEST_OS_SRC
"platform/posix/src/start_thread.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "OpenBSDX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
add_compile_options ("-std=c++11")
set (NSYNC_OS_SRC
"platform/c++11/src/nsync_semaphore_mutex.cc"
${NSYNC_OS_CPP_SRC}
)
set (NSYNC_TEST_OS_SRC
"platform/posix/src/start_thread.c"
)
endif ()
endif ()
# Pick the include directory for the compiler.
if ("${CMAKE_C_COMPILER_ID}X" STREQUAL "GNUX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/gcc")
set (THREADS_HAVE_PTHREAD_ARG ON)
elseif ("${CMAKE_C_COMPILER_ID}X" STREQUAL "ClangX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/clang")
set (THREADS_HAVE_PTHREAD_ARG ON)
elseif ("${CMAKE_C_COMPILER_ID}X" STREQUAL "MSVCX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/msvc")
else ()
message (WARNING "CMAKE_C_COMPILER_ID (${CMAKE_C_COMPILER_ID}) matched NOTHING")
endif ()
if (NOT "${NSYNC_LANGUAGE}X" STREQUAL "c++11X")
if ("${CMAKE_SYSTEM_NAME}X" STREQUAL "WindowsX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/win32")
set (NSYNC_OS_SRC
${NSYNC_POSIX_SRC}
"platform/win32/src/clock_gettime.c"
"platform/win32/src/init_callback_win32.c"
"platform/win32/src/nanosleep.c"
"platform/win32/src/nsync_semaphore_win32.c"
"platform/win32/src/pthread_cond_timedwait_win32.c"
"platform/win32/src/pthread_key_win32.cc"
)
set (NSYNC_TEST_OS_SRC
"platform/win32/src/start_thread.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "DarwinX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/macos")
set (NSYNC_POSIX ON)
set (NSYNC_OS_EXTRA_SRC
"platform/posix/src/clock_gettime.c"
"platform/posix/src/nsync_semaphore_mutex.c"
)
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "LinuxX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/linux")
set (NSYNC_POSIX ON)
set (NSYNC_OS_EXTRA_SRC
"platform/linux/src/nsync_semaphore_futex.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "NetBSDX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/netbsd")
set (NSYNC_POSIX ON)
set (NSYNC_OS_EXTRA_SRC
"platform/posix/src/nsync_semaphore_mutex.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "FreeBSDX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/freebsd")
set (NSYNC_POSIX ON)
set (NSYNC_OS_EXTRA_SRC
"platform/posix/src/nsync_semaphore_mutex.c"
)
elseif ("${CMAKE_SYSTEM_NAME}X" STREQUAL "OpenBSDX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/openbsd")
set (NSYNC_POSIX ON)
set (NSYNC_OS_EXTRA_SRC
"platform/posix/src/nsync_semaphore_mutex.c"
)
endif ()
endif ()
if (NSYNC_POSIX)
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
set (NSYNC_OS_SRC
${NSYNC_POSIX_SRC}
${NSYNC_OS_EXTRA_SRC}
)
set (NSYNC_TEST_OS_SRC
"platform/posix/src/start_thread.c"
)
endif ()
# Pick the include directory for the architecture.
if (("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "x86_64X") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "amd64X") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "AMD64X"))
include_directories ("${PROJECT_SOURCE_DIR}/platform/x86_64")
elseif (("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "x86_32X") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "i386X") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "i686X"))
include_directories ("${PROJECT_SOURCE_DIR}/platform/x86_32")
elseif (("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "armv6lX") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "armv7lX") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "armX"))
include_directories ("${PROJECT_SOURCE_DIR}/platform/arm")
elseif (("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "aarch64X") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "arm64X"))
include_directories ("${PROJECT_SOURCE_DIR}/platform/aarch64")
elseif (("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "ppcX") OR
("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "ppc32X"))
include_directories ("${PROJECT_SOURCE_DIR}/platform/ppc32")
elseif (("${CMAKE_SYSTEM_PROCESSOR}X" STREQUAL "ppc64X"))
include_directories ("${PROJECT_SOURCE_DIR}/platform/ppc64")
endif ()
# Windows uses some include files from the posix directory also.
if ("${CMAKE_SYSTEM_NAME}X" STREQUAL "WindowsX")
include_directories ("${PROJECT_SOURCE_DIR}/platform/posix")
endif ()
# -----------------------------------------------------------------
include_directories ("${PROJECT_SOURCE_DIR}/public")
include_directories ("${PROJECT_SOURCE_DIR}/internal")
set (NSYNC_SRC
"internal/common.c"
"internal/counter.c"
"internal/cv.c"
"internal/debug.c"
"internal/dll.c"
"internal/mu.c"
"internal/mu_wait.c"
"internal/note.c"
"internal/once.c"
"internal/sem_wait.c"
"internal/time_internal.c"
"internal/wait.c"
${NSYNC_OS_SRC}
)
add_library (nsync ${NSYNC_SRC})
set (NSYNC_TEST_SRC
"testing/array.c"
"testing/atm_log.c"
"testing/closure.c"
"testing/smprintf.c"
"testing/testing.c"
"testing/time_extra.c"
${NSYNC_TEST_OS_SRC}
)
add_library (nsync_test ${NSYNC_TEST_SRC})
set (NSYNC_TESTS
"counter_test"
"cv_mu_timeout_stress_test"
"cv_test"
"cv_wait_example_test"
"dll_test"
"mu_starvation_test"
"mu_test"
"mu_wait_example_test"
"mu_wait_test"
"note_test"
"once_test"
"pingpong_test"
"wait_test"
)
if ("${NSYNC_LANGUAGE}X" STREQUAL "c++11X")
foreach (s IN ITEMS ${NSYNC_SRC} ${NSYNC_TEST_SRC})
SET_SOURCE_FILES_PROPERTIES ("${s}" PROPERTIES LANGUAGE CXX)
endforeach (s)
foreach (t IN ITEMS ${NSYNC_TESTS})
SET_SOURCE_FILES_PROPERTIES ("testing/${t}.c" PROPERTIES LANGUAGE CXX)
endforeach (t)
endif ()
enable_testing ()
foreach (t IN ITEMS ${NSYNC_TESTS})
add_executable (${t} "testing/${t}.c")
endforeach (t)
find_package (Threads REQUIRED)
set (THREADS_PREFER_PTHREAD_FLAG ON)
foreach (t IN ITEMS "nsync" "nsync_test" ${NSYNC_TESTS})
if (THREADS_HAVE_PTHREAD_ARG)
target_compile_options (${t} PUBLIC "-pthread")
endif ()
if (CMAKE_THREAD_LIBS_INIT)
target_link_libraries (${t} "${CMAKE_THREAD_LIBS_INIT}")
endif ()
endforeach (t)
foreach (t IN ITEMS ${NSYNC_TESTS})
target_link_libraries (${t} nsync_test nsync)
add_test (NAME ${t} COMMAND ${t})
endforeach (t)
install (TARGETS nsync
LIBRARY DESTINATION lib COMPONENT RuntimeLibraries
ARCHIVE DESTINATION lib COMPONENT Development)
set (NSYNC_INCLUDES
"public/nsync.h"
"public/nsync_atomic.h"
"public/nsync_counter.h"
"public/nsync_cpp.h"
"public/nsync_cv.h"
"public/nsync_debug.h"
"public/nsync_mu.h"
"public/nsync_mu_wait.h"
"public/nsync_note.h"
"public/nsync_once.h"
"public/nsync_time.h"
"public/nsync_time_internal.h"
"public/nsync_waiter.h"
)
foreach (NSYNC_INCLUDE ${NSYNC_INCLUDES})
install (FILES ${NSYNC_INCLUDE} DESTINATION include COMPONENT Development)
endforeach ()

View File

@ -401,11 +401,12 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
tf_http_archive(
name = "nsync",
urls = [
"https://mirror.bazel.build/github.com/google/nsync/archive/1.20.0.tar.gz",
"https://github.com/google/nsync/archive/1.20.0.tar.gz",
"https://mirror.bazel.build/github.com/google/nsync/archive/1.20.1.tar.gz",
"https://github.com/google/nsync/archive/1.20.1.tar.gz",
],
sha256 = "0c1b03962b2f8450f21e74a5a46116bf2d6009a807c57eb4207e974a8c4bb7dd",
strip_prefix = "nsync-1.20.0",
sha256 = "692f9b30e219f71a6371b98edd39cef3cbda35ac3abc4cd99ce19db430a5591a",
strip_prefix = "nsync-1.20.1",
system_build_file = clean_dep("//third_party/systemlibs:nsync.BUILD"),
)
tf_http_archive(

23
third_party/systemlibs/nsync.BUILD vendored Normal file
View File

@ -0,0 +1,23 @@
licenses(["notice"]) # BSD 3-Clause
filegroup(
name = "LICENSE",
visibility = ["//visibility:public"],
)
cc_library(
name = "nsync_headers",
visibility = ["//visibility:public"],
)
cc_library(
name = "nsync",
linkopts = ["-lnsync"],
visibility = ["//visibility:public"],
)
cc_library(
name = "nsync_cpp",
linkopts = ["-lnsync_cpp"],
visibility = ["//visibility:public"],
)

View File

@ -7,9 +7,9 @@
the system version instead
"""
_TF_SYSTEM_LIBS="TF_SYSTEM_LIBS"
_TF_SYSTEM_LIBS = "TF_SYSTEM_LIBS"
VALID_LIBS=[
VALID_LIBS = [
"astor_archive",
"com_googlesource_code_re2",
"curl",
@ -22,6 +22,7 @@ VALID_LIBS=[
"jsoncpp_git",
"lmdb",
"nasm",
"nsync",
"org_sqlite",
"pcre",
"png_archive",
@ -32,112 +33,109 @@ VALID_LIBS=[
"zlib_archive",
]
def auto_configure_fail(msg):
"""Output failure message when syslibs configuration fails."""
red = "\033[0;31m"
no_color = "\033[0m"
fail("\n%sSystem Library Configuration Error:%s %s\n" % (red, no_color, msg))
"""Output failure message when syslibs configuration fails."""
red = "\033[0;31m"
no_color = "\033[0m"
fail("\n%sSystem Library Configuration Error:%s %s\n" % (red, no_color, msg))
def _is_windows(repository_ctx):
"""Returns true if the host operating system is windows."""
os_name = repository_ctx.os.name.lower()
if os_name.find("windows") != -1:
return True
return False
"""Returns true if the host operating system is windows."""
os_name = repository_ctx.os.name.lower()
if os_name.find("windows") != -1:
return True
return False
def _enable_syslibs(repository_ctx):
s = repository_ctx.os.environ.get(_TF_SYSTEM_LIBS, '').strip()
if not _is_windows(repository_ctx) and s != None and s != '':
return True
return False
s = repository_ctx.os.environ.get(_TF_SYSTEM_LIBS, "").strip()
if not _is_windows(repository_ctx) and s != None and s != "":
return True
return False
def _get_system_lib_list(repository_ctx):
"""Gets the list of deps that should use the system lib.
"""Gets the list of deps that should use the system lib.
Args:
repository_ctx: The repository context.
Args:
repository_ctx: The repository context.
Returns:
A string version of a python list
"""
if _TF_SYSTEM_LIBS not in repository_ctx.os.environ:
return []
Returns:
A string version of a python list
"""
if _TF_SYSTEM_LIBS not in repository_ctx.os.environ:
return []
libenv = repository_ctx.os.environ[_TF_SYSTEM_LIBS].strip()
libs = []
libenv = repository_ctx.os.environ[_TF_SYSTEM_LIBS].strip()
libs = []
for lib in list(libenv.split(',')):
lib = lib.strip()
if lib == "":
continue
if lib not in VALID_LIBS:
auto_configure_fail("Invalid system lib set: %s" % lib)
return []
libs.append(lib)
return libs
for lib in list(libenv.split(",")):
lib = lib.strip()
if lib == "":
continue
if lib not in VALID_LIBS:
auto_configure_fail("Invalid system lib set: %s" % lib)
return []
libs.append(lib)
return libs
def _format_system_lib_list(repository_ctx):
"""Formats the list of deps that should use the system lib.
"""Formats the list of deps that should use the system lib.
Args:
repository_ctx: The repository context.
Args:
repository_ctx: The repository context.
Returns:
A list of the names of deps that should use the system lib.
"""
libs = _get_system_lib_list(repository_ctx)
ret = ''
for lib in libs:
ret += "'%s',\n" % lib
Returns:
A list of the names of deps that should use the system lib.
"""
libs = _get_system_lib_list(repository_ctx)
ret = ""
for lib in libs:
ret += "'%s',\n" % lib
return ret
def _tpl(repository_ctx, tpl, substitutions={}, out=None):
if not out:
out = tpl.replace(":", "")
repository_ctx.template(
out,
Label("//third_party/systemlibs%s.tpl" % tpl),
substitutions,
False)
return ret
def _tpl(repository_ctx, tpl, substitutions = {}, out = None):
if not out:
out = tpl.replace(":", "")
repository_ctx.template(
out,
Label("//third_party/systemlibs%s.tpl" % tpl),
substitutions,
False,
)
def _create_dummy_repository(repository_ctx):
"""Creates the dummy repository to build with all bundled libraries."""
_tpl(repository_ctx, ":BUILD")
_tpl(repository_ctx, ":build_defs.bzl",
{
"%{syslibs_enabled}": 'False',
"%{syslibs_list}": '',
})
"""Creates the dummy repository to build with all bundled libraries."""
_tpl(repository_ctx, ":BUILD")
_tpl(
repository_ctx,
":build_defs.bzl",
{
"%{syslibs_enabled}": "False",
"%{syslibs_list}": "",
},
)
def _create_local_repository(repository_ctx):
"""Creates the repository to build with system libraries."""
_tpl(repository_ctx, ":BUILD")
_tpl(repository_ctx, ":build_defs.bzl",
{
"%{syslibs_enabled}": 'True',
"%{syslibs_list}": _format_system_lib_list(repository_ctx),
})
"""Creates the repository to build with system libraries."""
_tpl(repository_ctx, ":BUILD")
_tpl(
repository_ctx,
":build_defs.bzl",
{
"%{syslibs_enabled}": "True",
"%{syslibs_list}": _format_system_lib_list(repository_ctx),
},
)
def _syslibs_autoconf_impl(repository_ctx):
"""Implementation of the syslibs_configure repository rule."""
if not _enable_syslibs(repository_ctx):
_create_dummy_repository(repository_ctx)
else:
_create_local_repository(repository_ctx)
"""Implementation of the syslibs_configure repository rule."""
if not _enable_syslibs(repository_ctx):
_create_dummy_repository(repository_ctx)
else:
_create_local_repository(repository_ctx)
syslibs_configure = repository_rule(
implementation = _syslibs_autoconf_impl,