Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runtime.ini path section header name #1440

Merged
10 commits merged into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions docs/guide/controller-programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,17 @@ Environment variables in this file can contain references to other environment v
They will be automatically replaced by the actual value already existing in the environment.
The Webots "runtime.ini" supports 7 sections:

- `[environment variables with relative paths]`
- `[environment variables with paths]`

This section should contain only environment variables with relative paths.
Paths must be separated by the colon symbol ':' and the separator between
directories is the slash symbol '/'. Variables declared in this section will be
This section should only contain environment variables with either relative or
absolute paths. Paths must be separated using the colon symbol ':' and directory components
must be separated using the slash symbol '/'. Variables declared in this section will be
added on every platform. On Windows, colons will be replaced by semicolon and
slash will be replaced by backslash according to the Windows syntax.

**NOTE**: The legacy form of this section was ```[environment variables with relative path]```.
You are encouraged to follow the new notation, though the backward compability is kept.
This conversation was marked as resolved.
Show resolved Hide resolved

- `[environment variables]`

Environment variables defined in this section will also be added to the
Expand Down Expand Up @@ -523,7 +526,7 @@ Here is an example of a typical runtime.ini file.
```ini
; typical runtime.ini

[environment variables with relative paths]
[environment variables with paths]
WEBOTS_LIBRARY_PATH = lib:$(WEBOTS_LIBRARY_PATH):../../library

[environment variables]
Expand Down Expand Up @@ -559,7 +562,7 @@ In the example above, the resulting command issued by Webots will be: `/opt/loca
```ini
; runtime.ini for a Java controller on Windows

[environment variables with relative paths]
[environment variables with paths]
CLASSPATH = ../lib/MyLibrary.jar
JAVA_LIBRARY_PATH = ../lib

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[environment variables with relative paths]
[environment variables with paths]
PYTHONPATH=python/site-packages:kinetic/dist-packages

[environment variables]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[environment variables with relative paths]
[environment variables with paths]

WEBOTS_LIBRARY_PATH=$(WEBOTS_HOME)/projects/automobile/libraries/car:$(WEBOTS_HOME)/projects/automobile/libraries/driver:$(WEBOTS_HOME)/projects/automobile/libraries/CppCar:$(WEBOTS_HOME)/projects/automobile/libraries/CppDriver:$(WEBOTS_HOME)/projects/automobile/libraries/python:$(WEBOTS_LIBRARY_PATH)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[environment variables with relative paths]
[environment variables with paths]
PYTHONPATH=$(WEBOTS_HOME)/projects/languages/ros/controllers/ros_python/python/site-packages:$(WEBOTS_HOME)/projects/languages/ros/controllers/ros_python/kinetic/dist-packages

[environment variables]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[environment variables with relative paths]
[environment variables with paths]

AUTOMOBILE_LIBRARIES_PATH=$(WEBOTS_HOME)/projects/vehicles/libraries
WEBOTS_LIBRARY_PATH=$(AUTOMOBILE_LIBRARIES_PATH)/python:$(AUTOMOBILE_LIBRARIES_PATH)/CppCar:$(AUTOMOBILE_LIBRARIES_PATH)/CppDriver:$(AUTOMOBILE_LIBRARIES_PATH)/driver:$(AUTOMOBILE_LIBRARIES_PATH)/car:$(WEBOTS_LIBRARY_PATH)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[environment variables with relative paths]
[environment variables with paths]

ROBOTIS_PATH=$(WEBOTS_HOME)/projects/robots/robotis/darwin-op
WEBOTS_LIBRARY_PATH=$(ROBOTIS_PATH)/libraries/python:$(ROBOTIS_PATH)/libraries/python27:$(ROBOTIS_PATH)/libraries/python35:$(ROBOTIS_PATH)/libraries/python36:$(ROBOTIS_PATH)/libraries/python37:$(ROBOTIS_PATH)/libraries/robotis-op2:$(ROBOTIS_PATH)/libraries/managers:$(WEBOTS_LIBRARY_PATH)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[environment variables with relative paths]
[environment variables with paths]

FIREJAIL_PATH=$(WEBOTS_HOME)/projects/robots/gctronic/e-puck/plugins/remote_controls/e-puck_bluetooth/libe-puck_bluetooth.so
10 changes: 6 additions & 4 deletions src/webots/control/WbController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ void WbController::start() {
warn(tr("Environment variables from runtime.ini could not be loaded: the file contains illegal definitions."));
else {
for (int i = 0; i < iniParser.size(); ++i) {
if (iniParser.sectionAt(i).compare("environment variables with relative paths") != 0 &&
iniParser.sectionAt(i).compare("environment variables for Linux") != 0 &&
iniParser.sectionAt(i).compare("environment variables for Linux 64") != 0)
if ((iniParser.sectionAt(i).compare("environment variables with relative paths") ||
iniParser.sectionAt(i).compare("environment variables with paths")) &&
This conversation was marked as resolved.
Show resolved Hide resolved
iniParser.sectionAt(i).compare("environment variables for Linux") &&
iniParser.sectionAt(i).compare("environment variables for Linux 64"))
continue;

if (iniParser.keyAt(i) == ("WEBOTS_LIBRARY_PATH") || iniParser.keyAt(i) == ("FIREJAIL_PATH")) {
Expand Down Expand Up @@ -368,7 +369,8 @@ void WbController::setProcessEnvironment() {
for (int i = 0; i < iniParser.size(); ++i) {
const QString &value = iniParser.resolvedValueAt(i, env);
iniParser.setValue(i, value);
if (!iniParser.sectionAt(i).compare("environment variables with relative paths", Qt::CaseInsensitive))
if (!iniParser.sectionAt(i).compare("environment variables with relative paths", Qt::CaseInsensitive) ||
!iniParser.sectionAt(i).compare("environment variables with paths", Qt::CaseInsensitive))
addPathEnvironmentVariable(env, iniParser.keyAt(i), iniParser.valueAt(i), true);
if (!iniParser.sectionAt(i).compare("environment variables", Qt::CaseInsensitive))
addEnvironmentVariable(env, iniParser.keyAt(i), iniParser.valueAt(i));
Expand Down
3 changes: 2 additions & 1 deletion src/webots/core/WbIniParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ void WbIniParser::setValue(int index, QString newValue) {

QString WbIniParser::resolvedValueAt(int index, const QStringList &environment) const {
QString value = valueAt(index);
if (!sectionAt(index).compare("environment variables with relative paths", Qt::CaseInsensitive)) {
if (!sectionAt(index).compare("environment variables with relative paths", Qt::CaseInsensitive) ||
!sectionAt(index).compare("environment variables with paths", Qt::CaseInsensitive)) {
#ifdef _WIN32
QString newWindowsValue = value;
newWindowsValue.replace(':', ';');
Expand Down
2 changes: 1 addition & 1 deletion tests/api/controllers/runtime_config_file/runtime.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[environment variables with relative paths]
[environment variables with paths]
TEST_RELATIVE_PATHS=test1/test2:test3

[environment variables]
Expand Down