forked from clasp-developers/clasp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
1475 lines (1389 loc) · 65.4 KB
/
wscript
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
#-*- mode: python; coding: utf-8-unix -*-
import subprocess
from waflib.Tools import c_preproc
from waflib.Tools.compiler_cxx import cxx_compiler
from waflib.Tools.compiler_c import c_compiler
#cxx_compiler['linux'] = ['clang++']
#c_compiler['linux'] = ['clang']
import sys
import os
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from waflib.extras import clang_compilation_database
from waflib.Errors import ConfigurationError
from waflib import Utils
top = '.'
out = 'build'
APP_NAME = 'clasp'
VERSION = '0.0'
DARWIN_OS = 'darwin'
LINUX_OS = 'linux'
STAGE_CHARS = [ 'r', 'i', 'a', 'b', 'f', 'c' ]
GCS = [ 'boehm',
'boehmdc',
'mpsprep',
'mps' ]
# DEBUG_CHARS None == optimized
DEBUG_CHARS = [ None, 'd' ]
CLANG_LIBRARIES = [
'clangASTMatchers',
'clangDynamicASTMatchers',
'clangIndex',
'clangTooling',
'clangFormat',
'clangToolingCore',
'clangBasic',
'clangCodeGen',
'clangDriver',
'clangFrontend',
'clangFrontendTool',
'clangCodeGen',
'clangRewriteFrontend',
'clangARCMigrate',
'clangStaticAnalyzerFrontend',
'clangFrontend',
'clangDriver',
'clangParse',
'clangSerialization',
'clangSema',
'clangEdit',
'clangStaticAnalyzerCheckers',
'clangStaticAnalyzerCore',
'clangAnalysis',
'clangAST',
'clangRewrite',
'clangLex',
'clangBasic',
]
BOOST_LIBRARIES = [
'boost_filesystem',
'boost_date_time',
'boost_program_options',
'boost_system',
'boost_iostreams']
def update_submodules(cfg):
os.system("echo This is where I get submodules")
os.system("git submodule update --init src/lisp/kernel/contrib/sicl")
os.system("git submodule update --init src/lisp/kernel/contrib/Acclimation")
os.system("git submodule update --init src/mps")
os.system("git submodule update --init src/lisp/modules/asdf")
os.system("(cd src/lisp/modules/asdf; make)")
def sync_submodules(cfg):
os.system("echo This is where I sync submodules")
os.system("git submodule sync")
# run this from a completely cold system with:
# ./waf distclean configure
# ./waf build_cboehmdc
# ./waf build_impsprep
# ./waf analyze_clasp
# This is the static analyzer - formerly called 'redeye'
def analyze_clasp(cfg):
run_program_echo("build/boehmdc/iclasp-boehmdc",
"-i", "./build/boehmdc/fasl/cclasp-boehmdc-image.fasl",
"-f", "ignore-extensions",
"-e", '(load (compile-file #P"sys:modules;clang-tool;clang-tool.lisp" :print t))',
"-e", '(load (compile-file #P"sys:modules;clasp-analyzer;clasp-analyzer.lisp" :print t))',
"-e", "(defparameter *compile-commands* \"build/mpsprep/compile_commands.json\")",
"-e", "(time (clasp-analyzer:search/generate-code (clasp-analyzer:setup-clasp-analyzer-compilation-tool-database (pathname *compile-commands*))))",
"-e", "(core:quit)")
print("\n\n\n----------------- proceeding with static analysis --------------------")
def dump_command(cmd):
cmdstr = StringIO()
for x in cmd[:-1]:
cmdstr.write("%s \\\n" % repr(x))
cmdstr.write("%s\n" % cmd[-1])
print("command ========\n%s\n" % cmdstr.getvalue())
def libraries_as_link_flags(fmt,libs):
all_libs = []
for x in libs:
all_libs.append(fmt%"")
all_libs.append(x)
return all_libs
def libraries_as_link_flags_as_string(fmt,libs):
all_libs = StringIO()
for x in libs:
all_libs.write(" ")
all_libs.write(fmt % x)
return all_libs.getvalue()
def generate_dsym_files(name,path):
info_plist = path.find_or_declare("Contents/Info.plist")
dwarf_file = path.find_or_declare("Contents/Resources/DWARF/%s"%name)
# print("info_plist = %s" % info_plist)
# print("dwarf_file = %s" % dwarf_file)
return [info_plist,dwarf_file]
def stage_value(ctx,s):
if ( s == 'r' ):
sval = -1
elif ( s == 'i' ):
sval = 0
elif ( s == 'a' ):
sval = 1
elif ( s == 'b' ):
sval = 2
elif ( s == 'c' ):
sval = 4
elif ( s == 'f' ):
sval = 3
elif ( s == 'rebuild' ):
sval = 0
elif ( s == 'dangerzone' ):
sval = 0
else:
ctx.fatal("Illegal stage: %s" % s)
return sval
def yadda(cfg):
print("In Yadda")
# Called for each variant, at the end of the configure phase
def configure_common(cfg,variant):
# include_path = "%s/%s/%s/src/include/clasp/main/" % (cfg.path.abspath(),out,variant.variant_dir()) #__class__.__name__)
# cfg.env.append_value("CXXFLAGS", ['-I%s' % include_path])
# cfg.env.append_value("CFLAGS", ['-I%s' % include_path])
# These will end up in build/config.h
cfg.define("EXECUTABLE_NAME",variant.executable_name())
assert os.path.isdir(cfg.env.LLVM_BIN_DIR)
cfg.define("CLASP_CLANG_PATH", os.path.join(cfg.env.LLVM_BIN_DIR, "clang"))
cfg.define("APP_NAME",APP_NAME)
cfg.define("BITCODE_NAME",variant.bitcode_name())
cfg.define("VARIANT_NAME",variant.variant_name())
cfg.define("BUILD_STLIB", libraries_as_link_flags_as_string(cfg.env.STLIB_ST,cfg.env.STLIB))
cfg.define("BUILD_LIB", libraries_as_link_flags_as_string(cfg.env.LIB_ST,cfg.env.LIB))
print("cfg.env.LINKFLAGS=%s" % cfg.env.LINKFLAGS)
print("cfg.env.LDFLAGS=%s" % cfg.env.LDFLAGS)
cfg.define("BUILD_LINKFLAGS", ' '.join(cfg.env.LINKFLAGS) + ' ' + ' '.join(cfg.env.LDFLAGS))
def strip_libs(libs):
result = []
split_libs = libs.split()
for lib in split_libs:
result.append("%s" % str(lib[2:]))
return result
def fix_lisp_paths(bld_path,out,variant,paths):
nodes = []
for p in paths:
if ( p[:4] == "src/" ):
file_name = p
lsp_name = "%s.lsp"%file_name
lsp_res = bld_path.find_resource(lsp_name)
if (lsp_res == None):
lsp_name = "%s.lisp"%file_name
lsp_res = bld_path.find_resource(lsp_name)
# print("Looking for file_name with .lsp or .lisp: %s --> %s" % (file_name,lsp_res))
assert lsp_res!=None, "lsp_res could not be resolved for file %s - did you run ./waf update_submodules" % lsp_name
else: # generated files
# lsp_name = "%s/%s/%s.lisp"%(out,variant.variant_dir(),p)
lsp_name = "%s.lisp"%(p)
lsp_res = bld_path.find_or_declare(lsp_name)
# print("Looking for generated file with .lisp: %s --> %s" % (lsp_name,lsp_res))
assert lsp_res!=None, "lsp_res could not be resolved for file %s - did you run ./wfa update_submodules" % lsp_name
nodes.append(lsp_res)
return nodes
def debug_ext(c):
if (c):
return "-%s"%c
return ""
def debug_dir_ext(c):
if (c):
return "_%s"%c
return ""
class variant(object):
def debug_extension(self):
return debug_ext(self.debug_char)
def debug_dir_extension(self):
return debug_dir_ext(self.debug_char)
def executable_name(self,stage=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
if (not (use_stage>='a' and use_stage <= 'z')):
raise Exception("Bad stage: %s"% use_stage)
return '%s%s-%s%s' % (use_stage,APP_NAME,self.gc_name,self.debug_extension())
def extension_headers_node(self,bld):
return bld.path.find_or_declare("generated/extension_headers.h")
def fasl_name(self,stage=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
if (not (use_stage>='a' and use_stage <= 'z')):
raise Exception("Bad stage: %s"% use_stage)
return 'fasl/%s%s-%s%s-image.fasl' % (use_stage,APP_NAME,self.gc_name,self.debug_extension())
def fasl_dir(self,stage=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
return 'fasl/%s%s-%s' % (use_stage,APP_NAME,self.gc_name)
def common_lisp_bitcode_name(self,stage=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
if (not (use_stage>='a' and use_stage <= 'z')):
raise Exception("Bad stage: %s"% use_stage)
return 'fasl/%s%s-%s-common-lisp.bc' % (use_stage,APP_NAME,self.gc_name)
def variant_dir(self):
return "%s%s"%(self.gc_name,self.debug_dir_extension())
def variant_name(self):
return self.gc_name
def bitcode_name(self):
return "%s%s"%(self.gc_name,self.debug_extension())
def cxx_all_bitcode_name(self):
return 'fasl/%s-all-cxx.a' % self.bitcode_name()
def intrinsics_bitcode_archive_name(self):
return 'fasl/%s-intrinsics-cxx.a' % self.bitcode_name()
def intrinsics_bitcode_name(self):
return 'fasl/%s-intrinsics-cxx.bc' % self.bitcode_name()
def configure_for_release(self,cfg):
cfg.define("_RELEASE_BUILD",1)
cfg.env.append_value('CXXFLAGS', [ '-O3', '-g' ])
cfg.env.append_value('CFLAGS', [ '-O3', '-g' ])
if (os.getenv("CLASP_RELEASE_CXXFLAGS") != None):
cfg.env.append_value('CXXFLAGS', os.getenv("CLASP_RELEASE_CXXFLAGS").split() )
if (os.getenv("CLASP_RELEASE_LINKFLAGS") != None):
cfg.env.append_value('LINKFLAGS', os.getenv("CLASP_RELEASE_LINKFLAGS").split())
def configure_for_debug(self,cfg):
cfg.define("_DEBUG_BUILD",1)
cfg.define("DEBUG_ASSERT",1)
cfg.define("DEBUG_BOUNDS_ASSERT",1)
# cfg.define("DEBUG_ASSERT_TYPE_CAST",1) # checks runtime type casts
cfg.define("CONFIG_VAR_COOL",1)
# cfg.env.append_value('CXXFLAGS', [ '-O0', '-g' ])
cfg.env.append_value('CXXFLAGS', [ '-O0', '-g' ])
print("cfg.env.LTO_FLAG = %s" % cfg.env.LTO_FLAG)
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', [ '-Wl','-mllvm', '-O0', '-g' ])
cfg.env.append_value('CFLAGS', [ '-O0', '-g' ])
if (os.getenv("CLASP_DEBUG_CXXFLAGS") != None):
cfg.env.append_value('CXXFLAGS', os.getenv("CLASP_DEBUG_CXXFLAGS").split() )
if (os.getenv("CLASP_DEBUG_LINKFLAGS") != None):
cfg.env.append_value('LINKFLAGS', os.getenv("CLASP_DEBUG_LINKFLAGS").split())
def common_setup(self,cfg):
if ( self.debug_char == None ):
self.configure_for_release(cfg)
else:
self.configure_for_debug(cfg)
configure_common(cfg, self)
cfg.write_config_header("%s/config.h"%self.variant_dir(),remove=True)
class boehm_base(variant):
def configure_variant(self,cfg,env_copy):
cfg.define("USE_BOEHM",1)
if (cfg.env['DEST_OS'] == DARWIN_OS ):
print("boehm_base cfg.env.LTO_FLAG=%s" % cfg.env.LTO_FLAG)
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', '-Wl,-object_path_lto,%s.lto.o' % self.executable_name())
print("Setting up boehm library cfg.env.STLIB_BOEHM = %s " % cfg.env.STLIB_BOEHM)
print("Setting up boehm library cfg.env.LIB_BOEHM = %s" % cfg.env.LIB_BOEHM)
if (cfg.env.LIB_BOEHM == [] ):
cfg.env.append_value('STLIB',cfg.env.STLIB_BOEHM)
else:
cfg.env.append_value('LIB',cfg.env.LIB_BOEHM)
self.common_setup(cfg)
class boehm(boehm_base):
gc_name = 'boehm'
debug_char = None
def configure_variant(self,cfg,env_copy):
cfg.setenv(self.variant_dir(), env=env_copy.derive())
super(boehm,self).configure_variant(cfg,env_copy)
class boehm_d(boehm_base):
gc_name = 'boehm'
debug_char = 'd'
def configure_variant(self,cfg,env_copy):
cfg.setenv("boehm_d", env=env_copy.derive())
super(boehm_d,self).configure_variant(cfg,env_copy)
class boehmdc(boehm_base):
gc_name = 'boehmdc'
debug_char = None
def configure_variant(self,cfg,env_copy):
cfg.setenv("boehmdc", env=env_copy.derive())
cfg.define("USE_CXX_DYNAMIC_CAST",1)
super(boehmdc,self).configure_variant(cfg,env_copy)
class boehmdc_d(boehm_base):
gc_name = 'boehmdc'
debug_char = 'd'
def configure_variant(self,cfg,env_copy):
cfg.setenv("boehmdc_d", env=env_copy.derive())
cfg.define("USE_CXX_DYNAMIC_CAST",1)
super(boehmdc_d,self).configure_variant(cfg,env_copy)
class mps_base(variant):
def configure_variant(self,cfg,env_copy):
cfg.define("USE_MPS",1)
if (cfg.env['DEST_OS'] == DARWIN_OS ):
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', '-Wl,-object_path_lto,%s.lto.o' % self.executable_name())
# print("Setting up boehm library cfg.env.STLIB_BOEHM = %s " % cfg.env.STLIB_BOEHM)
# print("Setting up boehm library cfg.env.LIB_BOEHM = %s" % cfg.env.LIB_BOEHM)
# if (cfg.env.LIB_BOEHM == [] ):
# cfg.env.append_value('STLIB',cfg.env.STLIB_BOEHM)
# else:
# cfg.env.append_value('LIB',cfg.env.LIB_BOEHM)
self.common_setup(cfg)
class mpsprep(mps_base):
gc_name = 'mpsprep'
debug_char = None
def configure_variant(self,cfg,env_copy):
cfg.setenv("mpsprep", env=env_copy.derive())
cfg.define("RUNNING_GC_BUILDER",1)
super(mpsprep,self).configure_variant(cfg,env_copy)
class mpsprep_d(mps_base):
gc_name = 'mpsprep'
debug_char = 'd'
def configure_variant(self,cfg,env_copy):
cfg.setenv("mpsprep_d", env=env_copy.derive())
cfg.define("RUNNING_GC_BUILDER",1)
super(mpsprep_d,self).configure_variant(cfg,env_copy)
class mps(mps_base):
gc_name = 'mps'
debug_char = None
def configure_variant(self,cfg,env_copy):
cfg.setenv("mps", env=env_copy.derive())
super(mps,self).configure_variant(cfg,env_copy)
class mps_d(mps_base):
gc_name = 'mps'
debug_char = 'd'
def configure_variant(self,cfg,env_copy):
cfg.setenv("mps_d", env=env_copy.derive())
super(mps_d,self).configure_variant(cfg,env_copy)
class iboehm(boehm):
stage_char = 'i'
class aboehm(boehm):
stage_char = 'a'
class bboehm(boehm):
stage_char = 'b'
class cboehm(boehm):
stage_char = 'c'
class iboehm_d(boehm_d):
stage_char = 'i'
class aboehm_d(boehm_d):
stage_char = 'a'
class bboehm_d(boehm_d):
stage_char = 'b'
class cboehm_d(boehm_d):
stage_char = 'c'
class iboehmdc(boehmdc):
stage_char = 'i'
class aboehmdc(boehmdc):
stage_char = 'a'
class bboehmdc(boehmdc):
stage_char = 'b'
class cboehmdc(boehmdc):
stage_char = 'c'
class iboehmdc_d(boehmdc_d):
stage_char = 'i'
class aboehmdc_d(boehmdc_d):
stage_char = 'a'
class bboehmdc_d(boehmdc_d):
stage_char = 'b'
class cboehmdc_d(boehmdc_d):
stage_char = 'c'
class imps(mps):
stage_char = 'i'
class amps(mps):
stage_char = 'a'
class bmps(mps):
stage_char = 'b'
class cmps(mps):
stage_char = 'c'
class imps_d(mps_d):
stage_char = 'i'
class amps_d(mps_d):
stage_char = 'a'
class bmps_d(mps_d):
stage_char = 'b'
class cmps_d(mps_d):
stage_char = 'c'
class impsprep(mpsprep):
stage_char = 'i'
class ampsprep(mpsprep):
stage_char = 'a'
class bmpsprep(mpsprep):
stage_char = 'b'
class cmpsprep(mpsprep):
stage_char = 'c'
class impsprep_d(mpsprep_d):
stage_char = 'i'
class ampsprep_d(mpsprep_d):
stage_char = 'a'
class bmpsprep_d(mpsprep_d):
stage_char = 'b'
class cmpsprep_d(mpsprep_d):
stage_char = 'c'
# This function enables extra command line options for ./waf --help
def options(cfg):
cfg.load('compiler_cxx')
cfg.load('compiler_c')
def run_program(binary, *args):
# print("run_program for %s" % binary)
proc = subprocess.Popen([binary] + list(args), stdout = subprocess.PIPE, shell = False, universal_newlines = True)
(stdout, err) = proc.communicate()
return stdout
def run_program_echo(binary, *args):
# print("run_program for %s" % binary)
os.system("pwd")
proc = subprocess.Popen([binary] + list(args), shell = False, universal_newlines = True)
def get_git_commit(cfg):
return run_program(cfg.env.GIT_BINARY, "rev-parse", "--short", "HEAD").strip()
def get_clasp_version(cfg):
return run_program(cfg.env.GIT_BINARY, "describe", "--always").strip()
def run_llvm_config(cfg, *args):
print( "LLVM_CONFIG_BINARY = %s" % cfg.env.LLVM_CONFIG_BINARY)
result = run_program(cfg.env.LLVM_CONFIG_BINARY, *args)
assert len(result) > 0
return result.strip()
def run_llvm_config_for_libs(cfg, *args):
print("run_llvm_config_for_libs LLVM_CONFIG_BINARY_FOR_LIBS = %s" % cfg.env.LLVM_CONFIG_BINARY_FOR_LIBS)
result = run_program(cfg.env.LLVM_CONFIG_BINARY_FOR_LIBS, *args)
assert len(result) > 0
return result.strip()
def configure(cfg):
def update_exe_search_path(cfg):
externals = cfg.env.EXTERNALS_CLASP_DIR
if (externals!=[]):
print("externals = |%s|" % externals)
assert os.path.isdir(externals), "Please provide a valid EXTERNALS_CLASP_DIR instead of '%s'. See the wscript.config.template file." % externals
path = os.getenv("PATH").split(os.pathsep)
externals_bin_dir = os.path.join(externals, "build/release/bin/")
path.insert(0, externals_bin_dir)
cfg.environ["PATH"] = os.pathsep.join(path)
print("PATH has been prefixed with '%s'" % externals_bin_dir)
cfg.env['LLVM_CONFIG_BINARY'] = "%s/build/release/bin/llvm-config" % externals
#print("Updated search path for binaries: '%s'" % cfg.environ["PATH"])
def check_externals_clasp_version(cfg):
print("Hello there - check externals-clasp from here")
externals = cfg.env['EXTERNALS_CLASP_DIR']
if (externals == []):
print("Not checking externals-clasp because EXTERNALS_CLASP_DIR was not set")
return
print(" externals = %s" % externals)
fin = open(externals+"/makefile","r")
externals_clasp_llvm_hash = "c54021df3fd4d71d822b3112cba4e43d94927378"
correct_version = False
for x in fin:
if (externals_clasp_llvm_hash in x):
correct_version = True
fin.close()
if (not correct_version):
raise Exception("You do not have the correct version of externals-clasp installed - you need the one with the LLVM_COMMIT=%s" % externals_clasp_llvm_hash)
def load_local_config(cfg):
if not os.path.isfile("./wscript.config"):
print("Please provide the required config for the build; see the wscript.config.template file.")
sys.exit(1)
local_environment = {}
exec(open("./wscript.config").read(), globals(), local_environment)
cfg.env.update(local_environment)
# KLUDGE there should be a better way than this
cfg.env["BUILD_ROOT"] = os.path.abspath(top)
load_local_config(cfg)
cfg.load("why")
cfg.check_waf_version(mini = '1.7.5')
update_exe_search_path(cfg)
check_externals_clasp_version(cfg)
if (cfg.env.LLVM_CONFIG_BINARY):
pass
else:
cfg.env["LLVM_CONFIG_BINARY"] = cfg.find_program("llvm-config", var = "LLVM_CONFIG")[0]
if (cfg.env.LLVM_CONFIG_DEBUG_PATH):
print("LLVM_CONFIG_DEBUG_PATH is defined: %s" % cfg.env.LLVM_CONFIG_DEBUG_PATH)
cfg.env["LLVM_CONFIG_BINARY_FOR_LIBS"] = cfg.env.LLVM_CONFIG_DEBUG_PATH
else:
print("LLVM_CONFIG_DEBUG_PATH is not defined")
cfg.env["LLVM_CONFIG_BINARY_FOR_LIBS"] = cfg.env.LLVM_CONFIG_BINARY
cfg.env["LLVM_BIN_DIR"] = run_llvm_config(cfg, "--bindir")
cfg.env["LLVM_AR_BINARY"] = "%s/llvm-ar" % cfg.env.LLVM_BIN_DIR
# cfg.env["LLVM_AR_BINARY"] = cfg.find_program("llvm-ar", var = "LLVM_AR")[0]
cfg.env["GIT_BINARY"] = cfg.find_program("git", var = "GIT")[0]
print("cfg.env['LTO_OPTION'] = %s" % cfg.env['LTO_OPTION'])
if (cfg.env['LTO_OPTION']==[] or cfg.env['LTO_OPTION']=='thinlto'):
cfg.env.LTO_FLAG = '-flto=thin'
if (cfg.env['DEST_OS'] == LINUX_OS ):
cfg.env.append_value('LINKFLAGS', '-Wl,-plugin-opt,cache-dir=/tmp')
elif (cfg.env['DEST_OS'] == DARWIN_OS ):
cfg.env.append_value('LINKFLAGS', '-Wl,-cache_path_lto,/tmp')
elif (cfg.env['LTO_OPTION']=='lto'):
cfg.env.LTO_FLAG = '-flto'
elif (cfg.env['LTO_OPTION']=='obj'):
cfg.env.LTO_FLAG = []
else:
raise Exception("LTO_OPTION can only be 'thinlto'(default), 'lto', or 'obj' - you provided %s" % cfg.env['LTO_OPTION'])
print("default cfg.env.LTO_OPTION = %s" % cfg.env.LTO_OPTION)
print("default cfg.env.LTO_FLAG = %s" % cfg.env.LTO_FLAG)
run_llvm_config(cfg, "--version") # make sure we fail early
# find a lisp for the scraper
if not cfg.env.SCRAPER_LISP:
cfg.env["SBCL"] = cfg.find_program("sbcl", var = "SBCL")[0]
cfg.env["SCRAPER_LISP"] = [cfg.env.SBCL] + "--noinform --dynamic-space-size 4096 --lose-on-corruption --disable-ldb --no-userinit --disable-debugger".split()
global cxx_compiler, c_compiler
cxx_compiler['linux'] = ["clang++"]
c_compiler['linux'] = ["clang"]
cfg.load('compiler_cxx')
cfg.load('compiler_c')
### Without these checks the following error happens: AttributeError: 'BuildContext' object has no attribute 'variant_obj'
cfg.check_cxx(lib='gmpxx gmp'.split(), cflags='-Wall', uselib_store='GMP')
try:
cfg.check_cxx(stlib='gc', cflags='-Wall', uselib_store='BOEHM')
except ConfigurationError:
cfg.check_cxx(lib='gc', cflags='-Wall', uselib_store='BOEHM')
#libz
cfg.check_cxx(lib='z', cflags='-Wall', uselib_store='Z')
if (cfg.env['DEST_OS'] == LINUX_OS ):
cfg.check_cxx(lib='dl', cflags='-Wall', uselib_store='DL')
cfg.check_cxx(lib='ncurses', cflags='-Wall', uselib_store='NCURSES')
cfg.check_cxx(lib='m', cflags='-Wall', uselib_store='M')
cfg.check_cxx(stlib=BOOST_LIBRARIES, cflags='-Wall', uselib_store='BOOST')
cfg.extensions_include_dirs = []
cfg.extensions_gcinterface_include_files = []
cfg.extensions_stlib = []
cfg.extensions_lib = []
cfg.extensions_names = []
cfg.recurse('extensions')
print("cfg.extensions_names before sort = %s" % cfg.extensions_names)
cfg.extensions_names = sorted(cfg.extensions_names)
print("cfg.extensions_names after sort = %s" % cfg.extensions_names)
clasp_gc_filename = "clasp_gc.cc"
if (len(cfg.extensions_names) > 0):
clasp_gc_filename = "clasp_gc_%s.cc" % ("_".join(cfg.extensions_names))
print("clasp_gc_filename = %s"%clasp_gc_filename)
cfg.define("CLASP_GC_FILENAME",clasp_gc_filename)
llvm_liblto_dir = run_llvm_config(cfg, "--libdir")
llvm_lib_dir = run_llvm_config_for_libs(cfg, "--libdir")
print("llvm_lib_dir = %s" % llvm_lib_dir)
cfg.env.append_value('LINKFLAGS', ["-L%s" % llvm_lib_dir])
llvm_libraries = strip_libs(run_llvm_config_for_libs(cfg, "--libs"))
#dynamic llvm/clang
cfg.check_cxx(lib=llvm_libraries, cflags = '-Wall', uselib_store = 'LLVM', libpath = llvm_lib_dir )
cfg.check_cxx(lib=CLANG_LIBRARIES, cflags='-Wall', uselib_store='CLANG', libpath = llvm_lib_dir )
#static llvm/clang
# cfg.check_cxx(stlib=llvm_libraries, cflags = '-Wall', uselib_store = 'LLVM', stlibpath = llvm_lib_dir )
# cfg.check_cxx(stlib=CLANG_LIBRARIES, cflags='-Wall', uselib_store='CLANG', stlibpath = llvm_lib_dir )
llvm_include_dir = run_llvm_config_for_libs(cfg, "--includedir")
print("llvm_include_dir = %s" % llvm_include_dir)
cfg.env.append_value('CXXFLAGS', ['-I./', '-I' + llvm_include_dir])
cfg.env.append_value('CFLAGS', ['-I./'])
# if ('program_name' in cfg.__dict__):
# pass
# else:
# cfg.env.append_value('CXXFLAGS', ['-I%s/include/clasp/main/'% cfg.path.abspath() ])
# Check if GC_enumerate_reachable_objects_inner is available
# If so define BOEHM_GC_ENUMERATE_REACHABLE_OBJECTS_INNER_AVAILABLE
#
if (cfg.env["BOEHM_GC_ENUMERATE_REACHABLE_OBJECTS_INNER_AVAILABLE"] == True):
cfg.define("BOEHM_GC_ENUMERATE_REACHABLE_OBJECTS_INNER_AVAILABLE",1)
cfg.define("USE_CLASP_DYNAMIC_CAST",1)
cfg.define("BUILDING_CLASP",1)
print("cfg.env['DEST_OS'] == %s\n" % cfg.env['DEST_OS'])
if (cfg.env['DEST_OS'] == DARWIN_OS ):
cfg.define("_TARGET_OS_DARWIN",1)
elif (cfg.env['DEST_OS'] == LINUX_OS ):
cfg.define("_TARGET_OS_LINUX",1);
else:
raise Exception("Unknown OS %s"%cfg.env['DEST_OS'])
cfg.define("PROGRAM_CLASP",1)
cfg.define("CLASP_THREADS",1)
cfg.define("CLASP_GIT_COMMIT",get_git_commit(cfg))
cfg.define("CLASP_VERSION",get_clasp_version(cfg))
cfg.define("CLBIND_DYNAMIC_LINK",1)
cfg.define("DEFINE_CL_SYMBOLS",1)
# cfg.define("SOURCE_DEBUG",1)
cfg.define("USE_SOURCE_DATABASE",1)
cfg.define("USE_COMPILED_CLOSURE",1) # disable this in the future and switch to ClosureWithSlots
cfg.define("CLASP_UNICODE",1)
# cfg.define("EXPAT",1)
cfg.define("INCLUDED_FROM_CLASP",1)
cfg.define("INHERITED_FROM_SRC",1)
cfg.define("LLVM_VERSION_X100",400)
cfg.define("LLVM_VERSION","4.0")
cfg.define("NDEBUG",1)
# cfg.define("READLINE",1)
cfg.define("USE_AMC_POOL",1)
cfg.define("USE_EXPENSIVE_BACKTRACE",1)
cfg.define("X86_64",1)
# cfg.define("DEBUG_FUNCTION_CALL_COUNTER",1)
cfg.define("_ADDRESS_MODEL_64",1)
cfg.define("__STDC_CONSTANT_MACROS",1)
cfg.define("__STDC_FORMAT_MACROS",1)
cfg.define("__STDC_LIMIT_MACROS",1)
# cfg.env.append_value('CXXFLAGS', ['-v'] )
# cfg.env.append_value('CFLAGS', ['-v'] )
cfg.env.append_value('LINKFLAGS', ['-v'] )
# includes = [ 'include/' ]
# includes = includes + cfg.plugins_include_dirs
# includes_from_build_dir = []
# for x in includes:
# includes_from_build_dir.append("-I%s/%s"%(cfg.path.abspath(),x))
# cfg.env.append_value('CXXFLAGS', includes_from_build_dir )
# cfg.env.append_value('CFLAGS', includes_from_build_dir )
# print("DEBUG includes_from_build_dir = %s\n" % includes_from_build_dir)
cfg.env.append_value('CXXFLAGS', [ '-std=c++11'])
# cfg.env.append_value('CXXFLAGS', ["-D_GLIBCXX_USE_CXX11_ABI=1"])
if (cfg.env.LTO_FLAG):
cfg.env.append_value('CXXFLAGS', cfg.env.LTO_FLAG )
cfg.env.append_value('CFLAGS', cfg.env.LTO_FLAG )
cfg.env.append_value('LINKFLAGS', cfg.env.LTO_FLAG )
if (cfg.env['DEST_OS'] == LINUX_OS ):
cfg.env.append_value('LINKFLAGS', '-fuse-ld=gold')
cfg.env.append_value('LINKFLAGS', ['-stdlib=libstdc++'])
cfg.env.append_value('LINKFLAGS', ['-lstdc++'])
cfg.env.append_value('LINKFLAGS', '-pthread')
elif (cfg.env['DEST_OS'] == DARWIN_OS ):
cfg.env.append_value('LINKFLAGS', ['-Wl,-export_dynamic'])
cfg.env.append_value('LINKFLAGS', ['-Wl,-stack_size,0x1000000'])
lto_library_name = cfg.env.cxxshlib_PATTERN % "LTO" # libLTO.<os-dep-extension>
lto_library = "%s/%s" % ( llvm_liblto_dir, lto_library_name)
cfg.env.append_value('LINKFLAGS',["-Wl,-lto_library,%s" % lto_library])
cfg.env.append_value('LINKFLAGS', ['-lc++'])
cfg.env.append_value('LINKFLAGS', ['-stdlib=libc++'])
cfg.env.append_value('INCLUDES', [ run_llvm_config(cfg,"--includedir") ])
cfg.env.append_value('INCLUDES', ['/usr/include'] )
cfg.define("ENABLE_BACKTRACE_ARGS",1)
# --------------------------------------------------
# --------------------------------------------------
# --------------------------------------------------
#
# The following debugging flags slow down clasp
# They should be disabled in production code
#
if (cfg.env.ADDRESS_SANITIZER):
cfg.env.append_value('CXXFLAGS', ['-fsanitize=address'] )
cfg.env.append_value('LINKFLAGS', ['-fsanitize=address'])
if (cfg.env.DEBUG_GUARD):
cfg.define("DEBUG_GUARD",1)
cfg.define("DEBUG_GUARD_VALIDATE",1)
if (cfg.env.DEBUG_GUARD_EXHAUSTIVE_VALIDATE):
cfg.define("DEBUG_GUARD_EXHAUSTIVE_VALIDATE",1)
# Keep track of every allocation
cfg.define("METER_ALLOCATIONS",1)
cfg.define("DEBUG_TRACE_INTERPRETED_CLOSURES",1)
# cfg.define("DEBUG_CACHE",1) # Debug the dispatch caches - see cache.cc
# cfg.define("DEBUG_BITUNIT_CONTAINER",1) # prints debug info for bitunit containers
# cfg.define("DEBUG_ZERO_KIND",1);
# cfg.define("DEBUG_FLOW_CONTROL",1)
# cfg.define("DEBUG_DYNAMIC_BINDING_STACK",1)
# cfg.define("DEBUG_VALUES",1) # turn on printing (values x y z) values when core:*debug-values* is not nil
# cfg.define("DEBUG_IHS",1)
# cfg.define("DEBUG_ENSURE_VALID_OBJECT",1)
# cfg.define("DEBUG_THREADS",1)
# cfg.define("DEBUG_BOUNDS_ASSERT",1)
# cfg.define("DEBUG_QUICK_VALIDATE",1) # quick/cheap validate if on and comprehensive validate if not
# cfg.define("DEBUG_STARTUP",1)
# cfg.define("DEBUG_ACCESSORS",1)
# cfg.define("DEBUG_GFDISPATCH",1)
# -----------------
# defines that slow down program execution
# There are more defined in clasp/include/gctools/configure_memory.h
cfg.define("DEBUG_SLOW",1) # Code runs slower due to checks - undefine to remove checks
# ----------
# --------------------------------------------------
# --------------------------------------------------
# --------------------------------------------------
cfg.env.append_value('CXXFLAGS', ['-Wno-macro-redefined'] )
cfg.env.append_value('CXXFLAGS', ['-Wno-deprecated-register'] )
cfg.env.append_value('CXXFLAGS', ['-Wno-expansion-to-defined'] )
cfg.env.append_value('CXXFLAGS', ['-Wno-return-type-c-linkage'] )
cfg.env.append_value('CXXFLAGS', ['-Wno-invalid-offsetof'] )
cfg.env.append_value('CXXFLAGS', ['-Wno-#pragma-messages'] )
cfg.env.append_value('CXXFLAGS', ['-Wno-inconsistent-missing-override'] )
cfg.env.append_value('LIBPATH', ['/usr/lib'])
cfg.env.append_value('LINKFLAGS', ['-fvisibility=default'])
cfg.env.append_value('LINKFLAGS', ['-rdynamic'])
sep = " "
cfg.env.append_value('STLIB', cfg.extensions_stlib)
cfg.env.append_value('LIB', cfg.extensions_lib)
cfg.env.append_value('STLIB', cfg.env.STLIB_CLANG)
cfg.env.append_value('STLIB', cfg.env.STLIB_LLVM)
cfg.env.append_value('STLIB', cfg.env.STLIB_BOOST)
cfg.env.append_value('STLIB', cfg.env.STLIB_Z)
if (cfg.env['DEST_OS'] == LINUX_OS ):
cfg.env.append_value('LIB', cfg.env.LIB_DL)
cfg.env.append_value('LIB', cfg.env.LIB_CLANG)
cfg.env.append_value('LIB', cfg.env.LIB_LLVM)
cfg.env.append_value('LIB', cfg.env.LIB_NCURSES)
cfg.env.append_value('LIB', cfg.env.LIB_M)
cfg.env.append_value('LIB', cfg.env.LIB_GMP)
cfg.env.append_value('LIB', cfg.env.LIB_Z)
print("cfg.env.STLIB = %s" % cfg.env.STLIB)
print("cfg.env.LIB = %s" % cfg.env.LIB)
env_copy = cfg.env.derive()
for gc in GCS:
for debug_char in DEBUG_CHARS:
if (debug_char==None):
variant = gc
else:
variant = gc+"_"+debug_char
variant_instance = eval("i"+variant+"()")
print("Setting up variant: %s" % variant_instance.variant_dir())
variant_instance.configure_variant(cfg,env_copy)
def copy_tree(bld,src,dest):
print("Copy tree src = %s" % src)
print(" dest= %s" % dest)
def build(bld):
# bld(name='myInclude', export_includes=[bld.env.MY_MYSDK, 'include'])
if not bld.variant:
bld.fatal("Call waf with build_variant, e.g. 'nice -n19 ./waf --jobs 2 --verbose build_cboehm'")
stage = bld.stage
stage_val = stage_value(bld,stage)
print("Building stage --> %s" % stage)
bld.clasp_source_files = []
bld.clasp_aclasp = []
bld.clasp_bclasp = []
bld.clasp_cclasp = []
bld.clasp_cclasp_no_wrappers = []
bld.recurse('src')
bld.extensions_include_dirs = []
bld.extensions_include_files = []
bld.extensions_source_files = []
bld.extensions_gcinterface_include_files = []
bld.recurse('extensions')
bld.recurse('src/main')
source_files = bld.clasp_source_files + bld.extensions_source_files
bld.install_files('${INSTALL_PATH_PREFIX}/Contents/Resources/source-code/', source_files, relative_trick = True, cwd = bld.path)
print("bld.path = %s"%bld.path)
clasp_headers = bld.path.ant_glob("include/clasp/**/*.h")
bld.install_files('${INSTALL_PATH_PREFIX}/Contents/Resources/source-code/', clasp_headers, relative_trick = True, cwd = bld.path)
variant = eval(bld.variant+"()")
bld.env = bld.all_envs[bld.variant]
bld.variant_obj = variant
include_dirs = ['.']
include_dirs.append("%s/src/main/" % bld.path.abspath())
include_dirs.append("%s/include/" % (bld.path.abspath()))
include_dirs.append("%s/%s/%s/generated/" % (bld.path.abspath(),out,variant.variant_dir()))
include_dirs = include_dirs + bld.extensions_include_dirs
print("include_dirs = %s" % include_dirs)
print("Building with variant = %s" % variant)
wscript_node = bld.path.find_resource("wscript")
extension_headers_node = variant.extension_headers_node(bld)
print("extension_headers_node = %s" % extension_headers_node.abspath())
extensions_task = build_extension_headers(env=bld.env)
inputs = [wscript_node] + bld.extensions_gcinterface_include_files
extensions_task.set_inputs(inputs)
extensions_task.set_outputs([extension_headers_node])
bld.add_to_group(extensions_task)
# Always build the C++ code
iclasp_executable = bld.path.find_or_declare(variant.executable_name(stage='i'))
intrinsics_bitcode_node = bld.path.find_or_declare(variant.intrinsics_bitcode_archive_name())
if (bld.env['DEST_OS'] == LINUX_OS ):
executable_dir = "bin"
bld_task = bld.program(source=source_files,
includes=include_dirs,
target = [iclasp_executable], install_path = '${INSTALL_PATH_PREFIX}/bin')
elif (bld.env['DEST_OS'] == DARWIN_OS ):
executable_dir = "MacOS"
bld_task = bld.program(source=source_files,
includes=include_dirs,
target = [iclasp_executable], install_path = '${INSTALL_PATH_PREFIX}/MacOS')
if (bld.env.LTO_FLAG):
iclasp_lto_o = bld.path.find_or_declare('%s.lto.o' % variant.executable_name(stage='i'))
iclasp_dsym = bld.path.find_or_declare("%s.dSYM"%variant.executable_name(stage='i'))
iclasp_dsym_files = generate_dsym_files(variant.executable_name(stage='i'),iclasp_dsym)
dsymutil_iclasp = dsymutil(env=bld.env)
dsymutil_iclasp.set_inputs([iclasp_executable,iclasp_lto_o])
dsymutil_iclasp.set_outputs(iclasp_dsym_files)
bld.add_to_group(dsymutil_iclasp)
bld.install_files('${INSTALL_PATH_PREFIX}/%s/%s' % (executable_dir, iclasp_dsym.name), iclasp_dsym_files, relative_trick = True, cwd = iclasp_dsym)
if (stage_val <= -1):
print("About to add run_aclasp")
cmp_aclasp = run_aclasp(env=bld.env)
# print("clasp_aclasp as nodes = %s" % fix_lisp_paths(bld.path,out,variant,bld.clasp_aclasp))
cmp_aclasp.set_inputs([iclasp_executable,intrinsics_bitcode_node]+fix_lisp_paths(bld.path,out,variant,bld.clasp_aclasp))
aclasp_common_lisp_bitcode = bld.path.find_or_declare(variant.common_lisp_bitcode_name(stage='a'))
cmp_aclasp.set_outputs(aclasp_common_lisp_bitcode)
bld.add_to_group(cmp_aclasp)
if (stage_val >= 1):
print("About to add compile_aclasp")
cmp_aclasp = compile_aclasp(env=bld.env)
# print("clasp_aclasp as nodes = %s" % fix_lisp_paths(bld.path,out,variant,bld.clasp_aclasp))
cmp_aclasp.set_inputs([iclasp_executable,intrinsics_bitcode_node]+fix_lisp_paths(bld.path,out,variant,bld.clasp_aclasp))
aclasp_common_lisp_bitcode = bld.path.find_or_declare(variant.common_lisp_bitcode_name(stage='a'))
print("find_or_declare aclasp_common_lisp_bitcode = %s" % aclasp_common_lisp_bitcode)
cmp_aclasp.set_outputs(aclasp_common_lisp_bitcode)
bld.add_to_group(cmp_aclasp)
lnk_aclasp = link_fasl(env=bld.env)
lnk_aclasp.set_inputs([intrinsics_bitcode_node,aclasp_common_lisp_bitcode])
aclasp_link_product = bld.path.find_or_declare(variant.fasl_name(stage='a'))
lnk_aclasp.set_outputs([aclasp_link_product])
bld.add_to_group(lnk_aclasp)
bld.install_as('${INSTALL_PATH_PREFIX}/%s/%s' % (executable_dir, aclasp_link_product.name), aclasp_link_product)
bld.install_as('${INSTALL_PATH_PREFIX}/Contents/Resources/lib/%s' % variant.common_lisp_bitcode_name(stage='a'), aclasp_common_lisp_bitcode)
if (stage_val >= 2):
print("About to add compile_bclasp")
cmp_bclasp = compile_bclasp(env=bld.env)
cmp_bclasp.set_inputs([iclasp_executable,aclasp_link_product,intrinsics_bitcode_node]+fix_lisp_paths(bld.path,out,variant,bld.clasp_cclasp)) # bld.clasp_bclasp
bclasp_common_lisp_bitcode = bld.path.find_or_declare(variant.common_lisp_bitcode_name(stage='b'))
cmp_bclasp.set_outputs(bclasp_common_lisp_bitcode)
bld.add_to_group(cmp_bclasp)
bclasp_link_product = bld.path.find_or_declare(variant.fasl_name(stage='b'))
lnk_bclasp = link_fasl(env=bld.env)
lnk_bclasp.set_inputs([intrinsics_bitcode_node,bclasp_common_lisp_bitcode])
lnk_bclasp.set_outputs([bclasp_link_product])
bld.add_to_group(lnk_bclasp)
bld.install_as('${INSTALL_PATH_PREFIX}/%s/%s' % (executable_dir, bclasp_link_product.name), bclasp_link_product)
bld.install_as('${INSTALL_PATH_PREFIX}/Contents/Resources/lib/%s' % variant.common_lisp_bitcode_name(stage = 'b'), aclasp_common_lisp_bitcode)
if (stage_val >= 3):
print("About to add compile_cclasp")
# Build cclasp
cmp_cclasp = compile_cclasp(env=bld.env)
cxx_all_bitcode_node = bld.path.find_or_declare(variant.cxx_all_bitcode_name())
cmp_cclasp.set_inputs([iclasp_executable,bclasp_link_product,cxx_all_bitcode_node]+fix_lisp_paths(bld.path,out,variant,bld.clasp_cclasp))
cclasp_common_lisp_bitcode = bld.path.find_or_declare(variant.common_lisp_bitcode_name(stage='c'))
cmp_cclasp.set_outputs([cclasp_common_lisp_bitcode])
bld.add_to_group(cmp_cclasp)
if (stage == 'rebuild' or stage == 'dangerzone'):
print("!------------------------------------------------------------")
print("! You have entered the dangerzone! ")
print("! While you wait... https://www.youtube.com/watch?v=kyAn3fSs8_A")
print("!------------------------------------------------------------")
# Build cclasp
recmp_cclasp = recompile_cclasp(env=bld.env)
recmp_cclasp.set_inputs(fix_lisp_paths(bld.path,out,variant,bld.clasp_cclasp_no_wrappers))
cclasp_common_lisp_bitcode = bld.path.find_or_declare(variant.common_lisp_bitcode_name(stage='c'))
recmp_cclasp.set_outputs([cclasp_common_lisp_bitcode])
bld.add_to_group(recmp_cclasp)
if (stage == 'dangerzone' or stage == 'rebuild' or stage_val >= 3):
cclasp_fasl = bld.path.find_or_declare(variant.fasl_name(stage='c'))
lnk_cclasp_fasl = link_fasl(env=bld.env)
lnk_cclasp_fasl.set_inputs([intrinsics_bitcode_node,cclasp_common_lisp_bitcode])
lnk_cclasp_fasl.set_outputs([cclasp_fasl])
bld.add_to_group(lnk_cclasp_fasl)
bld.install_as('${INSTALL_PATH_PREFIX}/%s/%s' % (executable_dir, cclasp_fasl.name), cclasp_fasl)
if (stage == 'rebuild' or stage_val >= 3):
cclasp_common_lisp_bitcode = bld.path.find_or_declare(variant.common_lisp_bitcode_name(stage='c'))
bld.install_as('${INSTALL_PATH_PREFIX}/Contents/Resources/lib/%s' % variant.common_lisp_bitcode_name(stage = 'c'), cclasp_common_lisp_bitcode)
# Build serve-event
serve_event_fasl = bld.path.find_or_declare("%s/src/lisp/modules/serve-event/serve-event.fasl" % variant.fasl_dir(stage='c'))
cmp_serve_event = compile_module(env=bld.env)
cmp_serve_event.set_inputs([iclasp_executable,cclasp_fasl] + fix_lisp_paths(bld.path,out,variant,["src/lisp/modules/serve-event/serve-event"]))
cmp_serve_event.set_outputs(serve_event_fasl)
bld.add_to_group(cmp_serve_event)
bld.install_as('${INSTALL_PATH_PREFIX}/Contents/Resources/lib/%s/src/lisp/modules/serve-event/serve-event.fasl' % variant.fasl_dir(stage = "c"), serve_event_fasl)
# Build ASDF
asdf_fasl = bld.path.find_or_declare("%s/src/lisp/modules/asdf/asdf.fasl" % variant.fasl_dir(stage='c'))
cmp_asdf = compile_module(env=bld.env)
cmp_asdf.set_inputs([iclasp_executable,cclasp_fasl] + fix_lisp_paths(bld.path,out,variant,["src/lisp/modules/asdf/build/asdf"]))
cmp_asdf.set_outputs(asdf_fasl)
bld.add_to_group(cmp_asdf)
bld.install_as('${INSTALL_PATH_PREFIX}/Contents/Resources/lib/%s/src/lisp/modules/asdf/asdf.fasl' % variant.fasl_dir(stage = "c"), asdf_fasl)
build_node = bld.path.find_dir(out)
print("build_node = %s" % build_node)
clasp_symlink_node = build_node.make_node("clasp")
print("clasp_symlink_node = %s" % clasp_symlink_node)
if (os.path.islink(clasp_symlink_node.abspath())):
os.unlink(clasp_symlink_node.abspath())
if (stage == 'rebuild' or stage_val >= 4):
lnk_cclasp_exec = link_executable(env=bld.env)
cxx_all_bitcode_node = bld.path.find_or_declare(variant.cxx_all_bitcode_name())
lnk_cclasp_exec.set_inputs([cxx_all_bitcode_node,cclasp_common_lisp_bitcode])
cclasp_executable = bld.path.find_or_declare(variant.executable_name(stage='c'))
if ( bld.env['DEST_OS'] == DARWIN_OS ):
if (bld.env.LTO_FLAG):
cclasp_lto_o = bld.path.find_or_declare('%s.lto.o' % variant.executable_name(stage='c'))
lnk_cclasp_exec.set_outputs([cclasp_executable,cclasp_lto_o])
else:
cclasp_lto_o = None
lnk_cclasp_exec.set_outputs([cclasp_executable])
elif (bld.env['DEST_OS'] == LINUX_OS ):
cclasp_lto_o = None
lnk_cclasp_exec.set_outputs(cclasp_executable)
bld.add_to_group(lnk_cclasp_exec)
if ( bld.env['DEST_OS'] == DARWIN_OS ):
cclasp_dsym = bld.path.find_or_declare("%s.dSYM"%variant.executable_name(stage='c'))
cclasp_dsym_files = generate_dsym_files(variant.executable_name(stage='c'),cclasp_dsym)
print("cclasp_dsym_files = %s" % cclasp_dsym_files)
dsymutil_cclasp = dsymutil(env=bld.env)
if (cclasp_lto_o):
dsymutil_cclasp.set_inputs([cclasp_executable,cclasp_lto_o])
else:
dsymutil_cclasp.set_inputs([cclasp_executable])
dsymutil_cclasp.set_outputs(cclasp_dsym_files)
bld.add_to_group(dsymutil_cclasp)
bld.install_files('${INSTALL_PATH_PREFIX}/%s/%s' % (executable_dir, cclasp_dsym.name), cclasp_dsym_files, relative_trick = True, cwd = cclasp_dsym)
bld.install_as('${INSTALL_PATH_PREFIX}/%s/%s' % (executable_dir, cclasp_executable.name), cclasp_executable, chmod = Utils.O755)
bld.symlink_as('${INSTALL_PATH_PREFIX}/%s/clasp' % executable_dir, '%s' % cclasp_executable.name)
os.symlink(cclasp_executable.abspath(),clasp_symlink_node.abspath())
from waflib import TaskGen
from waflib import Task
class dsymutil(Task.Task):
color = 'BLUE';
def run(self):
cmd = 'dsymutil %s' % self.inputs[0]
print(" cmd: %s" % cmd)
return self.exec_command(cmd)
class link_fasl(Task.Task):
def run(self):
if (self.env.LTO_FLAG):
lto_option = self.env.LTO_FLAG
lto_optimize_flag = "-O2"
else:
lto_option = ""
lto_optimize_flag = ""
if (self.env['DEST_OS'] == DARWIN_OS ):
cmd = "%s %s %s %s %s -flat_namespace -undefined suppress -bundle -o %s" % (self.env.CXX[0],self.inputs[0].abspath(),self.inputs[1].abspath(),lto_option,lto_optimize_flag,self.outputs[0].abspath())
elif (self.env['DEST_OS'] == LINUX_OS ):
cmd = "%s %s %s %s %s -fuse-ld=gold -shared -o %s" % (self.env.CXX[0],self.inputs[0].abspath(),self.inputs[1].abspath(),lto_option,lto_optimize_flag,self.outputs[0].abspath())
else:
self.fatal("Illegal DEST_OS: %s" % self.env['DEST_OS'])
print(" link_fasl cmd: %s\n" % cmd)
return self.exec_command(cmd)
def exec_command(self, cmd, **kw):
kw['stdout'] = sys.stdout
return super(link_fasl, self).exec_command(cmd, **kw)
def keyword(self):
return 'Link fasl using... '
class link_executable(Task.Task):
def run(self):
if (self.env['DEST_OS'] == DARWIN_OS ):
if (self.env.LTO_FLAG):
lto_option_list = [self.env.LTO_FLAG,"-O2"]
lto_object_path_lto = ["-Wl,-object_path_lto,%s"% self.outputs[1].abspath()]
else: