Class: RBT::Make
Overview
Constant Summary
collapse
- DEFAULT_RUN_ALREADY =
false
LeanPrototype::ALL_COLOUR_METHODS, LeanPrototype::ARRAY_KDE_KONSOLE_COLOURS_IN_USE, LeanPrototype::DAY_NAMES, LeanPrototype::NAMESPACE, LeanPrototype::SILENT_REDIRECTION
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === RBT::Make[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#cat, #cd_back_to_the_current_working_directory, #consider_reporting_how_many_programs_are_registered, #cookbook_files?, #copy_recursively, #delete_code_of_conduct?, #determine_appdir_prefix_from_this_input, #directory_validation?, #do_not_show_names, #fast_return_file_size_of_this_program, #file_last_symlinked_program?, #file_programs_version_url, #gem_version, #is_a_64bit_system?, #is_ccache_available?, #is_porg_available?, #is_this_binary_registered?, #is_this_program_included?, #make_install_command?, #new_cookbook_instance_for, #program_exists?, #publish_list_of_all_programs_version, #rcp, registered_binaries?, #remove_symlink, #rename_kde_konsole_tab, #repackage, #report_n_programs, #report_working_directory, #return_compile_time_statistics, #return_n_random_characters, #return_version_of_this_program, #run_make_then_make_install, #sanitize_url1_entry, #set_source_directory, #show_overview_over_available_utility_scripts, #symlink_all_files_from_this_directory_to_that_directory, #system_tags?, #upload_list_of_all_programs_version, #use_yaml_database_for_tags?, #warn_and_exit, #wget
#a_or_an?, #abbreviations?, #absolute_path, #action, #add_to_the_commandline_arguments, #all_binaries?, #all_files_from, #all_libraries?, #allowed_cookbook_entries?, #appdir_location_of?, #append_onto_the_internal_hash, #append_what_into, #archive_type_of?, #available_programs?, #be_quiet?, #be_verbose?, #begins_with_a_comment?, #capitalize_first_alphabetical_character, #cd_to_the_log_directory, #cd_to_the_temp_directory, #change_directory, #change_permission, #cheering_person?, #chmod, #chop_off_archive, #clear_commandline_arguments, #cliner, #coloured_and_padded_e, #coloured_and_padded_esystem, #coloured_esystem, #colourize_directory_for_system_results, #colourize_this_error, #colourize_this_file_path, #colourize_this_warning, #commandline_arguments?, #commandline_arguments_without_hyphens?, #comment, #convert_dd_mm_yyyy_to_its_long_variant, #convert_env_variable, #copy_directory, #copy_files, #cpr, #create_directory, #current_hour?, #dd_mmm_yyy, #debug, #debug?, #directory_expanded_cookbooks?, #disable_colours, #display_md5sum?, #do_not_debug, #does_the_cookbook_include_this_program?, #does_this_expanded_cookbook_file_exist_for_this_program?, #does_this_file_exist?, #does_this_file_exist_and_is_it_a_file?, #e, #eblue, #ecomment, #ecrimson, #edir, #editor?, #efancy, #eimp, #enable_colours, #enable_debug, #ensure_main_encoding_for, #eparse, #esystem_gold, #etomato, #ewarn, #exit_program, #expanded_cookbooks_directory_exists?, #extract_this_archive, #extract_to?, #file_compiled_programs?, #file_dirname_retaining_trailing_slash, #file_predefined_installation_instructions?, #file_specification_of_registered_cookbook_entries, #find_cookbook_alias_for, #find_this_yaml_file, #first_argument?, #first_non_hyphen_argument?, #get_all_directories_from, #get_all_files_from, #get_all_programs, #get_date, #get_extended_date, #get_files_and_directories_from, #go_to_base_dir, #home_dir?, #host_system?, #infer_the_namespace, #internal_hash?, #internal_hash_set_commandline_arguments, #is_an_archive?, #is_directory?, #is_file?, #is_github_url?, #is_make_available?, #is_meson_installed?, #is_on_gobolinux?, #is_on_windows?, #is_roebe?, #is_superuser?, #is_symlink?, #is_this_a_header?, #is_this_a_library?, #is_this_program_included?, #iso_encoding?, #load_dataset_from_this_expanded_cookbook, #load_yaml, #load_yaml_file_from_the_cookbook_directory_for_this_program, #log_directory?, #main_encoding?, #meson_build_file_exists?, #months?, #move_file, #n_programs_are_available?, #n_programs_available?, #namespace?, #no_directory_exists_at, #no_directory_was_found_at, #no_opn, #no_such_file_exists, #open_in_browser, #open_in_editor, #opncomment, #opne, #opnef, #opnerev, #opnerror, #opnesystem, #opnewarn, #opnfancy, #opnn, #otomato, #packages_directory?, #path_to_this_expanded_cookbooks_dataset, #pkgconfig_directory?, #populate_the_internal_hash_with_default_values, #predefined_installation_instructions?, #prepend_this_commandline_argument, #program_version_of?, #project_base_directory?, #project_yaml_directory?, #query_path?, #rarrow?, #read_file, #read_file_in_default_encoding, #read_file_with_default_encoding, #readlines, #readlines_with_proper_encoding, #register_sigint, #registered_cookbook_entries?, #remove, #remove_archive_from_the_end, #remove_comments_from_each_line, #remove_directory, #remove_double_slashes, #remove_file, #remove_newlines, #remove_parens, #remove_symlink, #remove_the_first_commandline_argument, #remove_this_commandline_argument, #remove_this_entry_from_the_commandline_arguments, #remove_trailing_ANSII_escape_code, #remove_unnecessary_data_from_url, #rename, #report_pwd, #require_the_rbt_aliases, #reset_the_internal_hash, #return_all_archives_from_this_directory, #return_appdir_prefix, #return_commandline_arguments_with_leading_hyphens, #return_current_hour_minutes_second, #return_date, #return_day_of_the_month_based_on_utc, #return_full_time, #return_hours_minutes_seconds_based_on_utc, #return_location_to_this_programs_yaml_file, #return_month_based_on_this_number, #return_month_based_on_utc, #return_opnn, #return_program_name, #return_program_name_for_gobolinux_systems, #return_program_name_via_program_information, #return_pwd, #return_unicode_warning_symbol_or_empty_string, #return_utc, #return_utc_time_in_a_format_similar_to_slackware, #return_weekday_based_on_utc, #return_year_based_on_utc, #rev, #rpn, #run_simulation=, #run_simulation?, #sdir, #sdir_return_pwd, #set_be_silent, #set_be_verbose, #set_first_commandline_argument, #set_namespace, #set_use_colours, #set_use_opn, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #silently_create_this_directory_if_it_does_not_yet_exist, #simp, #source_base_directory?, #ssym, #stderr, #store_into_this_directory?, #string_right_arrow?, #swarn, #symlink, #sysbin_directory?, #sysetc_directory?, #sysinclude_directory?, #syslib_directory?, #sysshare_directory?, #system_directory?, #temp_directory?, #to_bool, #to_camelcase, #to_iso_encoding, #to_unicode, #today?, #touch, #try_to_require_beautiful_url, #try_to_require_the_environment_information_gem, #try_to_require_the_extracter_gem, #try_to_require_the_open_gem, #try_to_require_the_xorg_buffer, #try_to_require_wget, #try_to_return_a_special_compile_component, #unicode_cliner, #unicode_middle_cliner, #use_colours=, #use_colours?, #use_opn=, #use_opn?, #utf_encoding?, #verbose_truth, #word_wrap, #write_what_into, #write_what_into_via_unicode, #yes_or_no
Constructor Details
#initialize(optional_commandline_arguments = ARGV, run_already = DEFAULT_RUN_ALREADY) ⇒ Make
#
initialize
By default run_already will be false, as we wish to let the user more easily decide at which point to .run() on this class.
Do note that this class can also be invoked via the following way:
Make.new { :run }
#
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/rbt/make/make.rb', line 45
def initialize(
optional_commandline_arguments = ARGV,
run_already = DEFAULT_RUN_ALREADY
)
register_sigint
reset
@run_already = run_already
set_commandline_arguments(
optional_commandline_arguments
)
if block_given?
yielded = yield
handle_this_block(yielded)
end
run if @run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
702
703
704
|
# File 'lib/rbt/make/make.rb', line 702
def self.[](i = ARGV)
new(i).run
end
|
Instance Method Details
#append_make_options(i) ⇒ Object
Also known as:
parameters_to_make, append_these_options, append_this_option_to_make, append_these_make_options
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/rbt/make/make.rb', line 209
def append_make_options(i)
if i.is_a? String
if i.include?(',')
i = i.split(',')
elsif i.include?(';')
i = i.split(';')
end
end
@internal_hash[:make_options] << i
@internal_hash[:make_options].flatten!
end
|
#append_these_options? ⇒ Boolean
Also known as:
make_options?
#
append_these_options?
#
241
242
243
|
# File 'lib/rbt/make/make.rb', line 241
def append_these_options?
@internal_hash[:make_options]
end
|
#colourize_parser? ⇒ Boolean
Also known as:
cparser?
180
181
182
|
# File 'lib/rbt/make/make.rb', line 180
def colourize_parser?
@colourize_parser
end
|
#determine_which_commands_to_run ⇒ Object
#
determine_which_commands_to_run
#
152
153
154
|
# File 'lib/rbt/make/make.rb', line 152
def determine_which_commands_to_run
@array_run_these_commands << @internal_hash[:use_this_make_command]
end
|
#do_not_run_make ⇒ Object
642
643
644
|
# File 'lib/rbt/make/make.rb', line 642
def do_not_run_make
@run_make = false
end
|
#do_run_make_install ⇒ Object
276
277
278
|
# File 'lib/rbt/make/make.rb', line 276
def do_run_make_install
@run_make_install = true
end
|
#do_run_the_commands(i = @array_run_these_commands) ⇒ Object
#
do_run_the_commands (system tag)
This is the main powerhorse method of this class, aka the most important one.
#
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
|
# File 'lib/rbt/make/make.rb', line 652
def do_run_the_commands(
i = @array_run_these_commands
)
if @run_make
i.each {|entry|
unless @internal_hash[:make_options].empty?
entry = entry.dup if entry.frozen?
entry << ' '+joined_make_options?
end
entry = entry.dup if entry.frozen?
entry.squeeze!(' ')
entry << SILENT_REDIRECTION if silent_redirection?
now_running(entry)
run_this_command_via_io_popen(entry)
}
end
if run_make_install?
if use_porg?
entry = "porg -lp #{@program_name_and_program_version} \"#{make_command?} install\""
now_running(entry)
run_this_command_via_io_popen(entry)
else
cmd_to_run = "#{make_command?} install".squeeze(' ')
esystem cmd_to_run
end
end
end
|
#do_run_the_make_install_step_as_well ⇒ Object
#
do_run_the_make_install_step_as_well
#
248
249
250
|
# File 'lib/rbt/make/make.rb', line 248
def do_run_the_make_install_step_as_well
determine_whether_to_run_make_install(:yup)
end
|
#do_use_ninja ⇒ Object
Also known as:
use_ninja
418
419
420
|
# File 'lib/rbt/make/make.rb', line 418
def do_use_ninja
set_use_this_command :ninja
end
|
#do_use_porg ⇒ Object
159
160
161
|
# File 'lib/rbt/make/make.rb', line 159
def do_use_porg
@internal_hash[:use_porg] = true
end
|
#esystem(i) ⇒ Object
#
esystem
The following is an adaptation to esystem() defined on the toplevel namespace. Internally we use IO.popen, but this is only equivalent to system(), so the leading e (for puts) is omitted. Thus we must display it here, before then calling popen.
#
633
634
635
636
637
|
# File 'lib/rbt/make/make.rb', line 633
def esystem(i)
now_running(i) run_this_command_via_io_popen(i)
end
|
#handle_hash_or_symbol(i) ⇒ Object
#
handle_hash_or_symbol
#
283
284
285
286
287
288
289
|
# File 'lib/rbt/make/make.rb', line 283
def handle_hash_or_symbol(i)
if i.is_a? Hash
handle_this_hash(i)
elsif i.is_a? Symbol
handle_this_symbol(i)
end
end
|
#handle_symbols(i = nil) ⇒ Object
Also known as:
determine_whether_to_run_make_install, handle_this_symbol
#
handle_symbols
This method will specifically handle Symbols passed as a block to .new().
#
374
375
376
377
378
379
380
381
382
383
384
|
# File 'lib/rbt/make/make.rb', line 374
def handle_symbols(i = nil)
return unless i
case i
when :run,
:do_run
@run_already = true
when :and_run_make_install_as_well,
:yup
@run_make_install = true
end
end
|
#handle_this_hash(yielded) ⇒ Object
Also known as:
handle_this_block
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
|
# File 'lib/rbt/make/make.rb', line 294
def handle_this_hash(yielded)
if yielded.is_a? Hash
if yielded.has_key? :pad_the_output
set_pad_the_output(yielded[:pad_the_output])
end
if yielded.has_key? :append_these_options
_ = yielded[:append_these_options]
_ = _.join(' ').strip if _.is_a? Array
append_these_options(_.to_s)
elsif yielded.has_key?(:append)
append_these_options(yielded[:append].to_s)
end
if yielded.has_key? :run_make
@run_make = yielded.delete(:run_make)
end
if yielded.has_key? :use_this_make_command
use_this_command = yielded.delete(:use_this_make_command)
set_use_this_make_command(
use_this_command
)
end
if yielded.has_key? :use_porg
use_porg = yielded.delete(:use_porg)
set_use_porg(
use_porg
)
end
if yielded.has_key? :program_name_and_program_version
set_program_name_and_program_version(
yielded.delete(:program_name_and_program_version)
)
end
if yielded.has_key? :use_colours
set_use_colours(
yielded.delete(:use_colours)
)
end
if yielded.has_key? :run_make_install
set_run_make_install(
yielded.delete(:run_make_install)
)
end
elsif yielded.is_a? Symbol
handle_symbols(yielded)
end
end
|
#history_of_commands_run? ⇒ Boolean
#
history_of_commands_run?
#
255
256
257
|
# File 'lib/rbt/make/make.rb', line 255
def history_of_commands_run?
@array_history_of_commands_run
end
|
#joined_make_options? ⇒ Boolean
#
joined_make_options?
This method will return a String variant of the content found in We have to apply only .rstrip here because there may be valid padding on the left hand side, such as ‘ install’, which may become ‘make install’ subsequently.
#
202
203
204
|
# File 'lib/rbt/make/make.rb', line 202
def joined_make_options?
@internal_hash[:make_options].join(' ').rstrip
end
|
#make ⇒ Object
#
make
This method will essentially just run “make”, with any options given to make on top of that.
#
502
503
504
505
|
# File 'lib/rbt/make/make.rb', line 502
def make
cmd = "make #{joined_make_options?}".strip
esystem cmd
end
|
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
|
# File 'lib/rbt/make/make.rb', line 563
def (
i = commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?fast$/
e 'We will use "make -j 4".'
set_use_this_command 'make -j 4'
when /^--ninja$/
do_use_ninja
do_run_the_make_install_step_as_well
when /^--porg$/
do_use_porg
do_run_the_make_install_step_as_well
when /-?-?help$/
show_help
exit
when /-?-?install/,
/-?-?ins/,
/-?-?i$/
set_use_this_command 'make install'
when /^-?-?make(-|_)?install$/i,
/^-?-?install$/i
do_run_make_install
end
end
end
|
#now_running(i) ⇒ Object
432
433
434
435
|
# File 'lib/rbt/make/make.rb', line 432
def now_running(i)
e "#{rev}Now running `#{mediumturquoise(i)}#{rev}` "\
"from #{sdir_return_pwd}#{rev}."
end
|
#pad_the_output? ⇒ Boolean
556
557
558
|
# File 'lib/rbt/make/make.rb', line 556
def pad_the_output?
@internal_hash[:pad_the_output]
end
|
#reset ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/rbt/make/make.rb', line 68
def reset
super()
infer_the_namespace
@run_make = true @run_make_install = false
reset_internal_dataset
end
|
#reset_internal_dataset ⇒ Object
#
reset_internal_dataset
#
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
|
# File 'lib/rbt/make/make.rb', line 85
def reset_internal_dataset
@array_history_of_commands_run = []
@internal_hash[:make_options] = []
@internal_hash[:use_this_make_command] = 'make'
@internal_hash[:pad_the_output] = false
@array_run_these_commands = []
@colourize_parser = RBT::ColourizeParser.new
@internal_hash[:use_porg] = false
@program_name_and_program_version = nil
end
|
#run ⇒ Object
690
691
692
693
694
695
696
697
|
# File 'lib/rbt/make/make.rb', line 690
def run
if block_given?
determine_whether_to_run_make_install(yield)
end
determine_which_commands_to_run
do_run_the_commands
end
|
#run_make_install? ⇒ Boolean
269
270
271
|
# File 'lib/rbt/make/make.rb', line 269
def run_make_install?
@run_make_install
end
|
#run_this_command_via_io_popen(entry) ⇒ Object
Also known as:
run_this_sys_command
#
run_this_command_via_io_popen
#
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
|
# File 'lib/rbt/make/make.rb', line 440
def run_this_command_via_io_popen(entry)
cparser = cparser?
case entry
when /^make/
unless is_make_available?
opne tomato('Note that no binary called ')+sfancy('make')+
tomato(' is available on this computer system.')
opne tomato('This means that compilation will typically not work.')
opne tomato('Thus, we end here at this point - you will need '\
'a version of ')+sfancy('make')+tomato('.')
exit_program
end
end
io_object = IO.popen(entry, :err => [:child, :out]).each { |line|
if line.include? ' '
begin
line = line.dup if line.frozen?
line.squeeze!(' ')
rescue ArgumentError => error
pp error if is_on_roebe?
end
end
cparser.grab_this_line(line)
line = cparser.line?
@array_history_of_commands_run << line
e line }
io_object.close end
|
#set_commandline_arguments(i = nil) ⇒ Object
#
set_commandline_arguments
#
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
|
# File 'lib/rbt/make/make.rb', line 517
def set_commandline_arguments(
i = nil
)
if i.is_a? Hash
handle_hash_or_symbol(i)
if i.has_key? :use_this_make_command
set_use_this_make_command(
i.delete(:use_this_make_command)
)
end
if i.has_key? :run_make_install
if (i.delete(:run_make_install) == true) try_to_append_this_option_to_make(
' install'
)
end
end
if i.has_key? :run_make
do_not_run_make if i[:run_make] == false
end
end
@internal_hash[:commandline_arguments] = [i].flatten.compact
end
|
#set_pad_the_output(i) ⇒ Object
510
511
512
|
# File 'lib/rbt/make/make.rb', line 510
def set_pad_the_output(i)
@internal_hash[:pad_the_output] = i
end
|
#set_program_name_and_program_version(i) ⇒ Object
#
set_program_name_and_program_version
#
262
263
264
|
# File 'lib/rbt/make/make.rb', line 262
def set_program_name_and_program_version(i)
@program_name_and_program_version = i
end
|
#set_run_make_install(i) ⇒ Object
145
146
147
|
# File 'lib/rbt/make/make.rb', line 145
def set_run_make_install(i)
@run_make_install = i
end
|
#set_use_porg(i = false) ⇒ Object
136
137
138
139
140
|
# File 'lib/rbt/make/make.rb', line 136
def set_use_porg(
i = false
)
@internal_hash[:use_porg] = i
end
|
#set_use_this_make_command(i = :default) ⇒ Object
Also known as:
set_use_this_command
#
set_use_this_make_command
We need this setter-method so that we can toggle between, e. g. “make” or “ninja” or any other similar build system.
#
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
# File 'lib/rbt/make/make.rb', line 393
def set_use_this_make_command(
i = :default
)
case i
when :make_install
i = 'make' append_this_option_to_make('install')
when :ninja
i = 'ninja'
when :rake
i = 'rake'
when :default, nil, :make
i = 'make' end
@internal_hash[:use_this_make_command] = i
end
|
#show_help ⇒ Object
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/rbt/make/make.rb', line 166
def show_help
help_string = <<-EOF
Documented options include:
#{gold('--fast')} # #{slateblue('make use of more than one CPU core')}
EOF
e help_string
end
|
#try_to_append_this(i = ' install') ⇒ Object
Also known as:
try_to_append_this_option_to_make
230
231
232
233
234
235
236
|
# File 'lib/rbt/make/make.rb', line 230
def try_to_append_this(
i = ' install'
)
unless use_which_command?.end_with? i
append_these_make_options(i)
end
end
|
#use_porg? ⇒ Boolean
425
426
427
|
# File 'lib/rbt/make/make.rb', line 425
def use_porg?
@internal_hash[:use_porg]
end
|
#use_which_make_command? ⇒ Boolean
Also known as:
use_which_command?, make_command?
#
use_which_make_command?
#
187
188
189
|
# File 'lib/rbt/make/make.rb', line 187
def use_which_make_command?
@internal_hash[:use_this_make_command]
end
|