diff options
-rw-r--r-- | docs/markdown/Configuration.md | 1 | ||||
-rw-r--r-- | docs/markdown/Syntax.md | 7 | ||||
-rw-r--r-- | docs/markdown/snippets/integer-base.md | 9 | ||||
-rw-r--r-- | mesonbuild/backend/backends.py | 50 | ||||
-rw-r--r-- | mesonbuild/dependencies/ui.py | 2 | ||||
-rw-r--r-- | mesonbuild/environment.py | 4 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 3 | ||||
-rw-r--r-- | mesonbuild/mparser.py | 8 | ||||
-rw-r--r-- | mesonbuild/scripts/depfixer.py | 20 | ||||
-rw-r--r-- | test cases/common/68 number arithmetic/meson.build | 12 | ||||
-rw-r--r-- | test cases/failing/75 configuration immutable/input | 0 | ||||
-rw-r--r-- | test cases/failing/75 configuration immutable/meson.build | 12 | ||||
-rw-r--r-- | test cases/failing/76 int literal leading zero/meson.build | 6 |
13 files changed, 80 insertions, 54 deletions
diff --git a/docs/markdown/Configuration.md b/docs/markdown/Configuration.md index d8fa54e..89f423c 100644 --- a/docs/markdown/Configuration.md +++ b/docs/markdown/Configuration.md @@ -39,6 +39,7 @@ use a single `configuration_data` object as many times as you like, but it becomes immutable after being passed to the `configure_file` function. That is, after it has been used once to generate output the `set` function becomes unusable and trying to call it causes an error. +Copy of immutable `configuration_data` is still immutable. For more complex configuration file generation Meson provides a second form. To use it, put a line like this in your configuration file. diff --git a/docs/markdown/Syntax.md b/docs/markdown/Syntax.md index 42002f4..5a6734d 100644 --- a/docs/markdown/Syntax.md +++ b/docs/markdown/Syntax.md @@ -64,6 +64,13 @@ Hexadecimal literals are supported since version 0.45.0: int_255 = 0xFF ``` +Octal and binary literals are supported since version 0.47.0: + +```meson +int_493 = 0o755 +int_1365 = 0b10101010101 +``` + Strings can be converted to a number like this: ```meson diff --git a/docs/markdown/snippets/integer-base.md b/docs/markdown/snippets/integer-base.md new file mode 100644 index 0000000..0a27c9a --- /dev/null +++ b/docs/markdown/snippets/integer-base.md @@ -0,0 +1,9 @@ +## Octal and binary string literals + +Octal and binary integer literals can now be used in build and option files. + +```meson +int_493 = 0o755 +int_1365 = 0b10101010101 +``` + diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 6499105..02ce52d 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -334,38 +334,38 @@ class Backend: def rpaths_for_bundled_shared_libraries(self, target): paths = [] for dep in target.external_deps: - if isinstance(dep, (dependencies.ExternalLibrary, dependencies.PkgConfigDependency)): - la = dep.link_args - if len(la) == 1 and os.path.isabs(la[0]): - # The only link argument is an absolute path to a library file. - libpath = la[0] - if libpath.startswith(('/usr/lib', '/lib')): - # No point in adding system paths. - continue - if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so']: - continue - absdir = os.path.dirname(libpath) - if absdir.startswith(self.environment.get_source_dir()): - rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] - assert not os.path.isabs(rel_to_src), 'rel_to_src: {} is absolute'.format(rel_to_src) - paths.append(os.path.join(self.build_to_src, rel_to_src)) - else: - paths.append(absdir) + if not isinstance(dep, (dependencies.ExternalLibrary, dependencies.PkgConfigDependency)): + continue + la = dep.link_args + if len(la) != 1 or not os.path.isabs(la[0]): + continue + # The only link argument is an absolute path to a library file. + libpath = la[0] + if libpath.startswith(('/usr/lib', '/lib')): + # No point in adding system paths. + continue + # Windows doesn't support rpaths, but we use this function to + # emulate rpaths by setting PATH, so also accept DLLs here + if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so', '.dylib']: + continue + absdir = os.path.dirname(libpath) + if absdir.startswith(self.environment.get_source_dir()): + rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] + assert not os.path.isabs(rel_to_src), 'rel_to_src: {} is absolute'.format(rel_to_src) + paths.append(os.path.join(self.build_to_src, rel_to_src)) + else: + paths.append(absdir) return paths def determine_rpath_dirs(self, target): link_deps = target.get_all_link_deps() - result = [] + result = set() for ld in link_deps: if ld is target: continue - prospective = self.get_target_dir(ld) - if prospective not in result: - result.append(prospective) - for rp in self.rpaths_for_bundled_shared_libraries(target): - if rp not in result: - result += [rp] - return result + result.add(self.get_target_dir(ld)) + result.update(self.rpaths_for_bundled_shared_libraries(target)) + return list(result) def object_filename_from_source(self, target, source): assert isinstance(source, mesonlib.File) diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 2f31196..b136d2b 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -409,7 +409,7 @@ class SDL2Dependency(ExternalDependency): 'sdl2', environment, None, kwargs, ['sdl2-config'], 'sdl2-config') if ctdep.found(): ctdep.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args') - ctdep.links_args = ctdep.get_config_value(['--libs'], 'link_args') + ctdep.link_args = ctdep.get_config_value(['--libs'], 'link_args') return ctdep except Exception as e: mlog.debug('SDL 2 not found via sdl2-config. Trying next, error was:', str(e)) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 045be82..fc837d6 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -652,10 +652,6 @@ class Environment: def get_scratch_dir(self): return self.scratch_dir - def get_depfixer(self): - path = os.path.dirname(__file__) - return os.path.join(path, 'depfixer.py') - def detect_objc_compiler(self, want_cross): popen_exceptions = {} compilers, ccache, is_cross, exe_wrap = self._get_compilers('objc', 'OBJC', want_cross) diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 82f5031..4a977a1 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -229,9 +229,6 @@ def run_script_command(args): elif cmdname == 'delsuffix': import mesonbuild.scripts.delwithsuffix as abc cmdfunc = abc.run - elif cmdname == 'depfixer': - import mesonbuild.scripts.depfixer as abc - cmdfunc = abc.run elif cmdname == 'dirchanger': import mesonbuild.scripts.dirchanger as abc cmdfunc = abc.run diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 78683be..72cf143 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -94,8 +94,7 @@ class Lexer: # Need to be sorted longest to shortest. ('ignore', re.compile(r'[ \t]')), ('id', re.compile('[_a-zA-Z][_0-9a-zA-Z]*')), - ('hexnumber', re.compile('0[xX][0-9a-fA-F]+')), - ('number', re.compile(r'\d+')), + ('number', re.compile(r'0[bB][01]+|0[oO][0-7]+|0[xX][0-9a-fA-F]+|0|[1-9]\d*')), ('eol_cont', re.compile(r'\\\n')), ('eol', re.compile(r'\n')), ('multiline_string', re.compile(r"'''(.|\n)*?'''", re.M)), @@ -187,10 +186,7 @@ This will become a hard error in a future Meson release.""", self.getline(line_s lineno += len(lines) - 1 line_start = mo.end() - len(lines[-1]) elif tid == 'number': - value = int(match_text) - elif tid == 'hexnumber': - tid = 'number' - value = int(match_text, base=16) + value = int(match_text, base=0) elif tid == 'eol' or tid == 'eol_cont': lineno += 1 line_start = loc diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index 185c76a..1d2cc60 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -372,8 +372,11 @@ def fix_darwin(fname, new_rpath): # non-executable target. Just return. return try: - for rp in rpaths: - subprocess.check_call(['install_name_tool', '-delete_rpath', rp, fname], + if rpaths: + args = [] + for rp in rpaths: + args += ['-delete_rpath', rp] + subprocess.check_call(['install_name_tool', fname] + args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) if new_rpath: @@ -396,16 +399,3 @@ def fix_rpath(fname, new_rpath, verbose=True): if shutil.which('install_name_tool'): fix_darwin(fname, new_rpath) return 0 - -def run(args): - if len(args) < 1 or len(args) > 2: - print('This application resets target rpath.') - print('Don\'t run this unless you know what you are doing.') - print('%s: <binary file> <prefix>' % sys.argv[0]) - sys.exit(1) - fname = args[0] - new_rpath = None if len(args) == 1 else args[1] - return fix_rpath(fname, new_rpath) - -if __name__ == '__main__': - sys.exit(run(sys.argv[1:])) diff --git a/test cases/common/68 number arithmetic/meson.build b/test cases/common/68 number arithmetic/meson.build index f2e84a8..e31d7e4 100644 --- a/test cases/common/68 number arithmetic/meson.build +++ b/test cases/common/68 number arithmetic/meson.build @@ -62,3 +62,15 @@ hex2_255 = 0XFF assert(hex_255 == 255, 'Hex parsing is broken.') assert(hex2_255 == 255, 'Uppercase hex parsing is broken.') + +bin_123 = 0b1111011 +bin2_123 = 0B1111011 + +assert(bin_123 == 123, 'Bin number parsing is broken.') +assert(bin2_123 == 123, 'Uppercase bin number parsing is broken.') + +oct_493 = 0o755 +oct2_493 = 0O755 + +assert(oct_493 == 493, 'Oct number parsing is broken.') +assert(oct2_493 == 493, 'Uppercase oct number parsing is broken.') diff --git a/test cases/failing/75 configuration immutable/input b/test cases/failing/75 configuration immutable/input new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/failing/75 configuration immutable/input diff --git a/test cases/failing/75 configuration immutable/meson.build b/test cases/failing/75 configuration immutable/meson.build new file mode 100644 index 0000000..b6cac41 --- /dev/null +++ b/test cases/failing/75 configuration immutable/meson.build @@ -0,0 +1,12 @@ +project('configuration_data is immutable') + +a = configuration_data() + +configure_file( + configuration : a, + input : 'input', + output : 'output', +) + +still_immutable = a +still_immutable.set('hello', 'world') diff --git a/test cases/failing/76 int literal leading zero/meson.build b/test cases/failing/76 int literal leading zero/meson.build new file mode 100644 index 0000000..7ad64ae --- /dev/null +++ b/test cases/failing/76 int literal leading zero/meson.build @@ -0,0 +1,6 @@ + +# This should fail. +# Decimal syntax is 123. +# Octal syntax is 0o123. +fail_0123 = 0123 + |