easycompile 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +216 -0
  3. data/bin/easycompile +7 -0
  4. data/doc/DESIGN_DECISIONS.md +34 -0
  5. data/doc/README.gen +189 -0
  6. data/doc/todo/todo_for_the_easycompile_project.md +0 -0
  7. data/easycompile.gemspec +66 -0
  8. data/lib/easycompile/base/change_directory.rb +28 -0
  9. data/lib/easycompile/base/cmake.rb +53 -0
  10. data/lib/easycompile/base/colours.rb +88 -0
  11. data/lib/easycompile/base/commandline_arguments.rb +37 -0
  12. data/lib/easycompile/base/constants.rb +24 -0
  13. data/lib/easycompile/base/easycompile.rb +22 -0
  14. data/lib/easycompile/base/esystem.rb +59 -0
  15. data/lib/easycompile/base/gem.rb +35 -0
  16. data/lib/easycompile/base/help.rb +38 -0
  17. data/lib/easycompile/base/initialize.rb +33 -0
  18. data/lib/easycompile/base/menu.rb +140 -0
  19. data/lib/easycompile/base/meson_and_ninja.rb +36 -0
  20. data/lib/easycompile/base/misc.rb +1157 -0
  21. data/lib/easycompile/base/opn.rb +27 -0
  22. data/lib/easycompile/base/process_the_input.rb +107 -0
  23. data/lib/easycompile/base/remove.rb +77 -0
  24. data/lib/easycompile/base/reset.rb +140 -0
  25. data/lib/easycompile/base/run.rb +26 -0
  26. data/lib/easycompile/compile_as_appdir/compile_as_appdir.rb +45 -0
  27. data/lib/easycompile/constants/array_possible_archives.rb +45 -0
  28. data/lib/easycompile/constants/constants.rb +21 -0
  29. data/lib/easycompile/constants/file_and_directory_constants.rb +137 -0
  30. data/lib/easycompile/constants/misc.rb +23 -0
  31. data/lib/easycompile/constants/namespace.rb +16 -0
  32. data/lib/easycompile/constants/programs_directory.rb +46 -0
  33. data/lib/easycompile/easycompile/easycompile.rb +89 -0
  34. data/lib/easycompile/images/logo/EASYCOMPILE_LOGO.png +0 -0
  35. data/lib/easycompile/project/project.rb +29 -0
  36. data/lib/easycompile/requires/require_the_easycompile_project.rb +13 -0
  37. data/lib/easycompile/requires/require_the_toplevel_methods.rb +11 -0
  38. data/lib/easycompile/toplevel_methods/copy_file.rb +23 -0
  39. data/lib/easycompile/toplevel_methods/misc.rb +54 -0
  40. data/lib/easycompile/toplevel_methods/rinstall2.rb +29 -0
  41. data/lib/easycompile/version/version.rb +26 -0
  42. data/lib/easycompile/yaml/name_of_the_build_directory.yml +1 -0
  43. data/lib/easycompile.rb +5 -0
  44. data/test/testing_easycompile.rb +29 -0
  45. metadata +147 -0
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # By default we will try to use colours, even if the default value
6
+ # for the toplevel instance variable @can_we_use_colours is set to
7
+ # false - it will typically become true at a later point, in this
8
+ # file.
9
+ # =========================================================================== #
10
+ # require 'easycompile/base/colours.rb'
11
+ # =========================================================================== #
12
+ module Easycompile
13
+
14
+ # =========================================================================== #
15
+ # === @can_we_use_colours
16
+ # =========================================================================== #
17
+ @can_we_use_colours = false
18
+
19
+ # =========================================================================== #
20
+ # === Easycompile.set_can_we_use_colours
21
+ # =========================================================================== #
22
+ def self.set_can_we_use_colours(i = true)
23
+ @can_we_use_colours = i
24
+ end; self.instance_eval { alias can_we_use_colours= set_can_we_use_colours } # === Easycompile.can_we_use_colours=
25
+
26
+ # =========================================================================== #
27
+ # === Easycompile.can_we_use_colours?
28
+ # =========================================================================== #
29
+ def self.can_we_use_colours?
30
+ @can_we_use_colours
31
+ end
32
+
33
+ class Base # === Easycompile::Base
34
+
35
+ begin
36
+ require 'colours'
37
+ ::Easycompile.can_we_use_colours = true
38
+ rescue LoadError
39
+ ::Easycompile.can_we_use_colours = false
40
+ end
41
+
42
+ if ::Easycompile.can_we_use_colours?
43
+ include Colours
44
+ else
45
+ alias e puts
46
+ end
47
+
48
+ # ========================================================================= #
49
+ # === use_colours?
50
+ # ========================================================================= #
51
+ def use_colours?
52
+ ::Easycompile.can_we_use_colours?
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === rev
57
+ # ========================================================================= #
58
+ def rev
59
+ if use_colours?
60
+ ::Colours.rev
61
+ else
62
+ ''
63
+ end
64
+ end
65
+
66
+ # ========================================================================= #
67
+ # === e_colourize
68
+ # ========================================================================= #
69
+ def e_colourize(i)
70
+ if use_colours?
71
+ e sfancy(i)
72
+ else
73
+ e i
74
+ end
75
+ end
76
+
77
+ # ========================================================================= #
78
+ # === ecomment
79
+ # ========================================================================= #
80
+ def ecomment(i)
81
+ if use_colours?
82
+ ::Colours.ecomment(i)
83
+ else
84
+ i
85
+ end
86
+ end
87
+
88
+ end; end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/commandline_arguments.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ # ========================================================================= #
12
+ # === commandline_arguments?
13
+ # ========================================================================= #
14
+ def commandline_arguments?
15
+ @commandline_arguments
16
+ end
17
+
18
+ # ========================================================================= #
19
+ # === set_commandline_arguments
20
+ # ========================================================================= #
21
+ def set_commandline_arguments(i)
22
+ @commandline_arguments = [i].flatten.compact
23
+ end
24
+
25
+ # ========================================================================= #
26
+ # === return_all_arguments_with_hyphens
27
+ #
28
+ # This method will select all commandline arguments that begin with
29
+ # two -- hyphens.
30
+ # ========================================================================= #
31
+ def return_all_arguments_with_hyphens
32
+ @commandline_arguments.select {|entry|
33
+ entry.start_with? '--'
34
+ }
35
+ end
36
+
37
+ end; end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/constants.rb'
6
+ # =========================================================================== #
7
+ require 'easycompile/constants/constants.rb'
8
+
9
+ module Easycompile
10
+
11
+ class Base # === Easycompile::Base
12
+
13
+ include ::Easycompile::Constants
14
+
15
+ # ========================================================================= #
16
+ # === THIS_FILE
17
+ #
18
+ # This constant refers to the main .rb file for class Easycompile::Base,
19
+ # that is the file that contains most of the ruby code for the Base
20
+ # class.
21
+ # ========================================================================= #
22
+ THIS_FILE = "#{PROJECT_BASE_DIR}base/misc.rb"
23
+
24
+ end; end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Easycompile::Base
6
+ #
7
+ # This file will handle the installation of gems, which is the
8
+ # ruby-addon stuff.
9
+ # =========================================================================== #
10
+ # require 'easycompile/base/easycompile.rb'
11
+ # =========================================================================== #
12
+ require 'easycompile/base/change_directory.rb'
13
+ require 'easycompile/base/cmake.rb'
14
+ require 'easycompile/base/constants.rb'
15
+ require 'easycompile/base/initialize.rb'
16
+ require 'easycompile/base/gem.rb'
17
+ require 'easycompile/base/menu.rb'
18
+ require 'easycompile/base/meson_and_ninja.rb'
19
+ require 'easycompile/base/misc.rb'
20
+ require 'easycompile/base/opn.rb'
21
+ require 'easycompile/base/reset.rb'
22
+ require 'easycompile/base/run.rb'
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/esystem.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ require 'easycompile/constants/misc.rb'
12
+ # ========================================================================= #
13
+ # === esystem
14
+ #
15
+ # Run a colourized system() command here.
16
+ #
17
+ # This can either be through oldschool system(), or as of August 2017,
18
+ # preferentially via IO.popen().
19
+ # ========================================================================= #
20
+ def esystem(i)
21
+ e_colourize(i) # Output it here already.
22
+ i = i.dup if i.frozen?
23
+ i << ERROR_LINE
24
+ @result = i # Not in use right now.
25
+ internal_system(i) # Defined in this file here.
26
+ end; alias _ esystem # === _
27
+
28
+ # ========================================================================= #
29
+ # === cparser_is_available?
30
+ #
31
+ # Determine whether we can use the ColourizeParser from the RBT
32
+ # project.
33
+ # ========================================================================= #
34
+ def cparser_is_available?
35
+ Object.const_defined?(:RBT) and
36
+ RBT.const_defined?(:ColourizeParser)
37
+ end
38
+
39
+ # ========================================================================= #
40
+ # === internal_system
41
+ #
42
+ # The key idea for this method is to handle system()-related calls
43
+ # via IO.popen(). This gives us more control over as to what to
44
+ # do with the given input and output.
45
+ # ========================================================================= #
46
+ def internal_system(i)
47
+ cparser_is_available = cparser_is_available?
48
+ cparser = @colourize_parser if cparser_is_available
49
+ io_object = IO.popen(i, :err => [:child, :out]).each { |line|
50
+ if cparser_is_available
51
+ cparser.grab_this_line(line) # The cparser object will deal with colours.
52
+ line = cparser.line?
53
+ end
54
+ e line # Output here.
55
+ }
56
+ io_object.close # Close it here.
57
+ end
58
+
59
+ end; end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This file will handle the installation of gems, which is the
6
+ # ruby-addon stuff.
7
+ # =========================================================================== #
8
+ # require 'easycompile/base/gem.rb'
9
+ # =========================================================================== #
10
+ module Easycompile
11
+
12
+ class Base
13
+
14
+ require 'easycompile/base/esystem.rb'
15
+ # ========================================================================= #
16
+ # === install_this_gem
17
+ #
18
+ # Consistently use this method when trying to install a gem.
19
+ #
20
+ # We will ignore the dependencies, though, to speed up the
21
+ # installation process.
22
+ # ========================================================================= #
23
+ def install_this_gem(i)
24
+ _ = "gem install --ignore-dependencies #{i}"
25
+ esystem(_)
26
+ end
27
+
28
+ # ========================================================================= #
29
+ # === is_a_gem?
30
+ # ========================================================================= #
31
+ def is_a_gem?(i)
32
+ i.end_with? '.gem'
33
+ end
34
+
35
+ end; end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/help.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ # ========================================================================= #
12
+ # === show_help (help tag)
13
+ # ========================================================================= #
14
+ def show_help(
15
+ optional_shall_we_exit = false
16
+ )
17
+ case optional_shall_we_exit
18
+ when :then_exit
19
+ optional_shall_we_exit = true
20
+ end
21
+ e
22
+ opn_namespace; e 'The following help options are documented:'
23
+ e
24
+ ecomment ' --appdir # Compile as Appdir, into '\
25
+ 'its own prefix.'
26
+ ecomment ' --remove-all-after-compile # Remove '\
27
+ 'the archive after compilation is done.'
28
+ ecomment ' --with-deps '\
29
+ '# Compile with dependencies.'
30
+ ecomment ' --extract-to=/Depot/opt/ '\
31
+ '# extract to that particular directory.'
32
+ ecomment ' --homedir # '\
33
+ 'Compile into the home-directory as prefix'
34
+ e
35
+ exit if optional_shall_we_exit
36
+ end
37
+
38
+ end; end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/initialize.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ # ========================================================================= #
12
+ # === initialize
13
+ # ========================================================================= #
14
+ def initialize(
15
+ commandline_arguments = ARGV,
16
+ run_already = true
17
+ )
18
+ reset
19
+ set_commandline_arguments(
20
+ commandline_arguments
21
+ )
22
+ case run_already
23
+ # ======================================================================= #
24
+ # === :dont_run_yet
25
+ # ======================================================================= #
26
+ when :dont_run_yet,
27
+ :do_not_run_yet
28
+ run_already = false
29
+ end
30
+ run if run_already
31
+ end
32
+
33
+ end; end
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/menu.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ # ========================================================================= #
12
+ # === menu
13
+ # ========================================================================= #
14
+ def menu(
15
+ i = commandline_arguments?
16
+ )
17
+ if i.is_a? Array
18
+ i.each {|entry| menu(entry) }
19
+ else
20
+ case i
21
+ # ===================================================================== #
22
+ # === ecompile --home_dir
23
+ # ===================================================================== #
24
+ when /^-?-?home(_|-)?dir$/,
25
+ /^-?-?home(_|-)?directory$/,
26
+ /^-?-?home$/
27
+ set_prefix(:home_directory)
28
+ # ===================================================================== #
29
+ # === ecompile --help
30
+ #
31
+ # This option allows us to show the available help options, on
32
+ # the commandline.
33
+ # ===================================================================== #
34
+ when /^-?-?help$/i,
35
+ /^-?h$/i
36
+ show_help :then_exit
37
+ # ===================================================================== #
38
+ # === easycompile --homedir
39
+ # ===================================================================== #
40
+ when /^-?-?home(_|-)?dir$/i
41
+ use_the_home_directory_as_prefix
42
+ # ===================================================================== #
43
+ # === easycompile --OPEN_ITSELF
44
+ # ===================================================================== #
45
+ when /^-?-?OPEN(_|-)?ITSELF$/i,
46
+ /^-?-?OPEN$i/ # OPEN_SELF
47
+ open_this_file
48
+ exit
49
+ # ===================================================================== #
50
+ # === ALL
51
+ # ===================================================================== #
52
+ when /^-?-?all$/i,
53
+ /^-?-?everything$/i
54
+ set_compile_these_programs Dir['*']
55
+ # ===================================================================== #
56
+ # === --remove-all-after-compile
57
+ # ===================================================================== #
58
+ when /^-?-?remove(_|-| )?all(_|-| )?after(_|-| )?compile$/i
59
+ do_remove_all_after_compile
60
+ # ===================================================================== #
61
+ # === set_extract_to
62
+ #
63
+ # This entry allows us to define a custom temp-directory.
64
+ #
65
+ # Invocation example:
66
+ #
67
+ # ecompile php* --extract-to=/Depot/opt/
68
+ #
69
+ # ===================================================================== #
70
+ when /^-?-?set(_|-| )?extract(_|-| )?to=(.+)$/i, # $3
71
+ /^-?-?extract(_|-| )?to=(.+)$/i # $2
72
+ _ = $2
73
+ _ = $3.to_s.dup if $3
74
+ set_extract_to(_) { :be_verbose }
75
+ # ===================================================================== #
76
+ # === ecompile --sco
77
+ #
78
+ # Invocation example:
79
+ #
80
+ # ecompile --sco php*xz
81
+ #
82
+ # ===================================================================== #
83
+ when /^-?-?sco$/i,
84
+ /^-?-?extended-configure-options$/i,
85
+ /^-?-?use-configure-options$/i
86
+ @try_to_use_extended_configure_options = true
87
+ # ===================================================================== #
88
+ # === --wdeps
89
+ # ===================================================================== #
90
+ when /^-?-?wdeps$/i,
91
+ /^-?-?with(_|-| )?deps$/i
92
+ do_compile_with_dependencies
93
+ # ===================================================================== #
94
+ # === --skipmakeinstall
95
+ # ===================================================================== #
96
+ when /^-?-?SKIP_?MAKE_?INSTALL/i,
97
+ 'NO_MAKE_INSTALL',
98
+ 'NOMAKEINSTALL',
99
+ 'NOINSTALL',
100
+ 'SKIPINSTALL'
101
+ enable_skip_make_install # Skip the "make install" step.
102
+ # ===================================================================== #
103
+ # === --dontcompile
104
+ # ===================================================================== #
105
+ when /^-?-?DONT(_|-| )?COMPILE$/i
106
+ enable_dont_compile
107
+ # ===================================================================== #
108
+ # === --skip_extracting
109
+ # ===================================================================== #
110
+ when 'SKIP_EXTRACT',
111
+ /^-?-?SKIP(_|-| )?EXTRACTING$/i,
112
+ 'SKIPEXTRACTING'
113
+ skip_extracting
114
+ # ===================================================================== #
115
+ # === --appdir
116
+ # ===================================================================== #
117
+ when /^-?-?appdir$/i
118
+ set_prefix :appdir
119
+ opn; e 'Will compile as AppDir. The prefix now is '+simp(prefix?.to_s)
120
+ else # else tag
121
+ if File.exist?(i) or i.end_with?('.yml')
122
+ add_this_archive(i)
123
+ else
124
+ # ================================================================= #
125
+ # Next, we will attempt to find a valid entry.
126
+ # ================================================================= #
127
+ i = attempt_to_find_a_valid_file(i)
128
+ if i.respond_to?(:select)
129
+ add_these_files(
130
+ i.select {|file|
131
+ File.exist? file.to_s
132
+ }
133
+ )
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+ end; end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/meson_and_ninja.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ # ========================================================================= #
12
+ # === compile_as_meson_based_project
13
+ # ========================================================================= #
14
+ def compile_as_meson_based_project
15
+ use_this_build_directory = name_of_the_build_directory?
16
+ esystem 'meson --prefix='+prefix?+' '+use_this_build_directory
17
+ cd(use_this_build_directory)
18
+ ninjait
19
+ end
20
+
21
+ # ========================================================================= #
22
+ # === does_a_meson_build_file_exist?
23
+ # ========================================================================= #
24
+ def does_a_meson_build_file_exist?
25
+ File.exist?(MESON_BUILD_FILE)
26
+ end
27
+
28
+ # ========================================================================= #
29
+ # === ninjait
30
+ # ========================================================================= #
31
+ def ninjait
32
+ esystem 'ninja'
33
+ esystem 'ninja install'
34
+ end
35
+
36
+ end; end