aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-09-01 00:59:41 -0400
committerEli Schwartz <eschwartz@archlinux.org>2023-03-20 17:22:50 -0400
commita024d75e150334330954bf7a6fdbe8cb02a82491 (patch)
tree0504f3471f335d79d994d9f68028233f95f38bb5 /mesonbuild
parent2a0b80eb679f27402035faa93b3b6b16f5839724 (diff)
downloadmeson-a024d75e150334330954bf7a6fdbe8cb02a82491.zip
meson-a024d75e150334330954bf7a6fdbe8cb02a82491.tar.gz
meson-a024d75e150334330954bf7a6fdbe8cb02a82491.tar.bz2
backends: add a new "none" backend
It can only be used for projects that don't have any rules at all, i.e. they are purely using Meson to: - configure files - run (script?) tests - install files that exist by the end of the setup stage This can be useful e.g. for Meson itself, a pure python project.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py3
-rw-r--r--mesonbuild/backend/nonebackend.py31
-rw-r--r--mesonbuild/coredata.py2
-rw-r--r--mesonbuild/interpreter/interpreter.py2
-rw-r--r--mesonbuild/minstall.py14
-rw-r--r--mesonbuild/mtest.py8
6 files changed, 51 insertions, 9 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index aa9ba3e..fa1629b 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -251,6 +251,9 @@ def get_backend_from_name(backend: str, build: T.Optional[build.Build] = None, i
elif backend == 'xcode':
from . import xcodebackend
return xcodebackend.XCodeBackend(build, interpreter)
+ elif backend == 'none':
+ from . import nonebackend
+ return nonebackend.NoneBackend(build, interpreter)
return None
# This class contains the basic functionality that is needed by all backends.
diff --git a/mesonbuild/backend/nonebackend.py b/mesonbuild/backend/nonebackend.py
new file mode 100644
index 0000000..cf7c3dd
--- /dev/null
+++ b/mesonbuild/backend/nonebackend.py
@@ -0,0 +1,31 @@
+# Copyright 2022 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import annotations
+
+from .backends import Backend
+from .. import mlog
+from ..mesonlib import MesonBugException
+
+
+class NoneBackend(Backend):
+
+ name = 'none'
+
+ def generate(self):
+ if self.build.get_targets():
+ raise MesonBugException('None backend cannot generate target rules, but should have failed earlier.')
+ mlog.log('Generating simple install-only backend')
+ self.serialize_tests()
+ self.create_install_data_files()
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 564f54c..c252b22 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -61,7 +61,7 @@ if T.TYPE_CHECKING:
# But the corresponding Git tag needs to be '0.1.0rc1'
version = '1.0.99'
-backendlist = ['ninja', 'vs', 'vs2010', 'vs2012', 'vs2013', 'vs2015', 'vs2017', 'vs2019', 'vs2022', 'xcode']
+backendlist = ['ninja', 'vs', 'vs2010', 'vs2012', 'vs2013', 'vs2015', 'vs2017', 'vs2019', 'vs2022', 'xcode', 'none']
DEFAULT_YIELDING = False
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index b725b99..4c3f723 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -3090,6 +3090,8 @@ class Interpreter(InterpreterBase, HoldableObject):
"internal use. Please rename.")
def add_target(self, name: str, tobj: build.Target) -> None:
+ if self.backend.name == 'none':
+ raise InterpreterException('Install-only backend cannot generate target rules, try using `--backend=ninja`.')
if name == '':
raise InterpreterException('Target name must not be empty.')
if name.strip() == '':
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 6922c38..e61757b 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -14,7 +14,6 @@
from __future__ import annotations
from glob import glob
-from pathlib import Path
import argparse
import errno
import os
@@ -25,8 +24,7 @@ import subprocess
import sys
import typing as T
-from . import build
-from . import environment
+from . import build, coredata, environment
from .backend.backends import InstallData
from .mesonlib import MesonException, Popen_safe, RealPathAction, is_windows, setup_vsenv, pickle_load, is_osx
from .scripts import depfixer, destdir_join
@@ -755,8 +753,11 @@ class Installer:
# file mode needs to be set last, after strip/depfixer editing
self.set_mode(outname, install_mode, d.install_umask)
-def rebuild_all(wd: str) -> bool:
- if not (Path(wd) / 'build.ninja').is_file():
+def rebuild_all(wd: str, backend: str) -> bool:
+ if backend == 'none':
+ # nothing to build...
+ return True
+ if backend != 'ninja':
print('Only ninja backend is supported to rebuild the project before installation.')
return True
@@ -816,7 +817,8 @@ def run(opts: 'ArgumentType') -> int:
if not opts.no_rebuild:
b = build.load(opts.wd)
setup_vsenv(b.need_vsenv)
- if not rebuild_all(opts.wd):
+ backend = T.cast('str', b.environment.coredata.get_option(coredata.OptionKey('backend')))
+ if not rebuild_all(opts.wd, backend):
sys.exit(-1)
os.chdir(opts.wd)
with open(os.path.join(log_dir, 'install-log.txt'), 'w', encoding='utf-8') as lf:
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index e1c6a21..7685023 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -43,7 +43,7 @@ import xml.etree.ElementTree as et
from . import build
from . import environment
from . import mlog
-from .coredata import major_versions_differ, MesonVersionMismatchException
+from .coredata import MesonVersionMismatchException, OptionKey, major_versions_differ
from .coredata import version as coredata_version
from .mesonlib import (MesonException, OrderedSet, RealPathAction,
get_wine_shortpath, join_args, split_args, setup_vsenv)
@@ -2099,7 +2099,11 @@ def run(options: argparse.Namespace) -> int:
setup_vsenv(b.need_vsenv)
if not options.no_rebuild:
- if not (Path(options.wd) / 'build.ninja').is_file():
+ backend = b.environment.coredata.get_option(OptionKey('backend'))
+ if backend == 'none':
+ # nothing to build...
+ options.no_rebuild = True
+ elif backend != 'ninja':
print('Only ninja backend is supported to rebuild tests before running them.')
# Disable, no point in trying to build anything later
options.no_rebuild = True