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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b479d95328f8ce9a148d4eb71aac792c0cd17a908fa267a4e6416e98ed875caf
4
+ data.tar.gz: 1fb945e3988bc93ab40487a18045d89582fd156eb502f91702d0e41ca8c556ab
5
+ SHA512:
6
+ metadata.gz: 286ea4df146b3c7ede7bc213df57d59bc3f39996a2a0dd918b7b6b33f110ba00a9b63f7e110d332ad94ce2eb3efca673f8da197de0d6cb4b739ede0f9e3abe51
7
+ data.tar.gz: 8fdbf6fbd1dec2f40c2517a61ed52281aae02e516bca2dbd6d7bd66ed501d2de020a9152af817de524bae2783a2a5ab3f021ebde9125257b75c58d6b9bd660c3
data/README.md ADDED
@@ -0,0 +1,216 @@
1
+ [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](http://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/easycompile.svg)](https://badge.fury.io/rb/easycompile)
4
+
5
+ ## About this project
6
+
7
+ <img src="https://i.imgur.com/iAxqMCE.png" style="margin-left: 2em">
8
+
9
+ This project, called **easycompile**, allows the user to
10
+ quickly compile a given **local archive**, such as
11
+ the **foobar-1.2.3.tar.xz** tarball or
12
+ **barfoo-2.2.zip**.
13
+
14
+ In fact: this is the primary use-case for this project, and
15
+ explains why it has been created years ago. I needed a quick
16
+ way to compile a program into the **/usr/** prefix.
17
+
18
+ Let's showcase a few more specific usage examples for
19
+ **easycompile**, in ruby:
20
+
21
+ Easycompile.new('php-7.0.6.tar.xz')
22
+ Easycompile.compile('php-7.0.6.tar.xz')
23
+ Easycompile['php']
24
+
25
+ The above statements all essentially do the same thing: the
26
+ file called **php-7.0.6.tar.xz** will be compiled, if it exists
27
+ locally in the current directory.
28
+
29
+ The last statement, **Easycompile['php']** tries to **find matching
30
+ files** in the current working directory. This is done via a glob
31
+ operation, such as via **Dir[]**. The advantage here is that it
32
+ is **generic** - you do not need to provide the full name of an
33
+ archive to Easycompile. This can be useful if you do not really
34
+ care about any particular version.
35
+
36
+ You can also specify the full location to the target file,
37
+ e. g. the path too, such as **'/opt/php-7.1.2.tar.xz'**,
38
+ as the first argument to **Easycompile.new**.
39
+
40
+ **.gem files** can also be used, such as shown by the
41
+ following example:
42
+
43
+ easycompile rack-2.0.1.gem
44
+
45
+ Remote files could be used as well, in theory, including programs
46
+ offered through the http/https protocol. That is, you could simply
47
+ pass in the **complete URL**, and Easycompile will try to download
48
+ this remote fila via **wget**. However had, this approach is not
49
+ very reliable - it may be best to just simply download the remote
50
+ archive for now, on your own (via wget), and then work on a
51
+ local copy directly.
52
+
53
+ ## History of the Easycompile project
54
+
55
+ The **easycompile** project was created primarily because I managed to
56
+ break another, larger project, called **rbt** (**ruby build tools**) quite
57
+ a lot in the past. When that other project was broken, it typically took
58
+ some time to fix it, sometimes days or even weeks, and I did not always
59
+ have that time available at my disposal to fix it properly. Since I did
60
+ not want to use shell scripts for compiling different programs, I quickly
61
+ created this smaller project (**easycompile**), and since that day the
62
+ project helps me to quickly compile something **if** rbt is not
63
+ available, or not working, for whatever reason. This sums up most of
64
+ the origins of this project - it is a surrogate helper project.
65
+
66
+ Since RBT has also improved since these old days, the need for
67
+ **easycompile** has diminished significantly - but I keep it around
68
+ still, just in case. One day I may break something again ... **:)**
69
+
70
+ One evident design goal following this history is that the
71
+ Easycompile project has to work when RBT is not available -
72
+ but **if** RBT is available then Easycompile **can** tap into
73
+ some of the functionality, to enhance support of individual
74
+ aspects necessary for compiling a program. A good example
75
+ for this is to re-use the default configure options that
76
+ the RBT project is tracking or querying information stored in
77
+ yaml files.
78
+
79
+ ## Commandline usage for easycompile
80
+
81
+ The commandline variant can be invoked via the **bin/ecompile**
82
+ file. I recommend to use the --user-install option when installing
83
+ easycompile, as all bin/ files will be in a specific
84
+ subdirectory, to which you can then simply modify $PATH for.
85
+
86
+ Say that you have a local file called **php-7.2.0.tar.xz**.
87
+
88
+ Then simply do the following on the commandline:
89
+
90
+ easycompile php-7.2.0.tar.xz
91
+ easycompile php* # Or this variant; is shorter, evidently.
92
+
93
+ ## Support for meson and ninja
94
+
95
+ The easycompile project can compile meson/ninja based programs,
96
+ provided that a file called **meson.build** can be found in the
97
+ **extracted directory**. This requires **a separate build directory**,
98
+ which will default to the name **BUILD_DIRECTORY/** as far as the
99
+ easycompile project is concerned. The name of that build directory
100
+ is kept in a .yml file, the one at
101
+ **easycompile/yaml/name_of_the_build_directory.yml**.
102
+
103
+ ## Commandline options
104
+
105
+ This subsection will show some examples hwo to use the easycompile
106
+ project from the commandline.
107
+
108
+ To compile all local PHP archives in the current working directory:
109
+
110
+ ecompile php*
111
+
112
+ To do the same but specify a particular temp-directory for
113
+ extracting the source archive specifically:
114
+
115
+ ecompile php* --extract-to=/Depot/opt/
116
+ ecompile php* --extract-to=/tmp/
117
+
118
+ To get an overview over the available help options, try:
119
+
120
+ ecompile --help
121
+
122
+ ## Querying whether a given file is an archive
123
+
124
+ A simple toplevel-method can be used to query whether
125
+ a given input (String, such as a filename or filepath)
126
+ is an archive.
127
+
128
+ Usage example:
129
+
130
+ Easycompile.is_an_archive? 'foo.tar.xz' # => true
131
+ Easycompile.is_an_archive? 'foo.zip' # => true
132
+ Easycompile.is_an_archive? 'foo.zap' # => false
133
+
134
+ ## Making use of extended configure options
135
+
136
+ If you have the RBT project installed (see it being available
137
+ on rubygems.org) then you can make use of extended configure
138
+ options as well.
139
+
140
+ What are '**extended configure options**'?
141
+
142
+ Take the program called **sed**. In the RBT project, the
143
+ information in how to compile this program from source
144
+ are stored in the file called **sed.yml**.
145
+
146
+ If you look at that file you will notice that it has
147
+ entries for GNU configure, such as --disable-nls and
148
+ --disable-dependency-tracking. These are options that
149
+ the user typically supplies on the commandline, during
150
+ configure, before running **make** and **make install**.
151
+
152
+ By default this is NOT used, so you have to specifically
153
+ enable this for the current invocation of easycompile.
154
+
155
+ Invocation examples:
156
+
157
+ ecompile --sco php*xz
158
+ ecompile --extended-configure-options php*xz
159
+ ecompile --use-configure-options php*xz
160
+
161
+ This would try to compile the php*xz tarball (which has
162
+ to exist, so download it prior to invoking easycompile).
163
+
164
+ Note that **ecompile** is an alias to **easycompile**
165
+ on my computer system.
166
+
167
+ ## Maintenance mode since as of January 2020
168
+
169
+ Do note that the project is in light maintenance mode since as of
170
+ **January 2020**.
171
+
172
+ What this means is that I will mostly do some bug-fixes here and
173
+ there, and perhaps add a few new light features every some months,
174
+ at best.
175
+
176
+ For a more complete suite of software that goes beyond
177
+ the somewhat narrowly defined goals for **Easycompile**,
178
+ I recommend to make use of the **rbt** (**Ruby Build Tools**)
179
+ software suite instead, which has a much wider scope and
180
+ is more sophisticated than **easycompile**. Easycompile was
181
+ mostly created as a light-weight alternative to RBT, in the
182
+ event that I have to rewrite the RBT project.
183
+
184
+ ## Using the home directory as the user prefix
185
+
186
+ You can pass in --home or --homedir to compile into your
187
+ home directory, for the current compilation run. This
188
+ has been added in June 2020 mostly as a convenience
189
+ feature.
190
+
191
+
192
+ ## Contact information
193
+
194
+ If your creative mind has ideas and specific suggestions to make this
195
+ gem more useful in general, feel free to drop me an email at any
196
+ time, via:
197
+
198
+ shevy@inbox.lt
199
+
200
+ Before that email I used an email account at Google gmail, but in **2021** I
201
+ decided to slowly abandon gmail for various reasons. In part this is because
202
+ the UI annoys me (on non-chrome browser loading takes too long), but also
203
+ because of Google's attempt to establish mass surveillance via its
204
+ federated cohorts sniffing (FLoC). I do not know what happened at Google,
205
+ but enough is enough - there is only so much you can take while supporting
206
+ greed. When it comes to data mining done by private groups, ultimately
207
+ the user became the product.
208
+
209
+ Do keep in mind that responding to emails may take some time,
210
+ depending on the amount of work I may have at that moment, due
211
+ to reallife time constraints. I will, however had, read feedback
212
+ eventually. Patches and code changes are welcome too, of course,
213
+ as long as they are in the spirit of the project at hand, e. g.
214
+ fitting to the general theme. For this I may make use of github
215
+ as a discussion site, but this has a low priority right now.
216
+
data/bin/easycompile ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'easycompile'
6
+
7
+ Easycompile.easycompile(ARGV)
@@ -0,0 +1,34 @@
1
+ The project has a common base, the common actions, and then a specialized
2
+ part. We call the traditional compilation strategy [A], using prefix /usr/,
3
+ and the AppDir approach [B], which will compile into /Programs/NAME/VERSION/
4
+ or /home/Programs/NAME/VERSION/.
5
+
6
+ So as a summary, a short table for this is:
7
+
8
+ [A] '/usr/'
9
+ [B] '/home/Programs/NAME/VERSION/'
10
+
11
+ Common actions possible through this project are:
12
+
13
+ (1) Extraction of an Archive [IMPLEMENTED]
14
+ (2) Installation of gems [IMPLEMENTED]
15
+ (3) Installation via cmake [PARTIALLY IMPLEMENTED]
16
+ (4) Installation via meson/ninja [PARTIALLY IMPLEMENTED]
17
+
18
+ Differential actions are:
19
+
20
+ (1) AppDir compilation and /usr/ prefix compilation will
21
+ logically make use of different prefixes.
22
+ (2) Symlink-actions are only required for the AppDir
23
+ installation approach. For /usr/ we will not need
24
+ to symlink anything.
25
+
26
+ Now that we have defined the common and not common tasks, let's move
27
+ on to how we will do so:
28
+
29
+ - constants.rb # This file will require the other constants.
30
+ - base.rb # is the base class to subclass, called Easycompile::Base.
31
+
32
+ The programs directory is stored in the toplevel instance variable
33
+ called @programs_directory.
34
+
data/doc/README.gen ADDED
@@ -0,0 +1,189 @@
1
+ ADD_RUBY_BADGE
2
+
3
+ ## About this project
4
+
5
+ <img src="https://i.imgur.com/iAxqMCE.png" style="margin-left: 2em">
6
+
7
+ This project, called **easycompile**, allows the user to
8
+ quickly compile a given **local archive**, such as
9
+ the **foobar-1.2.3.tar.xz** tarball or
10
+ **barfoo-2.2.zip**.
11
+
12
+ In fact: this is the primary use-case for this project, and
13
+ explains why it has been created years ago. I needed a quick
14
+ way to compile a program into the **/usr/** prefix.
15
+
16
+ Let's showcase a few more specific usage examples for
17
+ **easycompile**, in ruby:
18
+
19
+ Easycompile.new('php-7.0.6.tar.xz')
20
+ Easycompile.compile('php-7.0.6.tar.xz')
21
+ Easycompile['php']
22
+
23
+ The above statements all essentially do the same thing: the
24
+ file called **php-7.0.6.tar.xz** will be compiled, if it exists
25
+ locally in the current directory.
26
+
27
+ The last statement, **Easycompile['php']** tries to **find matching
28
+ files** in the current working directory. This is done via a glob
29
+ operation, such as via **Dir[]**. The advantage here is that it
30
+ is **generic** - you do not need to provide the full name of an
31
+ archive to Easycompile. This can be useful if you do not really
32
+ care about any particular version.
33
+
34
+ You can also specify the full location to the target file,
35
+ e. g. the path too, such as **'/opt/php-7.1.2.tar.xz'**,
36
+ as the first argument to **Easycompile.new**.
37
+
38
+ **.gem files** can also be used, such as shown by the
39
+ following example:
40
+
41
+ easycompile rack-2.0.1.gem
42
+
43
+ Remote files could be used as well, in theory, including programs
44
+ offered through the http/https protocol. That is, you could simply
45
+ pass in the **complete URL**, and Easycompile will try to download
46
+ this remote fila via **wget**. However had, this approach is not
47
+ very reliable - it may be best to just simply download the remote
48
+ archive for now, on your own (via wget), and then work on a
49
+ local copy directly.
50
+
51
+ ## History of the Easycompile project
52
+
53
+ The **easycompile** project was created primarily because I managed to
54
+ break another, larger project, called **rbt** (**ruby build tools**) quite
55
+ a lot in the past. When that other project was broken, it typically took
56
+ some time to fix it, sometimes days or even weeks, and I did not always
57
+ have that time available at my disposal to fix it properly. Since I did
58
+ not want to use shell scripts for compiling different programs, I quickly
59
+ created this smaller project (**easycompile**), and since that day the
60
+ project helps me to quickly compile something **if** rbt is not
61
+ available, or not working, for whatever reason. This sums up most of
62
+ the origins of this project - it is a surrogate helper project.
63
+
64
+ Since RBT has also improved since these old days, the need for
65
+ **easycompile** has diminished significantly - but I keep it around
66
+ still, just in case. One day I may break something again ... **:)**
67
+
68
+ One evident design goal following this history is that the
69
+ Easycompile project has to work when RBT is not available -
70
+ but **if** RBT is available then Easycompile **can** tap into
71
+ some of the functionality, to enhance support of individual
72
+ aspects necessary for compiling a program. A good example
73
+ for this is to re-use the default configure options that
74
+ the RBT project is tracking or querying information stored in
75
+ yaml files.
76
+
77
+ ## Commandline usage for easycompile
78
+
79
+ The commandline variant can be invoked via the **bin/ecompile**
80
+ file. I recommend to use the --user-install option when installing
81
+ easycompile, as all bin/ files will be in a specific
82
+ subdirectory, to which you can then simply modify $PATH for.
83
+
84
+ Say that you have a local file called **php-7.2.0.tar.xz**.
85
+
86
+ Then simply do the following on the commandline:
87
+
88
+ easycompile php-7.2.0.tar.xz
89
+ easycompile php* # Or this variant; is shorter, evidently.
90
+
91
+ ## Support for meson and ninja
92
+
93
+ The easycompile project can compile meson/ninja based programs,
94
+ provided that a file called **meson.build** can be found in the
95
+ **extracted directory**. This requires **a separate build directory**,
96
+ which will default to the name **BUILD_DIRECTORY/** as far as the
97
+ easycompile project is concerned. The name of that build directory
98
+ is kept in a .yml file, the one at
99
+ **easycompile/yaml/name_of_the_build_directory.yml**.
100
+
101
+ ## Commandline options
102
+
103
+ This subsection will show some examples hwo to use the easycompile
104
+ project from the commandline.
105
+
106
+ To compile all local PHP archives in the current working directory:
107
+
108
+ ecompile php*
109
+
110
+ To do the same but specify a particular temp-directory for
111
+ extracting the source archive specifically:
112
+
113
+ ecompile php* --extract-to=/Depot/opt/
114
+ ecompile php* --extract-to=/tmp/
115
+
116
+ To get an overview over the available help options, try:
117
+
118
+ ecompile --help
119
+
120
+ ## Querying whether a given file is an archive
121
+
122
+ A simple toplevel-method can be used to query whether
123
+ a given input (String, such as a filename or filepath)
124
+ is an archive.
125
+
126
+ Usage example:
127
+
128
+ Easycompile.is_an_archive? 'foo.tar.xz' # => true
129
+ Easycompile.is_an_archive? 'foo.zip' # => true
130
+ Easycompile.is_an_archive? 'foo.zap' # => false
131
+
132
+ ## Making use of extended configure options
133
+
134
+ If you have the RBT project installed (see it being available
135
+ on rubygems.org) then you can make use of extended configure
136
+ options as well.
137
+
138
+ What are '**extended configure options**'?
139
+
140
+ Take the program called **sed**. In the RBT project, the
141
+ information in how to compile this program from source
142
+ are stored in the file called **sed.yml**.
143
+
144
+ If you look at that file you will notice that it has
145
+ entries for GNU configure, such as --disable-nls and
146
+ --disable-dependency-tracking. These are options that
147
+ the user typically supplies on the commandline, during
148
+ configure, before running **make** and **make install**.
149
+
150
+ By default this is NOT used, so you have to specifically
151
+ enable this for the current invocation of easycompile.
152
+
153
+ Invocation examples:
154
+
155
+ ecompile --sco php*xz
156
+ ecompile --extended-configure-options php*xz
157
+ ecompile --use-configure-options php*xz
158
+
159
+ This would try to compile the php*xz tarball (which has
160
+ to exist, so download it prior to invoking easycompile).
161
+
162
+ Note that **ecompile** is an alias to **easycompile**
163
+ on my computer system.
164
+
165
+ ## Maintenance mode since as of January 2020
166
+
167
+ Do note that the project is in light maintenance mode since as of
168
+ **January 2020**.
169
+
170
+ What this means is that I will mostly do some bug-fixes here and
171
+ there, and perhaps add a few new light features every some months,
172
+ at best.
173
+
174
+ For a more complete suite of software that goes beyond
175
+ the somewhat narrowly defined goals for **Easycompile**,
176
+ I recommend to make use of the **rbt** (**Ruby Build Tools**)
177
+ software suite instead, which has a much wider scope and
178
+ is more sophisticated than **easycompile**. Easycompile was
179
+ mostly created as a light-weight alternative to RBT, in the
180
+ event that I have to rewrite the RBT project.
181
+
182
+ ## Using the home directory as the user prefix
183
+
184
+ You can pass in --home or --homedir to compile into your
185
+ home directory, for the current compilation run. This
186
+ has been added in June 2020 mostly as a convenience
187
+ feature.
188
+
189
+ ADD_CONTACT_INFORMATION
File without changes
@@ -0,0 +1,66 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Easycompile.
3
+ # =========================================================================== #
4
+ require 'easycompile/version/version.rb'
5
+ require 'roebe'
6
+
7
+ Gem::Specification.new { |s|
8
+
9
+ s.name = 'easycompile'
10
+ s.version = Easycompile::VERSION
11
+ s.date = Time.now.strftime('%Y-%m-%d')
12
+
13
+ DESCRIPTION = <<-EOF
14
+
15
+ This project is called easycompile.
16
+
17
+ It allows you to compile a given source archive, such as a file
18
+ like "php-7.2.0.tar.xz". By default this will compile into the
19
+ prefix /usr/. In order for this to work, the file at hand
20
+ has to exist; in the case above, the file php-7.2.0.tar.xz
21
+ has to exist locally.
22
+
23
+ For more documentation, have a look at the link called
24
+ Documentation on the bottom right side of this webpage.
25
+
26
+ EOF
27
+
28
+ s.summary = DESCRIPTION
29
+ s.description = DESCRIPTION
30
+ s.extra_rdoc_files = %w()
31
+
32
+ # =============================================================== #
33
+ # Show this when a user installs this project.
34
+ # =============================================================== #
35
+ s.post_install_message = <<-EOF
36
+
37
+ You can run this project by issuing:
38
+
39
+ ecompile
40
+
41
+ on the commandline.
42
+
43
+ See
44
+
45
+ ecompile --help
46
+
47
+ for the available options.
48
+
49
+ EOF
50
+
51
+ s.authors = ['Robert A. Heiler']
52
+ s.email = Roebe.email?
53
+ s.files = Dir['**/*']
54
+ s.executables = Dir['bin/*'].map { |f| File.basename(f) }
55
+ s.license = 'GPL-2.0'
56
+ s.homepage = 'https://rubygems.org/gems/easycompile'
57
+
58
+ s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
59
+ s.required_rubygems_version = '>= '+Gem::VERSION
60
+ s.rubygems_version = '>= '+Gem::VERSION
61
+
62
+ s.add_dependency 'colours'
63
+ s.add_dependency 'opn'
64
+ s.add_dependency 'extracter'
65
+
66
+ }
@@ -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