eolang 0.6.0 → 0.8.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.
- package/README.md +16 -9
- package/itest/story.eo +4 -3
- package/package.json +1 -1
- package/renovate.json +6 -0
- package/src/commands/clean.js +9 -1
- package/src/commands/dataize.js +3 -1
- package/src/commands/gmi.js +45 -0
- package/src/commands/transpile.js +5 -0
- package/src/eoc.js +28 -8
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
<img alt="logo" src="https://www.objectionary.com/cactus.svg" height="
|
|
1
|
+
<img alt="logo" src="https://www.objectionary.com/cactus.svg" height="92px" />
|
|
2
|
+
|
|
3
|
+
[](https://www.elegantobjects.org)
|
|
4
|
+
[](https://www.jetbrains.com/idea/)
|
|
2
5
|
|
|
3
6
|
[](https://github.com/objectionary/eoc/actions/workflows/grunt.yml)
|
|
7
|
+
[](http://www.0pdd.com/p?name=objectionary/eoc)
|
|
8
|
+
[](https://hitsofcode.com/view/github/objectionary/eoc)
|
|
9
|
+

|
|
10
|
+
[](https://github.com/objectionary/eoc/blob/master/LICENSE.txt)
|
|
4
11
|
|
|
5
12
|
First, you install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
|
|
6
13
|
and [Java SE](https://www.oracle.com/java/technologies/downloads/).
|
|
@@ -33,17 +40,17 @@ That's it.
|
|
|
33
40
|
You can also do many other things with `eoc` commands
|
|
34
41
|
(the flow is explained in [this blog post](https://www.yegor256.com/2021/10/21/objectionary.html)):
|
|
35
42
|
|
|
36
|
-
* `register` finds necessary EO files and registers
|
|
37
|
-
* `assemble` parses EO files into XMIR, optimizes them, pulls foreign EO objects
|
|
38
|
-
* `transpile` converts XMIR to target programming language
|
|
39
|
-
* `compile` converts target language to binaries
|
|
43
|
+
* `register` finds necessary EO files and registers them in a JSON catalog
|
|
44
|
+
* `assemble` parses EO files into XMIR, optimizes them, and pulls foreign EO objects
|
|
45
|
+
* `transpile` converts XMIR to target programming language (Java by default)
|
|
46
|
+
* `compile` converts target language sources to binaries
|
|
40
47
|
* `link` puts all binaries together into a single executable binary
|
|
41
|
-
* `dataize`
|
|
42
|
-
* `test`
|
|
48
|
+
* `dataize` dataizes a single object from the executable binary
|
|
49
|
+
* `test` dataizes all visible unit tests
|
|
43
50
|
|
|
44
51
|
There are also commands that help manipulate with XMIR and EO sources (some of them are not implemented as of yet):
|
|
45
52
|
|
|
46
|
-
* `audit` inspects all packages and
|
|
53
|
+
* `audit` inspects all required packages and reports their status
|
|
47
54
|
* `foreign` inspects all objects found in the program after `assemble` step
|
|
48
55
|
* <del>`translate` converts Java/C++/Python/etc. program to EO program</del>
|
|
49
56
|
* <del>`demu` removes `cage` and `memory` objects</del>
|
|
@@ -64,4 +71,4 @@ If you want to run a single test:
|
|
|
64
71
|
$ npm test -- test/test_mvnw.js
|
|
65
72
|
```
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
Make your changes and then [make](https://www.yegor256.com/2014/04/15/github-guidelines.html) a pull request.
|
package/itest/story.eo
CHANGED
package/package.json
CHANGED
package/renovate.json
ADDED
package/src/commands/clean.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
const fs = require('fs');
|
|
26
26
|
const path = require('path');
|
|
27
|
+
const os = require('os');
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Deletes all temporary files.
|
|
@@ -32,5 +33,12 @@ const path = require('path');
|
|
|
32
33
|
module.exports = function(opts) {
|
|
33
34
|
const home = path.resolve(opts.target);
|
|
34
35
|
fs.rmSync(home, {recursive: true, force: true});
|
|
35
|
-
console.
|
|
36
|
+
console.info('The directory %s deleted', home);
|
|
37
|
+
if (opts.cached) {
|
|
38
|
+
const eo = path.join(os.homedir(), '.eo');
|
|
39
|
+
if (fs.existsSync(eo)) {
|
|
40
|
+
fs.rmSync(eo, {recursive: true});
|
|
41
|
+
console.info('The directory ~/.eo was deleted');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
36
44
|
};
|
package/src/commands/dataize.js
CHANGED
|
@@ -28,15 +28,17 @@ const path = require('path');
|
|
|
28
28
|
/**
|
|
29
29
|
* Runs the single executable binary.
|
|
30
30
|
* @param {String} obj - Name of object to dataize
|
|
31
|
+
* @param {Array} args - Arguments
|
|
31
32
|
* @param {Hash} opts - All options
|
|
32
33
|
*/
|
|
33
|
-
module.exports = function(obj, opts) {
|
|
34
|
+
module.exports = function(obj, args, opts) {
|
|
34
35
|
spawn(
|
|
35
36
|
`java`,
|
|
36
37
|
[
|
|
37
38
|
'-Dfile.encoding=UTF-8',
|
|
38
39
|
'-jar', path.resolve(opts.target, 'eoc.jar'),
|
|
39
40
|
obj,
|
|
41
|
+
...args,
|
|
40
42
|
],
|
|
41
43
|
{stdio: 'inherit'}
|
|
42
44
|
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 Yegor Bugayenko
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
|
14
|
+
* in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const mvnwSync = require('../mvnw');
|
|
27
|
+
const parserVersion = require('../parser-version');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generate GMI files from XMIR.
|
|
31
|
+
* @param {Hash} opts - All options
|
|
32
|
+
*/
|
|
33
|
+
module.exports = function(opts) {
|
|
34
|
+
mvnwSync([
|
|
35
|
+
'eo:gmi',
|
|
36
|
+
'-Deo.version=' + (opts.parserVersion ? opts.parserVersion : parserVersion()),
|
|
37
|
+
opts.verbose ? '' : '--quiet',
|
|
38
|
+
opts.gmi_xml ? '' : '-Deo.generateGmiXmlFiles',
|
|
39
|
+
opts.gmi_xembly ? '' : '-Deo.generateXemblyFiles',
|
|
40
|
+
opts.gmi_graph ? '' : '-Deo.generateGraphFiles',
|
|
41
|
+
opts.gmi_dot ? '' : '-Deo.generateDotFiles',
|
|
42
|
+
`-Deo.targetDir=${path.resolve(opts.target)}`,
|
|
43
|
+
]);
|
|
44
|
+
console.info('GMI files generated in %s', path.resolve(opts.target));
|
|
45
|
+
};
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
const mvnwSync = require('../mvnw');
|
|
26
|
+
const fs = require('fs');
|
|
26
27
|
const path = require('path');
|
|
27
28
|
const parserVersion = require('../parser-version');
|
|
28
29
|
|
|
@@ -32,6 +33,10 @@ const parserVersion = require('../parser-version');
|
|
|
32
33
|
*/
|
|
33
34
|
module.exports = function(opts) {
|
|
34
35
|
const sources = path.resolve(opts.target, 'generated-sources');
|
|
36
|
+
if (fs.existsSync(sources)) {
|
|
37
|
+
fs.rmSync(sources, {recursive: true, force: true});
|
|
38
|
+
console.info('Previously existed Java sources deleted in %s', sources);
|
|
39
|
+
}
|
|
35
40
|
mvnwSync([
|
|
36
41
|
'eo:transpile',
|
|
37
42
|
'-Deo.version=' + (opts.parserVersion ? opts.parserVersion : parserVersion()),
|
package/src/eoc.js
CHANGED
|
@@ -28,6 +28,7 @@ const tinted = require('./tinted-console');
|
|
|
28
28
|
const audit = require('./commands/audit');
|
|
29
29
|
const clean = require('./commands/clean');
|
|
30
30
|
const assemble = require('./commands/assemble');
|
|
31
|
+
const gmi = require('./commands/gmi');
|
|
31
32
|
const register = require('./commands/register');
|
|
32
33
|
const transpile = require('./commands/transpile');
|
|
33
34
|
const compile = require('./commands/compile');
|
|
@@ -44,7 +45,7 @@ if (process.argv.includes('--verbose')) {
|
|
|
44
45
|
|
|
45
46
|
program
|
|
46
47
|
.name('eoc')
|
|
47
|
-
.description('EO command-line toolkit')
|
|
48
|
+
.description('EO command-line toolkit (' + require('./version') + ')')
|
|
48
49
|
.version(require('./version'));
|
|
49
50
|
|
|
50
51
|
program
|
|
@@ -58,21 +59,26 @@ program
|
|
|
58
59
|
.option('--verbose', 'print debug messages and full output of child processes');
|
|
59
60
|
|
|
60
61
|
program.command('audit')
|
|
61
|
-
.description('
|
|
62
|
+
.description('inspect all packages and report their status')
|
|
62
63
|
.action((str, opts) => {
|
|
63
64
|
audit(program.opts());
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
program.command('foreign')
|
|
67
|
-
.description('
|
|
68
|
+
.description('inspect and print the list of foreign objects')
|
|
68
69
|
.action((str, opts) => {
|
|
69
70
|
foreign(program.opts());
|
|
70
71
|
});
|
|
71
72
|
|
|
72
|
-
program
|
|
73
|
+
program
|
|
74
|
+
.command('clean')
|
|
75
|
+
.option('--cached', 'delete ~/.eo directory')
|
|
73
76
|
.description('delete all temporary files')
|
|
74
77
|
.action((str, opts) => {
|
|
75
|
-
clean(
|
|
78
|
+
clean({
|
|
79
|
+
cached: str.cached,
|
|
80
|
+
...program.opts(),
|
|
81
|
+
});
|
|
76
82
|
});
|
|
77
83
|
|
|
78
84
|
program.command('register')
|
|
@@ -90,8 +96,22 @@ program.command('assemble')
|
|
|
90
96
|
assemble(program.opts());
|
|
91
97
|
});
|
|
92
98
|
|
|
99
|
+
program.command('gmi')
|
|
100
|
+
.description('generate GMI files from XMIR')
|
|
101
|
+
.option('--gmi-xml', 'generate .gmi.xml files')
|
|
102
|
+
.option('--gmi-xembly', 'generate .gmi.xe files')
|
|
103
|
+
.option('--gmi-graph', 'generate .gmi.graph files')
|
|
104
|
+
.option('--gmi-dot', 'generate .gmi.dot files')
|
|
105
|
+
.action((str, opts) => {
|
|
106
|
+
if (program.opts().alone == undefined) {
|
|
107
|
+
register(program.opts());
|
|
108
|
+
assemble(program.opts());
|
|
109
|
+
}
|
|
110
|
+
gmi(program.opts());
|
|
111
|
+
});
|
|
112
|
+
|
|
93
113
|
program.command('transpile')
|
|
94
|
-
.description('
|
|
114
|
+
.description('convert EO files into target language')
|
|
95
115
|
.action((str, opts) => {
|
|
96
116
|
if (program.opts().alone == undefined) {
|
|
97
117
|
register(program.opts());
|
|
@@ -101,7 +121,7 @@ program.command('transpile')
|
|
|
101
121
|
});
|
|
102
122
|
|
|
103
123
|
program.command('compile')
|
|
104
|
-
.description('
|
|
124
|
+
.description('compile target language sources into binaries')
|
|
105
125
|
.action((str, opts) => {
|
|
106
126
|
if (program.opts().alone == undefined) {
|
|
107
127
|
register(program.opts());
|
|
@@ -133,7 +153,7 @@ program.command('dataize')
|
|
|
133
153
|
compile(program.opts());
|
|
134
154
|
link(program.opts());
|
|
135
155
|
}
|
|
136
|
-
dataize(program.args[1], program.opts());
|
|
156
|
+
dataize(program.args[1], program.args.slice(2), program.opts());
|
|
137
157
|
});
|
|
138
158
|
|
|
139
159
|
program.command('test')
|
package/src/version.js
CHANGED