netlinx-compile 3.0.0 → 3.1.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.
- checksums.yaml +4 -4
- data/doc/NetLinx.html +15 -4
- data/doc/NetLinx/Compile.html +15 -4
- data/doc/NetLinx/Compile/Extension.html +16 -3
- data/doc/NetLinx/Compile/Extension/AXS.html +1 -1
- data/doc/NetLinx/Compile/ExtensionDiscovery.html +63 -16
- data/doc/NetLinx/Compile/ExtensionHandler.html +125 -53
- data/doc/NetLinx/Compile/Script.html +50 -10
- data/doc/NetLinx/Compiler.html +168 -53
- data/doc/NetLinx/CompilerResult.html +197 -50
- data/doc/NetLinx/NoCompilerError.html +9 -3
- data/doc/NetLinx/SourceFile.html +146 -59
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/file.license.html +2 -2
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/netlinx-compile.rb +11 -1
- data/lib/netlinx/compile/extension_discovery.rb +4 -2
- data/lib/netlinx/compile/extension_handler.rb +23 -25
- data/lib/netlinx/compile/script.rb +4 -3
- data/lib/netlinx/compiler.rb +39 -21
- data/lib/netlinx/compiler_result.rb +16 -17
- data/lib/netlinx/source_file.rb +16 -14
- data/license.txt +1 -1
- metadata +17 -17
data/doc/index.html
CHANGED
@@ -108,7 +108,7 @@ href="https://sourceforge.net/p/netlinx-compile/wiki/Home/">sourceforge.net/p/ne
|
|
108
108
|
</div></div>
|
109
109
|
|
110
110
|
<div id="footer">
|
111
|
-
Generated on Mon Jan 26 15:
|
111
|
+
Generated on Mon Jan 26 15:36:24 2015 by
|
112
112
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
113
|
0.8.7.6 (ruby-2.1.5).
|
114
114
|
</div>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on Mon Jan 26 15:
|
106
|
+
Generated on Mon Jan 26 15:36:24 2015 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.6 (ruby-2.1.5).
|
109
109
|
</div>
|
data/lib/netlinx-compile.rb
CHANGED
@@ -43,7 +43,7 @@ module NetLinx
|
|
43
43
|
.select{|c| not c.nil?}
|
44
44
|
end
|
45
45
|
|
46
|
-
#
|
46
|
+
# @return [Array<String>] workspace file extensions.
|
47
47
|
def workspace_extensions
|
48
48
|
@handlers
|
49
49
|
.select{|h| h.is_a_workspace?}
|
@@ -51,7 +51,9 @@ module NetLinx
|
|
51
51
|
.flatten
|
52
52
|
end
|
53
53
|
|
54
|
-
#
|
54
|
+
# @param filename [String] File or extension to find a
|
55
|
+
# {NetLinx::Compile::ExtensionHandler} for.
|
56
|
+
# @return [ExtensionHandler]
|
55
57
|
def get_handler(filename)
|
56
58
|
@handlers.select{|h| h.include? filename}.first
|
57
59
|
end
|
@@ -15,30 +15,28 @@ module NetLinx
|
|
15
15
|
# in this ExtensionHandler.
|
16
16
|
attr_reader :handler_class
|
17
17
|
|
18
|
-
#
|
19
|
-
#
|
20
|
-
# that this ExtensionHandler supports.
|
18
|
+
# @option kwargs [Array<String>] :extensions File extensions (without the
|
19
|
+
# leading dot) that this ExtensionHandler supports.
|
21
20
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# extension.
|
21
|
+
# @option kwargs [Array<String>] :usurps Future.
|
22
|
+
# Lets this ExtensionHandler take priority over other ones. For example,
|
23
|
+
# most third-party handlers would probably usurp the .apw NetLinx Studio
|
24
|
+
# workspace extension.
|
27
25
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
26
|
+
# @option kwargs [Boolean] :is_a_workspace Set to true if this
|
27
|
+
# ExtensionHandler is for compiling a workspace. False by default. This
|
28
|
+
# parameter assists with smart compiling, as {ExtensionDiscovery} can
|
29
|
+
# return all workspace_handlers.
|
32
30
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
def initialize(**
|
38
|
-
@extensions =
|
39
|
-
@usurps =
|
40
|
-
@is_a_workspace =
|
41
|
-
@handler_class =
|
31
|
+
# @option kwargs [Extension] :handler_class A reference to the class that
|
32
|
+
# should be instantiated if this handler is selected. For example,
|
33
|
+
# {NetLinx::SourceFile} is the class that handles files with the .axs
|
34
|
+
# extension.
|
35
|
+
def initialize(**kwargs)
|
36
|
+
@extensions = kwargs.fetch :extensions, []
|
37
|
+
@usurps = kwargs.fetch :usurps, []
|
38
|
+
@is_a_workspace = kwargs.fetch :is_a_workspace, false
|
39
|
+
@handler_class = kwargs.fetch :handler_class, nil
|
42
40
|
end
|
43
41
|
|
44
42
|
# Alias to add a file extension.
|
@@ -46,8 +44,8 @@ module NetLinx
|
|
46
44
|
@extensions << parse_extension(file_extension)
|
47
45
|
end
|
48
46
|
|
49
|
-
#
|
50
|
-
#
|
47
|
+
# @return [Boolean] true if the {ExtensionHandler} handles a workspace file
|
48
|
+
# (as opposed to a source code file).
|
51
49
|
#
|
52
50
|
# Workspace files are significant because they contain information
|
53
51
|
# about a project, connection settings for a master, and possibly
|
@@ -59,7 +57,7 @@ module NetLinx
|
|
59
57
|
@is_a_workspace
|
60
58
|
end
|
61
59
|
|
62
|
-
# Returns true if this ExtensionHandler can handle the specified
|
60
|
+
# Returns true if this {ExtensionHandler} can handle the specified
|
63
61
|
# file extension.
|
64
62
|
def include?(file_extension)
|
65
63
|
@extensions.include? parse_extension(file_extension)
|
@@ -69,7 +67,7 @@ module NetLinx
|
|
69
67
|
|
70
68
|
# Parse a file extension from the given string.
|
71
69
|
#
|
72
|
-
#
|
70
|
+
# @example
|
73
71
|
# apw
|
74
72
|
# .apw
|
75
73
|
# workspace.apw
|
@@ -10,9 +10,10 @@ module NetLinx
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
# Run the script.
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
# @option kwargs [Array<String>] :argv A convenience to override ARGV,
|
14
|
+
# like for testing.
|
15
|
+
def run(**kwargs)
|
16
|
+
args = kwargs.fetch :argv, ARGV
|
16
17
|
|
17
18
|
# Command line options.
|
18
19
|
@options = OpenStruct.new \
|
data/lib/netlinx/compiler.rb
CHANGED
@@ -2,38 +2,54 @@ require 'netlinx/compiler_result'
|
|
2
2
|
|
3
3
|
module NetLinx
|
4
4
|
# Raised when the NetLinx compiler (nlrc.exe) cannot be found on the system.
|
5
|
-
#
|
5
|
+
# @see NetLinx::Compiler
|
6
6
|
class NoCompilerError < Exception; end
|
7
7
|
|
8
8
|
# A wrapper class for the AMX NetLinx compiler executable (nlrc.exe).
|
9
9
|
class Compiler
|
10
10
|
|
11
11
|
# Checks for the AMX NetLinx compiler (third-party software, nlrc.exe) at the
|
12
|
-
# default installation path.
|
13
|
-
|
14
|
-
|
12
|
+
# default installation path.
|
13
|
+
#
|
14
|
+
# @option kwargs [String] :compiler_exe ('nlrc.exe')
|
15
|
+
# @option kwargs [String] :compiler_path Recommend a directory to look for
|
16
|
+
# the compiler_exe.
|
17
|
+
# @option kwargs [String] :use_wine (false) Set to true to force `wine` at
|
18
|
+
# the front of the compiler command. This is automatic if nlrc.exe is
|
19
|
+
# installed at Wine's default Program Files path.
|
20
|
+
# @raise [NetLinx::NoCompilerError] Compiler not found.
|
21
|
+
def initialize(**kwargs)
|
22
|
+
@compiler_exe = kwargs.fetch :compiler_exe, 'nlrc.exe'
|
23
|
+
user_specified_path = kwargs.fetch :compiler_path, nil
|
24
|
+
@use_wine = kwargs.fetch :use_wine, false
|
15
25
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# Compiler not found.
|
30
|
-
raise NetLinx::NoCompilerError, 'The NetLinx compiler (nlrc.exe) could not be found on the system.'
|
26
|
+
default_paths = [
|
27
|
+
user_specified_path,
|
28
|
+
'C:\Program Files (x86)\Common Files\AMXShare\COM', # 64-bit O/S path
|
29
|
+
'C:\Program Files\Common Files\AMXShare\COM', # 32-bit O/S path
|
30
|
+
'~/.wine/drive_c/Program\ Files/Common\ Files/AMXShare/COM', # Wine path
|
31
|
+
].compact
|
32
|
+
|
33
|
+
# Check for NetLinx compiler.
|
34
|
+
default_paths.each do |path|
|
35
|
+
if File.exists? File.expand_path(@compiler_exe, path)
|
36
|
+
@compiler_path = path
|
37
|
+
break
|
31
38
|
end
|
32
39
|
end
|
40
|
+
|
41
|
+
# ---------------------------------------------------------
|
42
|
+
# TODO: Check if the compiler was added to the system path.
|
43
|
+
# Execute system(@compiler_exe).
|
44
|
+
# ---------------------------------------------------------
|
45
|
+
|
46
|
+
# Compiler not found.
|
47
|
+
raise NetLinx::NoCompilerError, "The NetLinx compiler (#{@compiler_exe}) could not be found on the system." \
|
48
|
+
unless @compiler_path
|
33
49
|
end
|
34
50
|
|
35
51
|
# Compile the specified object with the NetLinx compiler.
|
36
|
-
#
|
52
|
+
# @see Test::NetLinx::Compilable.
|
37
53
|
def compile(compilable)
|
38
54
|
compiler = File.expand_path @compiler_exe, @compiler_path
|
39
55
|
result = []
|
@@ -51,7 +67,9 @@ module NetLinx
|
|
51
67
|
|
52
68
|
# Run the NetLinx compiler.
|
53
69
|
# Note: NLRC.exe v2.1 freaks out if empty arguments ("") are in the command.
|
54
|
-
cmd =
|
70
|
+
cmd = ''
|
71
|
+
cmd += 'wine ' if @use_wine or compiler.include? '/.wine/'
|
72
|
+
cmd += "\"#{compiler}\" \"#{target_file}\""
|
55
73
|
cmd += " \"#{include_paths}\"" if include_paths
|
56
74
|
cmd += " \"#{module_paths}\"" if module_paths
|
57
75
|
cmd += " \"#{library_paths}\"" if library_paths
|
@@ -19,19 +19,18 @@ module NetLinx
|
|
19
19
|
# See Compilable interface.
|
20
20
|
attr_reader :compiler_library_paths
|
21
21
|
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
@stream = kvargs.fetch :stream, ''
|
22
|
+
# @option kwargs [String] :stream The raw stream of text returned by the compiler.
|
23
|
+
# @option kwargs [Array<String>] :compiler_target_files See Compilable interface.
|
24
|
+
# @option kwargs [Array<String>] :compiler_include_paths See Compilable interface.
|
25
|
+
# @option kwargs [Array<String>] :compiler_module_paths See Compilable interface.
|
26
|
+
# @option kwargs [Array<String>] :compiler_library_paths See Compilable interface.
|
27
|
+
def initialize(**kwargs)
|
28
|
+
@stream = kwargs.fetch :stream, ''
|
30
29
|
|
31
|
-
@compiler_target_files =
|
32
|
-
@compiler_include_paths =
|
33
|
-
@compiler_module_paths =
|
34
|
-
@compiler_library_paths =
|
30
|
+
@compiler_target_files = kwargs.fetch :compiler_target_files, []
|
31
|
+
@compiler_include_paths = kwargs.fetch :compiler_include_paths, []
|
32
|
+
@compiler_module_paths = kwargs.fetch :compiler_module_paths, []
|
33
|
+
@compiler_library_paths = kwargs.fetch :compiler_library_paths, []
|
35
34
|
|
36
35
|
# Capture error and warning counts.
|
37
36
|
@errors = nil
|
@@ -43,27 +42,27 @@ module NetLinx
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
# Alias of #stream.
|
45
|
+
# Alias of {#stream}.
|
47
46
|
def to_s
|
48
47
|
@stream
|
49
48
|
end
|
50
49
|
|
51
|
-
#
|
50
|
+
# @return [String] the absolute path of the source code file that was compiled.
|
52
51
|
def target_file
|
53
52
|
@compiler_target_files.first
|
54
53
|
end
|
55
54
|
|
56
|
-
#
|
55
|
+
# @return [Boolean] true if compile was successful.
|
57
56
|
def success?
|
58
57
|
@errors == 0 && @warnings == 0
|
59
58
|
end
|
60
59
|
|
61
|
-
#
|
60
|
+
# @return [Array<String>] a list of warnings.
|
62
61
|
def warning_items
|
63
62
|
@stream.scan(/(^WARNING: .*$)/).map {|i| i.first}
|
64
63
|
end
|
65
64
|
|
66
|
-
#
|
65
|
+
# @return [Array<String>] a list of errors.
|
67
66
|
def error_items
|
68
67
|
@stream.scan(/(^ERROR: .*$)/).map {|i| i.first}
|
69
68
|
end
|
data/lib/netlinx/source_file.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
module NetLinx
|
2
|
+
# A NetLinx source code file.
|
3
|
+
# Typically .axs or .axi.
|
2
4
|
class SourceFile
|
3
5
|
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
def initialize(**
|
11
|
-
@compiler_target_files = [
|
12
|
-
@compiler_include_paths =
|
13
|
-
@compiler_module_paths =
|
6
|
+
# NOTE: SourceFile searches the body of the source file to automatically
|
7
|
+
# determine include and module paths.
|
8
|
+
#
|
9
|
+
# @option kwargs [String] :file Name or path of the file to compile.
|
10
|
+
# @option kwargs [Array<String>] :compiler_include_paths Additional paths for the compiler to find include files.
|
11
|
+
# @option kwargs [Array<String>] :compiler_module_paths Additional paths for the compiler to find module files.
|
12
|
+
def initialize(**kwargs)
|
13
|
+
@compiler_target_files = [ kwargs.fetch(:file, nil) ]
|
14
|
+
@compiler_include_paths = kwargs.fetch :compiler_include_paths, []
|
15
|
+
@compiler_module_paths = kwargs.fetch :compiler_module_paths, []
|
14
16
|
|
15
17
|
return unless @compiler_target_files.first
|
16
18
|
|
@@ -47,22 +49,22 @@ module NetLinx
|
|
47
49
|
@compiler_module_paths.uniq!
|
48
50
|
end
|
49
51
|
|
50
|
-
#
|
52
|
+
# @see _ lib/test/netlinx/compilable.rb interface.
|
51
53
|
def compiler_target_files
|
52
54
|
@compiler_target_files
|
53
55
|
end
|
54
56
|
|
55
|
-
#
|
57
|
+
# @see _ lib/test/netlinx/compilable.rb interface.
|
56
58
|
def compiler_include_paths
|
57
59
|
@compiler_include_paths
|
58
60
|
end
|
59
61
|
|
60
|
-
#
|
62
|
+
# @see _ lib/test/netlinx/compilable.rb interface.
|
61
63
|
def compiler_module_paths
|
62
64
|
@compiler_module_paths
|
63
65
|
end
|
64
66
|
|
65
|
-
#
|
67
|
+
# @see _ lib/test/netlinx/compilable.rb interface.
|
66
68
|
def compiler_library_paths
|
67
69
|
[]
|
68
70
|
end
|
data/license.txt
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netlinx-compile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex McLain
|
@@ -14,72 +14,72 @@ dependencies:
|
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '10.4'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '10.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yard
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.8.7
|
33
|
+
version: 0.8.7
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.8.7
|
40
|
+
version: 0.8.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.0
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.0
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-its
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0
|
61
|
+
version: '1.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0
|
68
|
+
version: '1.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fivemat
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|