Skip to content

Commit 0e0c425

Browse files
authored
Merge pull request #242 from lf-lang/fix-compiler
Updated compiler and compiler-flags property, removed cmake property
2 parents 242e569 + e7c3478 commit 0e0c425

File tree

2 files changed

+44
-134
lines changed

2 files changed

+44
-134
lines changed

docs/reference/target-declaration.mdx

+22-67
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ A target specification may have optional parameters, the names and values of whi
2828
- [**build-type**](#build-type): One of Debug (the default), Release, RelWithDebInfo and MinSizeRel.
2929
- [**cargo-dependencies**](#cargo-dependencies): (Rust only) list of dependencies to include in the generated Cargo.toml file.
3030
- [**cargo-features**](#cargo-features): (Rust only) List of string names of features to include.
31-
- [**cmake**](#cmake): Whether to use cmake for building.
3231
- [**cmake-include**](#cmake): List of paths to cmake files to guide compilation.
3332
- [**compiler**](#compiler): A string giving the name of the target language compiler to use.
33+
- [**compiler-flags**](#compiler-flags): An arrays of strings giving options to be passed to the target compiler.
3434
- [**docker**](#docker): A boolean to generate a Dockerfile.
3535
- [**external-runtime-path**](#external-runtime-path): Specify a pre-compiled external runtime library located to link to instead of the default.
3636
- [**export-dependency-graph**](#export-dependency-graph): To export the reaction dependency graph as a dot graph (for debugging).
3737
- [**fast**](#fast): A boolean specifying to execute as fast as possible without waiting for physical time to match logical time.
3838
- [**files**](#files): An array of paths to files or directories to be copied to the directory that contains the generated sources.
39-
- [**flags**](#flags): An arrays of strings giving options to be passed to the target compiler.
4039
- [**logging**](#logging): An indicator of how much information to print when executing the program.
4140
- [**no-compile**](#no-compile): If true, then do not invoke a target language compiler. Just generate code.
4241
- [**no-runtime-validation**](#no-runtime-validation): If true, disable runtime validation.
@@ -57,13 +56,12 @@ c={
5756
auth: <true or false>
5857
build: <string>,
5958
build-type: <Debug, Release, RelWithDebInfo, or MinSizeRel>,
60-
cmake: <true or false>,
6159
cmake-include: <string or list of strings>,
6260
compiler: <string>,
61+
compiler-flags: <string or list of strings>,
6362
docker: <true or false>,
6463
fast: <true or false>,
6564
files: <string or list of strings>,
66-
flags: <string or list of strings>,
6765
logging: <error, warning, info, log, debug>,
6866
no-compile: <true or false>,
6967
protobufs: <string or list of strings>,
@@ -76,6 +74,7 @@ cpp={
7674
`target Cpp {
7775
build-type: <Debug, Release, RelWithDebInfo, or MinSizeRel>,
7876
cmake-include: <string or list of strings>,
77+
compiler: <string>,
7978
external-runtime-path: <string>,
8079
export-dependency-graph <true or false>,
8180
fast: <true or false>,
@@ -276,35 +275,6 @@ This is a list of features of the generated crate. Supported are:
276275
</ShowIf>
277276
</ShowIfs>
278277

279-
## cmake
280-
281-
<ShowIfs>
282-
<ShowIf py rs ts>
283-
This target does not support the `cmake` target option.
284-
</ShowIf>
285-
<ShowIf cpp>
286-
The C++ target does not support the `cmake` target option because it always uses `cmake`.
287-
</ShowIf>
288-
<ShowIf c>
289-
```lf-c
290-
target C {
291-
cmake: <true or false>
292-
};
293-
```
294-
295-
This will enable or disable the CMake-based build system (the default is `true`). Enabling the CMake build system will result in a `CMakeLists.txt` being generated in the `src-gen` directory. This `CMakeLists.txt` is then used when `cmake` is invoked by the LF runtime (either the `lfc` or the IDE). Alternatively, the generated program can be built manually. To do so, in the `src-gen/ProgramName` directory, run:
296-
297-
```sh
298-
mkdir build && cd build
299-
cmake ../
300-
make
301-
```
302-
303-
If `cmake` is disabled, `gcc` is directly invoked after code generation by default. In this case, additional target properties, such as [compiler](#compiler) and [flags](#flags) can be used to gain finer control over the compilation process.
304-
</ShowIf>
305-
</ShowIfs>
306-
307-
308278
<ShowOnly c cpp>
309279

310280
## cmake-include
@@ -361,25 +331,33 @@ See [`AsyncCallback.lf`](https://github.com/lf-lang/lingua-franca/blob/master/te
361331
<ShowIf ts py rs>
362332
This target does not support the `compiler` target option.
363333
</ShowIf>
334+
<ShowIf c cpp>
335+
This parameter is a string giving the name of the compiler to use. Normally
336+
CMake selects the best compiler for your system, but you can use this parameter
337+
to point to your preferred compiler. Possible values are, for instance, `gcc`,
338+
`g++`, `clang`, or `clang++`.
339+
</ShowIf>
340+
</ShowIfs>
341+
342+
## compiler-flags
343+
344+
<ShowIfs>
345+
<ShowIf cpp py ts rs>
346+
This target does not support the `compiler-flags` parameter.
347+
</ShowIf>
364348
<ShowIf c>
365-
This parameter is a string giving the name of the C compiler to use.
366-
It is used only when [cmake](#cmake) is set to `false`. For example:
349+
This parameter is a list of strings giving additional arguments to pass to the target language compiler. For example:
367350

368351
```lf-c
369352
target C {
370-
cmake: false,
371-
compiler: "cc",
353+
compiler-flags: ["-g", "-I/usr/local/include", "-L/usr/local/lib", "-lpaho-mqtt3c"],
372354
};
373355
```
374356

375-
The `compiler` option here specifies to use `cc` rather than `gcc`.
376-
</ShowIf>
377-
<ShowIf cpp>
378-
This parameter is a string giving the name of the C++ compiler to use. Normally
379-
CMake selects the best compiler for your system, but you can use this parameter
380-
to point it to your preferred C++ compiler.
381-
</ShowIf>
357+
The `compiler-flags` option specifies to include debug information in the compiled code (`-g`); a directory to search for include files (`-I/usr/local/include`); a directory to search for library files (`-L/usr/local/lib`); a library to link with (`-lpaho-mqtt3c`, which will link with file `libpaho-mqtt3c.so`).
382358

359+
**Note**: Using the `compiler-flags` parameter is strongly discouraged, although supported. Flags are compiler-specific, and thus interfere with CMake's ability to find the most suitable compiler for each platform. In a similar fashion, we recommend against the use of the `compiler` standard parameter for the same reason. A better solution is to provide a `cmake-include` file.
360+
</ShowIf>
383361
</ShowIfs>
384362

385363
## docker
@@ -494,29 +472,6 @@ Moreover, the `files` target specification works in conjunction with the `import
494472
</ShowIf>
495473
</ShowIfs>
496474

497-
## flags
498-
499-
<ShowIfs>
500-
<ShowIf cpp py ts rs>
501-
This target does not support the `flags` parameter.
502-
</ShowIf>
503-
<ShowIf c>
504-
This parameter is a list of strings giving additional arguments to pass to the target language compiler.
505-
It is used only when [cmake](#cmake) is set to `false`. For example:
506-
507-
```lf-c
508-
target C {
509-
cmake: false,
510-
flags: ["-g", "-I/usr/local/include", "-L/usr/local/lib", "-lpaho-mqtt3c"],
511-
};
512-
```
513-
514-
The `flags` option specifies to include debug information in the compiled code (`-g`); a directory to search for include files (`-I/usr/local/include`); a directory to search for library files (`-L/usr/local/lib`); a library to link with (`-lpaho-mqtt3c`, which will link with file `libpaho-mqtt3c.so`).
515-
516-
**Note**: Using the `flags` standard parameter when `cmake` is enabled is strongly discouraged, although supported. Flags are compiler-specific, and thus interfere with CMake's ability to find the most suitable compiler for each platform. In a similar fashion, we recommend against the use of the `compiler` standard parameter for the same reason. A better solution is to provide a `cmake-include` file, as described next.
517-
</ShowIf>
518-
</ShowIfs>
519-
520475
## logging
521476

522477
<ShowIfs>

versioned_docs/version-0.6.0/reference/target-declaration.mdx

+22-67
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ A target specification may have optional parameters, the names and values of whi
2828
- [**build-type**](#build-type): One of Debug (the default), Release, RelWithDebInfo and MinSizeRel.
2929
- [**cargo-dependencies**](#cargo-dependencies): (Rust only) list of dependencies to include in the generated Cargo.toml file.
3030
- [**cargo-features**](#cargo-features): (Rust only) List of string names of features to include.
31-
- [**cmake**](#cmake): Whether to use cmake for building.
3231
- [**cmake-include**](#cmake): List of paths to cmake files to guide compilation.
3332
- [**compiler**](#compiler): A string giving the name of the target language compiler to use.
33+
- [**compiler-flags**](#compiler-flags): An arrays of strings giving options to be passed to the target compiler.
3434
- [**docker**](#docker): A boolean to generate a Dockerfile.
3535
- [**external-runtime-path**](#external-runtime-path): Specify a pre-compiled external runtime library located to link to instead of the default.
3636
- [**export-dependency-graph**](#export-dependency-graph): To export the reaction dependency graph as a dot graph (for debugging).
3737
- [**fast**](#fast): A boolean specifying to execute as fast as possible without waiting for physical time to match logical time.
3838
- [**files**](#files): An array of paths to files or directories to be copied to the directory that contains the generated sources.
39-
- [**flags**](#flags): An arrays of strings giving options to be passed to the target compiler.
4039
- [**logging**](#logging): An indicator of how much information to print when executing the program.
4140
- [**no-compile**](#no-compile): If true, then do not invoke a target language compiler. Just generate code.
4241
- [**no-runtime-validation**](#no-runtime-validation): If true, disable runtime validation.
@@ -57,13 +56,12 @@ c={
5756
auth: <true or false>
5857
build: <string>,
5958
build-type: <Debug, Release, RelWithDebInfo, or MinSizeRel>,
60-
cmake: <true or false>,
6159
cmake-include: <string or list of strings>,
6260
compiler: <string>,
61+
compiler-flags: <string or list of strings>,
6362
docker: <true or false>,
6463
fast: <true or false>,
6564
files: <string or list of strings>,
66-
flags: <string or list of strings>,
6765
logging: <error, warning, info, log, debug>,
6866
no-compile: <true or false>,
6967
protobufs: <string or list of strings>,
@@ -76,6 +74,7 @@ cpp={
7674
`target Cpp {
7775
build-type: <Debug, Release, RelWithDebInfo, or MinSizeRel>,
7876
cmake-include: <string or list of strings>,
77+
compiler: <string>,
7978
external-runtime-path: <string>,
8079
export-dependency-graph <true or false>,
8180
fast: <true or false>,
@@ -276,35 +275,6 @@ This is a list of features of the generated crate. Supported are:
276275
</ShowIf>
277276
</ShowIfs>
278277

279-
## cmake
280-
281-
<ShowIfs>
282-
<ShowIf py rs ts>
283-
This target does not support the `cmake` target option.
284-
</ShowIf>
285-
<ShowIf cpp>
286-
The C++ target does not support the `cmake` target option because it always uses `cmake`.
287-
</ShowIf>
288-
<ShowIf c>
289-
```lf-c
290-
target C {
291-
cmake: <true or false>
292-
};
293-
```
294-
295-
This will enable or disable the CMake-based build system (the default is `true`). Enabling the CMake build system will result in a `CMakeLists.txt` being generated in the `src-gen` directory. This `CMakeLists.txt` is then used when `cmake` is invoked by the LF runtime (either the `lfc` or the IDE). Alternatively, the generated program can be built manually. To do so, in the `src-gen/ProgramName` directory, run:
296-
297-
```sh
298-
mkdir build && cd build
299-
cmake ../
300-
make
301-
```
302-
303-
If `cmake` is disabled, `gcc` is directly invoked after code generation by default. In this case, additional target properties, such as [compiler](#compiler) and [flags](#flags) can be used to gain finer control over the compilation process.
304-
</ShowIf>
305-
</ShowIfs>
306-
307-
308278
<ShowOnly c cpp>
309279

310280
## cmake-include
@@ -361,25 +331,33 @@ See [`AsyncCallback.lf`](https://github.com/lf-lang/lingua-franca/blob/master/te
361331
<ShowIf ts py rs>
362332
This target does not support the `compiler` target option.
363333
</ShowIf>
334+
<ShowIf c cpp>
335+
This parameter is a string giving the name of the compiler to use. Normally
336+
CMake selects the best compiler for your system, but you can use this parameter
337+
to point to your preferred compiler. Possible values are, for instance, `gcc`,
338+
`g++`, `clang`, or `clang++`.
339+
</ShowIf>
340+
</ShowIfs>
341+
342+
## compiler-flags
343+
344+
<ShowIfs>
345+
<ShowIf cpp py ts rs>
346+
This target does not support the `compiler-flags` parameter.
347+
</ShowIf>
364348
<ShowIf c>
365-
This parameter is a string giving the name of the C compiler to use.
366-
It is used only when [cmake](#cmake) is set to `false`. For example:
349+
This parameter is a list of strings giving additional arguments to pass to the target language compiler. For example:
367350

368351
```lf-c
369352
target C {
370-
cmake: false,
371-
compiler: "cc",
353+
compiler-flags: ["-g", "-I/usr/local/include", "-L/usr/local/lib", "-lpaho-mqtt3c"],
372354
};
373355
```
374356

375-
The `compiler` option here specifies to use `cc` rather than `gcc`.
376-
</ShowIf>
377-
<ShowIf cpp>
378-
This parameter is a string giving the name of the C++ compiler to use. Normally
379-
CMake selects the best compiler for your system, but you can use this parameter
380-
to point it to your preferred C++ compiler.
381-
</ShowIf>
357+
The `compiler-flags` option specifies to include debug information in the compiled code (`-g`); a directory to search for include files (`-I/usr/local/include`); a directory to search for library files (`-L/usr/local/lib`); a library to link with (`-lpaho-mqtt3c`, which will link with file `libpaho-mqtt3c.so`).
382358

359+
**Note**: Using the `compiler-flags` parameter is strongly discouraged, although supported. Flags are compiler-specific, and thus interfere with CMake's ability to find the most suitable compiler for each platform. In a similar fashion, we recommend against the use of the `compiler` standard parameter for the same reason. A better solution is to provide a `cmake-include` file.
360+
</ShowIf>
383361
</ShowIfs>
384362

385363
## docker
@@ -498,29 +476,6 @@ Moreover, the `files` target specification works in conjunction with the `import
498476
</ShowIf>
499477
</ShowIfs>
500478
501-
## flags
502-
503-
<ShowIfs>
504-
<ShowIf cpp py ts rs>
505-
This target does not support the `flags` parameter.
506-
</ShowIf>
507-
<ShowIf c>
508-
This parameter is a list of strings giving additional arguments to pass to the target language compiler.
509-
It is used only when [cmake](#cmake) is set to `false`. For example:
510-
511-
```lf-c
512-
target C {
513-
cmake: false,
514-
flags: ["-g", "-I/usr/local/include", "-L/usr/local/lib", "-lpaho-mqtt3c"],
515-
};
516-
```
517-
518-
The `flags` option specifies to include debug information in the compiled code (`-g`); a directory to search for include files (`-I/usr/local/include`); a directory to search for library files (`-L/usr/local/lib`); a library to link with (`-lpaho-mqtt3c`, which will link with file `libpaho-mqtt3c.so`).
519-
520-
**Note**: Using the `flags` standard parameter when `cmake` is enabled is strongly discouraged, although supported. Flags are compiler-specific, and thus interfere with CMake's ability to find the most suitable compiler for each platform. In a similar fashion, we recommend against the use of the `compiler` standard parameter for the same reason. A better solution is to provide a `cmake-include` file, as described next.
521-
</ShowIf>
522-
</ShowIfs>
523-
524479
## logging
525480
526481
<ShowIfs>

0 commit comments

Comments
 (0)