qt-commander 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d43a05ff0467ceff3006f621631837aead13a88
|
4
|
+
data.tar.gz: cd9356b3ec8bd829fad5eb8625f336a452fb3399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19fce5a233b3b39ad9d87bf77bf744e2e0c2f36a57257b591f634eb5d448fc46bf4b7f07711ba41ba586605862717890c9b4baa56e62166b421fbdf44fc4c8b6
|
7
|
+
data.tar.gz: 1e7303ff595632e2632d3f9d4d4fa78bb9f938d18fb6d45005b996f9b05b6c68f86e04634d4ea482c5306693310491363bd6d5f38b1c042dc312d36d1c47345c
|
data/lib/qt/commander/creator.rb
CHANGED
@@ -1,4 +1,101 @@
|
|
1
1
|
|
2
|
+
require 'inifile'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
require_relative 'creator/info_object'
|
6
|
+
require_relative 'creator/toolchain'
|
7
|
+
require_relative 'creator/version'
|
8
|
+
require_relative 'creator/profile'
|
9
|
+
|
2
10
|
module Qt::Commander::Creator
|
11
|
+
class << self
|
12
|
+
|
13
|
+
attr_reader :config_ini
|
14
|
+
attr_reader :config_dir
|
15
|
+
|
16
|
+
def config_ini= path
|
17
|
+
@config_ini = path
|
18
|
+
|
19
|
+
@ini = IniFile.new File.read path
|
20
|
+
end
|
21
|
+
|
22
|
+
def config_dir= path
|
23
|
+
@config_dir = path
|
24
|
+
|
25
|
+
update_collection :toolchains, Toolchain, 'toolchains.xml'
|
26
|
+
update_collection :versions, Version, 'qtversion.xml'
|
27
|
+
update_collection :profiles, Profile, 'profiles.xml'
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_reader :ini
|
31
|
+
|
32
|
+
attr_reader :toolchains
|
33
|
+
attr_reader :versions
|
34
|
+
attr_reader :profiles
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def update_collection ivar, kls, file
|
39
|
+
val = File.read File.join @config_dir, file
|
40
|
+
val = parse_qt_xml(val).map do |_, info|
|
41
|
+
kls.new(info) if info.is_a? Hash
|
42
|
+
end.compact
|
43
|
+
instance_variable_set :"@#{ivar}", val
|
44
|
+
end
|
45
|
+
|
46
|
+
def parse_qt_xml string
|
47
|
+
from_value = from_valuelist = from_valuemap = nil
|
48
|
+
|
49
|
+
from_node = Proc.new do |node|
|
50
|
+
case node.name
|
51
|
+
when 'value'; from_value .call node
|
52
|
+
when 'valuelist'; from_valuelist.call node
|
53
|
+
when 'valuemap'; from_valuemap .call node
|
54
|
+
else; raise NotImplementedError, "name == #{node.name.inspect}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
from_value = Proc.new do |node|
|
59
|
+
text = node.children.first.to_s
|
60
|
+
|
61
|
+
case node['type']
|
62
|
+
when 'int'; Integer(text)
|
63
|
+
when 'bool'; text=='true'
|
64
|
+
when 'QString'; text
|
65
|
+
when 'QByteArray'; text
|
66
|
+
else; raise NotImplementedError, "['type'] == #{node['type'].inspect}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
from_valuelist = Proc.new do |node|
|
71
|
+
node.children
|
72
|
+
.reject{ |node| node.is_a? Nokogiri::XML::Text }
|
73
|
+
.each_with_object([]) do |node, ary|
|
74
|
+
ary.push from_node.call node
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
from_valuemap = Proc.new do |node|
|
79
|
+
node.children
|
80
|
+
.reject{ |node| node.is_a? Nokogiri::XML::Text }
|
81
|
+
.each_with_object({}) do |node, h|
|
82
|
+
h[node['key']] = from_node.call node
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Nokogiri::XML.parse(string).xpath('//data')
|
87
|
+
.each_with_object({}) do |node,h|
|
88
|
+
key, val = node.children.reject{ |node| node.is_a? Nokogiri::XML::Text }
|
89
|
+
|
90
|
+
key = key.children.first.to_s
|
91
|
+
val = from_node.call val
|
92
|
+
|
93
|
+
h[key] = val if key and val
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
self.config_ini = File.join Dir.home, ".config/QtProject/QtCreator.ini"
|
99
|
+
self.config_dir = File.join Dir.home, ".config/QtProject/qtcreator"
|
3
100
|
|
4
101
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
module Qt::Commander::Creator
|
3
|
+
class InfoObject
|
4
|
+
|
5
|
+
def self.key name, orig_name, opts={}
|
6
|
+
@keys ||= []
|
7
|
+
@keys << [ name, orig_name, opts ]
|
8
|
+
attr_reader name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.keys
|
12
|
+
@keys ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def [] key
|
17
|
+
instance_variable_get :"@#{key}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize info
|
21
|
+
self.class.keys.each do |name, orig_name, opts|
|
22
|
+
orig_name = [orig_name] unless orig_name.is_a? Array
|
23
|
+
val = info
|
24
|
+
|
25
|
+
orig_name.each do |orig|
|
26
|
+
val = val.fetch(orig) if val.key? orig or !opts[:optional]
|
27
|
+
end
|
28
|
+
|
29
|
+
instance_variable_set :"@#{name}", val unless val == info
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module Qt::Commander::Creator
|
3
|
+
class Profile < InfoObject
|
4
|
+
|
5
|
+
key :name, 'PE.Profile.Name'
|
6
|
+
key :id, 'PE.Profile.Id'
|
7
|
+
key :autodetected, 'PE.Profile.AutoDetected'
|
8
|
+
key :device, ['PE.Profile.Data', 'PE.Profile.Device']
|
9
|
+
key :type, ['PE.Profile.Data', 'PE.Profile.DeviceType']
|
10
|
+
key :sysroot, ['PE.Profile.Data', 'PE.Profile.SysRoot']
|
11
|
+
key :toolchain, ['PE.Profile.Data', 'PE.Profile.ToolChain']
|
12
|
+
key :version, ['PE.Profile.Data', 'QtSupport.QtInformation']
|
13
|
+
|
14
|
+
def initialize info
|
15
|
+
super
|
16
|
+
|
17
|
+
@toolchain = Qt::Commander::Creator.toolchains.detect do |tc|
|
18
|
+
tc.id == @toolchain
|
19
|
+
end
|
20
|
+
|
21
|
+
@version = Qt::Commander::Creator.versions.detect do |tc|
|
22
|
+
tc.id == @version || tc.autodetect_src == @version
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def android?
|
27
|
+
type =~ /Android/
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
module Qt::Commander::Creator
|
3
|
+
class Toolchain < InfoObject
|
4
|
+
|
5
|
+
key :name, 'ProjectExplorer.ToolChain.DisplayName'
|
6
|
+
key :id, 'ProjectExplorer.ToolChain.Id'
|
7
|
+
key :autodetect, 'ProjectExplorer.ToolChain.Autodetect'
|
8
|
+
key :path, 'ProjectExplorer.GccToolChain.Path'
|
9
|
+
key :supported, 'ProjectExplorer.GccToolChain.SupportedAbis'
|
10
|
+
key :target, 'ProjectExplorer.GccToolChain.TargetAbi'
|
11
|
+
|
12
|
+
key :android_ndk_tc_version, 'Qt4ProjectManager.Android.NDK_TC_VERION', optional:true
|
13
|
+
|
14
|
+
def android?
|
15
|
+
target =~ /android/
|
16
|
+
end
|
17
|
+
|
18
|
+
def env
|
19
|
+
if android?
|
20
|
+
envs = {
|
21
|
+
'TOOLCHAIN_PATH' => File.dirname(@path),
|
22
|
+
'TOOLCHAIN_HOST' => File.basename(@path.gsub(/-gcc$/, '')),
|
23
|
+
'TOOLCHAIN_NAME' => File.basename(@path.gsub(/-gcc$/, '-'+@android_ndk_tc_version)),
|
24
|
+
}
|
25
|
+
|
26
|
+
envs['ANDROID_NDK_ROOT'] = ndk_root = \
|
27
|
+
Qt::Commander::Creator.ini['AndroidConfigurations']['NDKLocation']
|
28
|
+
|
29
|
+
sep = File::SEPARATOR
|
30
|
+
tc_path = @path.scan(/#{ndk_root}#{sep}toolchains#{sep}.*?(?=#{sep})/)
|
31
|
+
config_mk = File.read(File.join(tc_path, "config.mk"))
|
32
|
+
|
33
|
+
config_mk =~ /TOOLCHAIN_ARCH\s*\:\=\s*(.*)/
|
34
|
+
envs['TOOLCHAIN_ARCH'] = $1
|
35
|
+
|
36
|
+
config_mk =~ /TOOLCHAIN_ABIS\s*\:\=\s*(.*)/
|
37
|
+
envs['TOOLCHAIN_ABIS'] = $1
|
38
|
+
|
39
|
+
else
|
40
|
+
raise NotImplementedError
|
41
|
+
end
|
42
|
+
|
43
|
+
envs.keys.each { |key| envs[key], ENV[key] = ENV[key], envs[key] }
|
44
|
+
yield if block_given?
|
45
|
+
envs.keys.each { |key| envs[key], ENV[key] = ENV[key], envs[key] }
|
46
|
+
|
47
|
+
return envs
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
module Qt::Commander::Creator
|
3
|
+
class Version < InfoObject
|
4
|
+
|
5
|
+
key :id, 'Id'
|
6
|
+
key :name, 'Name'
|
7
|
+
key :qmake, 'QMakePath'
|
8
|
+
key :type, 'QtVersion.Type'
|
9
|
+
key :autodetected, 'isAutodetected'
|
10
|
+
key :autodetect_src, 'autodetectionSource', optional:true
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qt-commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe McIlvain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +144,10 @@ extra_rdoc_files: []
|
|
130
144
|
files:
|
131
145
|
- lib/qt/commander.rb
|
132
146
|
- lib/qt/commander/creator.rb
|
147
|
+
- lib/qt/commander/creator/info_object.rb
|
148
|
+
- lib/qt/commander/creator/profile.rb
|
149
|
+
- lib/qt/commander/creator/toolchain.rb
|
150
|
+
- lib/qt/commander/creator/version.rb
|
133
151
|
homepage: https://github.com/jemc/qt-commander/
|
134
152
|
licenses:
|
135
153
|
- MIT
|