Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
work/bootstrap/* linguist-vendored
*.E linguist-language=Eiffel
32 changes: 27 additions & 5 deletions library/tools/eiffel/generation/et_c_generator.e
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ feature {NONE} -- Initialization
c_filenames.set_key_equality_tester (string_equality_tester)
make_rescue_data
make_external_regexps
set_output_directory (file_system.current_working_directory)
end

feature -- Access
Expand Down Expand Up @@ -350,6 +351,20 @@ feature -- Compilation options setting

feature -- Generation

set_output_directory (a_output_directory: STRING)
-- Define the C output directory
require
a_output_directory_not_void: a_output_directory /= Void
do
output_directory := a_output_directory
end

get_output_directory : STRING
-- Return the defined C output directory
do
Result := output_directory
end

generate (a_system_name: STRING)
-- Generate C code and C compilation script file for `current_dynamic_system'.
-- Set `has_fatal_error' if a fatal error occurred.
Expand All @@ -362,6 +377,10 @@ feature -- Generation
c_filenames.wipe_out
end

feature {NONE} -- Generation implementation

output_directory: STRING

feature {NONE} -- Compilation script generation

generate_compilation_script (a_system_name: STRING)
Expand Down Expand Up @@ -503,13 +522,15 @@ feature {NONE} -- Compilation script generation
else
l_script_filename := l_base_name + sh_file_extension
end
create l_file.make (l_script_filename)

create l_file.make (file_system.pathname (output_directory, l_script_filename))
l_file.open_write
if l_file.is_open_write then
if operating_system.is_windows then
l_file.put_line ("@echo off")
else
l_file.put_line ("#!/bin/sh")
l_file.put_line ("cd " + output_directory)
end
-- Compile files in reverse order so that it looks like
-- a countdown since the filenames are numbered.
Expand All @@ -534,7 +555,7 @@ feature {NONE} -- Compilation script generation
l_c_config.search ("rc")
if l_c_config.found then
l_rc_template := l_c_config.found_item
l_rc_filename := l_base_name + rc_file_extension
l_rc_filename := file_system.pathname (output_directory, l_base_name + rc_file_extension)
if file_system.file_exists (l_rc_filename) then
l_res_filename := l_base_name + res_file_extension
l_variables.force (l_rc_filename, "rc_file")
Expand Down Expand Up @@ -778,7 +799,7 @@ feature {NONE} -- C code Generation
old_system_name := system_name
system_name := a_system_name
l_header_filename := a_system_name + h_file_extension
create l_header_file.make (l_header_filename)
create l_header_file.make ( file_system.pathname (output_directory, l_header_filename))
l_header_file.open_write
if not l_header_file.is_open_write then
set_fatal_error
Expand Down Expand Up @@ -28384,7 +28405,7 @@ feature {NONE} -- Output files/buffers
l_header_filename := system_name + h_file_extension
l_filename := system_name + (c_filenames.count + 1).out
c_filenames.force_last (c_file_extension, l_filename)
create l_c_file.make (l_filename + c_file_extension)
create l_c_file.make (file_system.pathname (output_directory, l_filename + c_file_extension))
l_c_file.open_write
c_file := l_c_file
elseif not l_c_file.is_open_write then
Expand Down Expand Up @@ -28464,7 +28485,7 @@ feature {NONE} -- Output files/buffers
l_header_filename := system_name + h_file_extension
l_filename := system_name + (c_filenames.count + 1).out
c_filenames.force_last (cpp_file_extension, l_filename)
create l_cpp_file.make (l_filename + cpp_file_extension)
create l_cpp_file.make (file_system.pathname (output_directory, l_filename + cpp_file_extension))
l_cpp_file.open_write
cpp_file := l_cpp_file
elseif not l_cpp_file.is_open_write then
Expand Down Expand Up @@ -30252,6 +30273,7 @@ invariant
current_file_open_write: current_file.is_open_write
header_file_not_void: header_file /= Void
header_file_open_write: header_file.is_open_write
output_directory_is_valid: file_system.is_valid_directory (output_directory)
current_function_header_buffer_not_void: current_function_header_buffer /= Void
current_function_body_buffer_not_void: current_function_body_buffer /= Void
current_feature_not_void: current_feature /= Void
Expand Down
43 changes: 43 additions & 0 deletions library/utility/support/ut_enum.e
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
note

description:

"Enumerated type skeleton"

library: "Gobo Eiffel Utility Library"
copyright: "Copyright (c) 2015, Eric Bezault and others"
license: "MIT License"

deferred class UT_ENUM[G]

inherit

ANY -- Needed for SE 2.1b1.

feature {NONE}
-- Initialization

make(selected: G)
require
selected_not_void: selected /= Void
do
item := selected
end


feature
-- Access

item: G


feature {}

members: ARRAY [G]
deferred
end

invariant
item_is_valid: members.contains (item)

end
25 changes: 24 additions & 1 deletion src/gec/gec.e
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ feature {NONE} -- Processing
if split_size > 0 then
l_generator.set_split_threshold (split_size)
end
if not file_system.directory_exists (output_directory_generation) then
file_system.create_directory (output_directory_generation)
end
l_generator.set_output_directory (output_directory_generation)
l_generator.generate (l_system_name)
if is_verbose then
error_handler.info_file.put_string ("Never void targets: ")
Expand All @@ -308,7 +312,7 @@ feature {NONE} -- Processing
else
l_filename := l_system_name + ".sh"
end
create l_command.make (file_system.absolute_pathname (l_filename))
create l_command.make (file_system.pathname (output_directory_generation, l_filename))
l_command.execute
if l_command.exit_code /= 0 then
Exceptions.die (1)
Expand Down Expand Up @@ -378,6 +382,16 @@ feature -- Status report
Result := c_compile_option.was_found and then not c_compile_option.parameter
end

output_directory_generation: STRING
-- Get output directory folder for C generator.
do
if c_output_directory_option.parameters.is_empty then
Result := file_system.current_working_directory
else
Result := c_output_directory_option.parameters.item (1)
end
end

no_split: BOOLEAN
-- Should C code be generated into a single file?
do
Expand Down Expand Up @@ -425,6 +439,9 @@ feature -- Argument parsing
c_compile_option: AP_BOOLEAN_OPTION
-- Option for '--cc=<no|yes>'

c_output_directory_option: AP_STRING_OPTION
-- Option for '--cc=<"relative folder">'

split_option: AP_BOOLEAN_OPTION
-- Option for '--split=<no|yes>'

Expand Down Expand Up @@ -482,6 +499,10 @@ feature -- Argument parsing
c_compile_option.set_description ("Should the back-end C compiler be invoked on the generated C code? (default: yes)")
c_compile_option.set_parameter_description ("no|yes")
a_parser.options.force_last (c_compile_option)
create c_output_directory_option.make_with_long_form ("cc-output")
c_output_directory_option.set_description ("Backend output directory (default: current working directory)")
c_output_directory_option.set_parameter_description ("<current working directory>")
a_parser.options.force_last (c_output_directory_option)
-- split
create split_option.make_with_long_form ("split")
split_option.set_description ("Should generated C code be split over several C files instead of being held in a single possibly large C file? (default: yes)")
Expand Down Expand Up @@ -545,6 +566,7 @@ feature -- Argument parsing
silent_flag_not_void: silent_flag /= Void
verbose_flag_not_void: verbose_flag /= Void
c_compile_option_not_void: c_compile_option /= Void
c_output_directory_option_not_void: c_output_directory_option /=Void
split_option_not_void: split_option /= Void
split_size_option_not_void: split_size_option /= Void
gc_option_not_void: gc_option /= Void
Expand All @@ -561,6 +583,7 @@ invariant
silent_flag_not_void: silent_flag /= Void
verbose_flag_not_void: verbose_flag /= Void
c_compile_option_not_void: c_compile_option /= Void
c_output_directory_option_not_void: c_output_directory_option /= Void
split_option_not_void: split_option /= Void
split_size_option_not_void: split_size_option /= Void
new_instance_types_option_not_void: new_instance_types_option /= Void
Expand Down