From 2193df46d4e7721dbb99ce744fbc884c2447e1f9 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 1 Sep 2021 03:17:51 +0300 Subject: [PATCH] Use getenv from mspcore --- source/androidtools.cpp | 18 ++++++++++-------- source/jarsigner.cpp | 4 ++-- source/virtualfilesystem.cpp | 22 +++++++++++++--------- 3 files changed, 25 insertions(+), 19 deletions(-) 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) -- 2.43.0