diff options
-rw-r--r-- | docs/markdown/Adding-new-projects-to-wrapdb.md | 53 | ||||
-rw-r--r-- | docs/markdown/Reference-tables.md | 1 | ||||
-rw-r--r-- | docs/markdown/Unit-tests.md | 2 | ||||
-rw-r--r-- | docs/markdown/Users.md | 1 | ||||
-rw-r--r-- | docs/markdown/Wrap-maintainer-tools.md | 17 | ||||
-rw-r--r-- | docs/markdown/Wrap-review-guidelines.md | 42 | ||||
-rw-r--r-- | docs/sitemap.txt | 1 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 6 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 34 | ||||
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/cmake/traceparser.py | 5 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 108 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 33 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 3 | ||||
-rw-r--r-- | mesonbuild/dependencies/cuda.py | 16 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 3 | ||||
-rw-r--r-- | mesonbuild/mesonlib.py | 18 | ||||
-rw-r--r-- | test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt | 2 |
18 files changed, 222 insertions, 125 deletions
diff --git a/docs/markdown/Adding-new-projects-to-wrapdb.md b/docs/markdown/Adding-new-projects-to-wrapdb.md index bbe945d..25fb61c 100644 --- a/docs/markdown/Adding-new-projects-to-wrapdb.md +++ b/docs/markdown/Adding-new-projects-to-wrapdb.md @@ -6,14 +6,17 @@ Each wrap repository has a master branch with only one initial commit and *no* wrap files. And that is the only commit ever made on that branch. -For every release of a project a new branch is created. The new branch is named after the -the upstream release number (e.g. `1.0.0`). This branch holds a wrap file for +For every release of a project a new branch is created. The new branch is named after the +the upstream release number (e.g. `1.0.0`). This branch holds a wrap file for this particular release. There are two types of wraps on WrapDB - regular wraps and wraps with Meson build definition patches. A wrap file in a repository on WrapDB must have a name `upstream.wrap`. -Wraps with Meson build definition patches work in much the same way as Debian: we take the unaltered upstream source package and add a new build system to it as a patch. These build systems are stored as Git repositories on GitHub. They only contain build definition files. You may also think of them as an overlay to upstream source. +Wraps with Meson build definition patches work in much the same way as Debian: +we take the unaltered upstream source package and add a new build system to it as a patch. +These build systems are stored as Git repositories on GitHub. They only contain build definition files. +You may also think of them as an overlay to upstream source. Whenever a new commit is pushed into GitHub's project branch, a new wrap is generated with an incremented version number. All the old releases remain unaltered. @@ -21,13 +24,15 @@ New commits are always done via GitHub merge requests and must be reviewed by someone other than the submitter. Note that your Git repo with wrap must not contain the subdirectory of the source -release. That gets added automatically by the service. You also must not commit +release. That gets added automatically by the service. You also must not commit any source code from the original tarball into the wrap repository. ## Choosing the repository name Wrapped subprojects are used much like external dependencies. Thus -they should have the same name as the upstream projects. +they should have the same name as the upstream projects. + +NOTE: Repo names must fully match this regexp: `[a-z0-9._]+`. If the project provides a pkg-config file, then the repository name should be the same as the pkg-config name. Usually this is the name of the @@ -36,16 +41,19 @@ however. As an example the libogg project's chosen pkg-config name is `ogg` instead of `libogg`, which is the reason why the repository is named plain `ogg`. -If there is no a pkg-config file, the name the project uses/promotes should be used, +If there is no a pkg-config file, the name the project uses/promotes should be used, lowercase only (Catch2 -> catch2). +If the project name is too generic or ambiguous (e.g. `benchmark`), +consider using `organization-project` naming format (e.g. `google-benchmark`). + ## How to contribute a new wrap If the project already uses Meson build system, then only a wrap file - `upstream.wrap` -should be provided. In other case a Meson build definition patch - a set of `meson.build` +should be provided. In other case a Meson build definition patch - a set of `meson.build` files - should be also provided. -### Request a new repository or branch +### Request a new repository Create an issue on the [wrapdb bug tracker](https://github.com/mesonbuild/wrapdb/issues) using *Title* and *Description* below as a template. @@ -61,6 +69,9 @@ version: <version_you_have_a_wrap_for> Wait until the new repository or branch is created. A link to the new repository or branch will be posted in a comment to this issue. +NOTE: Requesting a branch is not necessary. WrapDB maintainer can create the branch and +modify the PR accordingly if the project repository exists. + ### Add a new wrap First you need to fork the repository to your own page. @@ -80,28 +91,28 @@ git commit -a -m 'Add wrap files for libfoo-1.0.0' git push origin 1.0.0 ``` -Now you should create a pull request on GitHub. Remember to create it against the -correct branch rather than master (`1.0.0` branch in this example). GitHub should do +Now you should create a pull request on GitHub. Remember to create it against the +correct branch rather than master (`1.0.0` branch in this example). GitHub should do this automatically. +If the branch doesn't exist file a pull request against master. +WrapDB maintainers can fix it before merging. + ## What is done by WrapDB maintainers +[mesonwrap tools](Wrap-maintainer-tools.md) must be used for the tasks below. + ### Adding new project to the Wrap provider service Each project gets its own repo. It is initialized like this: ``` -git init -git add readme.txt -git add LICENSE.build -git commit -a -m 'Create project foobar' -git remote add origin <repo url> -git push -u origin master +mesonwrap new_repo --homepage=$HOMEPAGE --directory=$NEW_LOCAL_PROJECT_DIR $PROJECT_NAME ``` -Note that this is the *only* commit that will ever be made to master branch. All other commits are done to branches. +The command creates a new repository and uploads it to Github. -Repo names must fully match this regexp: `[a-z0-9._]+`. +`--version` flag may be used to create a branch immediately. ### Adding a new branch to an existing project @@ -129,12 +140,6 @@ to functionality. All such changes must be submitted to upstream. You may also host your own Git repo with the changes if you wish. The Wrap system has native support for Git subprojects. -## Creator script - -The WrapDB repository has a -[helper script](https://github.com/mesonbuild/mesonwrap/blob/master/mesonwrap.py) -to generate new repositories, verify them and update them. - ## Reviewing wraps See [Wrap review guidelines](Wrap-review-guidelines.md). diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index c42d608..60a9720 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -121,6 +121,7 @@ These are provided by the `.system()` method call. | Value | Comment | | ----- | ------- | +| android | By convention only, subject to change | | cygwin | The Cygwin environment for Windows | | darwin | Either OSX or iOS | | dragonfly | DragonFly BSD | diff --git a/docs/markdown/Unit-tests.md b/docs/markdown/Unit-tests.md index bd91dbb..06664db6 100644 --- a/docs/markdown/Unit-tests.md +++ b/docs/markdown/Unit-tests.md @@ -136,7 +136,7 @@ For clarity, consider the meson.build containing: ```meson test('A', ..., suite: 'foo') -test('B', ..., suite: 'foo') +test('B', ..., suite: ['foo', 'bar']) test('C', ..., suite: 'bar') test('D', ..., suite: 'baz') diff --git a/docs/markdown/Users.md b/docs/markdown/Users.md index 41d8dfa..1867407 100644 --- a/docs/markdown/Users.md +++ b/docs/markdown/Users.md @@ -72,6 +72,7 @@ topic](https://github.com/topics/meson). - [Lc0](https://github.com/LeelaChessZero/lc0), LeelaChessZero is a UCI-compliant chess engine designed to play chess via neural network - [libcamera](https://git.linuxtv.org/libcamera.git/), a library to handle complex cameras on Linux, ChromeOS and Android - [Libdrm](https://gitlab.freedesktop.org/mesa/drm), a library for abstracting DRM kernel interfaces + - [libeconf](https://github.com/openSUSE/libeconf), Enhanced config file parsing library, which merges config files placed in several locations into one - [Libepoxy](https://github.com/anholt/libepoxy/), a library for handling OpenGL function pointer management - [libfuse](https://github.com/libfuse/libfuse), the reference implementation of the Linux FUSE (Filesystem in Userspace) interface - [Libgit2-glib](https://git.gnome.org/browse/libgit2-glib), a GLib wrapper for libgit2 diff --git a/docs/markdown/Wrap-maintainer-tools.md b/docs/markdown/Wrap-maintainer-tools.md new file mode 100644 index 0000000..717d0d2 --- /dev/null +++ b/docs/markdown/Wrap-maintainer-tools.md @@ -0,0 +1,17 @@ +# Wrap maintainer tools + +The [mesonwrap repository](https://github.com/mesonbuild/mesonwrap) provides tools +to maintain the WrapDB. Read-only features such can be used by anyone without Meson admin rights. + +## Personal access token + +Some tools require access to the Github API. +A [personal access token](https://github.com/settings/tokens) may be required +if the freebie Github API quota is exhausted. `public_repo` scope is required +for write operations. + +``` +$ cat ~/.config/mesonwrap.ini +[mesonwrap] +github_token = <github token> +``` diff --git a/docs/markdown/Wrap-review-guidelines.md b/docs/markdown/Wrap-review-guidelines.md index 512353c..3e41a8d 100644 --- a/docs/markdown/Wrap-review-guidelines.md +++ b/docs/markdown/Wrap-review-guidelines.md @@ -7,18 +7,30 @@ package is rejected. What should be done will be determined on a case-by-case basis. Similarly meeting all these requirements does not guarantee that the package will get accepted. Use common sense. -## Checklist - -Reviewer: copy-paste this to MR discussion box and tick all boxes that apply. - - - [ ] project() has version string - - [ ] project() has license string - - [ ] if new project, master has tagged commit as only commit - - [ ] if new branch, it is branched from master - - [ ] contains a readme.txt - - [ ] contains an upstream.wrap file - - [ ] download link points to authoritative upstream location - - [ ] wrap repository contains only build system files - - [ ] merge request is pointed to correct target branch (not master) - - [ ] wrap works - - [ ] repo does not have useless top level directory (i.e. libfoobar-1.0.0) +The review process is partially automated by the [mesonwrap](Wrap-maintainer-tools.md) +`review` tool. + +``` +mesonwrap review zlib --pull-request=1 [--approve] +``` + +Since not every check can be automated please pay attention to the following during the review: + +- Download link points to an authoritative upstream location. +- Version branch is created from master. +- Except for the existing code, `LICENSE.build` is mandatory. +- `project()` has a version and it matches the source version. +- `project()` has a license. +- Complex `configure_file()` inputs are documented. + If the file is a copy of a project file make sure it is clear what was changed. +- Unit tests are enabled if the project provides them. +- There are no guidelines if `install()` is a good or a bad thing in wraps. +- If the project can't be tested on the host platform consider using the `--cross-file` flag. + See [the issue](https://github.com/mesonbuild/mesonwrap/issues/125). + +Encourage wrap readability. Use your own judgement. + +## Approval + +If the code looks good use the `--approve` flag to merge it. +The tool automatically creates a release. diff --git a/docs/sitemap.txt b/docs/sitemap.txt index 4029a60..aa3f51a 100644 --- a/docs/sitemap.txt +++ b/docs/sitemap.txt @@ -72,6 +72,7 @@ index.md Adding-new-projects-to-wrapdb.md Using-the-WrapDB.md Using-wraptool.md + Wrap-maintainer-tools.md Wrap-best-practices-and-tips.md Wrap-review-guidelines.md Shipping-prebuilt-binaries-as-wraps.md diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 08fe092..cff35ee 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2188,6 +2188,10 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) curdir = '.' return compiler.get_include_args(curdir, False) + @lru_cache(maxsize=None) + def get_normpath_target(self, source) -> str: + return os.path.normpath(source) + def get_custom_target_dir_include_args(self, target, compiler): custom_target_include_dirs = [] for i in target.get_generated_sources(): @@ -2196,7 +2200,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) # own target build dir. if not isinstance(i, (build.CustomTarget, build.CustomTargetIndex)): continue - idir = os.path.normpath(self.get_target_dir(i)) + idir = self.get_normpath_target(self.get_target_dir(i)) if not idir: idir = '.' if idir not in custom_target_include_dirs: diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 6965c42..2f02213 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -992,23 +992,23 @@ class Vs2010Backend(backends.Backend): # Cflags required by external deps might have UNIX-specific flags, # so filter them out if needed if isinstance(d, dependencies.OpenMPDependency): - d_compile_args = compiler.openmp_flags() + ET.SubElement(clconf, 'OpenMPSupport').text = 'true' else: d_compile_args = compiler.unix_args_to_native(d.get_compile_args()) - for arg in d_compile_args: - if arg.startswith(('-D', '/D')): - define = arg[2:] - # De-dup - if define in target_defines: - target_defines.remove(define) - target_defines.append(define) - elif arg.startswith(('-I', '/I')): - inc_dir = arg[2:] - # De-dup - if inc_dir not in target_inc_dirs: - target_inc_dirs.append(inc_dir) - else: - target_args.append(arg) + for arg in d_compile_args: + if arg.startswith(('-D', '/D')): + define = arg[2:] + # De-dup + if define in target_defines: + target_defines.remove(define) + target_defines.append(define) + elif arg.startswith(('-I', '/I')): + inc_dir = arg[2:] + # De-dup + if inc_dir not in target_inc_dirs: + target_inc_dirs.append(inc_dir) + else: + target_args.append(arg) languages += gen_langs if len(target_args) > 0: @@ -1100,14 +1100,14 @@ class Vs2010Backend(backends.Backend): # Extend without reordering or de-dup to preserve `-L -l` sets # https://github.com/mesonbuild/meson/issues/1718 if isinstance(dep, dependencies.OpenMPDependency): - extra_link_args.extend_direct(compiler.openmp_flags()) + ET.SubElement(clconf, 'OpenMPSuppport').text = 'true' else: extra_link_args.extend_direct(dep.get_link_args()) for d in target.get_dependencies(): if isinstance(d, build.StaticLibrary): for dep in d.get_external_deps(): if isinstance(dep, dependencies.OpenMPDependency): - extra_link_args.extend_direct(compiler.openmp_flags()) + ET.SubElement(clconf, 'OpenMPSuppport').text = 'true' else: extra_link_args.extend_direct(dep.get_link_args()) # Add link args for c_* or cpp_* build options. Currently this only diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 09b633e..a5bf545 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -355,7 +355,7 @@ class ConverterTarget: if 'CONFIGURATIONS' in tgt.properties: cfgs += [x for x in tgt.properties['CONFIGURATIONS'] if x] cfg = cfgs[0] - + is_debug = self.env.coredata.get_builtin_option('debug'); if is_debug: if 'DEBUG' in cfgs: diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index f20bcc8..d94e774 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -64,6 +64,7 @@ class CMakeTarget: return for key, val in self.properties.items(): self.properties[key] = [x.strip() for x in val] + assert all([';' not in x for x in self.properties[key]]) class CMakeGeneratorTarget(CMakeTarget): def __init__(self, name): @@ -574,10 +575,10 @@ class CMakeTraceParser: continue if mode in ['INTERFACE', 'LINK_INTERFACE_LIBRARIES', 'PUBLIC', 'LINK_PUBLIC']: - interface += [i] + interface += i.split(';') if mode in ['PUBLIC', 'PRIVATE', 'LINK_PRIVATE']: - private += [i] + private += i.split(';') if paths: interface = self._guess_files(interface) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index b0fa5f5..4b286fe 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -14,6 +14,7 @@ import contextlib, os.path, re, tempfile import collections.abc +from collections import deque import itertools import typing as T from functools import lru_cache @@ -138,11 +139,15 @@ def is_llvm_ir(fname): fname = fname.fname return fname.split('.')[-1] == 'll' +@lru_cache(maxsize=None) +def cached_by_name(fname): + suffix = fname.split('.')[-1] + return suffix in obj_suffixes + def is_object(fname): if hasattr(fname, 'fname'): fname = fname.fname - suffix = fname.split('.')[-1] - return suffix in obj_suffixes + return cached_by_name(fname) def is_library(fname): if hasattr(fname, 'fname'): @@ -462,9 +467,47 @@ class CompilerArgs(collections.abc.MutableSequence): iterable: T.Optional[T.Iterable[str]] = None): self.compiler = compiler self.__container = list(iterable) if iterable is not None else [] # type: T.List[str] - self.__seen_args = set() - for arg in self.__container: - self.__seen_args.add(arg) + self.pre = deque() + self.post = deque() + + # Flush the saved pre and post list into the __container list + # + # This correctly deduplicates the entries after _can_dedup definition + # Note: This function is designed to work without delete operations, as deletions are worsening the performance a lot. + def flush_pre_post(self): + pre_flush = deque() + pre_flush_set = set() + post_flush = deque() + post_flush_set = set() + + #The two lists are here walked from the front to the back, in order to not need removals for deduplication + for a in reversed(self.pre): + dedup = self._can_dedup(a) + if a not in pre_flush_set: + pre_flush.appendleft(a) + if dedup == 2: + pre_flush_set.add(a) + for a in reversed(self.post): + dedup = self._can_dedup(a) + if a not in post_flush_set: + post_flush.appendleft(a) + if dedup == 2: + post_flush_set.add(a) + + #pre and post will overwrite every element that is in the container + #only copy over args that are in __container but not in the post flush or pre flush set + + for a in self.__container: + if a not in post_flush_set and a not in pre_flush_set: + pre_flush.append(a) + + self.__container = list(pre_flush) + list(post_flush) + self.pre.clear() + self.post.clear() + + def __iter__(self): + self.flush_pre_post() + return iter(self.__container); @T.overload # noqa: F811 def __getitem__(self, index: int) -> str: # noqa: F811 @@ -475,6 +518,7 @@ class CompilerArgs(collections.abc.MutableSequence): pass def __getitem__(self, index): # noqa: F811 + self.flush_pre_post() return self.__container[index] @T.overload # noqa: F811 @@ -486,24 +530,22 @@ class CompilerArgs(collections.abc.MutableSequence): pass def __setitem__(self, index, value) -> None: # noqa: F811 + self.flush_pre_post() self.__container[index] = value - for v in value: - self.__seen_args.add(v) def __delitem__(self, index: T.Union[int, slice]) -> None: - value = self.__container[index] + self.flush_pre_post() del self.__container[index] - if value in self.__seen_args and value in self.__container: # this is also honoring that you can have duplicated entries - self.__seen_args.remove(value) def __len__(self) -> int: - return len(self.__container) + return len(self.__container) + len(self.pre) + len(self.post) def insert(self, index: int, value: str) -> None: + self.flush_pre_post() self.__container.insert(index, value) - self.__seen_args.add(value) def copy(self) -> 'CompilerArgs': + self.flush_pre_post() return CompilerArgs(self.compiler, self.__container.copy()) @classmethod @@ -576,6 +618,7 @@ class CompilerArgs(collections.abc.MutableSequence): # between static libraries, and for recursively searching for symbols # needed by static libraries that are provided by object files or # shared libraries. + self.flush_pre_post() if copy: new = self.copy() else: @@ -635,11 +678,11 @@ class CompilerArgs(collections.abc.MutableSequence): for absolute paths to libraries, etc, which can always be de-duped safely. ''' + self.flush_pre_post() if os.path.isabs(arg): self.append(arg) else: self.__container.append(arg) - self.__seen_args.add(arg) def extend_direct(self, iterable: T.Iterable[str]) -> None: ''' @@ -647,6 +690,7 @@ class CompilerArgs(collections.abc.MutableSequence): reordering or de-dup except for absolute paths where the order of include search directories is not relevant ''' + self.flush_pre_post() for elem in iterable: self.append_direct(elem) @@ -662,6 +706,7 @@ class CompilerArgs(collections.abc.MutableSequence): self.extend_direct(lflags) def __add__(self, args: T.Iterable[str]) -> 'CompilerArgs': + self.flush_pre_post() new = self.copy() new += args return new @@ -671,9 +716,7 @@ class CompilerArgs(collections.abc.MutableSequence): Add two CompilerArgs while taking into account overriding of arguments and while preserving the order of arguments as much as possible ''' - this_round_added = set() # a dict that contains a value, when the value was added this round - pre = [] # type: T.List[str] - post = [] # type: T.List[str] + tmp_pre = deque() if not isinstance(args, collections.abc.Iterable): raise TypeError('can only concatenate Iterable[str] (not "{}") to CompilerArgs'.format(args)) for arg in args: @@ -683,37 +726,24 @@ class CompilerArgs(collections.abc.MutableSequence): dedup = self._can_dedup(arg) if dedup == 1: # Argument already exists and adding a new instance is useless - if arg in self.__seen_args or arg in pre or arg in post: + if arg in self.__container or arg in self.pre or arg in self.post: continue - should_prepend = self._should_prepend(arg) - if dedup == 2: - # Remove all previous occurrences of the arg and add it anew - if arg in self.__seen_args and arg not in this_round_added: # if __seen_args contains arg as well as this_round_added, then its not yet part in self. - self.remove(arg) - if should_prepend: - if arg in pre: - pre.remove(arg) - else: - if arg in post: - post.remove(arg) - if should_prepend: - pre.append(arg) + if self._should_prepend(arg): + tmp_pre.appendleft(arg) else: - post.append(arg) - self.__seen_args.add(arg) - this_round_added.add(arg) - # Insert at the beginning - self[:0] = pre - # Append to the end - self.__container += post + self.post.append(arg) + self.pre.extendleft(tmp_pre) + #pre and post is going to be merged later before a iter call return self def __radd__(self, args: T.Iterable[str]): + self.flush_pre_post() new = CompilerArgs(self.compiler, args) new += self return new def __eq__(self, other: T.Any) -> T.Union[bool, type(NotImplemented)]: + self.flush_pre_post() # Only allow equality checks against other CompilerArgs and lists instances if isinstance(other, CompilerArgs): return self.compiler == other.compiler and self.__container == other.__container @@ -728,6 +758,7 @@ class CompilerArgs(collections.abc.MutableSequence): self.__iadd__(args) def __repr__(self) -> str: + self.flush_pre_post() return 'CompilerArgs({!r}, {!r})'.format(self.compiler, self.__container) class Compiler: @@ -1087,6 +1118,9 @@ class Compiler: def openmp_flags(self): raise EnvironmentException('Language %s does not support OpenMP flags.' % self.get_display_language()) + def openmp_link_flags(self): + return self.openmp_flags() + def language_stdlib_only_link_flags(self): return [] diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 0ed0baa..b088fde 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -152,15 +152,24 @@ class CLikeCompiler: if not files: retval.append(d) continue - file_to_check = os.path.join(d, files[0]) - with open(file_to_check, 'rb') as fd: - header = fd.read(5) - # if file is not an ELF file, it's weird, but accept dir - # if it is elf, and the class matches, accept dir - if header[1:4] != b'ELF' or int(header[4]) == elf_class: - retval.append(d) - # at this point, it's an ELF file which doesn't match the - # appropriate elf_class, so skip this one + + for f in files: + file_to_check = os.path.join(d, f) + try: + with open(file_to_check, 'rb') as fd: + header = fd.read(5) + # if file is not an ELF file, it's weird, but accept dir + # if it is elf, and the class matches, accept dir + if header[1:4] != b'ELF' or int(header[4]) == elf_class: + retval.append(d) + # at this point, it's an ELF file which doesn't match the + # appropriate elf_class, so skip this one + # stop scanning after the first sucessful read + break + except OSError: + # Skip the file if we can't read it + pass + return tuple(retval) @functools.lru_cache() @@ -999,7 +1008,7 @@ class CLikeCompiler: return value[:] def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED): - code = 'int main(void) { return 0; }' + code = 'int main(void) { return 0; }\n' return self.find_library_impl(libname, env, extra_dirs, code, libtype) def find_framework_paths(self, env): @@ -1099,7 +1108,7 @@ class CLikeCompiler: 'the compiler you are using. has_link_argument or ' 'other similar method can be used instead.' .format(arg)) - code = 'int i;\n' + code = 'extern int i;\nint i;\n' return self.has_arguments(args, env, code, mode='compile') def has_multi_link_arguments(self, args, env): @@ -1108,7 +1117,7 @@ class CLikeCompiler: # false positive. args = self.linker.fatal_warnings() + args args = self.linker_to_compiler_args(args) - code = 'int main(void) { return 0; }' + code = 'int main(void) { return 0; }\n' return self.has_arguments(args, env, code, mode='link') @staticmethod diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index d0004ce..4dfd8b4 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -208,6 +208,9 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta): def openmp_flags(self) -> T.List[str]: return ['/openmp'] + def openmp_link_flags(self) -> T.List[str]: + return [] + # FIXME, no idea what these should be. def thread_flags(self, env: 'Environment') -> T.List[str]: return [] diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py index 9c189be..c962cae 100644 --- a/mesonbuild/dependencies/cuda.py +++ b/mesonbuild/dependencies/cuda.py @@ -157,11 +157,15 @@ class CudaDependency(ExternalDependency): mlog.debug('Falling back to extracting version from path') path_version_regex = self.path_version_win_regex if self._is_windows() else self.path_version_nix_regex - m = path_version_regex.match(os.path.basename(path)) - if m: - return m[1] + try: + m = path_version_regex.match(os.path.basename(path)) + if m: + return m.group(1) + else: + mlog.warning('Could not detect CUDA Toolkit version for {}'.format(path)) + except Exception as e: + mlog.warning('Could not detect CUDA Toolkit version for {}: {}'.format(path, str(e))) - mlog.warning('Could not detect CUDA Toolkit version for {}'.format(path)) return '0.0' def _read_toolkit_version_txt(self, path): @@ -172,7 +176,7 @@ class CudaDependency(ExternalDependency): version_str = version_file.readline() # e.g. 'CUDA Version 10.1.168' m = self.toolkit_version_regex.match(version_str) if m: - return self._strip_patch_version(m[1]) + return self._strip_patch_version(m.group(1)) except Exception as e: mlog.debug('Could not read CUDA Toolkit\'s version file {}: {}'.format(version_file_path, str(e))) @@ -192,7 +196,7 @@ class CudaDependency(ExternalDependency): raise DependencyException(msg.format(arch, 'Windows')) return os.path.join('lib', libdirs[arch]) elif machine.is_linux(): - libdirs = {'x86_64': 'lib64', 'ppc64': 'lib'} + libdirs = {'x86_64': 'lib64', 'ppc64': 'lib', 'aarch64': 'lib64'} if arch not in libdirs: raise DependencyException(msg.format(arch, 'Linux')) return libdirs[arch] diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 04dee06..5160fba 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -97,7 +97,8 @@ class OpenMPDependency(ExternalDependency): for name in header_names: if self.clib_compiler.has_header(name, '', self.env, dependencies=[self], disable_cache=True)[0]: self.is_found = True - self.compile_args = self.link_args = self.clib_compiler.openmp_flags() + self.compile_args = self.clib_compiler.openmp_flags() + self.link_args = self.clib_compiler.openmp_link_flags() break if not self.is_found: mlog.log(mlog.yellow('WARNING:'), 'OpenMP found but omp.h missing.') diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 26fe6eb..2413cb1 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -544,20 +544,24 @@ def darwin_get_object_archs(objpath: str) -> T.List[str]: return stdo.split() -def detect_vcs(source_dir: str) -> T.Optional[T.Dict[str, str]]: +def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]: vcs_systems = [ dict(name = 'git', cmd = 'git', repo_dir = '.git', get_rev = 'git describe --dirty=+', rev_regex = '(.*)', dep = '.git/logs/HEAD'), dict(name = 'mercurial', cmd = 'hg', repo_dir = '.hg', get_rev = 'hg id -i', rev_regex = '(.*)', dep = '.hg/dirstate'), dict(name = 'subversion', cmd = 'svn', repo_dir = '.svn', get_rev = 'svn info', rev_regex = 'Revision: (.*)', dep = '.svn/wc.db'), dict(name = 'bazaar', cmd = 'bzr', repo_dir = '.bzr', get_rev = 'bzr revno', rev_regex = '(.*)', dep = '.bzr'), ] - # FIXME: this is much cleaner with pathlib.Path - segs = source_dir.replace('\\', '/').split('/') - for i in range(len(segs), -1, -1): - curdir = '/'.join(segs[:i]) + if isinstance(source_dir, str): + source_dir = Path(source_dir) + + parent_paths_and_self = collections.deque(source_dir.parents) + # Prepend the source directory to the front so we can check it; + # source_dir.parents doesn't include source_dir + parent_paths_and_self.appendleft(source_dir) + for curdir in parent_paths_and_self: for vcs in vcs_systems: - if os.path.isdir(os.path.join(curdir, vcs['repo_dir'])) and shutil.which(vcs['cmd']): - vcs['wc_dir'] = curdir + if Path.is_dir(curdir.joinpath(vcs['repo_dir'])) and shutil.which(vcs['cmd']): + vcs['wc_dir'] = str(curdir) return vcs return None diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt index 50b1049..c9b2a20 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt @@ -20,7 +20,7 @@ set_target_properties(cmModLib PROPERTIES VERSION 1.0.1) add_executable(testEXE main.cpp) target_link_libraries(cmModLib ZLIB::ZLIB) -target_link_libraries(cmModLibStatic ZLIB::ZLIB) +target_link_libraries(cmModLibStatic ;ZLIB::ZLIB;) target_link_libraries(testEXE cmModLib) target_compile_definitions(cmModLibStatic PUBLIC CMMODLIB_STATIC_DEFINE) |