aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-07-08 20:47:55 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-07-08 20:47:55 +0300
commitbbc3664028d50516796235e8ad619490c2f8b94d (patch)
treecc29401ef77d58ea900b6f61123781ccdbcb4cbc
parent7e3d9518827ef33073c6cc039cf972e879592820 (diff)
downloadmeson-bbc3664028d50516796235e8ad619490c2f8b94d.zip
meson-bbc3664028d50516796235e8ad619490c2f8b94d.tar.gz
meson-bbc3664028d50516796235e8ad619490c2f8b94d.tar.bz2
Moved some print functions to logging.
-rw-r--r--dependencies.py42
-rw-r--r--interpreter.py5
-rwxr-xr-xmeson.py8
-rw-r--r--mlog.py6
4 files changed, 32 insertions, 29 deletions
diff --git a/dependencies.py b/dependencies.py
index 81d20a1..e38388b 100644
--- a/dependencies.py
+++ b/dependencies.py
@@ -24,6 +24,7 @@
import os, stat, glob, subprocess, shutil
from coredata import MesonException
import environment
+import mlog
class DependencyException(MesonException):
def __init__(self, *args, **kwargs):
@@ -80,14 +81,14 @@ class PkgConfigDependency(Dependency):
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
- print('Dependency', name, 'found: NO')
+ mlog.log('Dependency', name, 'found:', mlog.red('NO'))
if required:
raise DependencyException('Required dependency %s not found.' % name)
self.modversion = 'none'
self.cflags = []
self.libs = []
else:
- print('Dependency', name, 'found: YES')
+ mlog.log('Dependency', name, 'found:', mlog.green('YES'))
self.is_found = True
self.modversion = out.decode().strip()
p = subprocess.Popen(['pkg-config', '--cflags', name], stdout=subprocess.PIPE,
@@ -119,7 +120,7 @@ class PkgConfigDependency(Dependency):
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Pkg-config executable not found.')
- print('Found pkg-config version %s.' % out.decode().strip())
+ mlog.log('Found pkg-config version %s.' % out.decode().strip())
PkgConfigDependency.pkgconfig_found = True
def found(self):
@@ -133,9 +134,9 @@ class ExternalProgram():
else:
self.fullpath = shutil.which(name)
if self.found():
- print('Program %s found: YES (%s)' % (name, self.fullpath))
+ mlog.log('Program', name, 'found:', mlog.green('YES'), '(%s)' % self.fullpath)
else:
- print('Program %s found: NO' % name)
+ mlog.log('Program', name, 'found:,', mlog.red('NO'))
def found(self):
return self.fullpath is not None
@@ -187,10 +188,9 @@ class BoostDependency(Dependency):
self.detect_src_modules()
self.detect_lib_modules()
self.validate_requested()
- print('Dependency Boost (%s) found: YES (%s)' %
- (module_str, self.version))
+ mlog.log('Dependency Boost (%s) found:,' % module_str, mlog.green('YES'), self.version)
else:
- print("Dependency Boost (%s) found: NO" % module_str)
+ mlog.log("Dependency Boost (%s) found:" % module_str, mlog.red('NO'))
def get_compile_flags(self):
return []
@@ -288,7 +288,7 @@ class GTestDependency(Dependency):
if self.main:
self.link_flags.append('-lgtest_main')
self.sources = []
- print('Dependency GTest found: YES (prebuilt)')
+ mlog.log('Dependency GTest found:', mlog.green('YES'), '(prebuilt)')
elif os.path.exists(self.src_dir):
self.is_found = True
self.compile_flags = ['-I' + self.src_include_dir]
@@ -297,9 +297,9 @@ class GTestDependency(Dependency):
self.sources = [self.all_src, self.main_src]
else:
self.sources = [self.all_src]
- print('Dependency GTest found: YES (building self)')
+ mlog.log('Dependency GTest found:', mlog.green('YES'), '(building self)')
else:
- print('Dependency GTest found: NO')
+ mlog.log('Dependency GTest found:', mlog.red('NO'))
self.is_found = False
self.link_flags.append('-lpthread')
return self.is_found
@@ -336,7 +336,7 @@ class GMockDependency(Dependency):
self.compile_flags = []
self.link_flags = ['-lgmock']
self.sources = []
- print('Dependency GMock found: YES (prebuilt)')
+ mlog.log('Dependency GMock found:', mlog.green('YES'), '(prebuilt)')
elif os.path.exists(self.src_dir):
self.is_found = True
self.compile_flags = ['-I' + self.src_include_dir]
@@ -345,10 +345,10 @@ class GMockDependency(Dependency):
self.sources = [self.all_src, self.main_src]
else:
self.sources = [self.all_src]
- print('Dependency GMock found: YES (building self)')
+ mlog.log('Dependency GMock found:', mlog.green('YES'), '(building self)')
else:
- print('Dependency GMock found: NO')
+ mlog.log('Dependency GMock found:', mlog.red('NO'))
self.is_found = False
def get_version(self):
@@ -379,7 +379,7 @@ class Qt5Dependency(Dependency):
self.modules.append(PkgConfigDependency('Qt5' + module, False))
if len(self.modules) == 0:
raise DependencyException('No Qt5 modules specified.')
- print('Dependency Qt5 tools:')
+ mlog.log('Dependency Qt5 tools:')
self.find_exes()
def find_exes(self):
@@ -394,18 +394,18 @@ class Qt5Dependency(Dependency):
moc_ver = mp.communicate()[1].decode().strip()
if 'Qt 5' not in moc_ver:
raise DependencyException('Moc preprocessor is not for Qt 5. Output: %s' % moc_ver)
- print(' moc: YES (%s)' % moc_ver)
+ mlog.log(' moc:', mlog.green('YES'), '(%s)' % moc_ver)
else:
- print(' moc: NO')
+ mlog.log(' moc:', mlog.red('NO'))
if self.uic.found():
up = subprocess.Popen([self.uic.get_command(), '-v'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
uic_ver = up.communicate()[1].decode().strip()
if 'version 5.' not in uic_ver:
raise DependencyException('Uic compiler is not for Qt 5. Output: %s' % uic_ver)
- print(' uic: YES (%s)' % uic_ver)
+ mlog.log(' uic:', mlog.green('YES'), '(%s)' % uic_ver)
else:
- print(' uic: NO')
+ mlog.log(' uic:', mlog.red('NO'))
def get_version(self):
return self.modules[0].get_version()
@@ -462,7 +462,7 @@ class GnuStepDependency(Dependency):
gp.communicate()
if gp.returncode != 0:
self.flags = None
- print('Dependency GnuStep found: NO')
+ mlog.log('Dependency GnuStep found:', mlog.red('NO'))
return
if 'gui' in self.modules:
arg = '--gui-libs'
@@ -485,7 +485,7 @@ class GnuStepDependency(Dependency):
if fp.returncode != 0:
raise DependencyException('Error getting objc-lib flags: %s %s' % (libtxt, liberr))
self.libs = self.weird_filter(libtxt.split())
- print('Dependency GnuStep found: YES')
+ mlog.log('Dependency GnuStep found:', mlog.green('YES'))
def weird_filter(self, elems):
"""When building packages, the output of the enclosing Make
diff --git a/interpreter.py b/interpreter.py
index 15f05cd..21c26bb 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -17,6 +17,7 @@ import nodes
import environment
import coredata
import dependencies
+import mlog
import os, sys, platform, copy, subprocess, shutil
class InterpreterException(coredata.MesonException):
@@ -833,12 +834,12 @@ class Interpreter():
if self.build.project is not None:
raise InvalidCode('Second call to project().')
self.build.project = args[0]
- print('Project name is "%s".' % self.build.project)
+ mlog.log('Project name is "', mlog.bold(self.build.project), '".', sep='')
self.add_languages(node, args[1:])
def func_message(self, node, args, kwargs):
self.validate_arguments(args, 1, [str])
- print('Message: %s' % args[0])
+ mlog.log(mlog.bold('Message:'), args[0])
def add_languages(self, node, args):
for lang in args:
diff --git a/meson.py b/meson.py
index 5d32f98..378590a 100755
--- a/meson.py
+++ b/meson.py
@@ -19,7 +19,7 @@ import sys, stat, traceback
import os.path
import environment, interpreter
import backends, build
-import mlog
+import mlog, coredata
from coredata import version, MesonException
@@ -96,6 +96,10 @@ class MesonApp():
def generate(self):
env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_file, options)
mlog.initialize(env.get_log_dir())
+ mlog.log(mlog.bold('The Meson build system'))
+ mlog.log(' version:', coredata.version)
+ mlog.log('Source dir:', mlog.cyan(app.source_dir))
+ mlog.log('Build dir:', mlog.cyan(app.build_dir))
b = build.Build(env)
intr = interpreter.Interpreter(b)
intr.run()
@@ -125,8 +129,6 @@ if __name__ == '__main__':
else:
this_file = resolved
app = MesonApp(dir1, dir2, this_file, options)
- print ('Source dir: ' + app.source_dir)
- print ('Build dir: ' + app.build_dir)
try:
app.generate()
except Exception as e:
diff --git a/mlog.py b/mlog.py
index fb9418e..666fa10 100644
--- a/mlog.py
+++ b/mlog.py
@@ -62,10 +62,10 @@ def process_markup(args, keep):
arr.append(str(arg))
return arr
-def log(*args):
+def log(*args, **kwargs):
arr = process_markup(args, False)
if log_file is not None:
- print(*arr, file=log_file) # Log file never gets ANSI codes.
+ print(*arr, file=log_file, **kwargs) # Log file never gets ANSI codes.
if colorize_console:
arr = process_markup(args, True)
- print(*arr)
+ print(*arr, **kwargs)