summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/amalgamate.py4
-rwxr-xr-xtools/make_cmakelists.py53
-rw-r--r--tools/test_cinit.lua64
-rw-r--r--tools/upbc.lua91
4 files changed, 36 insertions, 176 deletions
diff --git a/tools/amalgamate.py b/tools/amalgamate.py
index 4739a94..9ad0286 100755
--- a/tools/amalgamate.py
+++ b/tools/amalgamate.py
@@ -51,6 +51,10 @@ output_path = sys.argv[2]
amalgamator = Amalgamator(include_path, output_path)
for filename in sys.argv[3:]:
+ # Leave JIT out of the amalgamation.
+ if "x64" in filename or "dynasm" in filename:
+ continue
+
amalgamator.add_src(filename.strip())
amalgamator.finish()
diff --git a/tools/make_cmakelists.py b/tools/make_cmakelists.py
index b8f46b9..c2700b6 100755
--- a/tools/make_cmakelists.py
+++ b/tools/make_cmakelists.py
@@ -59,27 +59,29 @@ class BuildFileFunctions(object):
pass
def cc_test(self, **kwargs):
- self.converter.toplevel += "add_executable(%s\n %s)\n" % (
- kwargs["name"],
- "\n ".join(kwargs["srcs"])
- )
- self.converter.toplevel += "add_test(NAME %s COMMAND %s)\n" % (
- kwargs["name"],
- kwargs["name"],
- )
-
- if "data" in kwargs:
- for data_dep in kwargs["data"]:
- self.converter.toplevel += textwrap.dedent("""\
- add_custom_command(
- TARGET %s POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_SOURCE_DIR}/%s
- ${CMAKE_CURRENT_BINARY_DIR}/%s)\n""" % (
- kwargs["name"], data_dep, data_dep
- ))
-
- self._add_deps(kwargs)
+ # Disable this until we properly support upb_proto_library().
+ # self.converter.toplevel += "add_executable(%s\n %s)\n" % (
+ # kwargs["name"],
+ # "\n ".join(kwargs["srcs"])
+ # )
+ # self.converter.toplevel += "add_test(NAME %s COMMAND %s)\n" % (
+ # kwargs["name"],
+ # kwargs["name"],
+ # )
+
+ # if "data" in kwargs:
+ # for data_dep in kwargs["data"]:
+ # self.converter.toplevel += textwrap.dedent("""\
+ # add_custom_command(
+ # TARGET %s POST_BUILD
+ # COMMAND ${CMAKE_COMMAND} -E copy
+ # ${CMAKE_SOURCE_DIR}/%s
+ # ${CMAKE_CURRENT_BINARY_DIR}/%s)\n""" % (
+ # kwargs["name"], data_dep, data_dep
+ # ))
+
+ # self._add_deps(kwargs)
+ pass
def py_library(self, **kwargs):
pass
@@ -120,9 +122,18 @@ class BuildFileFunctions(object):
def upb_proto_library(self, **kwargs):
pass
+ def upb_proto_reflection_library(self, **kwargs):
+ pass
+
def genrule(self, **kwargs):
pass
+ def config_setting(self, **kwargs):
+ pass
+
+ def select(self, arg_dict):
+ return []
+
def glob(*args):
return []
diff --git a/tools/test_cinit.lua b/tools/test_cinit.lua
deleted file mode 100644
index 8356d63..0000000
--- a/tools/test_cinit.lua
+++ /dev/null
@@ -1,64 +0,0 @@
---[[
-
- Tests for dump_cinit.lua. Runs first in a mode that generates
- some C code for an extension. The C code is compiled and then
- loaded by a second invocation of the test which checks that the
- generated defs are as expected.
-
---]]
-
-local dump_cinit = require "dump_cinit"
-local upb = require "upb"
-
--- Once APIs for loading descriptors are fleshed out, we should replace this
--- with a descriptor for a meaty protobuf like descriptor.proto.
-local symtab = upb.SymbolTable{
- upb.EnumDef{full_name = "MyEnum",
- values = {
- {"FOO", 1},
- {"BAR", 77}
- }
- },
- upb.MessageDef{full_name = "MyMessage",
- fields = {
- upb.FieldDef{label = upb.LABEL_REQUIRED, name = "field1", number = 1,
- type = upb.TYPE_INT32},
- upb.FieldDef{label = upb.LABEL_REPEATED, name = "field2", number = 2,
- type = upb.TYPE_ENUM, subdef_name = ".MyEnum"},
- upb.FieldDef{name = "field3", number = 3, type = upb.TYPE_MESSAGE,
- subdef_name = ".MyMessage"}
- }
- }
-}
-
-if arg[1] == "generate" then
- local f = assert(io.open(arg[2], "w"))
- local f_h = assert(io.open(arg[2] .. ".h", "w"))
- local appendc = dump_cinit.file_appender(f)
- local appendh = dump_cinit.file_appender(f_h)
- f:write('#include "lua.h"\n')
- f:write('#include "upb/bindings/lua/upb.h"\n')
- dump_cinit.dump_defs(symtab, "testdefs", appendh, appendc)
- f:write([[int luaopen_staticdefs(lua_State *L) {
- const upb_symtab *s = upbdefs_testdefs(&s);
- lupb_symtab_pushwrapper(L, s, &s);
- return 1;
- }]])
- f_h:close()
- f:close()
-elseif arg[1] == "test" then
- local symtab = require "staticdefs"
- local msg = assert(symtab:lookup("MyMessage"))
- local enum = assert(symtab:lookup("MyEnum"))
- local f2 = assert(msg:field("field2"))
- assert(msg:def_type() == upb.DEF_MSG)
- assert(msg:full_name() == "MyMessage")
- assert(enum:def_type() == upb.DEF_ENUM)
- assert(enum:full_name() == "MyEnum")
- assert(enum:value("FOO") == 1)
- assert(f2:name() == "field2")
- assert(f2:containing_type() == msg)
- assert(f2:subdef() == enum)
-else
- error("Unknown operation " .. arg[1])
-end
diff --git a/tools/upbc.lua b/tools/upbc.lua
deleted file mode 100644
index 80d2886..0000000
--- a/tools/upbc.lua
+++ /dev/null
@@ -1,91 +0,0 @@
---[[
-
- The upb compiler. It can write two different kinds of output
- files:
-
- - generated code for a C API (foo.upb.h, foo.upb.c)
- - (obsolete): definitions of upb defs. (foo.upbdefs.h, foo.upbdefs.c)
-
---]]
-
-local dump_cinit = require "dump_cinit"
-local upb = require "upb"
-
-local generate_upbdefs = false
-local outdir = "."
-
-i = 1
-while i <= #arg do
- argument = arg[i]
- if argument.sub(argument, 1, 2) == "--" then
- if argument == "--generate-upbdefs" then
- generate_upbdefs = true
- elseif argument == "--outdir" then
- i = i + 1
- outdir = arg[i]
- else
- print("Unknown flag: " .. argument)
- return 1
- end
- else
- if src then
- print("upbc can only handle one input file at a time.")
- return 1
- end
- src = argument
- end
- i = i + 1
-end
-
-if not src then
- print("Usage: upbc [--generate-upbdefs] <binary descriptor>")
- return 1
-end
-
-function strip_proto(filename)
- return string.gsub(filename, '%.proto$','')
-end
-
-local function open(filename)
- local full_name = outdir .. "/" .. filename
- return assert(io.open(full_name, "w"), "couldn't open " .. full_name)
-end
-
--- Open input/output files.
-local f = assert(io.open(src, "r"), "couldn't open input file " .. src)
-local descriptor = f:read("*all")
-local files = upb.load_descriptor(descriptor)
-local symtab = upb.SymbolTable()
-
-for _, file in ipairs(files) do
- symtab:add_file(file)
- local outbase = strip_proto(file:name())
-
- -- Write upbdefs.
-
- local hfilename = outbase .. ".upbdefs.h"
- local cfilename = outbase .. ".upbdefs.c"
-
- if os.getenv("UPBC_VERBOSE") then
- print("upbc:")
- print(string.format(" source file=%s", src))
- print(string.format(" output file base=%s", outbase))
- print(string.format(" hfilename=%s", hfilename))
- print(string.format(" cfilename=%s", cfilename))
- end
-
- os.execute(string.format("mkdir -p `dirname %s`", outbase))
-
- assert(generate_upbdefs)
- -- Legacy generated defs.
- local hfile = open(hfilename)
- local cfile = open(cfilename)
-
- local happend = dump_cinit.file_appender(hfile)
- local cappend = dump_cinit.file_appender(cfile)
-
- dump_cinit.dump_defs(file, happend, cappend)
-
- hfile:close()
- cfile:close()
-end
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback