forked from intelxed/xed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xed_mbuild.py
executable file
·2783 lines (2424 loc) · 104 KB
/
xed_mbuild.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- python -*-
#BEGIN_LEGAL
#
#Copyright (c) 2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#END_LEGAL
############################################################################
#See the execute() and work() functions down at the bottom of the file
#for the main routine.
############################################################################
## START OF IMPORTS SETUP
from __future__ import print_function
import sys
import os
import re
import shutil
import copy
import time
import types
import optparse
import collections
import stat
def _fatal(m):
sys.stderr.write("\n\nXED ERROR: %s\n\n" % (m) )
sys.exit(1)
try:
import mbuild
except:
_fatal("xed_mbuild.py could not find/import mbuild." +
" Should be a sibling of the xed directory.")
import xed_build_common as xbc
try:
import xed_build_common as xbc
except:
_fatal("xed_mbuild.py could not import xed_build_common.py")
## END OF IMPORTS SETUP
############################################################################
def aq(s):
t = mbuild.cond_add_quotes(s)
return t
def check_mbuild_file(mbuild_file, sig_file):
if os.path.exists(sig_file):
old_hash = open(sig_file,"r").readline().strip()
else:
old_hash = ''
hash = mbuild.hash_list(open(sys.argv[0],'r').readlines())
f = open(sig_file, 'w')
f.write(hash)
f.close()
if hash == old_hash:
retval = False
mbuild.msgb("MBUILD INPUT FILE", "does not appear to have changes.")
else:
retval = True
mbuild.msgb("MBUILD INPUT FILE", "appears to have changes.")
return retval
###########################################################################
# generators
class generator_inputs_t(object):
def __init__(self, build_dir,
amd_enabled=True,
limit_strings=False):
self.fields = ['dec-spine',
'dec-instructions',
'enc-instructions',
'dec-patterns',
'enc-patterns',
'enc-dec-patterns', # decode patterns used for encode
'fields',
'state',
'registers',
'widths',
'extra-widths',
'pointer-names',
'element-types',
'element-type-base',
'chip-models',
'conversion-table',
'ild-scanners',
'ild-getters',
'cpuid'
]
self.files = {} # lists of input files per field type
self.priority = {} # field type -> int
# output file names. We concatenate all the input files of a
# given type. These get used in the command are internal to the
# execution of the generator.
self.file_name = {}
for fld in self.fields:
self.files[fld] = [] # list of input files
self.file_name[fld] = 'all-' + fld + '.txt'
self.renamed = False
self.intermediate_dir = None
self.set_intermediate_dir(build_dir)
self.use_intermediate_files()
self.amd_enabled = amd_enabled
self.limit_strings = limit_strings
def add_file(self, file_type, file_name, priority=1):
"""Add a specific type of file to the right list"""
curp = 1
if file_type in self.priority:
curp = self.priority[file_type]
if curp > priority:
mbuild.msgb("Skipping low priority file for type %s: %s" %
(file_type, file_name))
return
elif curp < priority:
# new higher priority file blows away the list of files for
# this file type.
mbuild.msgb("Clearing file list for type %s: [ %s ]" %
(file_type,
", ".join(self.files[file_type])))
self.files[file_type] = []
self.priority[file_type]=priority
if file_name in self.files[file_type]:
xbc.cdie('duplicate line: {}:{}'.format(file_type,file_name))
self.files[file_type].append(file_name)
def remove_file(self, file_type, file_name):
"""Remove a specific file"""
try:
self.files[file_type].remove(file_name)
except:
xbc.cdie("Invalid type of file " +
"(%s) or file name (%s) not found: " % (file_type,
file_name) )
def clear_files(self,file_type):
"""Remove a specific type of file"""
try:
self.files[file_type] = []
mbuild.msgb("REMOVING FILE TYPE", file_type)
except:
xbc.cdie("Invalid type of file (%s) not found: " %
(file_type))
def all_input_files(self):
"""Return a list of all the input file names so we can hook up
the dependences"""
fnames = []
for flist in iter(self.files.values()):
fnames.extend(flist)
fnames.sort()
return fnames
def set_intermediate_dir(self, build_dir):
self.intermediate_dir = mbuild.join(build_dir,'dgen')
mbuild.cmkdir(self.intermediate_dir)
def use_intermediate_files(self):
"""Prefix al the files by the intermediate directory name"""
# just do this once
if self.renamed:
return
self.renamed = True
for f in self.fields:
ofn = mbuild.join(self.intermediate_dir,self.file_name[f])
self.file_name[f] = ofn # update file name-- only call once!
def concatenate_input_files(self,env):
"""Concatenate all the files of each type"""
for f in self.fields:
self.concatenate_one_set_of_files(env,
self.file_name[f],
self.files[f])
def decode_command(self, xedsrc, extra_args=None):
"""Produce a decoder generator command"""
s = []
s.append( '%(pythonarg)s' )
# s.append("-3") # python3.0 compliance checking using python2.6
s.append(aq(mbuild.join(xedsrc,'pysrc','generator.py')))
if self.limit_strings:
s.append('--limit-enum-strings')
s.append('--spine ' + aq(self.file_name['dec-spine']))
s.append('--isa ' + aq(self.file_name['dec-instructions']))
s.append('--patterns ' + aq(self.file_name['dec-patterns']))
s.append('--input-fields ' + aq(self.file_name['fields']))
s.append('--input-state ' + aq(self.file_name['state']))
s.append('--chip-models ' + aq(self.file_name['chip-models']))
s.append('--ctables ' + aq(self.file_name['conversion-table']))
s.append('--input-regs ' + aq(self.file_name['registers']))
s.append('--input-widths ' + aq(self.file_name['widths']))
s.append('--input-extra-widths ' +
aq(self.file_name['extra-widths']))
s.append('--input-element-types ' +
aq(self.file_name['element-types']))
s.append('--input-element-type-base ' +
aq(self.file_name['element-type-base']))
s.append('--input-pointer-names ' +
aq(self.file_name['pointer-names']))
s.append('--ild-scanners ' +
aq(self.file_name['ild-scanners']))
s.append('--cpuid ' +
aq(self.file_name['cpuid']))
if len(self.files['ild-getters']) > 0:
s.append('--ild-getters ' +
aq(self.file_name['ild-getters']))
if extra_args:
s.append(extra_args)
return ' '.join(s)
def encode_command(self, xedsrc, extra_args=None, amd_enabled=True):
"""Produce an encoder generator command"""
s = []
s.append( '%(pythonarg)s' )
# s.append("-3") # python3.0 compliance checking using python2.6
s.append( aq(mbuild.join(xedsrc,'pysrc', 'read-encfile.py')))
s.append('--isa %s' % aq(self.file_name['enc-instructions']))
s.append('--enc-patterns %s' % aq(self.file_name['enc-patterns']))
s.append('--enc-dec-patterns %s' %
aq(self.file_name['enc-dec-patterns']))
s.append('--input-fields %s' % aq(self.file_name['fields']))
s.append('--input-state %s' % aq(self.file_name['state']))
s.append('--input-regs %s' % aq(self.file_name['registers']))
if not amd_enabled:
s.append('--no-amd')
if extra_args:
s.append( extra_args)
return ' '.join(s)
def concatenate_one_set_of_files(self, env, target, inputs):
"""Concatenate input files creating the target file."""
try:
if mbuild.verbose(1):
mbuild.msgb("CONCAT", "%s <-\n\t\t%s" % (target ,
'\n\t\t'.join(inputs)))
output = open(target,"w")
for f in inputs:
if os.path.exists(f):
output.write("\n\n###FILE: %s\n\n" % (f))
for line in open(f,'r').readlines():
line = line.rstrip()
#replace the possible symbolic path %(cur_dir)s
#FIXME: could have used env's expand_string method,
#for src_dir and cur_dir.
file_dir = os.path.dirname(f)
line = line.replace('%(cur_dir)s', file_dir)
line = line.replace('%(xed_dir)s', env['src_dir'])
output.write(line + "\n")
else:
xbc.cdie("Could not read input file: " + f)
output.close()
except xbc.xed_exception_t as e:
raise # re-raise exception
except:
xbc.cdie("Could not write file %s from inputs: %s" %
( target, ', '.join(inputs)))
def run_generator_preparation(gc, env):
"""Prepare to run the encode and decode table generators"""
if env == None:
return (1, ['no env!'])
xedsrc = env['src_dir']
build_dir = env['build_dir']
gc.concatenate_input_files(env)
mbuild.touch(env.build_dir_join('dummy-prep'))
return (0, [] )
def read_file_list(fn):
a = []
for f in open(fn,'r').readlines():
a.append(f.rstrip())
return a
def run_decode_generator(gc, env):
"""Run the decode table generator. This function is executed as
required by the work_queue."""
if env == None:
return (1, ['no env!'])
xedsrc = env.escape_string(env['src_dir'])
build_dir = env.escape_string(env['build_dir'])
debug = ""
other_args = " ".join(env['generator_options'])
gen_extra_args = "--gendir %s --xeddir %s %s %s" % (build_dir,
xedsrc, debug,
other_args)
if env['gen_ild_storage']:
gen_extra_args += ' --gen-ild-storage'
if env['compress_operands']:
gen_extra_args += " --compress-operands"
cmd = env.expand(gc.decode_command(xedsrc, gen_extra_args))
if mbuild.verbose(2):
mbuild.msgb("DEC-GEN", cmd)
(retval, output, error_output) = mbuild.run_command(cmd,
separate_stderr=True)
oo = env.build_dir_join('DEC-OUT.txt')
oe = env.build_dir_join('DEC-ERR.txt')
xbc.write_file(oo, output)
xbc.write_file(oe, error_output)
if retval == 0:
list_of_files = read_file_list(gc.dec_output_file)
mbuild.hash_files(list_of_files, gc.dec_hash_file)
mbuild.msgb("DEC-GEN", "Return code: " + str(retval))
return (retval, error_output )
def run_encode_generator(gc, env):
"""Run the encoder table generator. This function is executed as
required by the work_queue."""
if env == None:
return (1, ['no env!'])
xedsrc = env.escape_string(env['src_dir'])
build_dir = env.escape_string(env['build_dir'])
gen_extra_args = "--gendir %s --xeddir %s" % (build_dir, xedsrc)
cmd = env.expand(gc.encode_command(xedsrc,
gen_extra_args,
env['amd_enabled']))
if mbuild.verbose(2):
mbuild.msgb("ENC-GEN", cmd)
(retval, output, error_output) = mbuild.run_command(cmd,
separate_stderr=True)
oo = env.build_dir_join('ENC-OUT.txt')
oe = env.build_dir_join('ENC-ERR.txt')
xbc.write_file(oo, output)
xbc.write_file(oe, error_output)
if retval == 0:
list_of_files = read_file_list(gc.enc_output_file)
mbuild.hash_files(list_of_files, gc.enc_hash_file)
mbuild.msgb("ENC-GEN", "Return code: " + str(retval))
return (retval, [] )
def _encode_command2(args):
"""Produce an encoder2 generator command."""
s = []
s.append( '%(pythonarg)s' )
s.append( aq(mbuild.join(args.xeddir, 'pysrc', 'enc2gen.py')))
s.append('--xeddir %s' % aq(args.xeddir))
s.append('--gendir %s' % aq(args.gendir))
s.extend( args.config.as_args() )
if args.test_checked_interface:
s.append('-chk' )
s.append('--output-file-list %s' % aq(args.enc2_output_file))
return ' '.join(s)
def run_encode_generator2(args, env):
"""Run the encoder2 table generator. This function is executed as
required by the work_queue."""
if env == None:
return (1, ['no env!'])
args.xeddir = env.escape_string(env['src_dir'])
# we append our own paths in the generator
args.gendir = env.escape_string(env['libxed_build_dir'])
cmd = env.expand( _encode_command2(args) )
if mbuild.verbose(2):
mbuild.msgb("ENC2-GEN", cmd)
(retval, output, error_output) = mbuild.run_command(cmd,
separate_stderr=True)
oo = env.build_dir_join('ENC2-OUT.txt')
oe = env.build_dir_join('ENC2-ERR.txt')
xbc.write_file(oo, output)
xbc.write_file(oe, error_output)
if retval == 0:
list_of_files = read_file_list(args.enc2_output_file)
mbuild.hash_files(list_of_files, args.enc2_hash_file)
mbuild.msgb("ENC2-GEN", "Return code: " + str(retval))
return (retval, [] )
def need_to_rebuild(fn,sigfile):
rebuild = False
if not os.path.exists(fn):
return True
list_of_files = read_file_list(fn)
if mbuild.file_hashes_are_valid(list_of_files, sigfile):
return False
return True
###########################################################################
# legal header tagging
def legal_header_tagging(env):
if 'apply-header' not in env['targets']:
return
source_files = [
mbuild.join(env['src_dir'],'examples','*.cpp'),
mbuild.join(env['src_dir'],'examples','*.c'),
mbuild.join(env['src_dir'],'examples','*.[hH]'),
mbuild.join(mbuild.join(env['build_dir'],'*.h')),
mbuild.join(env['src_dir'],'src','*','*.c'),
mbuild.join(env['src_dir'],'include', 'private','*.h'),
mbuild.join(env['src_dir'],'include', 'public', 'xed', '*.h') ]
data_files = [
mbuild.join(env['src_dir'],'examples','*.py'),
mbuild.join(env['src_dir'],'scripts','*.py'),
mbuild.join(env['src_dir'],'pysrc','*.py'),
mbuild.join(env['src_dir'],'*.py') ]
# find and classify the files in datafiles directories
for root,dirs,files in os.walk( mbuild.join(env['src_dir'],'datafiles') ):
for f in files :
fn = mbuild.join(root,f)
if 'test' not in fn:
if re.search(r'[~]$',fn):
# skip backup files
continue
elif re.search(r'[.][ch]$',fn):
source_files.append(fn)
else:
data_files.append(fn)
if env.on_windows():
xbc.cdie("ERROR","TAGGING THE IN-USE PYTHON FILES DOES " +
"NOT WORK ON WINDOWS.")
legal_header = open(mbuild.join(env['src_dir'],'misc',
'apache-header.txt'), 'r').readlines()
header_tag_files(env, source_files, legal_header, script_files=False)
header_tag_files(env, data_files, legal_header, script_files=True)
mbuild.msgb("STOPPING", "after %s" % 'header tagging')
xbc.cexit(0)
def header_tag_files(env, files, legal_header, script_files=False):
"""Apply the legal_header to the list of files"""
try:
import apply_legal_header
except:
xbc.cdie("XED ERROR: mfile.py could not find scripts directory")
for g in files:
print("G: ", g)
for f in mbuild.glob(g):
print("F: ", f)
if script_files:
apply_legal_header.apply_header_to_data_file(legal_header, f)
else:
apply_legal_header.apply_header_to_source_file(legal_header, f)
###########################################################################
# Doxygen build
def get_kit(env):
if xbc.installing(env):
return env['ikit'].kit
return env['wkit'].kit
def doxygen_subs(env,api_ref=True):
'''Create substitutions dictionary for customizing doxygen run'''
subs = {}
subs['XED_TOPSRCDIR'] = aq(env['src_dir'])
dir = get_kit(env)
if not os.path.exists(dir):
xbc.cdie("Cannot find kit directory ({}) when building docs.".format(dir))
subs['XED_KITDIR'] = aq(dir)
subs['XED_GENDOC'] = aq(env['doxygen_install'])
if api_ref:
subs['XED_INPUT_TOP'] = aq(env.src_dir_join(mbuild.join('docsrc',
'xed-doc-top.txt')))
else:
subs['XED_INPUT_TOP'] = aq(env.src_dir_join(mbuild.join('docsrc',
'xed-build.txt')))
#subs['XED_HTML_HEADER'] = aq(env.src_dir_join(mbuild.join('docsrc',
# 'xed-doxygen-header.txt')))
if env['doxygen_internal']:
subs['XED_EXTERNAL'] = ''
else:
subs['XED_EXTERNAL'] = 'EXTERNAL'
return subs
def make_doxygen_build(env, work_queue):
"""Make the doxygen how-to-build-xed manual"""
if 'doc-build' not in env['targets']:
return
mbuild.msgb("XED BUILDING 'build' DOCUMENTATION")
e2 = copy.deepcopy(env)
e2['doxygen_cmd']= e2['doxygen']
if e2['doxygen_install'] == '':
d= mbuild.join(e2['build_dir'],'doc')
else:
d = env['doxygen_install']
e2['doxygen_install'] = mbuild.join(d, 'build-manual')
mbuild.msgb("BUILDING BUILD MANUAL", e2['doxygen_install'])
mbuild.cmkdir(e2['doxygen_install'])
e2['doxygen_config'] = e2.src_dir_join(mbuild.join('docsrc',
'Doxyfile.build'))
subs = doxygen_subs(e2,api_ref=False)
e2['doxygen_top_src'] = subs['XED_INPUT_TOP']
inputs = [ subs['XED_INPUT_TOP'] ]
inputs.append( e2['mfile'] )
mbuild.doxygen_run(e2, inputs, subs, work_queue, 'dox-build')
def create_doxygen_api_documentation(env, work_queue):
# After applying the legal header, create the doxygen from the kit
# files, and place the output right in the kit.
if 'doc' in env['targets']:
if xbc.installing(env):
kitdoc = env['ikit'].doc
else:
kitdoc = env['wkit'].doc
make_doxygen_api(env, work_queue, kitdoc)
if env['doxygen_install']:
make_doxygen_api(env, work_queue, env['doxygen_install'])
def make_doxygen_api(env, work_queue, install_dir):
"""We may install in the kit or elsewhere using files from the kit"""
mbuild.msgb("XED BUILDING 'api' DOCUMENTATION")
e2 = copy.deepcopy(env)
e2['doxygen_cmd']= e2['doxygen']
e2['doxygen_install'] = mbuild.join(install_dir,'ref-manual')
mbuild.cmkdir(e2['doxygen_install'])
e2['doxygen_config'] = e2.src_dir_join(mbuild.join('docsrc','Doxyfile'))
subs = doxygen_subs(e2,api_ref=True)
e2['doxygen_top_src'] = subs['XED_INPUT_TOP']
inputs = []
inputs.append(subs['XED_INPUT_TOP'])
kitdir = get_kit(e2)
inputs.extend( mbuild.glob(kitdir,'include', 'xed', '*'))
inputs.extend( mbuild.glob(kitdir,'examples','*.c'))
inputs.extend( mbuild.glob(kitdir,'examples','*.cpp'))
inputs.extend( mbuild.glob(kitdir,'examples','*.[Hh]'))
inputs.append( e2['mfile'] )
mbuild.doxygen_run(e2, inputs, subs, work_queue, 'dox-ref')
def mkenv():
"""External entry point: create the environment"""
if not mbuild.check_python_version(2,7):
xbc.cdie("Need python 2.7 or later. Suggested >= 3.7")
if sys.version_info.major >= 3:
if not mbuild.check_python_version(3,4):
xbc.cdie("Need python 3.4 or later. Suggested >= 3.7")
# create an environment, parse args
env = mbuild.env_t()
standard_defaults = dict( doxygen_install='',
doxygen='',
doxygen_internal=False,
clean=False,
die_on_errors=True,
xed_messages=False,
xed_asserts=False,
pedantic=True,
clr=False,
use_werror=True,
gen_ild_storage=False,
show_dag=False,
ext=[],
extf=[],
xedext_dir='%(xed_dir)s/../xedext',
default_isa='',
avx=True,
avx512=True,
knc=False,
ivb=True,
hsw=True,
mpx=True,
cet=True,
skl=True,
skx=True,
clx=True,
cpx=True,
cnl=True,
icl=True,
tgl=True,
spr=True,
future=True,
knl=True,
knm=True,
bdw=True,
dbghelp=False,
install_dir=None,
prefix_dir='',
prefix_lib_dir='lib',
kit_kind='base',
win=False,
amd_enabled=True,
via_enabled=True,
encoder=True,
decoder=True,
dev=False,
generator_options=[],
legal_header=None,
pythonarg=None,
ld_library_path=[],
ld_library_path_for_tests=[],
use_elf_dwarf=False,
use_elf_dwarf_precompiled=False,
limit_strings=False,
strip='strip',
pti_test=False,
verbose = 0,
compress_operands=False,
test_perf=False,
example_linkflags='',
example_flags='',
example_rpaths=[],
android=False,
copy_libc=False,
pin_crt='',
static_stripped=False,
set_copyright=False,
asan=False,
enc2=False,
enc2_test=False,
enc2_test_checked=False,
first_lib=None,
last_lib=None)
env['xed_defaults'] = standard_defaults
env.set_defaults(env['xed_defaults'])
return env
def xed_args(env):
"""For command line invocation: parse the arguments"""
env.parser.add_option("--android",
dest="android",
action="store_true",
help="Android build (avoid rpath for examples)")
env.parser.add_option("--copy-runtime-libs",
dest="copy_libc",
action="store_true",
help="Copy the libc to the kit." +
" Rarely necessary if building on old linux " +
"dev systems. Default: false")
env.parser.add_option("--example-linkflags",
dest="example_linkflags",
action="store",
help="Extra link flags for the examples")
env.parser.add_option("--example-flags",
dest="example_flags",
action="store",
help="Extra compilation flags for the examples")
env.parser.add_option("--example-rpath",
dest="example_rpaths",
action="append",
help="Extra rpath dirs for examples")
env.parser.add_option("--doxygen-install",
dest="doxygen_install",
action="store",
help="Doxygen installation directory")
env.parser.add_option("--doxygen",
dest="doxygen",
action="store",
help="Doxygen command name")
env.parser.add_option("--doxygen-internal",
dest="doxygen_internal",
action="store_true",
help="Create internal version of build documentation (just changes paths for git repos)")
env.parser.add_option("-c","--clean",
dest="clean",
action="store_true",
help="Clean targets")
env.parser.add_option("--keep-going", '-k',
action="store_false",
dest="die_on_errors",
help="Keep going after errors occur when building")
env.parser.add_option("--messages",
action="store_true",
dest="xed_messages",
help="Enable use xed's debug messages")
env.parser.add_option("--no-pedantic",
action="store_false",
dest="pedantic",
help="Disable -pedantic (gnu/clang compilers).")
env.parser.add_option("--asserts",
action="store_true",
dest="xed_asserts",
help="Enable use xed's asserts")
env.parser.add_option("--clr",
action="store_true",
dest="clr",
help="Compile for Microsoft CLR")
env.parser.add_option("--no-werror",
action="store_false",
dest="use_werror",
help="Disable use of -Werror on GNU compiles")
env.parser.add_option("--gen-ild-storage",
action="store_true",
dest="gen_ild_storage",
help="Dump ILD storage data file.")
env.parser.add_option("--show-dag",
action="store_true",
dest="show_dag",
help="Show the dependence DAG")
env.parser.add_option("--ext",
action="append",
dest="ext",
help="Add extension files of the form " +
"pattern-name:file-name.txt")
env.parser.add_option("--extf",
action="append",
dest="extf",
help="Add extension configuration files " +
"that contain lines of form pattern-name:file-name.txt. All files " +
"references will be made relative to the directory in which the " +
"config file is located.")
env.parser.add_option("--xedext-dir",
action="store",
dest="xedext_dir",
help="XED extension dir")
env.parser.add_option("--default-isa-extf",
action="store",
dest="default_isa",
help="Override the default ISA files.cfg file")
env.parser.add_option("--knc",
action="store_true",
dest="knc",
help="Include KNC support")
env.parser.add_option("--no-avx",
action="store_false",
dest="avx",
help="Do not include AVX (nor down-stream unrelated technologies).")
env.parser.add_option("--no-avx512",
action="store_false",
dest="avx512",
help="Do not include AVX512 (nor down-stream unrelated technologies).")
env.parser.add_option("--no-ivb",
action="store_false",
dest="ivb",
help="Do not include IVB.")
env.parser.add_option("--no-hsw",
action="store_false",
dest="hsw",
help="Do not include HSW.")
env.parser.add_option("--no-mpx",
action="store_false",
dest="mpx",
help="Do not include MPX.")
env.parser.add_option("--no-cet",
action="store_false",
dest="cet",
help="Do not include CET.")
env.parser.add_option("--no-knl",
action="store_false",
dest="knl",
help="Do no include KNL AVX512{PF,ER}.")
env.parser.add_option("--no-knm",
action="store_false",
dest="knm",
help="Do not include KNM.")
env.parser.add_option("--no-skl",
action="store_false",
dest="skl",
help="Do not include SKL (Skylake Client).")
env.parser.add_option("--no-skx",
action="store_false",
dest="skx",
help="Do not include SKX (Skylake Server).")
env.parser.add_option("--no-clx",
action="store_false",
dest="clx",
help="Do not include CLX (Cascade Lake Server).")
env.parser.add_option("--no-cpx",
action="store_false",
dest="cpx",
help="Do not include CPX (Cooper Lake Server).")
env.parser.add_option("--no-cnl",
action="store_false",
dest="cnl",
help="Do not include CNL.")
env.parser.add_option("--no-icl",
action="store_false",
dest="icl",
help="Do not include ICL.")
env.parser.add_option("--no-tgl",
action="store_false",
dest="tgl",
help="Do not include TGL.")
env.parser.add_option("--no-spr",
action="store_false",
dest="spr",
help="Do not include SPR.")
env.parser.add_option("--no-future",
action="store_false",
dest="future",
help="Do not include future NI.")
env.parser.add_option("--dbghelp",
action="store_true",
dest="dbghelp",
help="Use dbghelp.dll on windows.")
env.parser.add_option("--prefix",
dest="prefix_dir",
action="store",
help="XED System install directory.")
env.parser.add_option("--prefix-lib-dir",
dest="prefix_lib_dir",
action="store",
help="library subdirectory name. Default: lib")
env.parser.add_option("--install-dir",
dest="install_dir",
action="store",
help="XED Install directory. " +
"Default: kits/xed-install-date-os-cpu")
env.parser.add_option("--kit-kind",
dest="kit_kind",
action="store",
help="Kit version string. " +
"The default is 'base'")
env.parser.add_option("--no-amd",
action="store_false",
dest="amd_enabled",
help="Disable AMD public instructions")
env.parser.add_option("--no-via",
action="store_false",
dest="via_enabled",
help="Disable VIA public instructions")
env.parser.add_option("--limit-strings",
action="store_true",
dest="limit_strings",
help="Remove some strings to save space.")
env.parser.add_option("--no-encoder",
action="store_false",
dest="encoder",
help="Disable the encoder")
env.parser.add_option("--no-decoder",
action="store_false",
dest="decoder",
help="Disable the decoder")
env.parser.add_option("--generator-options",
action="append",
dest="generator_options",
help="Options to pass through for " +
"the decode generator")
env.parser.add_option("--legal-header",
action="store",
dest="legal_header",
help="Use this special legal header " +
"on public header files and examples.")
env.parser.add_option("--python",
action="store",
dest="pythonarg",
help="Use a specific version of python " +
"for subprocesses.")
env.parser.add_option("--ld-library-path",
action="append",
dest="ld_library_path",
help="Specify additions to LD_LIBRARY_PATH " +
"for use when running ldd and making kits")
env.parser.add_option("--ld-library-path-for-tests",
action="append",
dest="ld_library_path_for_tests",
help="Specify additions to LD_LIBRARY_PATH " +
"for use when running the tests")
# elf.h is different than libelf.h.
env.parser.add_option("--elf-dwarf", "--dwarf",
action="store_true",
dest="use_elf_dwarf",
help="Use libelf/libdwarf. (Linux only)")
env.parser.add_option('--dev',
action='store_true',
dest='dev',
help='Developer knob. Updates VERSION file')
env.parser.add_option("--elf-dwarf-precompiled",
action="store_true",
dest="use_elf_dwarf_precompiled",
help="Use precompiled libelf/libdwarf from " +
" the XED source distribution." +
" This is the currently required" +
" if you are installing a kit." +
" Implies the --elf-dwarf knob."
" (Linux only)")
env.parser.add_option("--strip",
action="store",
dest="strip",
help="Path to strip binary. (Linux only)")
env.parser.add_option("--pti-test",
action="store_true",
dest="pti_test",
help="INTERNAL TESTING OPTION.")
env.parser.add_option("--compress-operands",
action="store_true",
dest="compress_operands",
help="use bit-fields to compress the "+
"operand storage.")
env.parser.add_option("--test-perf",
action="store_true",
dest="test_perf",
help="Do performance test (on linux). Requires" +
" specific external test binary.")
env.parser.add_option("--pin-crt",
action="store",
dest="pin_crt",
help="Compile for the Pin C-runtime. Specify" +
" path to pin kit")
env.parser.add_option("--static-stripped",
action="store_true",
dest="static_stripped",
help="Make a static libxed.a renaming internal symbols")
env.parser.add_option("--set-copyright",
action="store_true",
dest="set_copyright",
help="Set the Intel copyright on Windows XED executable")
env.parser.add_option("--asan",
action="store_true",
dest="asan",
help="Use Address Sanitizer (on linux)")
env.parser.add_option("--enc2",
action="store_true",
dest="enc2",
help="Build the enc2 fast encoder. Longer build.")
env.parser.add_option("--enc2-test",
action="store_true",
dest="enc2_test",
help="Build the enc2 fast encoder *tests*. Longer build.")
env.parser.add_option("--enc2-test-checked",
action="store_true",
dest="enc2_test_checked",
help="Build the enc2 fast encoder *tests*. Test the checked interface. Longer build.")
env.parse_args(env['xed_defaults'])
def init_once(env):
xbc.init_once(env)
def init(env):
if env['pythonarg']:
python_command = env['pythonarg']
else:
python_command = sys.executable
# Avoid using cygwin python which may be in the PATH of
# noncygwin shells.
if env.on_windows() and python_command in ['/bin/python',
'/usr/bin/python']:
if env.on_cygwin() and env['compiler'] in ['ms','icl']:
xbc.cdie("Cannot build with cygwin python. " +
"Please install win32 python")
if mbuild.is_python3():
python_commands = [ 'c:/python37/python.exe',
'c:/python36/python.exe',
'c:/python35/python.exe' ]
else:
python_commands = [ 'c:/python27/python.exe',
'c:/python26/python.exe',
'c:/python25/python.exe' ]
python_command = None
for p in python_commands:
if os.path.exists(p):
python_command = p
break
if not python_command:
xbc.cdie("Could not find win32 python at these locations: %s" %
"\n\t" + "\n\t".join(python_commands))
env['pythonarg'] = env.escape_string(python_command)
if mbuild.verbose(2):
mbuild.msgb("PYTHON", env['pythonarg'])
xbc.init(env)