mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Add way to disable "no extensions found" message (#2134)
We want it enabled by default, but there have been requests for a way to disable it.
This commit is contained in:
committed by
Peter Johnson
parent
4f951789fe
commit
b2ae75acd8
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "hal/Types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup hal_extensions Simulator Extensions
|
* @defgroup hal_extensions Simulator Extensions
|
||||||
* @ingroup hal_capi
|
* @ingroup hal_capi
|
||||||
@@ -41,5 +43,19 @@ int HAL_LoadOneExtension(const char* library);
|
|||||||
* @return the succes state of the initialization
|
* @return the succes state of the initialization
|
||||||
*/
|
*/
|
||||||
int HAL_LoadExtensions(void);
|
int HAL_LoadExtensions(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the message saying no HAL extensions were found.
|
||||||
|
*
|
||||||
|
* Some apps don't care, and the message create clutter. For general team code,
|
||||||
|
* we want it.
|
||||||
|
*
|
||||||
|
* This must be called before HAL_Initialize is called.
|
||||||
|
*
|
||||||
|
* This defaults to true.
|
||||||
|
*
|
||||||
|
* @param showMessage true to show message, false to not.
|
||||||
|
*/
|
||||||
|
void HAL_SetShowExtensionsNotFoundMessages(HAL_Bool showMessage);
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ void InitializeExtensions() {}
|
|||||||
} // namespace init
|
} // namespace init
|
||||||
} // namespace hal
|
} // namespace hal
|
||||||
|
|
||||||
|
static bool& GetShowNotFoundMessage() {
|
||||||
|
static bool showMsg = true;
|
||||||
|
return showMsg;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
int HAL_LoadOneExtension(const char* library) {
|
int HAL_LoadOneExtension(const char* library) {
|
||||||
@@ -91,8 +96,10 @@ int HAL_LoadExtensions(void) {
|
|||||||
wpi::SmallVector<wpi::StringRef, 2> libraries;
|
wpi::SmallVector<wpi::StringRef, 2> libraries;
|
||||||
const char* e = std::getenv("HALSIM_EXTENSIONS");
|
const char* e = std::getenv("HALSIM_EXTENSIONS");
|
||||||
if (!e) {
|
if (!e) {
|
||||||
wpi::outs() << "HAL Extensions: No extensions found\n";
|
if (GetShowNotFoundMessage()) {
|
||||||
wpi::outs().flush();
|
wpi::outs() << "HAL Extensions: No extensions found\n";
|
||||||
|
wpi::outs().flush();
|
||||||
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
wpi::StringRef env{e};
|
wpi::StringRef env{e};
|
||||||
@@ -105,4 +112,8 @@ int HAL_LoadExtensions(void) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HAL_SetShowExtensionsNotFoundMessages(HAL_Bool showMessage) {
|
||||||
|
GetShowNotFoundMessage() = showMessage;
|
||||||
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|||||||
Reference in New Issue
Block a user