xezat 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -16
  3. data/lib/xezat/bashvar.rb +15 -0
  4. data/lib/xezat/command/generate.rb +9 -0
  5. data/lib/xezat/command/validate.rb +4 -2
  6. data/lib/xezat/detector/asciidoc.rb +1 -1
  7. data/lib/xezat/detector/autoconf-archive.rb +27 -0
  8. data/lib/xezat/detector/autoconf.rb +1 -1
  9. data/lib/xezat/detector/automake.rb +1 -1
  10. data/lib/xezat/detector/boost.m4.rb +1 -1
  11. data/lib/xezat/detector/cmake.rb +1 -1
  12. data/lib/xezat/detector/docbook2X.rb +1 -1
  13. data/lib/xezat/detector/font-util.rb +20 -0
  14. data/lib/xezat/detector/gengetopt.rb +1 -1
  15. data/lib/xezat/detector/gettext-devel.rb +2 -2
  16. data/lib/xezat/detector/gnulib.rb +1 -1
  17. data/lib/xezat/detector/gobject-introspection.rb +1 -1
  18. data/lib/xezat/detector/halibut.rb +1 -1
  19. data/lib/xezat/detector/libQt5Core-devel.rb +1 -1
  20. data/lib/xezat/detector/libtool.rb +1 -1
  21. data/lib/xezat/detector/make.rb +1 -1
  22. data/lib/xezat/detector/meson.rb +1 -1
  23. data/lib/xezat/detector/nasm.rb +1 -1
  24. data/lib/xezat/detector/ninja.rb +1 -1
  25. data/lib/xezat/detector/python27.rb +1 -1
  26. data/lib/xezat/detector/python36.rb +1 -1
  27. data/lib/xezat/detector/python37.rb +1 -1
  28. data/lib/xezat/detector/python38.rb +1 -1
  29. data/lib/xezat/detector/python39-docutils.rb +2 -2
  30. data/lib/xezat/detector/python39.rb +1 -1
  31. data/lib/xezat/detector/roundup.rb +1 -1
  32. data/lib/xezat/detector/waf.rb +1 -1
  33. data/lib/xezat/detector/xorg-util-macros.rb +20 -0
  34. data/lib/xezat/detectors.rb +1 -1
  35. data/lib/xezat/generator/cmake.rb +44 -0
  36. data/lib/xezat/generator/pkgconfig.rb +5 -7
  37. data/lib/xezat/generator.rb +6 -0
  38. data/lib/xezat/main.rb +1 -0
  39. data/lib/xezat/variables.rb +4 -29
  40. data/lib/xezat/version.rb +1 -1
  41. data/lib/xezat.rb +10 -1
  42. data/share/xezat/autoconf-archive.yml +583 -0
  43. data/share/xezat/bashvar.sh +8 -0
  44. data/share/xezat/template/README.erb +1 -0
  45. data/share/xezat/template/cmake/cmake.erb +22 -0
  46. data/xezat.gemspec +32 -11
  47. metadata +57 -35
  48. data/.fasterer.yml +0 -6
  49. data/.github/workflows/ruby.yml +0 -45
  50. data/.gitignore +0 -11
  51. data/.gitmodules +0 -3
  52. data/.rspec +0 -2
  53. data/.rubocop.yml +0 -36
  54. data/.ruby-version +0 -1
  55. data/Gemfile +0 -8
  56. data/Rakefile +0 -8
  57. data/bin/console +0 -15
  58. data/bin/setup +0 -8
  59. data/share/xezat/var2yaml.sh +0 -32
  60. /data/share/xezat/template/{Makefile.am → pkgconfig/Makefile.am} +0 -0
  61. /data/share/xezat/template/{cmake.erb → pkgconfig/cmake.erb} +0 -0
  62. /data/share/xezat/template/{pkgconfig.erb → pkgconfig/pkgconfig.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bca5b54e336456b6aa2c9cc5af28c2f40c896e536a44df6374ce39dfdab700d
4
- data.tar.gz: fce7bb85622494444eb694b0973437b85de48d8ffb3e71cac01e118f08eda012
3
+ metadata.gz: 971a71dc0eae6338466af60e22d6cce153514be903f36ce3b8466cbe8e197f8d
4
+ data.tar.gz: 97ec5d3fd7386ae4022dc488e8fd1bb239629e91a54b606347fca99c3128378c
5
5
  SHA512:
6
- metadata.gz: 8ccfb592b7c4462ec9b9ffbf71db32e8fa7749ca858760a85c67925ec4b9ba276b264365d8737aa34462f3ac1765580ff783b1815af277e85d6adc03c23c53bc
7
- data.tar.gz: 6a2a950848dae1d7cb967555209cb61e78d711659aac02ea6fa85061625ba381845b585d559667fc8e55aa78cba5bcef131b293530895f8a74d0b8b823c07914
6
+ metadata.gz: a092f71a8b3f282c2d48dc736df3fc6081d8c1ec23bbb5de81f05db9a8e58e45eca00f193819e67d6680ff7c2ec8dcb0bd59c2fdafb16be47a2562669d6e5856
7
+ data.tar.gz: 7dda61ff0a0a7234486f085705b8bd2f0f2e19af108c8eb8c1696f224a66a33534069ffd159d76047dd4e31dd13dee32095d5795bdc054e9af744b05a9e4bb85
data/README.md CHANGED
@@ -1,39 +1,59 @@
1
1
  # Xezat
2
2
 
3
3
  [![Actions](https://github.com/fd00/xezat/actions/workflows/ruby.yml/badge.svg)](https://github.com/fd00/xezat/)
4
+ [![Gem Version](https://badge.fury.io/rb/xezat.svg)](https://badge.fury.io/rb/xezat)
4
5
 
5
- xezat helps you win at cygport.
6
+ Xezat is a helper tool for your daily packaging tasks with [Cygport](httpss://cygwin.com/cygport/).
6
7
 
7
- ## Installation
8
+ ## Features
8
9
 
9
- Add this line to your application's Gemfile:
10
+ Xezat provides the following subcommands through the `xezat` command:
10
11
 
11
- ```ruby
12
- gem 'xezat'
13
- ```
12
+ * `init`: Interactively generates a new `cygport` file.
13
+ * `bump`: Bumps the package version and updates the `README` file.
14
+ * `validate`: Validates that the `cygport` file and related files adhere to conventions.
15
+ * `port`: Copies the `cygport` to a Git repository.
16
+ * `announce`: Generates a template for ITP (Intent to Package) or `cygport` update announcements.
17
+ * `doctor`: Checks your system for potential problems.
18
+ * `generate`: Generates development files used by `cygport`.
19
+ * `debug`: Assists in debugging `cygport` files.
14
20
 
15
- And then execute:
21
+ You can check the details of each command with `xezat <command> --help`.
16
22
 
17
- $ bundle
23
+ ## Installation
18
24
 
19
- Or install it yourself as:
25
+ Install the gem:
20
26
 
21
- $ gem install xezat
27
+ ```bash
28
+ gem install xezat
29
+ ```
22
30
 
23
31
  ## Usage
24
32
 
25
- TODO: Write usage instructions here
33
+ ### 1. Creating a new package
34
+
35
+ ```bash
36
+ xezat init foo.cygport
37
+ ```
26
38
 
27
- ## Development
39
+ ### 2. Bumping the version
28
40
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+ ```bash
42
+ xezat bump foo.cygport
43
+ ```
30
44
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+ ### 3. Validating the package
46
+
47
+ ```bash
48
+ xezat validate foo.cygport
49
+ ```
32
50
 
33
51
  ## Contributing
34
52
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/fd00/xezat.
53
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/fd00/xezat](https://github.com/fd00/xezat).
54
+
55
+ This project utilizes Google Gemini for development assistance.
36
56
 
37
57
  ## License
38
58
 
39
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bashvar'
4
+ require 'open3'
5
+ require 'xezat'
6
+
7
+ module Xezat
8
+ def bashvar(cygport)
9
+ command = ['bash', File.expand_path(File.join(DATA_DIR, 'bashvar.sh')), cygport]
10
+ result, error, status = Open3.capture3(command.join(' '))
11
+ raise CygportProcessError, error unless status.success?
12
+
13
+ BashVar.parse(result, symbolize_names: true)
14
+ end
15
+ end
@@ -13,6 +13,15 @@ module Xezat
13
13
  require 'xezat/generator/pkgconfig'
14
14
  Generator::Pkgconfig.new(options, cygport).generate
15
15
  end
16
+
17
+ desc 'cmake cygport', 'Generate CMakeLists.txt'
18
+ option :overwrite, type: :boolean, aliases: '-o', desc: 'overwrite CMakeLists.txt'
19
+ option :srcdir, type: :string, aliases: '-s', desc: 'relative path to CMakeLists.txt'
20
+
21
+ def cmake(cygport)
22
+ require 'xezat/generator/cmake'
23
+ Generator::CMake.new(options, cygport).generate
24
+ end
16
25
  end
17
26
  end
18
27
  end
@@ -58,8 +58,10 @@ module Xezat
58
58
 
59
59
  def validate_category(category)
60
60
  categories_file = File.expand_path(File.join(DATA_DIR, 'categories.yaml'))
61
- Xezat.logger.error(" Category is invalid : #{category}") unless
62
- YAML.safe_load(File.open(categories_file), symbolize_names: true, permitted_classes: [Symbol]).include?(category.downcase)
61
+ valid_categories = YAML.safe_load(File.open(categories_file), symbolize_names: true, permitted_classes: [Symbol])
62
+ category.split.each do |cat|
63
+ Xezat.logger.error(" Category is invalid : #{cat}") unless valid_categories.include?(cat.downcase)
64
+ end
63
65
  end
64
66
 
65
67
  def validate_homepage(homepage)
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Asciidoc
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:S]) do |file|
10
10
  next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
11
 
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xezat
4
+ module Detector
5
+ class AutoconfArchive
6
+ def detect?(variables)
7
+ return false unless variables.keys.index do |key|
8
+ %i[_cmake_CYGCLASS_ _meson_CYGCLASS_ _ninja_CYGCLASS_].include?(key)
9
+ end.nil?
10
+
11
+ autoconf_archive_file = File.expand_path(File.join(DATA_DIR, 'autoconf-archive.yml'))
12
+ autoconf_archive_macros = YAML.safe_load(File.open(autoconf_archive_file), symbolize_names: true, permitted_classes: [Symbol])
13
+
14
+ Find.find(variables[:S]) do |file|
15
+ next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
16
+
17
+ autoconf_archive_macros.each do |macro|
18
+ File.foreach(file) do |line|
19
+ return true if line.scrub.strip.start_with?(macro)
20
+ end
21
+ end
22
+ end
23
+ false
24
+ end
25
+ end
26
+ end
27
+ end
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Autoconf
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return false unless variables.keys.index do |key|
10
10
  %i[_cmake_CYGCLASS_ _meson_CYGCLASS_ _ninja_CYGCLASS_].include?(key)
11
11
  end.nil?
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Automake
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return false unless variables.keys.index do |key|
10
10
  %i[_cmake_CYGCLASS_ _meson_CYGCLASS_ _ninja_CYGCLASS_].include?(key)
11
11
  end.nil?
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class BoostM4
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:S]) do |file|
10
10
  next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
11
 
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Cmake
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  variables.key?(:_cmake_CYGCLASS_)
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Docbook2x
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:S]) do |file|
10
10
  next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
11
 
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'find'
4
+
5
+ module Xezat
6
+ module Detector
7
+ class FontUtil
8
+ def detect?(variables)
9
+ Find.find(variables[:S]) do |file|
10
+ next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
+
12
+ File.foreach(file) do |line|
13
+ return true if line.start_with?('XORG_FONT_MACROS_VERSION')
14
+ end
15
+ end
16
+ false
17
+ end
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Gengetopt
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:S]) do |file|
10
10
  return true if file.end_with?('.ggo', '.ggo.in')
11
11
  end
@@ -3,12 +3,12 @@
3
3
  module Xezat
4
4
  module Detector
5
5
  class GettextDevel
6
- def detect(variables)
6
+ def detect?(variables)
7
7
  Find.find(variables[:S]) do |file|
8
8
  next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
9
9
 
10
10
  File.foreach(file) do |line|
11
- return true if /AM_GNU_GETTEXT|AM_ICONV|AC_GGZ_INTL/.match?(line.lstrip)
11
+ return true if /AM_GNU_GETTEXT|AM_ICONV|AC_GGZ_INTL/.match?(line.scrub.lstrip)
12
12
  end
13
13
  end
14
14
  false
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Gnulib
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  File.foreach(File.join(variables[:top], variables[:cygportfile])) do |line|
10
10
  return true if line.index('gnulib-tools')
11
11
  end
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class GobjectIntrospection
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  File.directory?(File.join(variables[:D], 'usr', 'lib', 'girepository-1.0'))
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Halibut
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:S]) do |file|
10
10
  return true if file.end_with?('.but')
11
11
  end
@@ -3,7 +3,7 @@
3
3
  module Xezat
4
4
  module Detector
5
5
  class Libqt5coreDevel
6
- def detect(variables)
6
+ def detect?(variables)
7
7
  variables.key?(:_qt5_qmake_CYGCLASS_)
8
8
  end
9
9
  end
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Libtool
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:S]) do |file|
10
10
  return true if file.end_with?("#{File::SEPARATOR}ltmain.sh")
11
11
  end
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Make
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:B]) do |file|
10
10
  return true if file.end_with?("#{File::SEPARATOR}Makefile", "#{File::SEPARATOR}makefile")
11
11
  end
@@ -3,7 +3,7 @@
3
3
  module Xezat
4
4
  module Detector
5
5
  class Meson
6
- def detect(variables)
6
+ def detect?(variables)
7
7
  variables.key?(:_meson_CYGCLASS_)
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module Xezat
4
4
  module Detector
5
5
  class Nasm
6
- def detect(variables)
6
+ def detect?(variables)
7
7
  if variables.key?(:_meson_CYGCLASS_)
8
8
  File.foreach(File.join(variables[:S], 'meson.build')) do |line|
9
9
  return true if line.include?("find_program('nasm')")
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Ninja
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return true if variables.key?(:_meson_CYGCLASS_)
10
10
 
11
11
  Find.find(variables[:B]) do |file|
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Python27
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return true if File.directory?(File.join(variables[:D], 'usr', 'lib', 'python2.7'))
10
10
 
11
11
  Find.find(variables[:D]) do |file|
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Python36
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return true if File.directory?(File.join(variables[:D], 'usr', 'lib', 'python3.6'))
10
10
 
11
11
  Find.find(variables[:D]) do |file|
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Python37
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return true if File.directory?(File.join(variables[:D], 'usr', 'lib', 'python3.7'))
10
10
 
11
11
  Find.find(variables[:D]) do |file|
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Python38
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return true if File.directory?(File.join(variables[:D], 'usr', 'lib', 'python3.8'))
10
10
 
11
11
  Find.find(variables[:D]) do |file|
@@ -5,12 +5,12 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Python39Docutils
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  Find.find(variables[:S]) do |file|
10
10
  next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
11
 
12
12
  File.foreach(file) do |line|
13
- return true if line.strip.start_with?('AC_CHECK_PROG') && line.index('rst2man').is_a?(Integer)
13
+ return true if line.scrub.strip.start_with?('AC_CHECK_PROG') && line.index('rst2man').is_a?(Integer)
14
14
  end
15
15
  end
16
16
  if variables.key?(:_meson_CYGCLASS_)
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Python39
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  return true if File.directory?(File.join(variables[:D], 'usr', 'lib', 'python3.9'))
10
10
 
11
11
  Find.find(variables[:D]) do |file|
@@ -5,7 +5,7 @@ require 'find'
5
5
  module Xezat
6
6
  module Detector
7
7
  class Roundup
8
- def detect(variables)
8
+ def detect?(variables)
9
9
  File.foreach(File.join(variables[:top], variables[:cygportfile])) do |line|
10
10
  return true if line.index('roundup')
11
11
  end
@@ -3,7 +3,7 @@
3
3
  module Xezat
4
4
  module Detector
5
5
  class Waf
6
- def detect(variables)
6
+ def detect?(variables)
7
7
  if variables.key?(:_waf_CYGCLASS_)
8
8
  Find.find(variables[:S]) do |file|
9
9
  return false if file.end_with?("#{File::SEPARATOR}waf")
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'find'
4
+
5
+ module Xezat
6
+ module Detector
7
+ class XorgUtilMacros
8
+ def detect?(variables)
9
+ Find.find(variables[:S]) do |file|
10
+ next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")
11
+
12
+ File.foreach(file) do |line|
13
+ return true if line.start_with?('XORG_MACROS_VERSION')
14
+ end
15
+ end
16
+ false
17
+ end
18
+ end
19
+ end
20
+ end
@@ -20,7 +20,7 @@ module Xezat
20
20
  @detectors.each do |name, detector|
21
21
  if variables[:PN].intern == name
22
22
  Xezat.logger.debug(" #{name} ... no (self)")
23
- elsif detector.detect(variables)
23
+ elsif detector.detect?(variables)
24
24
  tools << name
25
25
  Xezat.logger.debug(" #{name} ... yes")
26
26
  else
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat/generator'
4
+ require 'xezat/variables'
5
+
6
+ module Xezat
7
+ module Generator
8
+ class CMake
9
+ include Xezat
10
+
11
+ def initialize(options, cygport)
12
+ @options = options
13
+ @cygport = cygport
14
+ end
15
+
16
+ def generate
17
+ Xezat.logger.debug('Start CMakeLists.txt generation')
18
+ vars = variables(@cygport)
19
+ generate_cmakelists(vars, @options)
20
+ Xezat.logger.debug('End CMakeLists.txt generation')
21
+ end
22
+
23
+ def generate_cmakelists(variables, options)
24
+ srcdir = variables[:CYGCONF_SOURCE] || variables[:CYGCMAKE_SOURCE] || variables[:S]
25
+ srcdir = File.expand_path(File.join(variables[:S], options['srcdir'])) if options['srcdir']
26
+ Xezat.logger.debug(" srcdir = #{srcdir}")
27
+
28
+ cmakelists = File.expand_path(File.join(srcdir, 'CMakeLists.txt'))
29
+ raise UnregeneratableConfigurationError, 'CMakeLists.txt already exists' if File.exist?(cmakelists) && !options['overwrite']
30
+
31
+ Xezat.logger.debug(' Generate CMakeLists.txt')
32
+
33
+ File.atomic_write(cmakelists) do |f|
34
+ f.write(get_cmakelists(variables))
35
+ end
36
+ end
37
+
38
+ def get_cmakelists(variables)
39
+ erb = File.expand_path(File.join(TEMPLATE_DIR, 'cmake', 'cmake.erb'))
40
+ ERB.new(File.readlines(erb).join(nil), trim_mode: '%-').result(binding)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -3,12 +3,10 @@
3
3
  require 'English'
4
4
  require 'facets/file/atomic_open'
5
5
  require 'facets/file/atomic_write'
6
+ require 'xezat/generator'
6
7
  require 'xezat/variables'
7
8
 
8
9
  module Xezat
9
- class UnregeneratableConfigurationError < StandardError
10
- end
11
-
12
10
  class AutotoolsFileNotFoundError < StandardError
13
11
  end
14
12
 
@@ -51,7 +49,7 @@ module Xezat
51
49
  end
52
50
 
53
51
  def get_pkg_config(variables)
54
- erb = File.expand_path(File.join(TEMPLATE_DIR, 'pkgconfig.erb'))
52
+ erb = File.expand_path(File.join(TEMPLATE_DIR, 'pkgconfig', 'pkgconfig.erb'))
55
53
  ERB.new(File.readlines(erb).join(nil), trim_mode: '%-').result(binding)
56
54
  end
57
55
 
@@ -72,7 +70,7 @@ module Xezat
72
70
  end
73
71
 
74
72
  def get_cmakelists(variables)
75
- erb = File.expand_path(File.join(TEMPLATE_DIR, 'cmake.erb'))
73
+ erb = File.expand_path(File.join(TEMPLATE_DIR, 'pkgconfig', 'cmake.erb'))
76
74
  ERB.new(File.readlines(erb).join(nil), trim_mode: '%-').result(binding)
77
75
  end
78
76
 
@@ -84,7 +82,7 @@ module Xezat
84
82
  configure_ac = File.expand_path(File.join(srcdir, 'configure.in')) unless File.exist?(configure_ac)
85
83
  raise AutotoolsFileNotFoundError unless File.exist?(configure_ac)
86
84
 
87
- original_ac = File.read(configure_ac)
85
+ original_ac = File.read(configure_ac).scrub
88
86
 
89
87
  if /#{pn}.pc/.match?(original_ac)
90
88
  Xezat.logger.debug(" Not rewrite #{configure_ac}")
@@ -104,7 +102,7 @@ module Xezat
104
102
  break
105
103
  end
106
104
 
107
- commands_am = File.read(File.expand_path(File.join(TEMPLATE_DIR, 'Makefile.am')))
105
+ commands_am = File.read(File.expand_path(File.join(TEMPLATE_DIR, 'pkgconfig', 'Makefile.am')))
108
106
  File.atomic_open(makefile_am, 'a') do |fm|
109
107
  fm.write(commands_am)
110
108
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xezat
4
+ class UnregeneratableConfigurationError < StandardError
5
+ end
6
+ end
data/lib/xezat/main.rb CHANGED
@@ -8,6 +8,7 @@ require 'xezat/version'
8
8
  module Xezat
9
9
  class Main < Thor
10
10
  include ZshCompletion::Command
11
+
11
12
  class_option :config, type: :string, aliases: '-c', desc: 'specify config', default: CONFIG_FILE
12
13
  class_option :help, type: :boolean, aliases: '-h', desc: 'help message'
13
14
 
@@ -3,11 +3,9 @@
3
3
  require 'English'
4
4
  require 'etc'
5
5
  require 'facets/file/atomic_write'
6
- require 'facets/string/word_wrap'
7
- require 'open3'
8
- require 'uri'
9
6
  require 'yaml'
10
7
  require 'xezat'
8
+ require 'xezat/bashvar'
11
9
 
12
10
  module Xezat
13
11
  def variables(cygport)
@@ -23,36 +21,13 @@ module Xezat
23
21
  end
24
22
  end
25
23
 
26
- command = ['bash', File.expand_path(File.join(DATA_DIR, 'var2yaml.sh')), cygport]
27
- result, error, status = Open3.capture3(command.join(' '))
28
- raise CygportProcessError, error unless status.success?
29
-
30
- result.gsub!(/^.*\*\*\*.*$/, '')
31
-
32
- begin
33
- variables = YAML.safe_load(result, symbolize_names: true, permitted_classes: [Symbol]).each_value do |v|
34
- v.strip! if v.respond_to?(:strip)
35
- end
36
- rescue Psych::SyntaxError => e
37
- print_yaml(result)
38
- raise e
39
- end
40
-
41
- variables[:DESCRIPTION].word_wrap!(79)
24
+ vars = bashvar(cygport)
42
25
 
43
26
  File.atomic_write(cache_file) do |f|
44
27
  Xezat.logger.debug(' Write cache for variables')
45
- f.write(YAML.dump(variables))
28
+ f.write(YAML.dump(vars))
46
29
  end
47
30
 
48
- variables
49
- end
50
-
51
- def print_yaml(result)
52
- lineno = 1
53
- result.split($INPUT_RECORD_SEPARATOR).each do |line|
54
- printf '%<lineno>5d | %<line>s%<ls>s', lineno:, line:, ls: $INPUT_RECORD_SEPARATOR
55
- lineno += 1
56
- end
31
+ vars
57
32
  end
58
33
  end
data/lib/xezat/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xezat
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end