File: run.cpp

package info (click to toggle)
mapnik 3.0.12%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 17,084 kB
  • ctags: 18,454
  • sloc: cpp: 142,516; python: 1,416; sh: 769; makefile: 170; xml: 140; lisp: 13
file content (73 lines) | stat: -rw-r--r-- 1,687 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"

#include <string>
#include <mapnik/util/fs.hpp>
#include <mapnik/datasource_cache.hpp>
#include <boost/filesystem/convenience.hpp>

#include "cleanup.hpp" // run_cleanup()

std::string plugin_path;

inline void set_plugin_path(Catch::ConfigData&, std::string const& _plugin_path ) {
    plugin_path = _plugin_path;
}

std::string working_dir;

inline void set_working_dir(Catch::ConfigData&, std::string const& _working_dir ) {
    working_dir = _working_dir;
}


int main (int argc, char* const argv[])
{
    Catch::Session session;

    auto & cli = session.cli();

    cli["-p"]["--plugins"]
        .describe("path to mapnik plugins")
        .bind(&set_plugin_path, "plugins");

    cli["-C"]["--working-directory"]
        .describe("change working directory")
        .bind(&set_working_dir, "working directory");

    int result = session.applyCommandLine(argc, argv);

    if (!plugin_path.empty())
    {
        if (!mapnik::util::exists(plugin_path))
        {
            std::clog << "Could not find " << plugin_path << "\n";
            return -1;
        }
        mapnik::datasource_cache::instance().register_datasources(plugin_path);
    }
    else
    {
        mapnik::datasource_cache::instance().register_datasources("plugins/input/");
    }

    if (!working_dir.empty())
    {
        if (!mapnik::util::exists(working_dir))
        {
            std::clog << "Could not find " << working_dir << "\n";
            return -1;
        }
        boost::filesystem::current_path(working_dir);
    }

    if (result == 0)
    {
        result = session.run();
    }

    testing::run_cleanup();

    return result;

}