Allow empty sapi_embedded_dir flag in the header generator

PiperOrigin-RevId: 311478848
Change-Id: If94d2279989b3cfc76304bb0bb8624e0f0532ba6
This commit is contained in:
Christian Blichmann 2020-05-13 23:48:59 -07:00 committed by Copybara-Service
parent d6b8e0b3e3
commit ba47adc21d
2 changed files with 8 additions and 6 deletions

View File

@ -679,7 +679,7 @@ class Generator(object):
GUARD_START = ('#ifndef {0}\n' '#define {0}') GUARD_START = ('#ifndef {0}\n' '#define {0}')
GUARD_END = '#endif // {}' GUARD_END = '#endif // {}'
EMBED_INCLUDE = '#include \"{}/{}_embed.h"' EMBED_INCLUDE = '#include "{}"'
EMBED_CLASS = ('class {0}Sandbox : public ::sapi::Sandbox {{\n' EMBED_CLASS = ('class {0}Sandbox : public ::sapi::Sandbox {{\n'
' public:\n' ' public:\n'
' {0}Sandbox() : ::sapi::Sandbox({1}_embed_create()) {{}}\n' ' {0}Sandbox() : ::sapi::Sandbox({1}_embed_create()) {{}}\n'
@ -903,8 +903,10 @@ class Generator(object):
result.append('#include "sandboxed_api/sandbox.h"') result.append('#include "sandboxed_api/sandbox.h"')
result.append('#include "sandboxed_api/vars.h"') result.append('#include "sandboxed_api/vars.h"')
if embed_dir and embed_name: if (embed_dir is not None) and (embed_name is not None):
result.append(Generator.EMBED_INCLUDE.format(embed_dir, embed_name)) result.append(
Generator.EMBED_INCLUDE.format(
os.path.join(embed_dir, embed_name) + '_embed.h'))
if namespaces: if namespaces:
result.append('') result.append('')
@ -918,7 +920,7 @@ class Generator(object):
result.append('') result.append('')
if embed_dir and embed_name: if (embed_dir is not None) and (embed_name is not None):
result.append( result.append(
Generator.EMBED_CLASS.format(name, embed_name.replace('-', '_'))) Generator.EMBED_CLASS.format(name, embed_name.replace('-', '_')))

View File

@ -31,8 +31,8 @@ flags.DEFINE_string('sapi_ns', '', 'namespace')
flags.DEFINE_string('sapi_isystem', '', 'system includes') flags.DEFINE_string('sapi_isystem', '', 'system includes')
flags.DEFINE_list('sapi_functions', [], 'function list to analyze') flags.DEFINE_list('sapi_functions', [], 'function list to analyze')
flags.DEFINE_list('sapi_in', None, 'input files to analyze') flags.DEFINE_list('sapi_in', None, 'input files to analyze')
flags.DEFINE_string('sapi_embed_dir', None, 'directory with embed includes') flags.DEFINE_string('sapi_embed_dir', '', 'directory with embed includes')
flags.DEFINE_string('sapi_embed_name', None, 'name of the embed object') flags.DEFINE_string('sapi_embed_name', '', 'name of the embed object')
flags.DEFINE_bool( flags.DEFINE_bool(
'sapi_limit_scan_depth', False, 'sapi_limit_scan_depth', False,
'scan only functions from top level file in compilation unit') 'scan only functions from top level file in compilation unit')