]> git.tdb.fi Git - builder.git/commitdiff
Use getenv from mspcore
authorMikko Rasa <tdb@tdb.fi>
Wed, 1 Sep 2021 00:17:51 +0000 (03:17 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 1 Sep 2021 00:19:48 +0000 (03:19 +0300)
source/androidtools.cpp
source/jarsigner.cpp
source/virtualfilesystem.cpp

index 93b7bfac7a05d941f128ab55fcf05c088736e51d..118926e1aa3e29dd277d77f138090c65305536b2 100644 (file)
@@ -1,4 +1,4 @@
-#include <cstdlib>
+#include <msp/core/environ.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/strings/format.h>
@@ -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";
index b8c9a5092607f2c817147bb2b877864f465705cc..991a7188088da7d4b2b7bfcc016839d25d96f53d 100644 (file)
@@ -1,4 +1,4 @@
-#include <cstdlib>
+#include <msp/core/environ.h>
 #include <msp/fs/utils.h>
 #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");
index 36fe1c129190e83ebd7736e7557a2619d27e9db8..e240fb9e777b74590f39dfe23d2d417d18fb7303 100644 (file)
@@ -1,4 +1,4 @@
-#include <cstdlib>
+#include <msp/core/environ.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
 #include <msp/io/print.h>
@@ -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<string> parts = split(env_path, ':');
-               for(vector<string>::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<string> parts = split(env_path, ':');
+                       for(vector<string>::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)