easycompile 1.0.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of easycompile might be problematic. Click here for more details.

Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +198 -0
  3. data/bin/easycompile +7 -0
  4. data/doc/DESIGN_DECISIONS.md +34 -0
  5. data/doc/README.gen +181 -0
  6. data/easycompile.gemspec +65 -0
  7. data/lib/easycompile.rb +5 -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 +35 -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 +80 -0
  34. data/lib/easycompile/project/project.rb +29 -0
  35. data/lib/easycompile/requires/require_the_easycompile_project.rb +13 -0
  36. data/lib/easycompile/requires/require_the_toplevel_methods.rb +11 -0
  37. data/lib/easycompile/toplevel_methods/copy_file.rb +23 -0
  38. data/lib/easycompile/toplevel_methods/misc.rb +54 -0
  39. data/lib/easycompile/toplevel_methods/rinstall2.rb +29 -0
  40. data/lib/easycompile/version/version.rb +26 -0
  41. data/lib/easycompile/yaml/name_of_the_build_directory.yml +1 -0
  42. data/test/testing_easycompile.rb +29 -0
  43. metadata +144 -0
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'easycompile/requires/require_the_easycompile_project.rb'
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/change_directory.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ # ========================================================================= #
12
+ # === change_directory (cd tag)
13
+ #
14
+ # Use this method when changing directories.
15
+ # ========================================================================= #
16
+ def change_directory(i)
17
+ if i
18
+ File.expand_path(i) if i.start_with? '.'
19
+ if File.exist?(i)
20
+ Dir.chdir(i)
21
+ else
22
+ show_namespace
23
+ e "Can not change into #{sdir(i)} as it does not exist."
24
+ end
25
+ end
26
+ end; alias cd change_directory # === cd
27
+
28
+ end; end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'easycompile/base/cmake.rb'
6
+ # =========================================================================== #
7
+ module Easycompile
8
+
9
+ class Base
10
+
11
+ # ========================================================================= #
12
+ # === cmake_file?
13
+ #
14
+ # This method wille ssentially refer to "CMakeLists.txt".
15
+ # ========================================================================= #
16
+ def cmake_file?
17
+ CMAKE_FILE
18
+ end
19
+
20
+ # ========================================================================= #
21
+ # === run_cmake_command (cmake tag)
22
+ #
23
+ # Compiling via cmake can yield errors. We will try to capture such
24
+ # an error.
25
+ #
26
+ # Note that cmake-based projects typically require a dedicated build
27
+ # directory - this is why the method do_make_use_of_a_build_directory()
28
+ # is called within this method.
29
+ #
30
+ # cmake -DCMAKE_INSTALL_PREFIX=/usr
31
+ # ========================================================================= #
32
+ def run_cmake_command
33
+ do_make_use_of_a_build_directory
34
+ _ = 'cmake'.dup
35
+ # ======================================================================= #
36
+ # Next, we will use the install prefix.
37
+ # ======================================================================= #
38
+ _ << " -DCMAKE_INSTALL_PREFIX=#{prefix?}"
39
+ _ << ' .'
40
+ _ << '.' if shall_we_create_a_build_directory? # Append this.
41
+ if shall_we_create_a_build_directory?
42
+ use_this_name = name_of_build_directory?
43
+ unless File.directory?(use_this_name)
44
+ opn; e "Next creating the build directory called `"\
45
+ "#{sdir(use_this_name)}`."
46
+ mkdir(use_this_name)
47
+ end
48
+ cd use_this_name
49
+ end
50
+ esystem _
51
+ end; alias run_cmake run_cmake_command # === run_cmake
52
+
53
+ end; end
@@ -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,35 @@
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(optional_shall_we_exit = false)
15
+ if optional_shall_we_exit == :then_exit
16
+ optional_shall_we_exit = true
17
+ end
18
+ e
19
+ opn_namespace; e 'Documented help options are these here:'
20
+ opn_namespace; e
21
+ opn_namespace; ecomment ' --appdir # Compile as Appdir, into '\
22
+ 'its own prefix.'
23
+ opn_namespace; ecomment ' --remove-all-after-compile # Remove '\
24
+ 'the archive after compilation is done.'
25
+ opn_namespace; ecomment ' --with-deps '\
26
+ '# Compile with dependencies.'
27
+ opn_namespace; ecomment ' --extract-to=/Depot/opt/ '\
28
+ '# extract to that particular directory.'
29
+ opn_namespace; ecomment ' --homedir # '\
30
+ 'Compile into the home-directory as prefix'
31
+ opn_namespace; e
32
+ exit if optional_shall_we_exit
33
+ end
34
+
35
+ 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