diff options
author | Frederico Linhares <fred@linhares.blue> | 2022-05-23 16:07:47 -0300 |
---|---|---|
committer | Frederico Linhares <fred@linhares.blue> | 2022-05-23 17:31:11 -0300 |
commit | c85fd4823767733be979cd9b3b9bc8c32afb6dda (patch) | |
tree | aff958199a278706e17d9cb76c63dd705554cd02 | |
parent | 9f3bf608e9b300d7f5c85acf591c7e3c2a0d4f43 (diff) |
buil Create a task that generates a tar.gz package
* Rakefile: Create a task to generate a tar.gz package and add DESTDIR
environment variable to the install task. Both changes help when
generating packages for Linux distributions.
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Rakefile | 33 |
2 files changed, 32 insertions, 4 deletions
@@ -1,4 +1,5 @@ candy_gear doc +pkg -*.o
\ No newline at end of file +*.o @@ -17,11 +17,16 @@ require 'rake/loaders/makefile' OBJ = 'candy_gear' +VERSION = '0.1.0' + DATA_DIR = '/usr/local/share/candy_gear' C_FILES = FileList[ 'src/*.c' ] +C_H_FILES = FileList[ + 'src/*.h' +] C_OBJS = C_FILES.ext('.o') CPP_FILES = FileList[ @@ -57,6 +62,25 @@ rule '.o' => ['.cpp'] do |t| `g++ -c -std=c++17 #{t.source} -o #{t.name}` end +task :pkg do + name = "#{OBJ}-#{VERSION}" + files = + FileList[ + 'CODE_OF_CONDUCT.markdown', + 'Doxyfile', + 'LICENSE.txt', + 'Rakefile', + 'README.markdown' + ] + + C_FILES + + C_H_FILES + + CPP_FILES + + RB_LIBS + + `mkdir -p pkg` + `tar -czvf pkg/#{name}.tar.gz --transform 's,^,#{name}/,' #{files}` +end + task build: OBJ_FILES do libs = LIBRARIES.inject('') {_1 + "-l#{_2} "} @@ -64,9 +88,12 @@ task build: OBJ_FILES do end task :install do - `install #{OBJ} /usr/local/bin` - `install -d #{DATA_DIR}/lib` - RB_LIBS.each {`install #{_1} #{DATA_DIR}/lib`} + destdir = ENV['DESTDIR'] || '' + + `install -d #{destdir}/usr/local/bin` + `install #{OBJ} #{destdir}/usr/local/bin` + `install -d #{destdir}#{DATA_DIR}/lib` + RB_LIBS.each {`install #{_1} #{destdir}#{DATA_DIR}/lib`} end task default: %[build] |