From 9610c4e2adfdba22455fe07d1e7c4406d17e38b7 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 10 Jun 2024 15:35:30 +0100 Subject: [PATCH] SConstruct - use `pkg-config proj --variable=datadir` ro determine PROJ_LIB directory --- SConstruct | 51 +++++++-------------------------------------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/SConstruct b/SConstruct index 0c2b618d8..2720a0b7a 100644 --- a/SConstruct +++ b/SConstruct @@ -1,6 +1,6 @@ # This file is part of Mapnik (c++ mapping toolkit) # -# Copyright (C) 2021 Artem Pavlenko +# Copyright (C) 2024 Artem Pavlenko # # Mapnik is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -22,7 +22,7 @@ import re import platform from glob import glob from copy import copy -from subprocess import Popen, PIPE +from subprocess import run, Popen, PIPE from SCons.SConf import SetCacheMode import pickle @@ -949,54 +949,17 @@ int main() return ret def CheckProjData(context, silent=False): - if not silent: context.Message('Checking for PROJ_LIB directory...') - ret, out = context.TryRun(""" + result = run(['pkg-config', 'proj', '--variable=datadir'], stdout=PIPE) + value = result.stdout.decode('utf-8').strip() -#include -#include -#include -#include -#include -#include - -std::vector split_searchpath(std::string const& paths) -{ - std::vector output; - std::stringstream ss(paths); - std::string path; - - for( std::string path;std::getline(ss, path, ':');) - { - output.push_back(path); - } - return output; -} - -int main() -{ - PJ_INFO info = proj_info(); - std::string result = info.searchpath; - for (auto path : split_searchpath(result)) - { - std::ifstream file(path + "/proj.db"); - if (file) - { - std::cout << path; - return 0; - } - } - return -1; -} - -""", '.cpp') - value = out.strip() if silent: context.did_show_result=1 - if ret: - context.Result('proj_info.searchpath returned %s' % value) + if os.path.exists(value): + context.Result('`pkg-config proj --variable=datadir` returned:\n%s ' % value) else: + value = None context.Result('Failed to detect (mapnik-config will have null value)') return value