@@ -40,11 +40,12 @@ def get_solidity():
40
40
return solc_wrapper
41
41
42
42
43
- def solc_arguments (libraries = None , combined = 'bin,abi' , optimize = True ):
43
+ def solc_arguments (libraries = None , combined = 'bin,abi' , optimize = True , extra_args = '' ):
44
44
""" Build the arguments to call the solc binary. """
45
45
args = [
46
46
'--combined-json' , combined ,
47
47
'--add-std' ,
48
+ extra_args
48
49
]
49
50
50
51
if optimize :
@@ -221,7 +222,7 @@ def solidity_unresolved_symbols(hex_code):
221
222
return set (re .findall (r"_.{39}" , hex_code ))
222
223
223
224
224
- def compile_file (filepath , libraries = None , combined = 'bin,abi' , optimize = True ):
225
+ def compile_file (filepath , libraries = None , combined = 'bin,abi' , optimize = True , extra_args = '' ):
225
226
""" Return the compile contract code.
226
227
227
228
Args:
@@ -236,7 +237,7 @@ def compile_file(filepath, libraries=None, combined='bin,abi', optimize=True):
236
237
237
238
workdir , filename = os .path .split (filepath )
238
239
239
- args = solc_arguments (libraries = libraries , combined = combined , optimize = optimize )
240
+ args = solc_arguments (libraries = libraries , combined = combined , optimize = optimize , extra_args = extra_args )
240
241
args .insert (0 , get_compiler_path ())
241
242
args .append (filename )
242
243
@@ -245,18 +246,19 @@ def compile_file(filepath, libraries=None, combined='bin,abi', optimize=True):
245
246
return solc_parse_output (output )
246
247
247
248
248
- def compile_contract (filepath , contract_name , libraries = None , combined = 'bin,abi' , optimize = True ):
249
+ def compile_contract (filepath , contract_name , libraries = None , combined = 'bin,abi' , optimize = True , extra_args = '' ):
249
250
all_contracts = compile_file (
250
251
filepath ,
251
252
libraries = libraries ,
252
253
combined = combined ,
253
254
optimize = optimize ,
255
+ extra_args = extra_args
254
256
)
255
257
256
258
return all_contracts [contract_name ]
257
259
258
260
259
- def compile_last_contract (filepath , libraries = None , combined = 'bin,abi' , optimize = True ):
261
+ def compile_last_contract (filepath , libraries = None , combined = 'bin,abi' , optimize = True , extra_args = '' ):
260
262
with open (filepath ) as handler :
261
263
all_names = solidity_names (handler .read ())
262
264
@@ -273,11 +275,12 @@ def compile_last_contract(filepath, libraries=None, combined='bin,abi', optimize
273
275
libraries = libraries ,
274
276
combined = combined ,
275
277
optimize = optimize ,
278
+ extra_args = extra_args
276
279
)
277
280
278
281
279
- def compile_code (sourcecode , libraries = None , combined = 'bin,abi' , optimize = True ):
280
- args = solc_arguments (libraries = libraries , combined = combined , optimize = optimize )
282
+ def compile_code (sourcecode , libraries = None , combined = 'bin,abi' , optimize = True , extra_args = '' ):
283
+ args = solc_arguments (libraries = libraries , combined = combined , optimize = optimize , extra_args = extra_args )
281
284
args .insert (0 , get_compiler_path ())
282
285
283
286
process = subprocess .Popen (args , stdin = subprocess .PIPE , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
@@ -297,17 +300,17 @@ class Solc(object):
297
300
compiler_version = staticmethod (compiler_version )
298
301
299
302
@staticmethod
300
- def _code_or_path (sourcecode , path , contract_name , libraries , combined ):
303
+ def _code_or_path (sourcecode , path , contract_name , libraries , combined , extra_args ):
301
304
warnings .warn ('solc_wrapper is deprecated, please use the functions compile_file or compile_code' )
302
305
303
306
if sourcecode and path :
304
307
raise ValueError ('sourcecode and path are mutually exclusive.' )
305
308
306
309
if path and contract_name :
307
- return compile_contract (path , contract_name , libraries = libraries , combined = combined )
310
+ return compile_contract (path , contract_name , libraries = libraries , combined = combined , extra_args = extra_args )
308
311
309
312
if path :
310
- return compile_last_contract (path , libraries = libraries , combined = combined )
313
+ return compile_last_contract (path , libraries = libraries , combined = combined , extra_args = extra_args )
311
314
312
315
all_names = solidity_names (sourcecode )
313
316
all_contract_names = [
@@ -316,20 +319,20 @@ def _code_or_path(sourcecode, path, contract_name, libraries, combined):
316
319
]
317
320
last_contract = all_contract_names [- 1 ]
318
321
319
- result = compile_code (sourcecode , libraries = libraries , combined = combined )
322
+ result = compile_code (sourcecode , libraries = libraries , combined = combined , extra_args = extra_args )
320
323
return result [last_contract ]
321
324
322
325
@classmethod
323
- def compile (cls , code , path = None , libraries = None , contract_name = '' ):
326
+ def compile (cls , code , path = None , libraries = None , contract_name = '' , extra_args = '' ):
324
327
""" Return the binary of last contract in code. """
325
- result = cls ._code_or_path (code , path , contract_name , libraries , 'bin' )
328
+ result = cls ._code_or_path (code , path , contract_name , libraries , 'bin' , extra_args )
326
329
return result ['bin' ]
327
330
328
331
@classmethod
329
- def mk_full_signature (cls , code , path = None , libraries = None , contract_name = '' ):
332
+ def mk_full_signature (cls , code , path = None , libraries = None , contract_name = '' , extra_args = '' ):
330
333
"returns signature of last contract in code"
331
334
332
- result = cls ._code_or_path (code , path , contract_name , libraries , 'abi' )
335
+ result = cls ._code_or_path (code , path , contract_name , libraries , 'abi' , extra_args )
333
336
return result ['abi' ]
334
337
335
338
@classmethod
0 commit comments