ruby-yasm 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +30 -0
- data/.gitignore +5 -3
- data/ChangeLog.md +8 -1
- data/Gemfile +16 -0
- data/LICENSE.txt +1 -1
- data/README.md +49 -26
- data/Rakefile +6 -32
- data/gemspec.yml +3 -5
- data/lib/yasm/command.rb +272 -0
- data/lib/yasm/program.rb +30 -26
- data/lib/yasm/version.rb +1 -1
- data/lib/yasm.rb +1 -0
- data/ruby-yasm.gemspec +38 -85
- data/spec/command_spec.rb +91 -0
- data/spec/program_spec.rb +89 -10
- data/spec/spec_helper.rb +2 -3
- data/spec/yasm_spec.rb +1 -1
- metadata +31 -71
- data/lib/yasm/task.rb +0 -153
- data/spec/task_spec.rb +0 -70
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3a2caa603f754d40e6ba2d6f10ff5e4e63829a28ee3e89a5c0eb76aee4e9b38c
|
4
|
+
data.tar.gz: df4c5fab51e3a804d7b4f16f515f05eef1e2295742a7e1f36743fddfe4b857e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79baa6465f54ff67bb4697aff6338d6566a1b59611b58af8e69f90f680819828747a2657699d579f1a8c50b1e67cdb00179e9872159b78fa59b7a2fd75ca7d38
|
7
|
+
data.tar.gz: 7df6abee2fe8b61463e2dff4c361c72c2566996658f99830e0bd2699e9229cec6dcf1556e109cddae3eb72dbbb175c2c1cb96bef0fa4f757b3847639ba5167b7
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [ push, pull_request ]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
tests:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby:
|
12
|
+
- 2.6
|
13
|
+
- 2.7
|
14
|
+
- 3.0
|
15
|
+
- jruby
|
16
|
+
name: Ruby ${{ matrix.ruby }}
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- name: Install yasm
|
24
|
+
run: |
|
25
|
+
sudo apt update -y && \
|
26
|
+
sudo apt install -y --no-install-recommends --no-install-suggests yasm
|
27
|
+
- name: Install dependencies
|
28
|
+
run: bundle install --jobs 4 --retry 3
|
29
|
+
- name: Run tests
|
30
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
### 0.3.0 / 2022-01-07
|
2
|
+
|
3
|
+
* Replace rprogram with [command_mapper].
|
4
|
+
* Added {YASM::Command}.
|
5
|
+
* Deprecated {YASM::Program} in favor of {YASM::Command}.
|
6
|
+
|
1
7
|
### 0.2.1 / 2012-05-27
|
2
8
|
|
3
|
-
*
|
9
|
+
* `YASM::Task#target!` now raises an `ArgumentError` when given an unknown
|
4
10
|
target.
|
5
11
|
* Replaced ore-tasks with
|
6
12
|
[rubygems-tasks](https://github.com/postmodern/rubygems-tasks#readme).
|
@@ -22,3 +28,4 @@
|
|
22
28
|
|
23
29
|
* Initial release.
|
24
30
|
|
31
|
+
[command_mapper]: https://github.com/postmodern/command_mapper.rb#readme
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
# gem 'command_mapper', '~> 0.1', github: 'postmodern/command_mapper.rb'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'rake'
|
9
|
+
gem 'rubygems-tasks', '~> 0.2'
|
10
|
+
gem 'rspec', '~> 3.0'
|
11
|
+
gem 'simplecov', '~> 0.7'
|
12
|
+
|
13
|
+
gem 'kramdown'
|
14
|
+
gem 'yard', '~> 0.9'
|
15
|
+
gem 'yard-spellcheck'
|
16
|
+
end
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,19 +2,17 @@
|
|
2
2
|
|
3
3
|
* [Source](https://github.com/sophsec/ruby-yasm/)
|
4
4
|
* [Issues](https://github.com/sophsec/ruby-yasm/issues)
|
5
|
-
* [
|
6
|
-
* [www.tortall.net/projects/yasm](http://www.tortall.net/projects/yasm/)
|
7
|
-
* [www.sophsec.com](http://www.sophsec.com/)
|
5
|
+
* [Documentation](https://rubydoc.info/gems/ruby-yasm)
|
8
6
|
|
9
7
|
## Description
|
10
8
|
|
11
|
-
A Ruby interface to YASM.
|
9
|
+
A Ruby interface to [YASM][yasm].
|
12
10
|
|
13
|
-
YASM is a complete rewrite of the NASM assembler, YASM currently supports
|
14
|
-
the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes,
|
15
|
-
outputs binary, ELF32, ELF64, 32 and 64-bit Mach-O, RDOFF2, COFF, Win32,
|
16
|
-
and Win64 object formats, and generates source debugging information in
|
17
|
-
STABS, DWARF 2, and CodeView 8 formats.
|
11
|
+
> YASM is a complete rewrite of the NASM assembler, YASM currently supports
|
12
|
+
> the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes,
|
13
|
+
> outputs binary, ELF32, ELF64, 32 and 64-bit Mach-O, RDOFF2, COFF, Win32,
|
14
|
+
> and Win64 object formats, and generates source debugging information in
|
15
|
+
> STABS, DWARF 2, and CodeView 8 formats.
|
18
16
|
|
19
17
|
## Features
|
20
18
|
|
@@ -24,37 +22,62 @@ STABS, DWARF 2, and CodeView 8 formats.
|
|
24
22
|
|
25
23
|
Assemble a binary file:
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
yasm.output = 'hello_world.o'
|
31
|
-
end
|
25
|
+
```ruby
|
26
|
+
YASM::Command.run(syntax: :gas, file: 'hello_world.S', output: 'hello_world.o')
|
27
|
+
```
|
32
28
|
|
33
29
|
Assemble amd64 assembly, in GAS syntax, into an ELF64 file with
|
34
30
|
debugging information:
|
35
31
|
|
36
|
-
|
37
|
-
|
32
|
+
```ruby
|
33
|
+
YASM::Command.run do |yasm|
|
34
|
+
yasm.target = :amd64
|
38
35
|
|
39
|
-
|
40
|
-
|
36
|
+
yasm.syntax = :gas
|
37
|
+
yasm.file = 'hello_world.S'
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
yasm.output = 'hello_world.o'
|
40
|
+
yasm.output_format = :elf64
|
41
|
+
yasm.debug_format = :stabs
|
42
|
+
end
|
43
|
+
```
|
46
44
|
|
47
45
|
## Requirements
|
48
46
|
|
49
|
-
* [yasm]
|
50
|
-
* [
|
47
|
+
* [yasm] >= 0.8.0
|
48
|
+
* [command_mapper] ~> 0.1
|
51
49
|
|
52
50
|
## Install
|
53
51
|
|
54
|
-
|
52
|
+
```shell
|
53
|
+
$ gem install ruby-yasm
|
54
|
+
```
|
55
|
+
|
56
|
+
### yasm
|
57
|
+
|
58
|
+
* Debian / Ubuntu:
|
59
|
+
|
60
|
+
```shell
|
61
|
+
$ sudo apt install yasm
|
62
|
+
```
|
63
|
+
|
64
|
+
* RedHat / Fedora:
|
65
|
+
|
66
|
+
```shell
|
67
|
+
$ sudo dnf install yasm
|
68
|
+
```
|
69
|
+
|
70
|
+
* Homebrew:
|
71
|
+
|
72
|
+
```shell
|
73
|
+
$ brew install yasm
|
74
|
+
```
|
55
75
|
|
56
76
|
## License
|
57
77
|
|
58
|
-
Copyright (c) 2009-
|
78
|
+
Copyright (c) 2009-2022 Hal Brodigan
|
59
79
|
|
60
80
|
See {file:LICENSE.txt} for license information.
|
81
|
+
|
82
|
+
[yasm]: https://www.tortall.net/projects/yasm/
|
83
|
+
[command_mapper]: https://github.com/postmodern/command_mapper.rb#readme
|
data/Rakefile
CHANGED
@@ -1,36 +1,10 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
1
|
+
require 'rubygems/tasks'
|
2
|
+
Gem::Tasks.new
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
require 'rubygems/tasks'
|
7
|
-
|
8
|
-
Gem::Tasks.new
|
9
|
-
rescue LoadError => e
|
10
|
-
warn e.message
|
11
|
-
warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
|
12
|
-
end
|
13
|
-
|
14
|
-
begin
|
15
|
-
gem 'rspec', '~> 2.4'
|
16
|
-
require 'rspec/core/rake_task'
|
17
|
-
|
18
|
-
RSpec::Core::RakeTask.new
|
19
|
-
rescue LoadError => e
|
20
|
-
task :spec do
|
21
|
-
abort "Please run `gem install rspec` to install RSpec."
|
22
|
-
end
|
23
|
-
end
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new
|
24
6
|
task :test => :spec
|
25
7
|
task :default => :spec
|
26
8
|
|
27
|
-
|
28
|
-
|
29
|
-
require 'yard'
|
30
|
-
|
31
|
-
YARD::Rake::YardocTask.new
|
32
|
-
rescue LoadError => e
|
33
|
-
task :yard do
|
34
|
-
abort "Please run `gem install yard` to install YARD."
|
35
|
-
end
|
36
|
-
end
|
9
|
+
require 'yard'
|
10
|
+
YARD::Rake::YardocTask.new
|
data/gemspec.yml
CHANGED
@@ -6,15 +6,13 @@ description:
|
|
6
6
|
license: MIT
|
7
7
|
authors: Postmodern
|
8
8
|
email: postmodern.mod3@gmail.com
|
9
|
-
homepage: https://github.com/
|
9
|
+
homepage: https://github.com/postmodern/ruby-yasm#readme
|
10
10
|
has_yard: true
|
11
11
|
|
12
12
|
requirements: yasm >= 0.6.0
|
13
13
|
|
14
14
|
dependencies:
|
15
|
-
|
15
|
+
command_mapper: ~> 0.1
|
16
16
|
|
17
17
|
development_dependencies:
|
18
|
-
|
19
|
-
rspec: ~> 2.4
|
20
|
-
yard: ~> 0.7
|
18
|
+
bundler: ~> 2.0
|
data/lib/yasm/command.rb
ADDED
@@ -0,0 +1,272 @@
|
|
1
|
+
require 'command_mapper/command'
|
2
|
+
|
3
|
+
module YASM
|
4
|
+
#
|
5
|
+
# Provides an interface for invoking the `yasm` utility.
|
6
|
+
#
|
7
|
+
# ## Examples
|
8
|
+
#
|
9
|
+
# Assemble a binary file:
|
10
|
+
#
|
11
|
+
# YASM::Command.run(syntax: :gas, file: 'hello_world.S', output: 'hello_world.o')
|
12
|
+
#
|
13
|
+
# Assemble amd64 assembly, in GAS syntax, into an ELF64 file with
|
14
|
+
# debugging information:
|
15
|
+
#
|
16
|
+
# YASM::Command.run do |yasm|
|
17
|
+
# yasm.target = :amd64
|
18
|
+
#
|
19
|
+
# yasm.syntax = :gas
|
20
|
+
# yasm.file = 'hello_world.S'
|
21
|
+
#
|
22
|
+
# yasm.output = 'hello_world.o'
|
23
|
+
# yasm.output_format = :elf64
|
24
|
+
# yasm.debug_format = :stabs
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# ## `yasm` options:
|
28
|
+
#
|
29
|
+
# * `--version` - `yasm.version`
|
30
|
+
# * `--license` - `yasm.license`
|
31
|
+
# * `--help` - `yasm.help`
|
32
|
+
# * `--arch` - `yasm.arch`
|
33
|
+
# * `x86` - x86 (IA-32 and derivatives), AMD64
|
34
|
+
# * `lc3b` - LC-3b
|
35
|
+
# * `--parser` - `yasm.parser`
|
36
|
+
# * `gas` - GNU AS (GAS)-compatible parser
|
37
|
+
# * `gnu` - GNU AS (GAS)-compatible parser
|
38
|
+
# * `nasm` - NASM-compatible parser
|
39
|
+
# * `tasm` - TASM-compatible parser
|
40
|
+
# * `--preproc` - `yasm.preprocessor`
|
41
|
+
# * `nasm` - Real NASM Preprocessor
|
42
|
+
# * `tasm` - Real TASM Preprocessor
|
43
|
+
# * `raw` - Disable preprocessing
|
44
|
+
# * `cpp` - Run input through external C preprocessor
|
45
|
+
# * `gas` - GNU AS (GAS)-compatible preprocessor
|
46
|
+
# * `--oformat` - `yasm.output_format`
|
47
|
+
# * `dbg` - Trace of all info passed to object format module
|
48
|
+
# * `bin` - Flat format binary
|
49
|
+
# * `dosexe` - DOS .EXE format binary
|
50
|
+
# * `elf` - ELF
|
51
|
+
# * `elf32` - ELF (32-bit)
|
52
|
+
# * `elf64` - ELF (64-bit)
|
53
|
+
# * `elfx32` - ELF (x32)
|
54
|
+
# * `coff` - COFF (DJGPP)
|
55
|
+
# * `macho` - Mac OS X ABI Mach-O File Format
|
56
|
+
# * `macho32` - Mac OS X ABI Mach-O File Format (32-bit)
|
57
|
+
# * `macho64` - Mac OS X ABI Mach-O File Format (64-bit)
|
58
|
+
# * `rdf` - Relocatable Dynamic Object File Format (RDOFF) v2.0
|
59
|
+
# * `win32` - Win32
|
60
|
+
# * `win64` - Win64
|
61
|
+
# * `x64` - Win64
|
62
|
+
# * `xdf` - Extended Dynamic Object
|
63
|
+
# * `--dformat` - `yasm.debug_format`
|
64
|
+
# * `cv8` - CodeView debugging format for VC8
|
65
|
+
# * `dwarf2` - DWARF2 debugging format
|
66
|
+
# * `null` - No debugging info
|
67
|
+
# * `stabs` - Stabs debugging format
|
68
|
+
# * `--lformat` - `yasm.list_format`
|
69
|
+
# * `nasm` -NASM-style list format
|
70
|
+
# * `--list` - `yasm.list_file`
|
71
|
+
# * `--objfile` - `yasm.output`
|
72
|
+
# * `--mapfile` - `yasm.map_file`
|
73
|
+
# * `--machine` - `yasm.machine`
|
74
|
+
# * `x86` - IA-32 and derivatives
|
75
|
+
# * `amd64` - AMD64
|
76
|
+
# * `x32` - X32
|
77
|
+
# * `--force-strict` - `yasm.force_strict`
|
78
|
+
# * `-w` - `yasm.inhibit_warnings`
|
79
|
+
# * `-W` - `yasm.toggle_warnings`
|
80
|
+
# * `-M` - `yasm.gen_makefile_deps`
|
81
|
+
# * `-E` - `yasm.redirect_errors_to`
|
82
|
+
# * `-e` - `yasm.redirect_errors`
|
83
|
+
# * `--preproc-only` - `yasm.preprocessor_only`
|
84
|
+
# * `-I` - `yasm.include`
|
85
|
+
# * `-P` - `yasm.pre_include`
|
86
|
+
# * `-D` - `yasm.define`
|
87
|
+
# * `-U` - `yasm.undefine`
|
88
|
+
# * `-X` - `yasm.message_style`
|
89
|
+
# * `gnu`
|
90
|
+
# * `vc`
|
91
|
+
# * `--prefix` - `yasm.prefix`
|
92
|
+
# * `--suffix` - `yasm.suffix`
|
93
|
+
# * `file` - `yasm.file`
|
94
|
+
#
|
95
|
+
# @since 0.3.0
|
96
|
+
#
|
97
|
+
# @api public
|
98
|
+
#
|
99
|
+
class Command < CommandMapper::Command
|
100
|
+
|
101
|
+
command 'yasm' do
|
102
|
+
option '--version'
|
103
|
+
option '--license'
|
104
|
+
option '--help'
|
105
|
+
|
106
|
+
option '--arch', equals: true,
|
107
|
+
value: {
|
108
|
+
type: Enum[
|
109
|
+
:x86, # x86 (IA-32 and derivatives), AMD64
|
110
|
+
:lc3b # LC-3b
|
111
|
+
]
|
112
|
+
}
|
113
|
+
|
114
|
+
option '--parser', equals: true,
|
115
|
+
value: {
|
116
|
+
type: Enum[
|
117
|
+
:gas, # GNU AS (GAS)-compatible parser
|
118
|
+
:gnu, # GNU AS (GAS)-compatible parser
|
119
|
+
:nasm, # NASM-compatible parser
|
120
|
+
:tasm # TASM-compatible parser
|
121
|
+
]
|
122
|
+
}
|
123
|
+
|
124
|
+
option '--preproc', equals: true,
|
125
|
+
value: {
|
126
|
+
type: Enum[
|
127
|
+
:nasm, # Real NASM Preprocessor
|
128
|
+
:tasm, # Real TASM Preprocessor
|
129
|
+
:raw, # Disable preprocessing
|
130
|
+
:cpp, # Run input through external C preprocessor
|
131
|
+
:gas # GNU AS (GAS)-compatible preprocessor
|
132
|
+
]
|
133
|
+
},
|
134
|
+
name: :preprocessor
|
135
|
+
option '--oformat', equals: true,
|
136
|
+
value: {
|
137
|
+
type: Enum[
|
138
|
+
:dbg, # Trace of all info passed to object format module
|
139
|
+
:bin, # Flat format binary
|
140
|
+
:dosexe, # DOS .EXE format binary
|
141
|
+
:elf, # ELF
|
142
|
+
:elf32, # ELF (32-bit)
|
143
|
+
:elf64, # ELF (64-bit)
|
144
|
+
:elfx32, # ELF (x32)
|
145
|
+
:coff, # COFF (DJGPP)
|
146
|
+
:macho, # Mac OS X ABI Mach-O File Format
|
147
|
+
:macho32, # Mac OS X ABI Mach-O File Format (32-bit)
|
148
|
+
:macho64, # Mac OS X ABI Mach-O File Format (64-bit)
|
149
|
+
:rdf, # Relocatable Dynamic Object File Format (RDOFF) v2.0
|
150
|
+
:win32, # Win32
|
151
|
+
:win64, # Win64
|
152
|
+
:x64, # Win64
|
153
|
+
:xdf # Extended Dynamic Object
|
154
|
+
]
|
155
|
+
},
|
156
|
+
name: :output_format
|
157
|
+
option '--dformat', equals: true,
|
158
|
+
value: {
|
159
|
+
type: Enum[
|
160
|
+
:cv8, # CodeView debugging format for VC8
|
161
|
+
:dwarf2, # DWARF2 debugging format
|
162
|
+
:null, # No debugging info
|
163
|
+
:stabs # Stabs debugging format
|
164
|
+
]
|
165
|
+
},
|
166
|
+
name: :debug_format
|
167
|
+
option '--lformat', equals: true,
|
168
|
+
value: {
|
169
|
+
type: Enum[
|
170
|
+
:nasm # NASM-style list format
|
171
|
+
]
|
172
|
+
},
|
173
|
+
name: :list_format
|
174
|
+
|
175
|
+
option '--list', equals: true,
|
176
|
+
value: true,
|
177
|
+
name: :list_file
|
178
|
+
|
179
|
+
option '--objfile', equals: true,
|
180
|
+
value: true,
|
181
|
+
name: :output
|
182
|
+
|
183
|
+
option '--mapfile', equals: true,
|
184
|
+
value: true,
|
185
|
+
name: :map_file
|
186
|
+
|
187
|
+
option '--machine', equals: true,
|
188
|
+
value: {
|
189
|
+
type: Enum[
|
190
|
+
:x86, # IA-32 and derivatives
|
191
|
+
:amd64, # AMD64
|
192
|
+
:x32 # X32
|
193
|
+
]
|
194
|
+
}
|
195
|
+
|
196
|
+
option '--force-strict'
|
197
|
+
option '-w', name: :inhibit_warnings
|
198
|
+
option '-W', name: :toggle_warnings
|
199
|
+
option '-M', name: :gen_makefile_deps
|
200
|
+
option '-E', value: true, name: :redirect_errors_to
|
201
|
+
option '-s', name: :redirect_errors
|
202
|
+
option '--preproc-only', name: :preprocessor_only
|
203
|
+
|
204
|
+
option '-I', value: {type: InputDir.new},
|
205
|
+
repeats: true,
|
206
|
+
name: :include
|
207
|
+
|
208
|
+
option '-P', value: {type: InputFile.new},
|
209
|
+
repeats: true,
|
210
|
+
name: :pre_include
|
211
|
+
|
212
|
+
option '-D', name: :define, repeats: true
|
213
|
+
|
214
|
+
option '-U', value: true,
|
215
|
+
repeats: true,
|
216
|
+
name: :undefine
|
217
|
+
|
218
|
+
option '-X', value: {type: Enum[:gnu, :vc]},
|
219
|
+
name: :message_style
|
220
|
+
|
221
|
+
option '--prefix'
|
222
|
+
option '--suffix'
|
223
|
+
|
224
|
+
argument :file, type: InputFile.new
|
225
|
+
end
|
226
|
+
|
227
|
+
# The known YASM targets
|
228
|
+
TARGETS = {
|
229
|
+
x86: {arch: :x86, machine: :x86},
|
230
|
+
amd64: {arch: :x86, machine: :amd64},
|
231
|
+
lc3b: {arch: :lc3b, machine: :lc3b}
|
232
|
+
}
|
233
|
+
|
234
|
+
#
|
235
|
+
# Determines which target was set.
|
236
|
+
#
|
237
|
+
# @return [:x86, :amd64, :lc3b, nil]
|
238
|
+
# The target name or `nil` if no target has been set.
|
239
|
+
#
|
240
|
+
def target
|
241
|
+
if arch && machine
|
242
|
+
TARGETS.key(arch: arch.to_sym, machine: machine.to_sym)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
#
|
247
|
+
# Sets that target.
|
248
|
+
#
|
249
|
+
# @param [:x86, :amd64, :lc3b] name
|
250
|
+
# The target name.
|
251
|
+
#
|
252
|
+
# @return [Symbol]
|
253
|
+
# The set target.
|
254
|
+
#
|
255
|
+
# @raise [ArgumentError]
|
256
|
+
# An unknown target name was given.
|
257
|
+
#
|
258
|
+
def target=(name)
|
259
|
+
target = TARGETS.fetch(name.to_sym) do
|
260
|
+
raise(ArgumentError,"unknown YASM target: #{name.inspect}")
|
261
|
+
end
|
262
|
+
|
263
|
+
self.arch = target[:arch]
|
264
|
+
self.machine = target[:machine]
|
265
|
+
return name
|
266
|
+
end
|
267
|
+
|
268
|
+
alias syntax parser
|
269
|
+
alias syntax= parser=
|
270
|
+
|
271
|
+
end
|
272
|
+
end
|
data/lib/yasm/program.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'yasm/
|
2
|
-
|
3
|
-
require 'rprogram'
|
1
|
+
require 'yasm/command'
|
4
2
|
|
5
3
|
module YASM
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
#
|
5
|
+
# @deprecated Please use {Command} instead.
|
6
|
+
#
|
7
|
+
class Program < Command
|
9
8
|
|
10
9
|
#
|
11
10
|
# Finds the `yasm` program and assembles a file.
|
@@ -13,15 +12,12 @@ module YASM
|
|
13
12
|
# @param [Hash{Symbol => Object}] options
|
14
13
|
# Additional options for yasm.
|
15
14
|
#
|
16
|
-
# @
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# @yield [task]
|
20
|
-
# If a block is given, it will be passed a task object used to
|
15
|
+
# @yield [program]
|
16
|
+
# If a block is given, it will be passed a program object used to
|
21
17
|
# specify options for yasm.
|
22
18
|
#
|
23
|
-
# @yieldparam [
|
24
|
-
# The yasm
|
19
|
+
# @yieldparam [Program] program
|
20
|
+
# The yasm program object.
|
25
21
|
#
|
26
22
|
# @return [Boolean]
|
27
23
|
# Specifies whether the command exited normally.
|
@@ -44,8 +40,8 @@ module YASM
|
|
44
40
|
#
|
45
41
|
# @see #assemble
|
46
42
|
#
|
47
|
-
def self.assemble(options={}
|
48
|
-
|
43
|
+
def self.assemble(options={},&block)
|
44
|
+
new(options,&block).assemble()
|
49
45
|
end
|
50
46
|
|
51
47
|
#
|
@@ -54,15 +50,12 @@ module YASM
|
|
54
50
|
# @param [Hash{Symbol => Object}] options
|
55
51
|
# Additional options for yasm.
|
56
52
|
#
|
57
|
-
# @
|
58
|
-
#
|
59
|
-
#
|
60
|
-
# @yield [task]
|
61
|
-
# If a block is given, it will be passed a task object used to
|
53
|
+
# @yield [program]
|
54
|
+
# If a block is given, it will be passed a program object used to
|
62
55
|
# specify options for yasm.
|
63
56
|
#
|
64
|
-
# @yieldparam [
|
65
|
-
# The yasm
|
57
|
+
# @yieldparam [Program] program
|
58
|
+
# The yasm program object.
|
66
59
|
#
|
67
60
|
# @return [Boolean]
|
68
61
|
# Specifies whether the command exited normally.
|
@@ -83,11 +76,22 @@ module YASM
|
|
83
76
|
# yasm.output = 'code.o'
|
84
77
|
# end
|
85
78
|
#
|
86
|
-
|
87
|
-
|
79
|
+
def assemble(options={})
|
80
|
+
options.each do |name,value|
|
81
|
+
self[name] = value
|
82
|
+
end
|
83
|
+
|
84
|
+
yield self if block_given?
|
85
|
+
|
86
|
+
run_command()
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# @deprecated Please use {#target=} instead.
|
88
91
|
#
|
89
|
-
def
|
90
|
-
|
92
|
+
def target!(name)
|
93
|
+
self.target = name
|
94
|
+
return true
|
91
95
|
end
|
92
96
|
|
93
97
|
end
|
data/lib/yasm/version.rb
CHANGED
data/lib/yasm.rb
CHANGED