From 04f04993a25e7494996a04611db9c5a9cc650792 Mon Sep 17 00:00:00 2001 From: Greg Hartman Date: Fri, 12 Oct 2018 19:01:50 -0700 Subject: Add additional Android.bp files to make libs visible BUG: 117561734 Test: Builds on oreo and oreo-mr1 Change-Id: Ie295ccd3ca252f35763f9ec5097075e722ed37f3 --- Android.bp | 18 ++++++++++++++++++ host/Android.bp | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Android.bp diff --git a/Android.bp b/Android.bp new file mode 100644 index 000000000..7f25a9135 --- /dev/null +++ b/Android.bp @@ -0,0 +1,18 @@ +// +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +subdirs = [ + "host", +] diff --git a/host/Android.bp b/host/Android.bp index 5464fac40..b2fe7a4e8 100644 --- a/host/Android.bp +++ b/host/Android.bp @@ -1,3 +1,23 @@ +// +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +subdirs = [ + "commands", + "libs", +] + cc_library_headers { name: "virtio_gpu_uapi_headers", host_supported: true, -- cgit v1.2.3 From b647927ff80c6f4f44d07c978d16936f33ff2e61 Mon Sep 17 00:00:00 2001 From: Greg Hartman Date: Fri, 12 Oct 2018 23:48:17 -0700 Subject: Remove spurious Android.mk BUG: 117561734 Test: Local build gets further Change-Id: I96a0d285b98f97bed38a8f18657b9f12f21e6b47 --- host/commands/emugen/Android.mk | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 host/commands/emugen/Android.mk diff --git a/host/commands/emugen/Android.mk b/host/commands/emugen/Android.mk deleted file mode 100644 index 81d130de6..000000000 --- a/host/commands/emugen/Android.mk +++ /dev/null @@ -1,39 +0,0 @@ -# Determine if the emugen build needs to be builts from -# sources. -LOCAL_PATH:=$(call my-dir) - -$(call emugl-begin-host-executable,emugen) -LOCAL_SRC_FILES := \ - ApiGen.cpp \ - EntryPoint.cpp \ - main.cpp \ - Parser.cpp \ - strUtils.cpp \ - TypeFactory.cpp \ - -ifeq ($(BUILD_HOST_OS),linux) - # Make sure libc++.so can be found - LOCAL_LDFLAGS +=-Wl,-rpath=$(BUILD_OBJS_DIR)/intermediates64 -endif - -LOCAL_INSTALL := false - -$(call emugl-end-module) - -# The location of the emugen host tool that is used to generate wire -# protocol encoders/ decoders. This variable is used by other emugl modules. -EMUGL_EMUGEN := $(LOCAL_BUILT_MODULE) - -$(call emugl-begin-host-executable,emugen_unittests) -LOCAL_SRC_FILES := \ - Parser.cpp \ - Parser_unittest.cpp - -LOCAL_INSTALL := false - -$(call emugl-import,libemugl_gtest_host) -ifeq ($(BUILD_HOST_OS),linux) - # Make sure libc++.so can be found - LOCAL_LDFLAGS +=-Wl,-rpath=$(BUILD_OBJS_DIR)/intermediates64 -m64 -endif -$(call emugl-end-module) -- cgit v1.2.3 From b8b13e8c7ed6201565f4435136d64a47a7668648 Mon Sep 17 00:00:00 2001 From: Greg Hartman Date: Fri, 12 Oct 2018 23:09:58 -0700 Subject: Hack to allow compilation on oreo and oreo-mr1 Change-Id: I2ddf71162da32b99e4c5f23bc0e505bcc43fb75e Test: Compiles --- host/commands/Android.bp | 14 -- host/commands/gen_entries.py | 317 --------------------------------- host/libs/virglrenderer/Android.bp | 34 ++-- host/libs/virglrenderer/gen_entries.py | 317 +++++++++++++++++++++++++++++++++ 4 files changed, 333 insertions(+), 349 deletions(-) delete mode 100755 host/commands/gen_entries.py create mode 100755 host/libs/virglrenderer/gen_entries.py diff --git a/host/commands/Android.bp b/host/commands/Android.bp index 485e2ef26..ddca16065 100644 --- a/host/commands/Android.bp +++ b/host/commands/Android.bp @@ -16,17 +16,3 @@ subdirs = [ "emugen", ] - -python_binary_host { - name: "gen_entries_cuttlefish", - srcs: ["gen_entries.py"], - main: "gen_entries.py", - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} diff --git a/host/commands/gen_entries.py b/host/commands/gen_entries.py deleted file mode 100755 index fbfdb4daf..000000000 --- a/host/commands/gen_entries.py +++ /dev/null @@ -1,317 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2015 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Utility functions used to parse a list of DLL entry points. -# Expected format: -# -# -> ignored -# # -> ignored -# % -> verbatim output for header files. -# ! -> prefix name for header files. -# ; -> entry point declaration. -# -# Anything else is an error. - -import re -import sys -import argparse - -re_func = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)\((.*)\);$""") -re_param = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)$""") - -class Entry: - """Small class used to model a single DLL entry point.""" - def __init__(self, func_name, return_type, parameters): - """Initialize Entry instance. |func_name| is the function name, - |return_type| its return type, and |parameters| is a list of - (type,name) tuples from the entry's signature. - """ - self.func_name = func_name - self.return_type = return_type - self.parameters = "" - self.vartypes = [] - self.varnames = [] - self.call = "" - comma = "" - for param in parameters: - self.vartypes.append(param[0]) - self.varnames.append(param[1]) - self.parameters += "%s%s %s" % (comma, param[0], param[1]) - self.call += "%s%s" % (comma, param[1]) - comma = ", " - -def banner_command(argv): - """Return sanitized command-line description. - |argv| must be a list of command-line parameters, e.g. sys.argv. - Return a string corresponding to the command, with platform-specific - paths removed.""" - - # Remove path from first parameter - argv = argv[:] - argv[0] = "host/commands/gen-entries.py" - return ' '.join(argv) - -def parse_entries_file(lines): - """Parse an .entries file and return a tuple of: - entries: list of Entry instances from the file. - prefix_name: prefix name from the file, or None. - verbatim: list of verbatim lines from the file. - errors: list of errors in the file, prefixed by line number. - """ - entries = [] - verbatim = [] - errors = [] - lineno = 0 - prefix_name = None - for line in lines: - lineno += 1 - line = line.strip() - if len(line) == 0: # Ignore empty lines - continue - if line[0] == '#': # Ignore comments - continue - if line[0] == '!': # Prefix name - prefix_name = line[1:] - continue - if line[0] == '%': # Verbatim line copy - verbatim.append(line[1:]) - continue - # Must be a function signature. - m = re_func.match(line) - if not m: - errors.append("%d: '%s'" % (lineno, line)) - continue - - return_type, func_name, parameters = m.groups() - return_type = return_type.strip() - parameters = parameters.strip() - params = [] - failure = False - if parameters != "void": - for parameter in parameters.split(','): - parameter = parameter.strip() - m = re_param.match(parameter) - if not m: - errors.append("%d: parameter '%s'" % (lineno, parameter)) - failure = True - break - else: - param_type, param_name = m.groups() - params.append((param_type.strip(), param_name.strip())) - - if not failure: - entries.append(Entry(func_name, return_type, params)) - - return (entries, prefix_name, verbatim, errors) - - -def gen_functions_header(entries, prefix_name, verbatim, filename, with_args): - """Generate a C header containing a macro listing all entry points. - |entries| is a list of Entry instances. - |prefix_name| is a prefix-name, it will be converted to upper-case. - |verbatim| is a list of verbatim lines that must appear before the - macro declaration. Useful to insert #include <> statements. - |filename| is the name of the original file. - """ - prefix_name = prefix_name.upper() - - print "// Auto-generated with: %s" % banner_command(sys.argv) - print "// DO NOT EDIT THIS FILE" - print "" - print "#ifndef %s_FUNCTIONS_H" % prefix_name - print "#define %s_FUNCTIONS_H" % prefix_name - print "" - for line in verbatim: - print line - - print "#define LIST_%s_FUNCTIONS(X) \\" % prefix_name - for entry in entries: - if with_args: - print " X(%s, %s, (%s), (%s)) \\" % \ - (entry.return_type, entry.func_name, entry.parameters, - entry.call) - else: - print " X(%s, %s, (%s)) \\" % \ - (entry.return_type, entry.func_name, entry.parameters) - - print "" - print "" - print "#endif // %s_FUNCTIONS_H" % prefix_name - -def gen_dll_wrapper(entries, prefix_name, verbatim, filename): - """Generate a C source file that contains functions that act as wrappers - for entry points located in another shared library. This allows the - code that calls these functions to perform lazy-linking to system - libraries. - |entries|, |prefix_name|, |verbatim| and |filename| are the same as - for gen_functions_header() above. - """ - upper_name = prefix_name.upper() - - ENTRY_PREFIX = "__dll_" - - print "// Auto-generated with: %s" % banner_command(sys.argv) - print "// DO NOT EDIT THIS FILE" - print "" - print "#include " - for line in verbatim: - print line - - print "" - print "///" - print "/// W R A P P E R P O I N T E R S" - print "///" - print "" - for entry in entries: - ptr_name = ENTRY_PREFIX + entry.func_name - print "static %s (*%s)(%s) = 0;" % \ - (entry.return_type, ptr_name, entry.parameters) - - print "" - print "///" - print "/// W R A P P E R F U N C T I O N S" - print "///" - print "" - - for entry in entries: - print "%s %s(%s) {" % \ - (entry.return_type, entry.func_name, entry.parameters) - ptr_name = ENTRY_PREFIX + entry.func_name - if entry.return_type != "void": - print " return %s(%s);" % (ptr_name, entry.call) - else: - print " %s(%s);" % (ptr_name, entry.call) - print "}\n" - - print "" - print "///" - print "/// I N I T I A L I Z A T I O N F U N C T I O N" - print "///" - print "" - - print "int %s_dynlink_init(void* lib) {" % prefix_name - for entry in entries: - ptr_name = ENTRY_PREFIX + entry.func_name - print " %s = (%s(*)(%s))dlsym(lib, \"%s\");" % \ - (ptr_name, - entry.return_type, - entry.parameters, - entry.func_name) - print " if (!%s) return -1;" % ptr_name - print " return 0;" - print "}" - - -def gen_windows_def_file(entries): - """Generate a windows DLL .def file. |entries| is a list of Entry instances. - """ - print "EXPORTS" - for entry in entries: - print " %s" % entry.func_name - - -def gen_unix_sym_file(entries): - """Generate an ELF linker version file. |entries| is a list of Entry - instances. - """ - print "VERSION {" - print "\tglobal:" - for entry in entries: - print "\t\t%s;" % entry.func_name - print "\tlocal:" - print "\t\t*;" - print "};" - -def gen_symbols(entries, underscore): - """Generate a list of symbols from |entries|, a list of Entry instances. - |underscore| is a boolean. If True, then prepend an underscore to each - symbol name. - """ - prefix = "" - if underscore: - prefix = "_" - for entry in entries: - print "%s%s" % (prefix, entry.func_name) - -def parse_file(filename, lines, mode): - """Generate one of possible outputs from |filename|. |lines| must be a list - of text lines from the file, and |mode| is one of the --mode option - values. - """ - entries, prefix_name, verbatim, errors = parse_entries_file(lines) - if errors: - for error in errors: - print >> sys.stderr, "ERROR: %s:%s" % (filename, error) - sys.exit(1) - - if not prefix_name: - prefix_name = "unknown" - - if mode == 'def': - gen_windows_def_file(entries) - elif mode == 'sym': - gen_unix_sym_file(entries) - elif mode == 'wrapper': - gen_dll_wrapper(entries, prefix_name, verbatim, filename) - elif mode == 'symbols': - gen_symbols(entries, False) - elif mode == '_symbols': - gen_symbols(entries, True) - elif mode == 'functions': - gen_functions_header(entries, prefix_name, verbatim, filename, False) - elif mode == 'funcargs': - gen_functions_header(entries, prefix_name, verbatim, filename, True) - - -# List of valid --mode option values. -mode_list = [ - 'def', 'sym', 'wrapper', 'symbols', '_symbols', 'functions', 'funcargs' -] - -# Argument parsing. -parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter, - description="""\ -A script used to parse an .entries input file containing a list of function -declarations, and generate various output files depending on the value of -the --mode option, which can be: - - def Generate a windows DLL .def file. - sym Generate a Unix .so linker script. - wrapper Generate a C source file containing wrapper functions. - symbols Generate a simple list of symbols, one per line. - _symbols Generate a simple list of symbols, prefixed with _. - functions Generate a C header containing a macro listing all functions. - funcargs Like 'functions', but adds function call arguments to listing. - -""") -parser.add_argument("--mode", help="Output mode", choices=mode_list) -parser.add_argument("--output", help="output file") -parser.add_argument("file", help=".entries file path") - -args = parser.parse_args() - -if not args.mode: - print >> sys.stderr, "ERROR: Please use --mode=, see --help." - sys.exit(1) - -if args.output: - sys.stdout = open(args.output, "w+") - -if args.file == '--': - parse_file("", sys.stdin, args.mode) -else: - parse_file(args.file, open(args.file), args.mode) diff --git a/host/libs/virglrenderer/Android.bp b/host/libs/virglrenderer/Android.bp index 6c31b7a02..b0f5d03ff 100644 --- a/host/libs/virglrenderer/Android.bp +++ b/host/libs/virglrenderer/Android.bp @@ -89,68 +89,66 @@ genrule { ], } -// out/host/linux-x86/bin/emugen_cuttlefish -i device/generic/opengl-transport/host/libs/virglrenderer/renderControl_dec -D /tmp/foo renderControl - genrule { name: "gles1_core_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/gles1_core.entries"], out: ["gles1_core_functions.h"], } genrule { name: "gles1_extensions_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/gles1_extensions.entries"], out: ["gles1_extensions_functions.h"], } genrule { name: "egl_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/egl.entries"], out: ["egl_functions.h"], } genrule { name: "gles3_only_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/gles3_only.entries"], out: ["gles3_only_functions.h"], } genrule { name: "gles31_only_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/gles31_only.entries"], out: ["gles31_only_functions.h"], } genrule { name: "gles2_extensions_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/gles2_extensions.entries"], out: ["gles2_extensions_functions.h"], } genrule { name: "egl_extensions_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/egl_extensions.entries"], out: ["egl_extensions_functions.h"], } genrule { name: "gles2_core_functions_hdr", - tools: ["gen_entries_cuttlefish"], - cmd: "$(location gen_entries_cuttlefish) --mode=funcargs $(in) --output $(out)", + tool_files: ["gen_entries.py"], + cmd: "python device/generic/opengl-transport/host/libs/virglrenderer/gen_entries.py --mode=funcargs $(in) --output $(out)", srcs: ["OpenGLESDispatch/gles2_core.entries"], out: ["gles2_core_functions.h"], } diff --git a/host/libs/virglrenderer/gen_entries.py b/host/libs/virglrenderer/gen_entries.py new file mode 100755 index 000000000..fbfdb4daf --- /dev/null +++ b/host/libs/virglrenderer/gen_entries.py @@ -0,0 +1,317 @@ +#!/usr/bin/env python + +# Copyright 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Utility functions used to parse a list of DLL entry points. +# Expected format: +# +# -> ignored +# # -> ignored +# % -> verbatim output for header files. +# ! -> prefix name for header files. +# ; -> entry point declaration. +# +# Anything else is an error. + +import re +import sys +import argparse + +re_func = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)\((.*)\);$""") +re_param = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)$""") + +class Entry: + """Small class used to model a single DLL entry point.""" + def __init__(self, func_name, return_type, parameters): + """Initialize Entry instance. |func_name| is the function name, + |return_type| its return type, and |parameters| is a list of + (type,name) tuples from the entry's signature. + """ + self.func_name = func_name + self.return_type = return_type + self.parameters = "" + self.vartypes = [] + self.varnames = [] + self.call = "" + comma = "" + for param in parameters: + self.vartypes.append(param[0]) + self.varnames.append(param[1]) + self.parameters += "%s%s %s" % (comma, param[0], param[1]) + self.call += "%s%s" % (comma, param[1]) + comma = ", " + +def banner_command(argv): + """Return sanitized command-line description. + |argv| must be a list of command-line parameters, e.g. sys.argv. + Return a string corresponding to the command, with platform-specific + paths removed.""" + + # Remove path from first parameter + argv = argv[:] + argv[0] = "host/commands/gen-entries.py" + return ' '.join(argv) + +def parse_entries_file(lines): + """Parse an .entries file and return a tuple of: + entries: list of Entry instances from the file. + prefix_name: prefix name from the file, or None. + verbatim: list of verbatim lines from the file. + errors: list of errors in the file, prefixed by line number. + """ + entries = [] + verbatim = [] + errors = [] + lineno = 0 + prefix_name = None + for line in lines: + lineno += 1 + line = line.strip() + if len(line) == 0: # Ignore empty lines + continue + if line[0] == '#': # Ignore comments + continue + if line[0] == '!': # Prefix name + prefix_name = line[1:] + continue + if line[0] == '%': # Verbatim line copy + verbatim.append(line[1:]) + continue + # Must be a function signature. + m = re_func.match(line) + if not m: + errors.append("%d: '%s'" % (lineno, line)) + continue + + return_type, func_name, parameters = m.groups() + return_type = return_type.strip() + parameters = parameters.strip() + params = [] + failure = False + if parameters != "void": + for parameter in parameters.split(','): + parameter = parameter.strip() + m = re_param.match(parameter) + if not m: + errors.append("%d: parameter '%s'" % (lineno, parameter)) + failure = True + break + else: + param_type, param_name = m.groups() + params.append((param_type.strip(), param_name.strip())) + + if not failure: + entries.append(Entry(func_name, return_type, params)) + + return (entries, prefix_name, verbatim, errors) + + +def gen_functions_header(entries, prefix_name, verbatim, filename, with_args): + """Generate a C header containing a macro listing all entry points. + |entries| is a list of Entry instances. + |prefix_name| is a prefix-name, it will be converted to upper-case. + |verbatim| is a list of verbatim lines that must appear before the + macro declaration. Useful to insert #include <> statements. + |filename| is the name of the original file. + """ + prefix_name = prefix_name.upper() + + print "// Auto-generated with: %s" % banner_command(sys.argv) + print "// DO NOT EDIT THIS FILE" + print "" + print "#ifndef %s_FUNCTIONS_H" % prefix_name + print "#define %s_FUNCTIONS_H" % prefix_name + print "" + for line in verbatim: + print line + + print "#define LIST_%s_FUNCTIONS(X) \\" % prefix_name + for entry in entries: + if with_args: + print " X(%s, %s, (%s), (%s)) \\" % \ + (entry.return_type, entry.func_name, entry.parameters, + entry.call) + else: + print " X(%s, %s, (%s)) \\" % \ + (entry.return_type, entry.func_name, entry.parameters) + + print "" + print "" + print "#endif // %s_FUNCTIONS_H" % prefix_name + +def gen_dll_wrapper(entries, prefix_name, verbatim, filename): + """Generate a C source file that contains functions that act as wrappers + for entry points located in another shared library. This allows the + code that calls these functions to perform lazy-linking to system + libraries. + |entries|, |prefix_name|, |verbatim| and |filename| are the same as + for gen_functions_header() above. + """ + upper_name = prefix_name.upper() + + ENTRY_PREFIX = "__dll_" + + print "// Auto-generated with: %s" % banner_command(sys.argv) + print "// DO NOT EDIT THIS FILE" + print "" + print "#include " + for line in verbatim: + print line + + print "" + print "///" + print "/// W R A P P E R P O I N T E R S" + print "///" + print "" + for entry in entries: + ptr_name = ENTRY_PREFIX + entry.func_name + print "static %s (*%s)(%s) = 0;" % \ + (entry.return_type, ptr_name, entry.parameters) + + print "" + print "///" + print "/// W R A P P E R F U N C T I O N S" + print "///" + print "" + + for entry in entries: + print "%s %s(%s) {" % \ + (entry.return_type, entry.func_name, entry.parameters) + ptr_name = ENTRY_PREFIX + entry.func_name + if entry.return_type != "void": + print " return %s(%s);" % (ptr_name, entry.call) + else: + print " %s(%s);" % (ptr_name, entry.call) + print "}\n" + + print "" + print "///" + print "/// I N I T I A L I Z A T I O N F U N C T I O N" + print "///" + print "" + + print "int %s_dynlink_init(void* lib) {" % prefix_name + for entry in entries: + ptr_name = ENTRY_PREFIX + entry.func_name + print " %s = (%s(*)(%s))dlsym(lib, \"%s\");" % \ + (ptr_name, + entry.return_type, + entry.parameters, + entry.func_name) + print " if (!%s) return -1;" % ptr_name + print " return 0;" + print "}" + + +def gen_windows_def_file(entries): + """Generate a windows DLL .def file. |entries| is a list of Entry instances. + """ + print "EXPORTS" + for entry in entries: + print " %s" % entry.func_name + + +def gen_unix_sym_file(entries): + """Generate an ELF linker version file. |entries| is a list of Entry + instances. + """ + print "VERSION {" + print "\tglobal:" + for entry in entries: + print "\t\t%s;" % entry.func_name + print "\tlocal:" + print "\t\t*;" + print "};" + +def gen_symbols(entries, underscore): + """Generate a list of symbols from |entries|, a list of Entry instances. + |underscore| is a boolean. If True, then prepend an underscore to each + symbol name. + """ + prefix = "" + if underscore: + prefix = "_" + for entry in entries: + print "%s%s" % (prefix, entry.func_name) + +def parse_file(filename, lines, mode): + """Generate one of possible outputs from |filename|. |lines| must be a list + of text lines from the file, and |mode| is one of the --mode option + values. + """ + entries, prefix_name, verbatim, errors = parse_entries_file(lines) + if errors: + for error in errors: + print >> sys.stderr, "ERROR: %s:%s" % (filename, error) + sys.exit(1) + + if not prefix_name: + prefix_name = "unknown" + + if mode == 'def': + gen_windows_def_file(entries) + elif mode == 'sym': + gen_unix_sym_file(entries) + elif mode == 'wrapper': + gen_dll_wrapper(entries, prefix_name, verbatim, filename) + elif mode == 'symbols': + gen_symbols(entries, False) + elif mode == '_symbols': + gen_symbols(entries, True) + elif mode == 'functions': + gen_functions_header(entries, prefix_name, verbatim, filename, False) + elif mode == 'funcargs': + gen_functions_header(entries, prefix_name, verbatim, filename, True) + + +# List of valid --mode option values. +mode_list = [ + 'def', 'sym', 'wrapper', 'symbols', '_symbols', 'functions', 'funcargs' +] + +# Argument parsing. +parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description="""\ +A script used to parse an .entries input file containing a list of function +declarations, and generate various output files depending on the value of +the --mode option, which can be: + + def Generate a windows DLL .def file. + sym Generate a Unix .so linker script. + wrapper Generate a C source file containing wrapper functions. + symbols Generate a simple list of symbols, one per line. + _symbols Generate a simple list of symbols, prefixed with _. + functions Generate a C header containing a macro listing all functions. + funcargs Like 'functions', but adds function call arguments to listing. + +""") +parser.add_argument("--mode", help="Output mode", choices=mode_list) +parser.add_argument("--output", help="output file") +parser.add_argument("file", help=".entries file path") + +args = parser.parse_args() + +if not args.mode: + print >> sys.stderr, "ERROR: Please use --mode=, see --help." + sys.exit(1) + +if args.output: + sys.stdout = open(args.output, "w+") + +if args.file == '--': + parse_file("", sys.stdin, args.mode) +else: + parse_file(args.file, open(args.file), args.mode) -- cgit v1.2.3 From 355f36f2b669a29d07ce306d31b329c794996db4 Mon Sep 17 00:00:00 2001 From: Greg Hartman Date: Thu, 25 Oct 2018 22:37:37 -0700 Subject: Fix build break on mac Test: Visual inspection There's no reason that emugen wouldn't compile on the mac, and turning it off here breaks things. Change-Id: Icaa6e06a8e69d89a7739b4702a62906767c03d58 (cherry picked from commit a688f6d6369222c9bdf5bd30a7b87aafa22ed7cd) --- host/commands/emugen/Android.bp | 1 - 1 file changed, 1 deletion(-) diff --git a/host/commands/emugen/Android.bp b/host/commands/emugen/Android.bp index 717a96633..516d116a0 100644 --- a/host/commands/emugen/Android.bp +++ b/host/commands/emugen/Android.bp @@ -9,5 +9,4 @@ cc_binary_host { "TypeFactory.cpp", ], cflags: ["-Wno-unused-parameter"], - defaults: ["cuttlefish_host_only"], } -- cgit v1.2.3 From 1b1f008f36c6d406da123cc41700072d70355b3f Mon Sep 17 00:00:00 2001 From: Greg Hartman Date: Fri, 26 Oct 2018 09:23:32 -0700 Subject: Document why we can't build this for Mac BUG: 118466250 Test: TH Change-Id: I2858aa77749eb8637afb1e5c9e26f184ba3d525e --- host/libs/virglrenderer/Android.bp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/host/libs/virglrenderer/Android.bp b/host/libs/virglrenderer/Android.bp index b0f5d03ff..e66086041 100644 --- a/host/libs/virglrenderer/Android.bp +++ b/host/libs/virglrenderer/Android.bp @@ -179,8 +179,6 @@ cc_library_host_shared { ], cflags: ["-Wno-unused-parameter", "-DOPENGL_DEBUG_PRINTOUT"], host_ldlibs: [ "-ldl" ], - version_script : "libvirglrenderer.lds", - defaults: [ "cuttlefish_host_only" ], generated_sources: [ "glesv1_dec_cuttlefish_gensrc", "glesv3_dec_cuttlefish_gensrc", @@ -203,4 +201,8 @@ cc_library_host_shared { "virtio_gpu_uapi_headers", "virgl_headers" ], + + // TODO(b/118466250): Make this work on the Mac + version_script : "libvirglrenderer.lds", + defaults: [ "cuttlefish_host_only" ], } -- cgit v1.2.3 From 286422f8ce1fdcb26c140ab8b999ce5fa77b0536 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Mon, 29 Oct 2018 14:53:56 -0700 Subject: Fix implicit-fallthrough warnings in AVDVirglRenderer.cpp etc. It will be a global error by default. Test: make checkbuild Bug: 112564944 Exempt-From-Owner-Approval: do not block on new warnings --- host/commands/emugen/main.cpp | 2 +- host/libs/virglrenderer/AVDVirglRenderer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/host/commands/emugen/main.cpp b/host/commands/emugen/main.cpp index 5408617a1..6200349f7 100644 --- a/host/commands/emugen/main.cpp +++ b/host/commands/emugen/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) break; case ':': fprintf(stderr, "Missing argument !!\n"); - // fall through + [[fallthrough]]; default: usage(argv[0]); exit(0); diff --git a/host/libs/virglrenderer/AVDVirglRenderer.cpp b/host/libs/virglrenderer/AVDVirglRenderer.cpp index 2be15d5a1..95e725600 100644 --- a/host/libs/virglrenderer/AVDVirglRenderer.cpp +++ b/host/libs/virglrenderer/AVDVirglRenderer.cpp @@ -788,7 +788,7 @@ int virgl_renderer_create_fence(int client_fence_id, uint32_t cmd_type) { g_last_submit_cmd_ctx->setFence(client_fence_id); break; } - // Fall through + [[fallthrough]]; default: { std::lock_guard lk(g_fence_deque_mutex); g_fence_deque.push_back(client_fence_id); -- cgit v1.2.3