示例#1
0
	def _internal_compile (self, X_code, additional_commands):
		ec_path = os.path.expandvars (os.path.join ("$ISE_EIFFEL", "studio", "spec", "$ISE_PLATFORM", "bin", _append_exe('ec')))
		ecf_path = os.path.join (self._project_path, self._ecf)
		
			# Print some information about the compilation step in the console.
		SystemLogger.info("EiffelStudio: " + ec_path)
		SystemLogger.info("ECF: " + ecf_path)
		SystemLogger.info("Target: " + self._target)
		SystemLogger.info("ISE_EIFFEL: " + os.environ['ISE_EIFFEL'])
		SystemLogger.info("ISE_LIBRARY: " + os.environ['ISE_LIBRARY'])
		SystemLogger.info("EIFFEL_SRC: " + os.environ['EIFFEL_SRC'])
		
		if os.path.isfile (ecf_path):
			
				# Invoke the Eiffel compiler with the right arguments.
			command = [ec_path, '-config', ecf_path, '-batch'] + additional_commands
			code = eutils.execute (command, SystemLogger.get_file(), self._project_path)
			
				# Check if the compilation was successful and store last_result.
			generated_binary = os.path.join (self._project_path, 'EIFGENs', self._target, X_code, self._binary)
			
			if code == 0 and generated_binary != None and os.path.isfile (generated_binary):
				self._last_result = generated_binary
				SystemLogger.success ("Compilation of Eiffel project " + ecf_path + " (" + self._target + ") successful.")
			else:
				self._last_result = None
				SystemLogger.error ("Compilation of Eiffel project " + ecf_path + " (" + self._target + ") failed.")
		else:
			SystemLogger.error("ECF file '" + ecf_path + "' does not exist")
示例#2
0
def precompile(target):
    if target == "all" or target == None:
        precompile("base")
        precompile("base-safe")
        precompile("base-mt")
        precompile("base-scoop-safe")
    else:
        l_path = os.path.expandvars(os.path.join("$ISE_EIFFEL", "precomp", "spec", "$ISE_PLATFORM", target + ".ecf"))
        l_project = ecompile.EiffelProject(l_path, target, "driver")
        if l_project.precompile():
            SystemLogger.success("Precompilation of " + target + " successful.")
        else:
            SystemLogger.error("Precompilation of " + target + " failed.")
示例#3
0
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
示例#4
0
def install():
    assert os.environ["ISE_EIFFEL"] != None, "ISE_EIFFEL is not set."
    assert os.environ["ISE_PLATFORM"] != None, "ISE_PLATFORM is not set."
    assert os.environ["ISE_LIBRARY"] != None, "ISE_LIBRARY is no set."
    assert os.environ["EWEASEL"] != None, "EWEASEL is not set."

    update()

    l_path = os.path.expandvars(os.path.join("$EWEASEL", "source", "eweasel.ecf"))
    l_project = ecompile.EiffelProject(l_path, "eweasel_mt", "eweasel-mt")
    if l_project.finalize():
        l_target_dir = os.path.expandvars(os.path.join("$EWEASEL", "spec", "$ISE_PLATFORM", "bin"))
        if not os.path.exists(l_target_dir):
            os.makedirs(l_target_dir)
        elocation.copy(l_project.last_result(), l_target_dir)
        l_project.clean()
        SystemLogger.success("Eweasel installation successful.")
        SystemLogger.warning("Make sure that $EWEASEL/spec/$ISE_PLATFORM/bin is in your PATH variable!")
    else:
        SystemLogger.error("Installation of eweasel failed.")
示例#5
0
def update_repository(url, path):
	"""Update repository at given path. If no checkout exists, do a new checkout from given url."""
	revision = -1
	if os.path.exists(path):
		SystemLogger.info("Updating repository")
		SystemLogger.info("Path: " + path)
		remote_url = info_remote_url(path)
		if url == remote_url:
			revision = info_local_revision_number(path)
			remote_revision = info_remote_revision_number(url)
			SystemLogger.debug("Local revision: " + str(revision))
			SystemLogger.debug("Remote revision: " + str(remote_revision))
			if revision == remote_revision:
				SystemLogger.success("Repository '" + path + "' is up-to-date at revision " + str(revision))
			else:
				revision = update(path)
				SystemLogger.success("Repository '" + path + "' is updated to revision " + str(revision))
		else:
			SystemLogger.error("Repository URL of existing directory '" + path + "'  does not match expected remote url")
			SystemLogger.error("Existing URL: " + remote_url)
			SystemLogger.error("Expected URL: " + url)
	else:
		SystemLogger.info("Checking out repository")
		SystemLogger.info("URL: " + url)
		SystemLogger.info("Location: " + path)
		revision = checkout(url, path)
		SystemLogger.success("Checkout of revision " + str(revision) + " complete")
	return revision 
示例#6
0
def main ():
	SystemLogger.success ("Starting tests.")
	#test_svn()
	test_location()
	test_compress()
示例#7
0
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
示例#8
0
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""")
示例#9
0
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