Fixes for macOS build. Also run tests in CMake test.

pull/13171/head
Joshua Haberman 6 years ago
parent 9e44a757ed
commit 35fa3df8ec
  1. 2
      BUILD
  2. 6
      CMakeLists.txt
  3. 2
      build_defs.bzl
  4. 22
      tools/make_cmakelists.py

@ -407,7 +407,7 @@ cc_binary(
make_shell_script( make_shell_script(
name = "gen_run_cmake_build", name = "gen_run_cmake_build",
out = "run_cmake_build.sh", out = "run_cmake_build.sh",
contents = "mkdir build && cd build && cmake .. && make -j8" contents = "mkdir build && cd build && cmake .. && make -j8 && make test"
) )
sh_test( sh_test(

@ -117,11 +117,9 @@ add_library(upb_json
upb/json/printer.h) upb/json/printer.h)
target_link_libraries(upb_json target_link_libraries(upb_json
upb) upb)
add_library(upb_cc_bindings add_library(upb_cc_bindings INTERFACE)
upb/bindings/stdc++/string.h) target_link_libraries(upb_cc_bindings INTERFACE
target_link_libraries(upb_cc_bindings
upb) upb)
set_target_properties(upb_cc_bindings PROPERTIES LINKER_LANGUAGE CXX)
add_library(upb_test add_library(upb_test
tests/testmain.cc tests/testmain.cc
tests/test_util.h tests/test_util.h

@ -147,7 +147,7 @@ def generated_file_staleness_test(name, outs, generated_pattern):
srcs = [script_src], srcs = [script_src],
testonly = 1, testonly = 1,
cmd = "cat $(location " + script_src + ") > $@; " + cmd = "cat $(location " + script_src + ") > $@; " +
"sed -i 's|INSERT_FILE_LIST_HERE|" + "\\n ".join(file_list) + "|' $@", "sed -i '' -e 's|INSERT_FILE_LIST_HERE|" + "\\\n ".join(file_list) + "|' $@",
) )
native.py_test( native.py_test(

@ -22,11 +22,12 @@ class BuildFileFunctions(object):
def __init__(self, converter): def __init__(self, converter):
self.converter = converter self.converter = converter
def _add_deps(self, kwargs): def _add_deps(self, kwargs, keyword=""):
if "deps" not in kwargs: if "deps" not in kwargs:
return return
self.converter.toplevel += "target_link_libraries(%s\n %s)\n" % ( self.converter.toplevel += "target_link_libraries(%s%s\n %s)\n" % (
kwargs["name"], kwargs["name"],
keyword,
"\n ".join(StripColons(kwargs["deps"])) "\n ".join(StripColons(kwargs["deps"]))
) )
@ -37,17 +38,22 @@ class BuildFileFunctions(object):
if kwargs["name"] == "amalgamation" or kwargs["name"] == "upbc_generator": if kwargs["name"] == "amalgamation" or kwargs["name"] == "upbc_generator":
return return
files = kwargs.get("srcs", []) + kwargs.get("hdrs", []) files = kwargs.get("srcs", []) + kwargs.get("hdrs", [])
if filter(IsSourceFile, files):
# Has sources, make this a normal library.
self.converter.toplevel += "add_library(%s\n %s)\n" % ( self.converter.toplevel += "add_library(%s\n %s)\n" % (
kwargs["name"], kwargs["name"],
"\n ".join(files) "\n ".join(files)
) )
self._add_deps(kwargs) self._add_deps(kwargs)
else:
# CMake wants to know if each library is C or C++. # Header-only library, have to do a couple things differently.
# If there are only .h files, it can't infer. Assume C++. # For some info, see:
if not filter(IsSourceFile, files): # http://mariobadr.com/creating-a-header-only-library-with-cmake.html
line = "set_target_properties(%s PROPERTIES LINKER_LANGUAGE CXX)\n" self.converter.toplevel += "add_library(%s INTERFACE)\n" % (
self.converter.toplevel += line % (kwargs["name"]) kwargs["name"]
)
self._add_deps(kwargs, " INTERFACE")
def cc_binary(self, **kwargs): def cc_binary(self, **kwargs):
pass pass

Loading…
Cancel
Save