1
0
Fork 0

Build- and run-time concept of developer mode.

Make a single Cmake value to expose the build type to code, and use
this to default a run-time ‘developer-mode’ property, which can be
over-ridden from the command line.

Use this to drive the different warning levels. Policies subject to
review, especially whether nightly builds should default to 
developer mode or not.
This commit is contained in:
James Turner 2017-02-27 23:15:07 +00:00
parent be0ede64be
commit 3653508412
12 changed files with 95 additions and 96 deletions

View file

@ -25,6 +25,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"MinSizeRel" "RelWithDebInfo")
endif()
if(NOT FG_BUILD_TYPE)
message(STATUS "Setting build type to 'Dev' as none was specified.")
set(FG_BUILD_TYPE Dev CACHE STRING "Choose the FlightGear build type" FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE FG_BUILD_TYPE PROPERTY STRINGS "Dev" "Nightly" "Release")
endif()
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks")
# when building, don't use the install RPATH already
@ -176,8 +183,6 @@ option(SYSTEM_SPEEX "Set to ON to build IAXClient with the system's speex a
option(SYSTEM_GSM "Set to ON to build IAXClient with the system's GSM library" ${SYSTEM_GSM_DEFAULT})
option(SYSTEM_FLITE "Set to ON to build Flightgear with the system's Flite library" ${SYSTEM_FLITE_DEFAULT})
option(SYSTEM_HTS_ENGINE "Set to ON to build Flightgear with the system's HTS Engine library" ${SYSTEM_HTS_ENGINE_DEFAULT})
option(FG_NIGHTLY "Set to ON to mark this as a nightly build" OFF)
option(ENABLE_DEV_WARNINGS "Set to ON to include developer-warnings" OFF)
# additional utilities
option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON)

View file

@ -576,11 +576,9 @@ void FGSubmodelMgr::setData(int id, const string& path, bool serviceable, const
sm->pitch_offset = new FGXMLAutopilot::InputValue(*prop_root, b ? *b : n);
if (b) old = true;
#if defined(ENABLE_DEV_WARNINGS)
if (old) {
SG_LOG(SG_AI, SG_WARN, "Submodels: <*-offset> is deprecated. Use <offsets> instead");
SG_LOG(SG_AI, SG_DEV_WARN, "Submodels: <*-offset> is deprecated. Use <offsets> instead");
}
#endif
}
// Randomness

View file

@ -231,11 +231,9 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
if(a->hasAttribute("version")) {
_airplane.setVersion( a->getValue("version") );
}
#if defined(ENABLE_DEV_WARNINGS)
if( !_airplane.isVersionOrNewer( Version::YASIM_VERSION_CURRENT ) ) {
SG_LOG(SG_FLIGHT,SG_ALERT, "This aircraft does not use the latest yasim configuration version.");
SG_LOG(SG_FLIGHT, SG_DEV_ALERT, "This aircraft does not use the latest yasim configuration version.");
}
#endif
} else if(eq(name, "approach")) {
float spd = attrf(a, "speed") * KTS2MPS;
float alt = attrf(a, "alt", 0) * FT2M;

View file

@ -1,7 +1,6 @@
#cmakedefine FG_NDEBUG
#cmakedefine FG_NIGHTLY
#cmakedefine ENABLE_SIMD
#cmakedefine ENABLE_SP_FDM
@ -52,4 +51,4 @@
#cmakedefine HAVE_QT
#cmakedefine ENABLE_DEV_WARNINGS
#define FG_BUILD_TYPE "@FG_BUILD_TYPE@"

View file

@ -289,9 +289,7 @@ int main ( int argc, char **argv )
::snprintf(buf, 16, "%d", HUDSON_BUILD_NUMBER);
crAddProperty("hudson-build-number", buf);
crAddProperty("git-revision", REVISION);
#if defined(FG_NIGHTLY)
crAddProperty("nightly-build", "true");
#endif
crAddProperty("build-type", FG_BUILD_TYPE);
}
#endif
@ -372,4 +370,3 @@ void fgExitCleanup() {
simgear::shutdownLogging();
}

View file

@ -474,6 +474,21 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
options->init(argc, argv, dataPath);
}
// establish default for developer-mode based upon compiled build types
bool developerMode = true;
if (!strcmp(FG_BUILD_TYPE, "Release")) {
developerMode = false;
}
// allow command line to override
if (options->isOptionSet("developer")) {
string s = options->valueForOption("developer", "yes");
developerMode = simgear::strutils::to_bool(s);
}
fgSetBool("/sim/developer-mode", developerMode);
sglog().setDeveloperMode(developerMode);
// Read global defaults from $FG_ROOT/defaults
SG_LOG(SG_GENERAL, SG_INFO, "Reading global defaults");
SGPath defaultsXML = globals->get_fg_root() / "defaults.xml";

View file

@ -82,14 +82,12 @@ public:
string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir));
if (!aircraftDirPieces.empty() && (aircraftDirPieces.back() == pieces[1])) {
// disable this warning for release builds
#if defined(ENABLE_DEV_WARNINGS)
SGPath betterPath;
for (unsigned int i=2; i<pieces.size(); ++i) {
betterPath.append(pieces[i]);
}
SG_LOG(SG_AIRCRAFT, SG_WARN, "resolved path:" << aResource << " using /sim/aircraft-dir.\n"
SG_LOG(SG_AIRCRAFT, SG_DEV_WARN, "resolved path:" << aResource << " using /sim/aircraft-dir.\n"
"This is legacy behaviour, change to an aircraft relative path:" << betterPath);
#endif
// current aircraft-dir matches resource aircraft
SGPath r(aircraftDir);

View file

@ -455,6 +455,7 @@ int fgMainInit( int argc, char **argv )
std::string version(FLIGHTGEAR_VERSION);
SG_LOG( SG_GENERAL, SG_INFO, "FlightGear: Version "
<< version );
SG_LOG( SG_GENERAL, SG_INFO, "FlightGear: Build Type " << FG_BUILD_TYPE );
SG_LOG( SG_GENERAL, SG_INFO, "Built with " << SG_COMPILER_STR);
SG_LOG( SG_GENERAL, SG_INFO, "Jenkins number/ID " << HUDSON_BUILD_NUMBER << ":"
<< HUDSON_BUILD_ID);

View file

@ -243,11 +243,7 @@ void fgSetDefaults ()
v->setValueReadOnly("build-number", HUDSON_BUILD_NUMBER);
v->setValueReadOnly("build-id", HUDSON_BUILD_ID);
v->setValueReadOnly("hla-support", bool(FG_HAVE_HLA));
#if defined(FG_NIGHTLY)
v->setValueReadOnly("nightly-build", true);
#else
v->setValueReadOnly("nightly-build", false);
#endif
v->setValueReadOnly("build-type", FG_BUILD_TYPE);
char* envp = ::getenv( "http_proxy" );
if( envp != NULL )
@ -1755,6 +1751,7 @@ struct OptionDesc {
{"no-default-config", false, OPTION_IGNORE, "", false, "", 0},
{"prop", true, OPTION_FUNC | OPTION_MULTI, "", false, "", fgOptSetProperty},
{"load-tape", true, OPTION_FUNC, "", false, "", fgOptLoadTape },
{"developer", true, OPTION_IGNORE | OPTION_BOOL, "", false, "", nullptr },
{0}
};
@ -2637,6 +2634,7 @@ void Options::showVersion() const
cout << "FlightGear version: " << FLIGHTGEAR_VERSION << endl;
cout << "Revision: " << REVISION << endl;
cout << "Build-Id: " << HUDSON_BUILD_ID << endl;
cout << "Build-Type: " << FG_BUILD_TYPE << endl;
cout << "FG_ROOT=" << globals->get_fg_root().utf8Str() << endl;
cout << "FG_HOME=" << globals->get_fg_home().utf8Str() << endl;
cout << "FG_SCENERY=";
@ -2673,6 +2671,7 @@ void Options::printJSONReport() const
cJSON_AddStringToObject(generalNode, "name", "FlightGear");
cJSON_AddStringToObject(generalNode, "version", FLIGHTGEAR_VERSION);
cJSON_AddStringToObject(generalNode, "build ID", HUDSON_BUILD_ID);
cJSON_AddStringToObject(generalNode, "build type", FG_BUILD_TYPE);
cJSON *configNode = cJSON_CreateObject();
cJSON_AddItemToObject(rootNode, "config", configNode);

View file

@ -375,12 +375,10 @@ void FGElectricalSystem::init () {
if ( path.length() ) {
SGPath config = globals->resolve_aircraft_path(path);
#if defined(ENABLE_DEV_WARNINGS)
// load an obsolete xml configuration
SG_LOG( SG_SYSTEMS, SG_WARN,
SG_LOG( SG_SYSTEMS, SG_DEV_WARN,
"Reading deprecated xml electrical system model from\n "
<< config.str() );
#endif
try {
readProperties( config, config_props );

View file

@ -321,9 +321,7 @@ private:
if (!FGAISchedule::validModelPath(mdl)) {
missingModels.insert(mdl);
#if defined(ENABLE_DEV_WARNINGS)
SG_LOG(SG_AI, SG_WARN, "TrafficMgr: Missing model path:" << mdl);
#endif
SG_LOG(SG_AI, SG_DEV_WARN, "TrafficMgr: Missing model path:" << mdl);
requiredAircraft = homePort = "";
return;
}
@ -586,17 +584,13 @@ void FGTrafficManager::finishInit()
assert(doingInit);
SG_LOG(SG_AI, SG_INFO, "finishing AI-Traffic init");
loadHeuristics();
#if defined(ENABLE_DEV_WARNINGS)
PerformanceDB* perfDB = globals->get_subsystem<PerformanceDB>();
#endif
// Do sorting and scoring separately, to take advantage of the "homeport" variable
BOOST_FOREACH(FGAISchedule* schedule, scheduledAircraft) {
schedule->setScore();
#if defined(ENABLE_DEV_WARNINGS)
if (!perfDB->havePerformanceDataForAircraftType(schedule->getAircraft())) {
SG_LOG(SG_AI, SG_WARN, "AI-Traffic: schedule aircraft missing performance data:" << schedule->getAircraft());
SG_LOG(SG_AI, SG_DEV_WARN, "AI-Traffic: schedule aircraft missing performance data:" << schedule->getAircraft());
}
#endif
}
sort(scheduledAircraft.begin(), scheduledAircraft.end(),
@ -641,10 +635,8 @@ void FGTrafficManager::loadHeuristics()
break;
HeuristicMapIterator itr = heurMap.find(h.registration);
if (itr != heurMap.end()) {
#if defined(ENABLE_DEV_WARNINGS)
SG_LOG(SG_AI, SG_WARN,"Traffic Manager Warning: found duplicate tailnumber " <<
SG_LOG(SG_AI, SG_DEV_WARN,"Traffic Manager Warning: found duplicate tailnumber " <<
h.registration << " for AI aircraft");
#endif
} else {
heurMap[h.registration] = h;
}

View file

@ -176,13 +176,12 @@ void SplashScreen::createNodes()
osgText::Text::RIGHT_BOTTOM,
fgGetNode("/sim/startup/splash-progress-spinner", true));
#if defined(FG_NIGHTLY)
if (!strcmp(FG_BUILD_TYPE, "Nightly")) {
addText(geode, osg::Vec2(0.5, 0.5), 0.03,
"Unstable nightly build - some features may be under active development",
osgText::Text::CENTER_CENTER,
nullptr, -1.0, osg::Vec4(1.0, 0.0, 0.0, 1.0));
#endif
}
///////////