From: Mikko Rasa Date: Wed, 1 Sep 2021 00:17:51 +0000 (+0300) Subject: Use getenv from mspcore X-Git-Url: http://git.tdb.fi/?p=builder.git;a=commitdiff_plain;h=2193df46d4e7721dbb99ce744fbc884c2447e1f9 Use getenv from mspcore --- diff --git a/source/androidtools.cpp b/source/androidtools.cpp index 93b7bfa..118926e 100644 --- a/source/androidtools.cpp +++ b/source/androidtools.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -36,14 +36,16 @@ AndroidDevKit::AndroidDevKit(Builder &b, const string &type, const FS::Path &def builder(b) { string var = format("ANDROID_%s_ROOT", type); - if(const char *value = getenv(var.c_str())) - root = value; - else if(!default_path.empty() && FS::exists(default_path)) - root = default_path; - else + root = getenv(var); + if(root.empty()) { - builder.get_logger().log("problems", format("Android %s not found", type)); - return; + if(!default_path.empty() && FS::exists(default_path)) + root = default_path; + else + { + builder.get_logger().log("problems", format("Android %s not found", type)); + return; + } } FS::Path platforms_dir = root/"platforms"; diff --git a/source/jarsigner.cpp b/source/jarsigner.cpp index b8c9a50..991a718 100644 --- a/source/jarsigner.cpp +++ b/source/jarsigner.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "component.h" #include "externaltask.h" @@ -28,7 +28,7 @@ Task *JarSigner::run(const Target &tgt) const argv.push_back(executable->get_path().str()); // TODO Make this generic - FS::Path home_dir = getenv("HOME"); + FS::Path home_dir = Msp::getenv("HOME"); argv.push_back("-keystore"); argv.push_back((home_dir/".android"/"debug.keystore").str()); argv.push_back("-storepass"); diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index 36fe1c1..e240fb9 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -144,16 +144,20 @@ FileTarget *VirtualFileSystem::find_binary(const string &name) SearchPath path; if(FS::Path(name).is_absolute()) path.push_back("/"); - else if(const char *env_path = getenv("PATH")) - { - vector parts = split(env_path, ':'); - for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) - path.push_back(*i); - } else { - path.push_back("/bin"); - path.push_back("/usr/bin"); + string env_path = Msp::getenv("PATH"); + if(!env_path.empty()) + { + vector parts = split(env_path, ':'); + for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) + path.push_back(*i); + } + else + { + path.push_back("/bin"); + path.push_back("/usr/bin"); + } } for(SearchPath::const_iterator i=path.begin(); i!=path.end(); ++i)