@@ -141,15 +141,37 @@ def __init__(self, *args, **kwargs):
141141 build .__init__ (self , * args , ** kwargs )
142142
143143
144+ DEBUG_MODE = os .environ .get ("DEBUG_MODE" , False )
145+
146+
144147class LibSQLCipherBuilder (build_ext ):
145148
146149 description = ("Build C extension linking against libsqlcipher library." )
147150
148151 def build_extension (self , ext ):
152+ if DEBUG_MODE :
153+ self .__remove_compiler_option ("-O2" )
154+ self .__remove_compiler_option ("-O1" )
155+
149156 ext .extra_compile_args .append ("-I/usr/include/sqlcipher/" )
150157 ext .extra_link_args .append ("-lsqlcipher" )
151158 build_ext .build_extension (self , ext )
152159
160+ def __remove_compiler_option (self , option ):
161+ """
162+ Remove the specified compiler option.
163+
164+ Return true if the option was found. Return false otherwise.
165+ """
166+ found = 0
167+ for attrname in ('compiler' , 'compiler_so' ):
168+ compiler = getattr (self .compiler , attrname , None )
169+ if compiler is not None :
170+ while option in compiler :
171+ compiler .remove (option )
172+ found += 1
173+ return found
174+
153175
154176class MyBuildExt (build_ext ):
155177 amalgamation = True # We want amalgamation on the default build for now
@@ -353,7 +375,7 @@ def get_setup_args():
353375 {"build_docs" : DocBuilder ,
354376 "build_ext" : MyBuildExt ,
355377 "build_static" : AmalgamationBuilder ,
356- "build_sqlcipher " : LibSQLCipherBuilder ,
378+ "build_with_system_sqlcipher " : LibSQLCipherBuilder ,
357379 "cross_bdist_wininst" : cross_bdist_wininst .bdist_wininst })
358380 return setup_args
359381
0 commit comments