-
Notifications
You must be signed in to change notification settings - Fork 0
/
eve.py
788 lines (707 loc) · 29.9 KB
/
eve.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
# ============================================================================
# EVE main script
# ----------------------------------------------------------------------------
# default directory layout:
# CWD/EiffelStudioXY_zzzz location of EiffelStudio installation
# CWD/eve location of EVE source checkout
# CWD/delivery location of generated EVE deliveries
# CWD/merge location where merge is performed
# ----------------------------------------------------------------------------
# main commands:
# //not yet implemented//- python eve.py
# print status information and offer command selection
# - python eve.py update
# install or update to latest nightly build of EiffelStudio
# checkout or update latest EVE source
# checkout or update latest EVE scripts
# compile EVE runtime
# compile workbench verision of EVE bench target
# - python eve.py delivery
# create EVE delivery (no update performed)
# - python eve.py merge
# merge EiffelStudio Trunk into EVE source (uses clean repositories)
# create EVE delivery
# - python eve.py es
# run EiffelStudio
# ----------------------------------------------------------------------------
# individual commands:
# - python eve.py check
# check installation and environment
# - python eve.py update es
# install or update to latest nightly build of EiffelStudio
# - python eve.py update source
# checkout or update latest EVE source
# - python eve.py compile runtime
# compile EVE runtime
# - python eve.py compile eve
# compile workbench version of EVE bench target
# - python eve.py finalize eve
# compile finalized version of EVE bench target
# ----------------------------------------------------------------------------
# dependencies:
# - Python 2.7.x
# - [choice] pysvn for corresponding python/svn versions (necessary for merge)
# - [choice] SVN executable in path (if pysvn not available)
# - [optional] colorama: http://pypi.python.org/pypi/colorama
# - [Windows only] msc - Microsoft C compiler
# - [Windows only] 7zip - installed at default location C:\Program Files\7-zip
# ============================================================================
# TODO
# http://www.tutorialspoint.com/python/python_gui_programming.htm
import config
import elocation
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# SETUP VARIABLES
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Base directory where EiffelStudio will be installed
# EiffelStudio will be installed in a subdirectory EiffelStudioXY_zzzzzz
v_dir_eiffelstudio_base = elocation.base_directory() #"."
# Set this to a string of a specific version of EiffelStudio that is already installed (i.e. "12345")
v_force_es_version = None
# Directory where EVE source will be checked out
#v_dir_eve_source = "./eve"
v_dir_eve_source = elocation.trunk_source()
# Directory where generated deliveries will be saved
v_dir_delivery = "./delivery"
v_dir_delivery_remote = r"\\fs.meyer.inf.ethz.ch\web\htdocs\research\eve\builds"
v_remote_base_url = r"http://se.inf.ethz.ch/research/eve/builds"
# Directory where Boogie/Z3 bundle is installed
v_dir_boogie = "./eve/Delivery/studio/tools/boogie"
# Directory where merge will be performed (checkout directory for eve)
v_dir_merge = "./merge_eve"
# URLs
v_url_svn_eve = "https://svn.eiffel.com/eiffelstudio/branches/eth/eve"
#v_url_svn_eve_src = "https://svn.eiffel.com/eiffelstudio/branches/eth/eve/Src"
v_url_svn_eve_src = config.v_url_svn_eve_src
#v_url_svn_trunk = "https://svn.eiffel.com/eiffelstudio/trunk"
v_url_svn_trunk = config.v_url_svn_trunk_src
v_url_eiffelstudio_download = ["ftp://ftp.eiffel.com/pub/beta/nightly", "ftp://ftp.eiffel.com/pub/beta/15.08/", "ftp://ftp.eiffel.com/pub/beta/15.11/"]
v_svn_user = ""
v_svn_password = ""
v_email_merge_info = "" # email to merge-resposible
v_email_merge_update = "[email protected];[email protected]" # email to group
# 0: no output
# 1: error/warning/success output
# 2: info output
# 3: log output
v_verbose_level = 3
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import os
import os.path
import platform
import sys
import time
import shutil
import subprocess
try:
import urllib.request as urllib2
except ImportError:
import urllib2
import re
import errno
import glob
from elogger import SystemLogger
import esvn
import elocation
import eutils
import ecompile
import eweasel
# Make input a synonym of raw_input in Python 2
try:
input = raw_input
except NameError:
pass
# ----------------------------------------------------------------------------
# Gather system information
# ----------------------------------------------------------------------------
d_ise_platform = None
d_ise_c_compiler = None
d_archive_extension = None
d_eve_exe_name = None
if platform.system() == 'Windows':
if 'PROGRAMFILES(X86)' in os.environ:
d_ise_platform = 'win64'
else:
d_ise_platform = 'windows'
d_eve_exe_name = 'ec.exe'
d_ise_c_compiler = 'msc'
d_archive_extension = '7z'
elif platform.system() == 'Linux':
if platform.architecture()[0] == '64bit':
d_ise_platform = 'linux-x86-64'
else:
d_ise_platform = 'linux-x86'
d_eve_exe_name = 'ec'
d_ise_c_compiler = 'gcc'
d_archive_extension = 'tar.bz2'
else:
SystemLogger.error("Platform " + platform.system() + " not supported")
sys.exit()
# ----------------------------------------------------------------------------
# helper functions: process
# ----------------------------------------------------------------------------
def execute(program, output_file = None, execution_directory = None):
SystemLogger.debug("Executing " + ' '.join(program))
if isinstance(output_file, str):
pipe = open(output_file, 'a')
else:
pipe = output_file
if execution_directory is None:
proc = subprocess.Popen(program, stdin=pipe, stdout=pipe, stderr=pipe)
else:
proc = subprocess.Popen(program, cwd=execution_directory, stdin=pipe, stdout=pipe, stderr=pipe)
proc.communicate()
if isinstance(output_file, str):
pipe.close()
SystemLogger.debug("Finished with code " + str(proc.returncode))
return proc.returncode
# ----------------------------------------------------------------------------
# helper functions: files
# ----------------------------------------------------------------------------
def download_file(url, filename):
SystemLogger.debug("Downloading file")
SystemLogger.debug("URL: " + url)
SystemLogger.debug("Path: " + filename)
try:
response = urllib2.urlopen(url)
data = response.read()
path = os.path.realpath(filename)
with open(path, "wb") as file:
file.write(data)
SystemLogger.debug("Download complete")
except URLError as e:
path = None
if hasattr(e, 'reason'):
SystemLogger.error("Download of '" + url + "' failed. Reason: " + e.reason)
elif hasattr(e, 'code'):
SystemLogger.error("Download of '" + url + "' failed with HTTP error code " + str(e.code))
else:
raise e
return path
def replace_in_file(path, search, replace):
SystemLogger.debug("Replacing in file")
SystemLogger.debug("Path: " + path)
SystemLogger.debug("Search: " + search)
SystemLogger.debug("Replace: " + replace)
import fileinput
for line in fileinput.FileInput(path, inplace=1):
line = line.replace(search, replace)
print (line),
# ----------------------------------------------------------------------------
# helper functions: email
# ----------------------------------------------------------------------------
import smtplib
try:
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
except ImportError:
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email import encoders
def send_mail(to, subject, text, attach=None):
"""Send email"""
SystemLogger.info("Sending email '" + subject + "' to " + str(to))
if to != None:
email_user = "[email protected]"
msg = MIMEMultipart()
msg['From'] = "EVE <" + email_user + ">"
msg['To'] = to
msg['Subject'] = subject
msg.attach(MIMEText(text))
if attach != None:
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(attach, 'rb').read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(attach))
msg.attach(part)
mailServer = smtplib.SMTP("smtp0.ethz.ch", 25, "localhost")
mailServer.sendmail(email_user, to, msg.as_string())
mailServer.quit()
# ----------------------------------------------------------------------------
# update EiffelStudio
# ----------------------------------------------------------------------------
def update_EiffelStudio():
SystemLogger.info("Updating EiffelStudio")
if v_force_es_version != None:
SystemLogger.warning("Forcing EiffelStudio version " + v_force_es_version)
name, filename, version, url = get_nightly_build(d_ise_platform, d_archive_extension)
current_version, current_path = get_installed_version()
if version > current_version or (v_force_es_version != None and current_version != v_force_es_version):
target_file = os.path.join(v_dir_eiffelstudio_base, filename)
download_file(url, target_file)
eutils.extract(target_file)
elocation.move(os.path.join('.', name), os.path.join(v_dir_eiffelstudio_base, name + '_' + str(version)))
elocation.delete(target_file)
update_environment_variables()
current_version = version
SystemLogger.success("EiffelStudio version " + str(version) + " installed")
else:
update_environment_variables()
SystemLogger.success("EiffelStudio is up-to-date at version " + str(current_version))
return current_version
def get_nightly_build(platform, extension):
expr = re.compile(r'.*((Eiffel_[\d.]+)_gpl_([\d]+)-([^.]+)\.([^\s]*)).*')
name = None
filename = None
version = -1
url = None
for download_page in v_url_eiffelstudio_download:
response = urllib2.urlopen(download_page)
for line in response:
m = expr.match(line.decode('utf-8'))
if m != None:
parsed_version = int (m.group (3))
if m.group(4) == platform and m.group(5) == extension and ((v_force_es_version == None and version < parsed_version) or (v_force_es_version != None and v_force_es_version == parsed_version)):
name = m.group(2)
version = parsed_version
filename = m.group(1)
url = download_page + '/' + filename
return name, filename, version, url
def get_installed_version():
files = os.listdir(v_dir_eiffelstudio_base)
version = -1
path = None
for filename in files:
if os.path.isdir(os.path.join (v_dir_eiffelstudio_base, filename)):
#expr = re.compile(r'Eiffel[\d.]+_([\d]+)')
expr = re.compile(r'Eiffel_[\d.]+_([\d]+)')
m = expr.match(filename)
if m != None:
parsed_version = int (m.group(1))
if (v_force_es_version == None and parsed_version > version) or (v_force_es_version != None and parsed_version == v_force_es_version):
version = parsed_version
path = os.path.realpath(os.path.join(v_dir_eiffelstudio_base, filename))
return version, path
# ----------------------------------------------------------------------------
# compile run-time
# ----------------------------------------------------------------------------
#TODO: Get rid of this function.
def compile_runtime():
ecompile.compile_runtime()
def compile_eve(target, binary_name = 'ec'):
l_path = os.path.join ("$EIFFEL_SRC", "Eiffel", "Ace", "ec.ecf")
l_project = ecompile.EiffelProject (l_path, target, binary_name)
l_project.clean()
l_project.freeze()
def finalize_eve(target, binary_name = 'ec'):
l_path = os.path.join ("$EIFFEL_SRC", "Eiffel", "Ace", "ec.ecf")
l_project = ecompile.EiffelProject (l_path, target, binary_name)
l_project.clean()
l_project.finalize()
def is_eve_compilation_successful(target, finalized = False):
success = False
compile_dir = "W_code"
if finalized:
compile_dir = "F_code"
exe_path = os.path.realpath(os.path.join(v_dir_eve_source, "Eiffel", "Ace", "EIFGENs", target, compile_dir, d_eve_exe_name)) #TODO
if os.path.isfile(exe_path):
if execute([exe_path, "-version"], subprocess.PIPE) == 0:
success = True
return success
# ----------------------------------------------------------------------------
# Delivery
# ----------------------------------------------------------------------------
def make_delivery():
SystemLogger.info("Generating new delivery")
eve_version = esvn.info_local_revision_number(v_dir_eve_source) #TODO
delivery_name = 'eve_' + str(eve_version)
delivery_path = os.path.realpath(os.path.join(v_dir_delivery, delivery_name))
# generate finalized version
check_environment_variables()
compile_runtime()
update_version_number()
finalize_eve('bench')
revert_version_number()
# copy EiffelStudio to delivery destination (this copies the runtime)
elocation.copy(os.getenv("ISE_EIFFEL"), delivery_path)
# copy finalized eve to delivery destination
eve_exe_source = os.path.join(v_dir_eve_source, 'Eiffel', 'Ace', 'EIFGENs', 'bench', 'F_code', d_eve_exe_name)
eve_exe_target = os.path.join(delivery_path, 'studio', 'spec', os.getenv("ISE_PLATFORM"), 'bin', d_eve_exe_name)
elocation.copy(eve_exe_source, eve_exe_target)
# AutoProof: copy update to base library
source = os.path.join(v_dir_eve_source, 'library', 'base', 'eve')
target = os.path.join(delivery_path, 'library', 'base', 'eve')
elocation.copy(source, target)
source = os.path.join(v_dir_eve_source, 'library', 'base', 'base2')
target = os.path.join(delivery_path, 'library', 'base', 'base2')
elocation.copy(source, target)
source = os.path.join(v_dir_eve_source, 'library', 'base', 'mml')
target = os.path.join(delivery_path, 'library', 'base', 'mml')
elocation.copy(source, target)
source = os.path.join(v_dir_eve_source, 'library', 'base', 'base-eve.ecf')
target = os.path.join(delivery_path, 'library', 'base', 'base-eve.ecf')
elocation.copy(source, target)
# AutoProof: copy ecf for precompile
source = os.path.join(v_dir_eve_source, 'Delivery', 'precomp', 'spec', 'platform', 'base-eve.ecf')
target = os.path.join(delivery_path, 'precomp', 'spec', os.getenv("ISE_PLATFORM"), 'base-eve.ecf')
elocation.copy(source, target)
# AutoProof: copy Boogie files
source = os.path.join(v_dir_eve_source, 'Delivery', 'studio', 'tools', 'autoproof')
target = os.path.join(delivery_path, 'studio', 'tools', 'autoproof')
elocation.copy(source, target)
# copy Boogie to delivery destination
boogie_target = os.path.join(delivery_path, 'studio', 'tools', 'boogie')
elocation.copy(v_dir_boogie, boogie_target)
# copy libraries to delivery destination
source = os.path.join(v_dir_eve_source, 'library', 'fixing')
target = os.path.join(delivery_path, 'library', 'fixing')
elocation.copy(source, target)
# TODO
# copy install/run scripts to destination
source = os.path.join(v_dir_eve_source, 'Delivery', 'run_eve.bat')
target = os.path.join(delivery_path, 'run_eve.bat')
elocation.copy(source, target)
source = os.path.join(v_dir_eve_source, 'Delivery', 'run_eve.py')
target = os.path.join(delivery_path, 'run_eve.py')
elocation.copy(source, target)
# generate zip archive
archive_path = eutils.compress(delivery_path, delivery_name + "-" + d_ise_platform)
delivery_file = os.path.join(v_dir_delivery, os.path.basename(archive_path))
elocation.move(archive_path, delivery_file)
# clean up
elocation.delete(delivery_path)
SystemLogger.success("Delivery " + delivery_name + " finished")
# upload zip to server
result = None
if os.path.exists(v_dir_delivery_remote):
remote_file = os.path.join(v_dir_delivery_remote, os.path.basename(delivery_file))
elocation.copy(delivery_file, remote_file)
SystemLogger.success("Delivery copied to remote location")
result = v_remote_base_url + '/' + os.path.basename(delivery_file)
else:
if v_dir_delivery_remote != None:
SystemLogger.error("Remote location (" + v_dir_delivery_remote + ") does not exist")
return result
def update_version_number():
file = os.path.join(v_dir_eve_source, 'framework', 'environment', 'interface', 'product_names.e')
replace_in_file(file, 'EiffelStudio', 'EVE')
file = os.path.join(v_dir_eve_source, 'Eiffel', 'API', 'constants', 'system_constants.e')
replace_in_file(file, '0000', str(esvn.info_local_revision_number(v_dir_eve_source)))
def revert_version_number():
file = os.path.join(v_dir_eve_source, 'framework', 'environment', 'interface', 'product_names.e')
replace_in_file(file, 'EVE', 'EiffelStudio')
file = os.path.join(v_dir_eve_source, 'Eiffel', 'API', 'constants', 'system_constants.e')
replace_in_file(file, str(esvn.info_local_revision_number(v_dir_eve_source)), '0000')
# ----------------------------------------------------------------------------
# Merge
# ----------------------------------------------------------------------------
def make_merge():
global v_dir_eve_source
# set up parameters
merge_path = os.path.realpath(v_dir_merge)
v_dir_eve_source = os.path.join(merge_path, 'Src')
os.environ['EIFFEL_SRC'] = v_dir_eve_source
os.environ['ISE_LIBRARY'] = v_dir_eve_source
# update dependencies
update_EiffelStudio()
# update repository
try:
elocation.delete(merge_path)
esvn.update_repository(v_url_svn_eve, merge_path)
except Exception as e1:
SystemLogger.warning("Checkout failed. Trying one more time.")
send_mail(v_email_merge_info, "[EVE] WARNING: checkout failed", "I will try again.")
try:
elocation.delete(merge_path)
esvn.update_repository(v_url_svn_eve, merge_path)
except Exception as e2:
SystemLogger.error("Checkout failed, again...")
send_mail(v_email_merge_info, "[EVE] ERROR: checkout failed again", "I give up...")
sys.exit(0)
# send email to block commits
send_mail(v_email_merge_update, '[EVE] merge started', """Dear assistants,
The eve branch is being synchronized with the trunk.
Please do not commit to the eve branch until the synchronization is complete.
Regards,
EVE""")
# merge
trunk_revision = esvn.info_remote_revision_number(v_url_svn_trunk)
last_merge_revision = esvn.last_merge_revision_number(v_url_svn_eve)
esvn.merge(merge_path, v_url_svn_trunk, pysvn.Revision(pysvn.opt_revision_kind.number, last_merge_revision), pysvn.Revision(pysvn.opt_revision_kind.number, trunk_revision))
# wait for conflicts to be resolved
success = not esvn.has_conflicts(merge_path)
first = True
while not success:
if first:
first = False
SystemLogger.error("Merge has produced conflicts")
send_mail(v_email_merge_info, "[EVE] WAITING: merge produced conflicts", "Resolve conflicts manually and then continue script.")
else:
SystemLogger.error("There are still conflits!")
print ("---")
print ("Press enter when conflicts are resolved.")
input()
success = not esvn.has_conflicts(merge_path)
SystemLogger.success("Merge successful")
# compile
check_environment_variables()
compile_runtime()
compile_eve('bench')
# wait for compilation to be successful
success = is_eve_compilation_successful('bench')
first = True
while not success:
if first:
first = False
SystemLogger.error("EVE compilation failed")
send_mail(v_email_merge_info, "[EVE] WAITING: EVE compilation failed", "Solve compilation problems manually and then continue script.")
else:
SystemLogger.error("compilation still fails!")
print ("---")
print ("Press enter when compilation problems are resolved.")
input()
if not is_eve_compilation_successful('bench'):
compile_runtime()
compile_eve('bench')
success = is_eve_compilation_successful('bench')
SystemLogger.success("Compilation successful")
# commit
message = "<<Merged from trunk#" + str(trunk_revision) + ".>>"
esvn.commit(merge_path, message)
first = True
esvn.update (merge_path, True)
while esvn.info_local_revision_number(merge_path) <= trunk_revision and False: #???
if first:
first = False
SystemLogger.error("EVE commit failed")
send_mail(v_email_merge_info, "[EVE] WAITING: commit failed", "Commit manually and then continue script.")
else:
SystemLogger.error("Local revision (" + str(esvn.info_local_revision_number(merge_path)) + ") still smaller than TRUNK (" + str(trunk_revision) + ")")
print ("---")
print ("Press enter when you have commited the repository manually.")
print ("Commit message: " + message)
input()
esvn.update (merge_path, true)
SystemLogger.success("Commit successful")
# make delivery
delivery_url = make_delivery()
version, path = get_installed_version()
# send email
if delivery_url == None:
send_mail(v_email_merge_update, "[EVE] merge completed with trunk#" + str(trunk_revision) + ".", """Dear assistants,
The eve branch is now synchronized with trunk#""" + str(trunk_revision) + """ using EiffelStudio """ + str(version) + """.
You can now update your checkout of eve and commit again.
Regards,
EVE""")
send_mail(v_email_merge_info, "[EVE] Delivery creation failed", "See log for more information.")
else:
send_mail(v_email_merge_update, "[EVE] merge completed with trunk#" + str(trunk_revision) + " and new delivery available.", """Dear assistants,
The eve branch is now synchronized with trunk#""" + str(trunk_revision) + """ using EiffelStudio """ + str(version) + """.
You can now update your checkout of eve and commit again.
A """ + d_ise_platform + """ delivery of EVE has been created and is available at
""" + delivery_url + """
Regards,
EVE""")
# ----------------------------------------------------------------------------
# Environment variables
# ----------------------------------------------------------------------------
def check_environment_variables():
result = True
# ISE_PLATFORM
if not "ISE_PLATFORM" in os.environ:
SystemLogger.error("Environment variable ISE_PLATFORM not set")
result = False
elif os.getenv("ISE_PLATFORM") != d_ise_platform:
SystemLogger.error("Value of environment variable ISE_PLATFORM (" + os.getenv("ISE_PLATFORM") + ") should be '" + d_ise_platform + "'")
result = False
else:
SystemLogger.debug("ISE_PLATFORM = " + os.getenv("ISE_PLATFORM"))
# ISE_EIFFEL
if not "ISE_EIFFEL" in os.environ:
SystemLogger.error("Environment variable ISE_EIFFEL not set")
result = False
elif not os.path.isdir(os.getenv("ISE_EIFFEL")):
SystemLogger.error("Path from environment variable ISE_EIFFEL (" + os.getenv("ISE_EIFFEL") + ") does not exist")
result = False
elif not os.path.isdir(os.path.join(os.getenv("ISE_EIFFEL"), "studio", "spec", os.getenv("ISE_PLATFORM"))):
SystemLogger.error("Installed EiffelStudio version invalid (no directory found under " + os.path.join(os.getenv("ISE_EIFFEL"), "studio", "spec", os.getenv("ISE_PLATFORM")) + ")")
result = False
else:
SystemLogger.debug("ISE_EIFFEL = " + os.getenv("ISE_EIFFEL"))
# ISE_C_COMPILER
if not "ISE_C_COMPILER" in os.environ:
SystemLogger.error("Environment variable ISE_C_COMPILER not set")
result = False
elif os.getenv("ISE_C_COMPILER") != d_ise_c_compiler:
SystemLogger.error("Value of environment variable ISE_C_COMPILER (" + os.getenv("ISE_C_COMPILER") + ") should be '" + d_ise_c_compiler + "'")
result = False
else:
SystemLogger.debug("ISE_C_COMPILER = " + os.getenv("ISE_C_COMPILER"))
# EIFFEL_SRC
if not "EIFFEL_SRC" in os.environ:
SystemLogger.error("Environment variable EIFFEL_SRC not set. EVE compilation not possible")
result = False
elif not os.path.isdir(os.getenv("EIFFEL_SRC")):
SystemLogger.error("Path from environment variable EIFFEL_SRC (" + os.getenv("EIFFEL_SRC") + ") does not exist")
result = False
else:
SystemLogger.debug("EIFFEL_SRC = " + os.getenv("EIFFEL_SRC"))
# EWEASEL
if not "EWEASEL" in os.environ:
SystemLogger.error("Environment variable EWEASEL not set. EVE compilation not possible")
result = False
elif not os.path.isdir(os.getenv("EWEASEL")):
SystemLogger.error("Path from environment variable EWEASEL (" + os.getenv("EWEASEL") + ") does not exist")
result = False
else:
SystemLogger.debug("EWEASEL = " + os.getenv("EWEASEL"))
# ISE_LIBRARY
if not "ISE_LIBRARY" in os.environ:
SystemLogger.error("Environment variable ISE_LIBRARY not set. EVE compilation not possible")
result = False
elif not os.path.isdir(os.getenv("ISE_LIBRARY")):
SystemLogger.error("Path from environment variable ISE_LIBRARY (" + os.getenv("ISE_LIBRARY") + ") does not exist")
result = False
else:
SystemLogger.debug("ISE_LIBRARY = " + os.getenv("ISE_LIBRARY"))
# PATH: EiffelStudio, Boogie, Z3
if not "PATH" in os.environ:
SystemLogger.error("Environment variable PATH not set")
result = False
elif False: # TODO: check PATH contents
result = False
# final check
if result:
SystemLogger.success("Environment variables checked")
return result
def update_environment_variables():
# ISE_PLATFORM
if not "ISE_PLATFORM" in os.environ or os.getenv("ISE_PLATFORM") != d_ise_platform:
set_persistent_environment_variable("ISE_PLATFORM", d_ise_platform)
# ISE_EIFFEL
version, path = get_installed_version()
if "ISE_EIFFEL" in os.environ and path == None:
SystemLogger.debug ("WARNING: No nightly build available. Using ISE_EIFFEL = " + os.getenv("ISE_EIFFEL"))
elif not "ISE_EIFFEL" in os.environ or os.getenv("ISE_EIFFEL") != path:
set_persistent_environment_variable("ISE_EIFFEL", path)
# else:
# raise Exception ("Could not set ISE_EIFFEL environment variable.")
# ISE_C_COMPILER
if not "ISE_C_COMPILER" in os.environ or os.getenv("ISE_C_COMPILER") != d_ise_c_compiler:
set_persistent_environment_variable("ISE_C_COMPILER", d_ise_c_compiler)
# EIFFEL_SRC
eiffel_source = os.path.realpath(elocation.trunk_source())
if not "EIFFEL_SRC" in os.environ or os.getenv("EIFFEL_SRC") != eiffel_source:
set_persistent_environment_variable("EIFFEL_SRC", eiffel_source)
# EWEASEL
if not "EWEASEL" in os.environ or os.getenv("EWEASEL") != elocation.eweasel():
set_persistent_environment_variable("EWEASEL", elocation.eweasel())
# ISE_LIBRARY
eiffel_source = os.path.realpath(elocation.trunk_source())
if not "ISE_LIBRARY" in os.environ or os.getenv("ISE_LIBRARY") != eiffel_source:
set_persistent_environment_variable("ISE_LIBRARY", eiffel_source)
# PATH: EiffelStudio
# TODO: update PATH contents
# Temporary path update for execution in same session
os.environ['PATH'] = os.path.join(os.getenv("ISE_EIFFEL"), 'studio', 'spec', os.getenv("ISE_PLATFORM"), 'bin') + os.pathsep + os.environ['PATH']
if platform.system() != "Windows":
with open (os.path.join (elocation.base_directory(), 'scripts', 'nightly.unix.sh'), 'w') as l_file:
l_file.write ('export ISE_EIFFEL=')
l_file.write (path)
l_file.write ('\n')
return
def set_persistent_environment_variable(varname, value):
SystemLogger.debug("setting environment variable " + varname + " to " + value)
os.environ[varname] = value
if platform.system() == 'Windows':
execute(['setx', varname, value], SystemLogger.get_file())
return
# ----------------------------------------------------------------------------
# Run EiffelStudio or finalized EiffelStudio
# ----------------------------------------------------------------------------
def run_eiffel_studio():
# Select EiffelStudio (or install if not available)
current_version, current_path = get_installed_version()
if current_version == -1:
update_EiffelStudio()
current_version, current_path = get_installed_version()
# Update Environment variables
update_environment_variables()
# Run EiffelStudio
execute(['ec', '-gui'])
def run_eve():
# Select EiffelStudio (or install if not available)
current_version, current_path = get_installed_version()
if current_version == -1:
update_EiffelStudio()
current_version, current_path = get_installed_version()
# Update Environment variables
update_environment_variables()
os.environ["ISE_PRECOMP"] = os.path.join(v_dir_eve_source, "Delivery", "precomp", "spec", "platform"); #TODO
# Run EiffelStudio
exe_path = os.path.realpath(os.path.join(v_dir_eve_source, "Eiffel", "Ace", "EIFGENs", "bench", "F_code", d_eve_exe_name)) #TODO
if os.path.isfile(exe_path):
execute([exe_path, '-gui'])
else:
SystemLogger.error("Finalized eve executable does not exist (" + exe_path + ").")
# ----------------------------------------------------------------------------
# Main program
# ----------------------------------------------------------------------------
def main():
mode = 'default'
submode = None
if (len(sys.argv) > 1):
mode = sys.argv[1]
if (len(sys.argv) > 2):
submode = sys.argv[2]
if mode == 'default':
print('usage:\n'
' eve.py update --- Update or install EiffelStudio; update and compile EVE.\n'
' eve.py finalize eve --- Finalize EVE.\n'
' eve.py eve --- Launch finalized EVE.\n'
' eve.py es --- Launch EiffelStudio.\n')
elif mode == 'es':
run_eiffel_studio()
elif mode == 'eve':
run_eve()
elif mode == 'check':
if not check_environment_variables():
update_environment_variables()
elif mode == 'update' and submode == None:
update_EiffelStudio()
esvn.update_repository(config.v_url_svn_trunk_src, elocation.trunk_source())
compile_runtime()
compile_eve('bench')
elif mode == 'update' and (submode == 'EiffelStudio' or submode == 'es'):
update_EiffelStudio()
elif mode == 'update' and submode == 'source':
esvn.update_repository(config.v_url_svn_trunk_src, elocation.trunk_source())
elif mode == 'compile' and submode == 'runtime':
if not check_environment_variables():
update_environment_variables()
ecompile.compile_runtime()
elif mode == 'compile' and (submode == None or submode == 'eve'):
if not check_environment_variables():
update_environment_variables()
#compile_eve('bench')
compile_eve ('batch', 'ecb')
elif mode == 'finalize' and (submode == None or submode == 'eve'):
if not check_environment_variables():
update_environment_variables()
#finalize_eve('bench')
#finalize_eve ('batch', 'ecb')
finalize_eve ('bench', 'ec')
elif mode == 'delivery':
if not check_environment_variables():
update_environment_variables()
make_delivery()
elif mode == 'merge':
make_merge()
elif mode == 'eweasel':
eweasel.main (sys.argv[1:])
else:
if submode == None:
SystemLogger.error("invalid option " + mode)
else:
SystemLogger.error("invalid option " + mode + " / " + submode)
return
if __name__ == "__main__":
try:
main()
except Exception as e:
import traceback
traceback.print_exc()
input()