Address review comments

This commit is contained in:
Ryoji Yoshida 2020-03-25 10:33:22 +09:00
parent d7cca2a791
commit 4ffbd46cea
3 changed files with 28 additions and 28 deletions

View File

@ -16,13 +16,15 @@ GENERATE_DEBUG_SYMS :=
endif endif
ifeq ($(findstring _NT,$(OS)),_NT) ifeq ($(findstring _NT,$(OS)),_NT)
FIRST_PARTY := first_party.lib ARCHIVE_EXT := lib
THIRD_PARTY := third_party.lib
else else
FIRST_PARTY := first_party.a ARCHIVE_EXT := a
THIRD_PARTY := third_party.a
endif endif
FIRST_PARTY := first_party.$(ARCHIVE_EXT)
THIRD_PARTY := third_party.$(ARCHIVE_EXT)
all: bindings all: bindings
clean-keep-third-party: clean-keep-third-party:

View File

@ -15,7 +15,7 @@ if sys.platform.startswith('win'):
DBG_ARGS = ['/Od', '/MTd', '/Zi', '/U NDEBUG', '/D DEBUG'] DBG_ARGS = ['/Od', '/MTd', '/Zi', '/U NDEBUG', '/D DEBUG']
OPENFST_DIR = 'third_party/openfst-1.6.9-win' OPENFST_DIR = 'third_party/openfst-1.6.9-win'
else: else:
ARGS = ['-DKENLM_MAX_ORDER=6', '-std=c++11', '-Wno-unused-local-typedefs', '-Wno-sign-compare'] ARGS = ['fPIC', '-DKENLM_MAX_ORDER=6', '-std=c++11', '-Wno-unused-local-typedefs', '-Wno-sign-compare']
OPT_ARGS = ['-O3', '-DNDEBUG'] OPT_ARGS = ['-O3', '-DNDEBUG']
DBG_ARGS = ['-O0', '-g', '-UNDEBUG', '-DDEBUG'] DBG_ARGS = ['-O0', '-g', '-UNDEBUG', '-DDEBUG']
OPENFST_DIR = 'third_party/openfst-1.6.7' OPENFST_DIR = 'third_party/openfst-1.6.7'
@ -51,6 +51,8 @@ CTC_DECODER_FILES = [
def build_archive(srcs=[], out_name='', build_dir='temp_build/temp_build', debug=False, num_parallel=1): def build_archive(srcs=[], out_name='', build_dir='temp_build/temp_build', debug=False, num_parallel=1):
compiler = os.environ.get('CXX', 'g++') compiler = os.environ.get('CXX', 'g++')
if sys.platform.startswith('win'):
compiler = '"{}"'.format(compiler)
ar = os.environ.get('AR', 'ar') ar = os.environ.get('AR', 'ar')
libtool = os.environ.get('LIBTOOL', 'libtool') libtool = os.environ.get('LIBTOOL', 'libtool')
cflags = os.environ.get('CFLAGS', '') + os.environ.get('CXXFLAGS', '') cflags = os.environ.get('CFLAGS', '') + os.environ.get('CXXFLAGS', '')
@ -69,24 +71,19 @@ def build_archive(srcs=[], out_name='', build_dir='temp_build/temp_build', debug
return return
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
cmd = '"{cc}" -c {cflags} {args} {includes} {infile} -Fo"{outfile}"'.format( file = '"{}"'.format(file.replace('\\', '/'))
cc=compiler, output = '/Fo"{}"'.format(outfile.replace('\\', '/'))
cflags=cflags,
args=' '.join(args),
includes=' '.join('-I' + i for i in INCLUDES),
infile=file,
outfile=outfile,
)
cmd = cmd.replace('\\', '/')
else: else:
cmd = '{cc} -fPIC -c {cflags} {args} {includes} {infile} -o {outfile}'.format( output = '-o ' + outfile
cc=compiler,
cflags=cflags, cmd = '{cc} -c {cflags} {args} {includes} {infile} {output}'.format(
args=' '.join(args), cc=compiler,
includes=' '.join('-I' + i for i in INCLUDES), cflags=cflags,
infile=file, args=' '.join(args),
outfile=outfile, includes=' '.join('-I' + i for i in INCLUDES),
) infile=file,
output=output,
)
print(cmd) print(cmd)
subprocess.check_call(shlex.split(cmd)) subprocess.check_call(shlex.split(cmd))
return outfile return outfile
@ -103,9 +100,7 @@ def build_archive(srcs=[], out_name='', build_dir='temp_build/temp_build', debug
print(cmd) print(cmd)
subprocess.check_call(shlex.split(cmd)) subprocess.check_call(shlex.split(cmd))
elif sys.platform.startswith('win'): elif sys.platform.startswith('win'):
obj_files = [s for s in obj_files if s != None]
cmd = '"lib.exe" /OUT:"{outfile}" {infiles} /MACHINE:X64 /NOLOGO'.format( cmd = '"lib.exe" /OUT:"{outfile}" {infiles} /MACHINE:X64 /NOLOGO'.format(
ar=ar,
outfile=out_name, outfile=out_name,
infiles=' '.join(obj_files)) infiles=' '.join(obj_files))
cmd = cmd.replace('\\', '/') cmd = cmd.replace('\\', '/')

View File

@ -54,12 +54,15 @@ def maybe_rebuild(srcs, out_name, build_dir):
project_version = read('../../VERSION').strip() project_version = read('../../VERSION').strip()
build_dir = 'temp_build/temp_build' build_dir = 'temp_build/temp_build'
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
third_party_build = 'third_party.lib' archive_ext = 'lib'
ctc_decoder_build = 'first_party.lib'
else: else:
third_party_build = 'third_party.a' archive_ext = 'a'
ctc_decoder_build = 'first_party.a'
third_party_build = 'third_party.{}'.format(archive_ext)
ctc_decoder_build = 'first_party.{}'.format(archive_ext)
maybe_rebuild(KENLM_FILES, third_party_build, build_dir) maybe_rebuild(KENLM_FILES, third_party_build, build_dir)
maybe_rebuild(CTC_DECODER_FILES, ctc_decoder_build, build_dir) maybe_rebuild(CTC_DECODER_FILES, ctc_decoder_build, build_dir)