Debug build for ds_ctcdecoder package
This commit is contained in:
parent
d9b79a6689
commit
aad1b2234b
@ -9,6 +9,12 @@ ifeq ($(TARGET),rpi3-armv8)
|
|||||||
LDFLAGS_NEEDED += $(RASPBIAN)/lib/aarch64-linux-gnu/libm.so.6
|
LDFLAGS_NEEDED += $(RASPBIAN)/lib/aarch64-linux-gnu/libm.so.6
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS),Darwin)
|
||||||
|
GENERATE_DEBUG_SYMS := dsymutil temp_build/temp_build/ds_ctcdecoder/_swigwrapper.*.so
|
||||||
|
else
|
||||||
|
GENERATE_DEBUG_SYMS :=
|
||||||
|
endif
|
||||||
|
|
||||||
all: bindings
|
all: bindings
|
||||||
|
|
||||||
clean-keep-common:
|
clean-keep-common:
|
||||||
@ -22,5 +28,13 @@ bindings: clean-keep-common
|
|||||||
pip install --quiet $(PYTHON_PACKAGES) wheel==0.31.0 setuptools==39.1.0
|
pip install --quiet $(PYTHON_PACKAGES) wheel==0.31.0 setuptools==39.1.0
|
||||||
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py build_ext --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py build_ext --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||||
find temp_build -type f -name "*.o" -delete
|
find temp_build -type f -name "*.o" -delete
|
||||||
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py bdist_wheel --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py bdist_wheel $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||||
|
rm -rf temp_build
|
||||||
|
|
||||||
|
bindings-debug: clean-keep-common
|
||||||
|
pip install --quiet $(PYTHON_PACKAGES) wheel==0.31.0 setuptools==39.1.0
|
||||||
|
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py build_ext --debug --num_processes $(NUM_PROCESSES) $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||||
|
$(GENERATE_DEBUG_SYMS)
|
||||||
|
find temp_build -type f -name "*.o" -delete
|
||||||
|
AS=$(AS) CC=$(CC) CXX=$(CXX) LD=$(LD) CFLAGS="$(CFLAGS) $(CXXFLAGS)" LDFLAGS="$(LDFLAGS_NEEDED)" $(PYTHON_PATH) $(NUMPY_INCLUDE) python ./setup.py bdist_wheel $(PYTHON_PLATFORM_NAME) $(SETUP_FLAGS)
|
||||||
rm -rf temp_build
|
rm -rf temp_build
|
||||||
|
@ -9,8 +9,9 @@ import sys
|
|||||||
|
|
||||||
from multiprocessing.dummy import Pool
|
from multiprocessing.dummy import Pool
|
||||||
|
|
||||||
ARGS = ['-O3', '-DNDEBUG', '-DKENLM_MAX_ORDER=6', '-std=c++11',
|
ARGS = ['-DKENLM_MAX_ORDER=6', '-std=c++11', '-Wno-unused-local-typedefs', '-Wno-sign-compare']
|
||||||
'-Wno-unused-local-typedefs', '-Wno-sign-compare']
|
OPT_ARGS = ['-O3', '-DNDEBUG']
|
||||||
|
DBG_ARGS = ['-O0', '-g', '-UNDEBUG']
|
||||||
|
|
||||||
INCLUDES = [
|
INCLUDES = [
|
||||||
'..',
|
'..',
|
||||||
@ -33,11 +34,12 @@ COMMON_FILES = [
|
|||||||
|
|
||||||
COMMON_FILES += glob.glob('*.cpp')
|
COMMON_FILES += glob.glob('*.cpp')
|
||||||
|
|
||||||
def build_common(out_name='common.a', build_dir='temp_build/temp_build', num_parallel=1):
|
def build_common(out_name='common.a', build_dir='temp_build/temp_build', debug=False, num_parallel=1):
|
||||||
compiler = os.environ.get('CXX', 'g++')
|
compiler = os.environ.get('CXX', 'g++')
|
||||||
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', '')
|
||||||
|
args = ARGS + (DBG_ARGS if debug else OPT_ARGS)
|
||||||
|
|
||||||
for file in COMMON_FILES:
|
for file in COMMON_FILES:
|
||||||
outfile = os.path.join(build_dir, os.path.splitext(file)[0] + '.o')
|
outfile = os.path.join(build_dir, os.path.splitext(file)[0] + '.o')
|
||||||
@ -54,7 +56,7 @@ def build_common(out_name='common.a', build_dir='temp_build/temp_build', num_par
|
|||||||
cmd = '{cc} -fPIC -c {cflags} {args} {includes} {infile} -o {outfile}'.format(
|
cmd = '{cc} -fPIC -c {cflags} {args} {includes} {infile} -o {outfile}'.format(
|
||||||
cc=compiler,
|
cc=compiler,
|
||||||
cflags=cflags,
|
cflags=cflags,
|
||||||
args=' '.join(ARGS),
|
args=' '.join(args),
|
||||||
includes=' '.join('-I' + i for i in INCLUDES),
|
includes=' '.join('-I' + i for i in INCLUDES),
|
||||||
infile=file,
|
infile=file,
|
||||||
outfile=outfile,
|
outfile=outfile,
|
||||||
|
@ -31,10 +31,11 @@ parser.add_argument(
|
|||||||
default=1,
|
default=1,
|
||||||
type=int,
|
type=int,
|
||||||
help="Number of cpu processes to build package. (default: %(default)d)")
|
help="Number of cpu processes to build package. (default: %(default)d)")
|
||||||
args = parser.parse_known_args()
|
known_args, unknown_args = parser.parse_known_args()
|
||||||
|
debug = '--debug' in unknown_args
|
||||||
|
|
||||||
# reconstruct sys.argv to pass to setup below
|
# reconstruct sys.argv to pass to setup below
|
||||||
sys.argv = [sys.argv[0]] + args[1]
|
sys.argv = [sys.argv[0]] + unknown_args
|
||||||
|
|
||||||
def read(fname):
|
def read(fname):
|
||||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||||
@ -50,7 +51,8 @@ if not os.path.exists(common_build):
|
|||||||
|
|
||||||
build_common(out_name='common.a',
|
build_common(out_name='common.a',
|
||||||
build_dir=build_dir,
|
build_dir=build_dir,
|
||||||
num_parallel=args[0].num_processes)
|
num_parallel=known_args.num_processes,
|
||||||
|
debug=debug)
|
||||||
|
|
||||||
decoder_module = Extension(
|
decoder_module = Extension(
|
||||||
name='ds_ctcdecoder._swigwrapper',
|
name='ds_ctcdecoder._swigwrapper',
|
||||||
@ -58,7 +60,7 @@ decoder_module = Extension(
|
|||||||
swig_opts=['-c++', '-extranative'],
|
swig_opts=['-c++', '-extranative'],
|
||||||
language='c++',
|
language='c++',
|
||||||
include_dirs=INCLUDES + [numpy_include],
|
include_dirs=INCLUDES + [numpy_include],
|
||||||
extra_compile_args=ARGS,
|
extra_compile_args=ARGS + (DBG_ARGS if debug else OPT_ARGS),
|
||||||
extra_link_args=[common_build],
|
extra_link_args=[common_build],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user