You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* validate Pointer incl. tests
* using cargo clippy for coding style as well as cargo fmt
* multi-type declarations incl. tests
* subcommand as well as simple build description file
* improved subcommand
* improved build description file
* adding libraries and parsing them
* documentation and minor improvements
* Pull Request improvements
* improvements from review
* adding sysroot and target-triple as inline parameters for subcommand
Co-authored-by: Ghaith Hachem <ghaith.hachem@gmail.com>
In addition to the comprehensive help, `rustyc` offers a build description file, that simplifies the build process. Instead of having numerous inline arguments, using the build description file makes passing the arguments easier and neater. The build description file needs to be safed as a [json](https://en.wikipedia.org/wiki/JSON) format.
4
+
5
+
`rustyc build [Config]`
6
+
7
+
Note that if `rustyc` cannot find the `plc.json` file, it will throw an error and request the path. The default location for the build file is the current directory. The command for building with an additional path looks like this:
8
+
9
+
`rustyc build src/plc.json`
10
+
11
+
12
+
# Plc.json
13
+
14
+
For the build description file to work, the build description file must be the [json](https://en.wikipedia.org/wiki/JavaScript_Object_Notation) format. All the keys used in the build description file are described in the following sections.
15
+
16
+
17
+
## files
18
+
19
+
The key `files` is the equivalent to the `input` parameter, which adds all the `.st` files that needs to be compiled. The value of `files` is an array of strings, definied as followed:
20
+
```json
21
+
"files" : [
22
+
"examples/hello_world.st",
23
+
"examples/hw.st"
24
+
]
25
+
```
26
+
27
+
28
+
## optimization
29
+
30
+
`rustyc` offers 4 levels of optimization which correspond to the levels established by llvm respectively [clang](https://clang.llvm.org/docs/CommandGuide/clang.html#code-generation-options) (`none` to `agressive`).
31
+
To use an optimization, the key `optimization` is required:
32
+
-`"optimization" : "none"`
33
+
-`"optimization" : "less"`
34
+
-`"optimization" : "default"`
35
+
-`"optimization" : "aggressive"`
36
+
37
+
By default `rustyc` will use `default` which corresponds to clang's `-o2`.
38
+
39
+
40
+
## error_format
41
+
42
+
`rustyc` offers 2 levels of formatting errors. To specify which error format is wanted, the key `error_format` is required:
43
+
-`"error_format" : "Clang"` This is used to get fewer error messaged
44
+
-`"error_format" : "Rich"` This is used to get a verbose error description.
45
+
46
+
47
+
## libraries
48
+
49
+
To link several executables `rustyc` has the option to add libraries and automatically build and like them together. if no compile type has been selected `rustyc` will link the files on default.
50
+
51
+
```json
52
+
"libraries" : [
53
+
{
54
+
"name" : "iec61131std",
55
+
"path" : "path/to/lib/",
56
+
"include_path" : [
57
+
"examples/hw.st",
58
+
"examples/hello_world.st"
59
+
]
60
+
}
61
+
]
62
+
```
63
+
64
+
## output
65
+
66
+
Similarly to specifying an output file via the `-o` or `--output` option, in the build file we use `"output" : "output.so"` to define the output file. The default location is likewise to the location for the build file, namely the current directory.
67
+
68
+
69
+
70
+
## Optional Keys
71
+
### sysroot
72
+
73
+
`rustyc` is using the `sysroot` key for linking purposes. It is considered to be the root directory for the purpose of locating headers and libraries.
74
+
75
+
76
+
### target
77
+
78
+
To build and compile [structured text](https://en.wikipedia.org/wiki/Structured_text) for the rigth platform we need to specify the `target`. As `rustyc` is using [LLVM](https://en.wikipedia.org/wiki/LLVM) a target-tripple supported by LLVM needs to be selected. The default `target` is `x86_64-linux-gnu`.
79
+
80
+
81
+
### compile_type
82
+
There are six options for choosing the `compile_type`. The valid options are:
83
+
<!-- TODO we should probably describe what each of those options do -->
84
+
-`Static` bindings have to be done at compile time
85
+
-`PIC` Position Independent Code
86
+
-`Shared` (dynamic) binginds will be done dynamically
87
+
-`Relocatable` generates Relocatable
88
+
-`Bitcode` adds bitcode alongside machine code in executable file
89
+
-`IR` Intermediate Representation
90
+
91
+
To specify which of the above mentioned compile formats is wanted, it needs to be added to the build description file as followed: `"compile_type" : "Shared"`.
0 commit comments