Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Nov 2016 13:06:01 +0000 (UTC)
From:      Koop Mast <kwm@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r426047 - in head/devel: . meson meson/files
Message-ID:  <201611131306.uADD61qq005805@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kwm
Date: Sun Nov 13 13:06:00 2016
New Revision: 426047
URL: https://svnweb.freebsd.org/changeset/ports/426047

Log:
  Add meson.
  
  Meson is a cross-platform build system designed to be both as fast and as
  user friendly as possible. It supports many languages and compilers, including
  GCC, Clang and Visual Studio. Its build definitions are written in a simple
  non-turing complete DSL. The main design point of Meson is that every moment
  a developer spends writing or debugging build definitions is a second wasted.
  So is every second spent waiting for the build system to actually start
  compiling code.
  
  Submitted by:	Ting-Wei Lan

Added:
  head/devel/meson/
  head/devel/meson/Makefile   (contents, props changed)
  head/devel/meson/distinfo   (contents, props changed)
  head/devel/meson/files/
  head/devel/meson/files/patch-mesonbuild_compilers-1.py   (contents, props changed)
  head/devel/meson/files/patch-mesonbuild_compilers-2.py   (contents, props changed)
  head/devel/meson/files/patch-mesonbuild_compilers-3.py   (contents, props changed)
  head/devel/meson/files/patch-mesonbuild_compilers-4.py   (contents, props changed)
  head/devel/meson/files/patch-mesonbuild_scripts_scanbuild.py   (contents, props changed)
  head/devel/meson/files/patch-setup.py   (contents, props changed)
  head/devel/meson/pkg-descr   (contents, props changed)
Modified:
  head/devel/Makefile

Modified: head/devel/Makefile
==============================================================================
--- head/devel/Makefile	Sun Nov 13 12:58:12 2016	(r426046)
+++ head/devel/Makefile	Sun Nov 13 13:06:00 2016	(r426047)
@@ -1555,6 +1555,7 @@
     SUBDIR += mercator
     SUBDIR += mercurial
     SUBDIR += mercurialeclipse
+    SUBDIR += meson
     SUBDIR += mico
     SUBDIR += mime
     SUBDIR += mimir

Added: head/devel/meson/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/Makefile	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,20 @@
+# Created by: Ting-Wei Lan <lantw44@gmail.com>
+# $FreeBSD$
+
+PORTNAME=	meson
+PORTVERSION=	0.35.1
+CATEGORIES=	devel python
+MASTER_SITES=	https://github.com/mesonbuild/${PORTNAME}/releases/download/${PORTVERSION}/
+
+MAINTAINER=	gnome@FreeBSD.org
+COMMENT=	High performance build system
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+RUN_DEPENDS=	ninja:devel/ninja
+
+USES=		python:3
+USE_PYTHON=	autoplist distutils
+
+.include <bsd.port.mk>

Added: head/devel/meson/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/distinfo	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1478286789
+SHA256 (meson-0.35.1.tar.gz) = b47edb53bd7554cb7890a32399fdf6402e8079379393893ab3dec8fffcbfba2c
+SIZE (meson-0.35.1.tar.gz) = 510957

Added: head/devel/meson/files/patch-mesonbuild_compilers-1.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/files/patch-mesonbuild_compilers-1.py	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,44 @@
+From b8ef693a2af7463be0cfa3cc752decd4c4955587 Mon Sep 17 00:00:00 2001
+From: Nirbheek Chauhan <nirbheek@centricular.com>
+Date: Sat, 29 Oct 2016 12:38:36 +0530
+Subject: [PATCH] Clang also supports gnu89/99/11, gnu++03/11/14/1z
+
+The list of supported standards is identical for GCC and Clang.
+
+We don't list duplicate standard names however, such as c++03 and c++09
+
+https://github.com/llvm-mirror/clang/blob/master/include/clang/Frontend/LangStandards.def
+--- mesonbuild/compilers.py.orig	2016-10-17 17:38:14 UTC
++++ mesonbuild/compilers.py
+@@ -1968,7 +1968,8 @@ class GnuCCompiler(GnuCompiler, CCompile
+ 
+     def get_options(self):
+         opts = {'c_std' : coredata.UserComboOption('c_std', 'C language standard to use',
+-                                                   ['none', 'c89', 'c99', 'c11', 'gnu89', 'gnu99', 'gnu11'],
++                                                   ['none', 'c89', 'c99', 'c11',
++                                                    'gnu89', 'gnu99', 'gnu11'],
+                                                    'none')}
+         if self.gcc_type == GCC_MINGW:
+             opts.update({
+@@ -2097,7 +2098,8 @@ class ClangCCompiler(ClangCompiler, CCom
+ 
+     def get_options(self):
+         return {'c_std' : coredata.UserComboOption('c_std', 'C language standard to use',
+-                                                   ['none', 'c89', 'c99', 'c11'],
++                                                   ['none', 'c89', 'c99', 'c11',
++                                                    'gnu89', 'gnu99', 'gnu11',],
+                                                    'none')}
+ 
+     def get_option_compile_args(self, options):
+@@ -2124,8 +2126,9 @@ class ClangCPPCompiler(ClangCompiler,   
+ 
+     def get_options(self):
+         return {'cpp_std' : coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+-                                                   ['none', 'c++03', 'c++11', 'c++14', 'c++1z'],
+-                                                   'none')}
++                                                     ['none', 'c++03', 'c++11', 'c++14', 'c++1z',
++                                                      'gnu++03', 'gnu++11', 'gnu++14', 'gnu++1z'],
++                                                     'none')}
+ 
+     def get_option_compile_args(self, options):
+         args = []

Added: head/devel/meson/files/patch-mesonbuild_compilers-2.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/files/patch-mesonbuild_compilers-2.py	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,184 @@
+From ac58c13bbfa6c7b47cc54f30e32bd405c944076d Mon Sep 17 00:00:00 2001
+From: Nirbheek Chauhan <nirbheek@centricular.com>
+Date: Tue, 25 Oct 2016 02:32:57 +0530
+Subject: [PATCH] has_function: Only ignore prototype when no includes are
+ specified
+
+The Autoconf-style check we were doing gives false positives when the
+linker uses the prototype defined in the SDK header to decide whether
+a function is available or not.
+
+For example, with macOS 10.12, clock_gettime is now implemented
+(alongwith other functions). These functions are always defined in the
+XCode 8 SDK as weak imports and you're supposed to do a runtime check to
+see if the symbols are available and use fallback code if they aren't.
+
+The linker will always successfully link if you use one of those symbols
+(without a runtime fallback) even if you target an older OS X version
+with -mmacosx-version-min. This is the intended behaviour by Apple.
+
+But this makes has_function useless because to test if the symbol is
+available, we must know at link-time whether it is available.
+
+To force the linker to do the check at link-time you must use
+'-Wl,-no_weak_imports` *and* use the prototype in time.h which has an
+availability macro which tells the linker whether the symbol is
+available or not based on the -mmacosx-version-min flag.
+
+An autoconf-style check would override this prototype and use its own
+which would result in the linker thinking that the function is always
+available (a false positive). Worse, this would manifest at runtime and
+might not be picked up immediately.
+
+We now use the function prototype in the user-provided includes if the
+'prefix' kwarg contains a `#include` and use the old Autoconf-style
+check if not. I've tested that the configure checks done by GStreamer
+and GLib are completely unaffected by this; at least on Linux.
+
+The next commit will also add `-Wl,-no_weak_imports` to extra_args by
+default so that Meson avoids this mess completely. We always want this
+because the user would not do a has_function check if they have
+a runtime fallback for the function in their code.
+--- mesonbuild/compilers.py.orig	2016-11-09 17:25:49 UTC
++++ mesonbuild/compilers.py
+@@ -891,55 +891,65 @@ int main(int argc, char **argv) {
+             raise EnvironmentException('Could not determine alignment of %s. Sorry. You might want to file a bug.' % typename)
+         return align
+ 
+-    def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None):
++    @staticmethod
++    def _no_prototype_templ():
+         """
+-        First, this function looks for the symbol in the default libraries
+-        provided by the compiler (stdlib + a few others usually). If that
+-        fails, it checks if any of the headers specified in the prefix provide
+-        an implementation of the function, and if that fails, it checks if it's
+-        implemented as a compiler-builtin.
++        Try to find the function without a prototype from a header by defining
++        our own dummy prototype and trying to link with the C library (and
++        whatever else the compiler links in by default). This is very similar
++        to the check performed by Autoconf for AC_CHECK_FUNCS.
+         """
+-        if extra_args is None:
+-            extra_args = []
+-        # Define the symbol to something else in case it is defined by the
+-        # includes or defines listed by the user `{0}` or by the compiler.
+-        # Then, undef the symbol to get rid of it completely.
+-        templ = '''
++        # Define the symbol to something else since it is defined by the
++        # includes or defines listed by the user (prefix -> {0}) or by the
++        # compiler. Then, undef the symbol to get rid of it completely.
++        head = '''
+         #define {1} meson_disable_define_of_{1}
+         #include <limits.h>
+         {0}
+         #undef {1}
+         '''
+-
+         # Override any GCC internal prototype and declare our own definition for
+         # the symbol. Use char because that's unlikely to be an actual return
+         # value for a function which ensures that we override the definition.
+-        templ += '''
++        head += '''
+         #ifdef __cplusplus
+         extern "C"
+         #endif
+         char {1} ();
+         '''
+-
+-        # glibc defines functions that are not available on Linux as stubs that
+-        # fail with ENOSYS (such as e.g. lchmod). In this case we want to fail
+-        # instead of detecting the stub as a valid symbol.
+-        # We always include limits.h above to ensure that these are defined for
+-        # stub functions.
+-        stubs_fail = '''
+-        #if defined __stub_{1} || defined __stub___{1}
+-        fail fail fail this function is not going to work
+-        #endif
+-        '''
+-        templ += stubs_fail
+-
+-        # And finally the actual function call
+-        templ += '''
+-        int
+-        main ()
++        # The actual function call
++        main = '''
++        int main ()
+         {{
+           return {1} ();
+         }}'''
++        return head, main
++
++    @staticmethod
++    def _have_prototype_templ():
++        """
++        Returns a head-er and main() call that uses the headers listed by the
++        user for the function prototype while checking if a function exists.
++        """
++        # Add the 'prefix', aka defines, includes, etc that the user provides
++        head = '#include <limits.h>\n{0}\n'
++        # We don't know what the function takes or returns, so just add
++        # a useless reference to it
++        main = '\nint main() {{ {1}; }}'
++        return head, main
++
++    def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None):
++        """
++        First, this function looks for the symbol in the default libraries
++        provided by the compiler (stdlib + a few others usually). If that
++        fails, it checks if any of the headers specified in the prefix provide
++        an implementation of the function, and if that fails, it checks if it's
++        implemented as a compiler-builtin.
++        """
++        if extra_args is None:
++            extra_args = []
++
++        # Short-circuit if the check is already provided by the cross-info file
+         varname = 'has function ' + funcname
+         varname = varname.replace(' ', '_')
+         if self.is_cross:
+@@ -948,16 +958,35 @@ int main(int argc, char **argv) {
+                 if isinstance(val, bool):
+                     return val
+                 raise EnvironmentException('Cross variable {0} is not a boolean.'.format(varname))
+-        if self.links(templ.format(prefix, funcname), env, extra_args, dependencies):
+-            return True
++
++        # glibc defines functions that are not available on Linux as stubs that
++        # fail with ENOSYS (such as e.g. lchmod). In this case we want to fail
++        # instead of detecting the stub as a valid symbol.
++        # We already included limits.h earlier to ensure that these are defined
++        # for stub functions.
++        stubs_fail = '''
++        #if defined __stub_{1} || defined __stub___{1}
++        fail fail fail this function is not going to work
++        #endif
++        '''
++
++        # If we have any includes in the prefix supplied by the user, assume
++        # that the user wants us to use the symbol prototype defined in those
++        # includes. If not, then try to do the Autoconf-style check with
++        # a dummy prototype definition of our own.
++        # This is needed when the linker determines symbol availability from an
++        # SDK based on the prototype in the header provided by the SDK.
++        # Ignoring this prototype would result in the symbol always being
++        # marked as available.
++        if '#include' in prefix:
++            head, main = self._have_prototype_templ()
++        else:
++            head, main = self._no_prototype_templ()
++        templ = head + stubs_fail + main
++
+         # Add -O0 to ensure that the symbol isn't optimized away by the compiler
+         args = extra_args + self.get_no_optimization_args()
+-        # Sometimes the implementation is provided by the header, or the header
+-        # redefines the symbol to be something else. In that case, we want to
+-        # still detect the function. We still want to fail if __stub_foo or
+-        # _stub_foo are defined, of course.
+-        header_templ = '#include <limits.h>\n{0}\n' + stubs_fail + '\nint main() {{ {1}; }}'
+-        if self.links(header_templ.format(prefix, funcname), env, args, dependencies):
++        if self.links(templ.format(prefix, funcname), env, extra_args, dependencies):
+             return True
+         # Some functions like alloca() are defined as compiler built-ins which
+         # are inlined by the compiler, so test for that instead. Built-ins are

Added: head/devel/meson/files/patch-mesonbuild_compilers-3.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/files/patch-mesonbuild_compilers-3.py	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,23 @@
+From 4be8e71fb380a0541b69992539a0695ea29b3205 Mon Sep 17 00:00:00 2001
+From: Nirbheek Chauhan <nirbheek@centricular.com>
+Date: Tue, 25 Oct 2016 08:01:21 +0530
+Subject: [PATCH] has_function: Try to use the function being checked
+
+Simply placing a reference to it isn't enough for the linker to try and
+think it's being used and do a symbol availability check with
+-Wl,-no_weak_imports on OS X ld.
+--- mesonbuild/compilers.py.orig	2016-11-09 17:43:55 UTC
++++ mesonbuild/compilers.py
+@@ -933,9 +933,9 @@ int main(int argc, char **argv) {
+         """
+         # Add the 'prefix', aka defines, includes, etc that the user provides
+         head = '#include <limits.h>\n{0}\n'
+-        # We don't know what the function takes or returns, so just add
+-        # a useless reference to it
+-        main = '\nint main() {{ {1}; }}'
++        # We don't know what the function takes or returns, so try to use it as
++        # a function pointer
++        main = '\nint main() {{ int a = (int) &{1}; }}'
+         return head, main
+ 
+     def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None):

Added: head/devel/meson/files/patch-mesonbuild_compilers-4.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/files/patch-mesonbuild_compilers-4.py	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,20 @@
+From f144e50f5ca65ba67c23ff262a79c35a2c444006 Mon Sep 17 00:00:00 2001
+From: Nirbheek Chauhan <nirbheek@centricular.com>
+Date: Tue, 8 Nov 2016 16:22:40 +0530
+Subject: [PATCH] has_function: Cast to void* instead of int
+
+Clang++ doesn't allow that, but void* will always be allowed because
+lots of projects depend on that.
+
+error: cast from pointer to smaller type 'int' loses information
+--- mesonbuild/compilers.py.orig	2016-11-09 17:42:03 UTC
++++ mesonbuild/compilers.py
+@@ -935,7 +935,7 @@ int main(int argc, char **argv) {
+         head = '#include <limits.h>\n{0}\n'
+         # We don't know what the function takes or returns, so try to use it as
+         # a function pointer
+-        main = '\nint main() {{ int a = (int) &{1}; }}'
++        main = '\nint main() {{ void *a = (void*) &{1}; }}'
+         return head, main
+ 
+     def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None):

Added: head/devel/meson/files/patch-mesonbuild_scripts_scanbuild.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/files/patch-mesonbuild_scripts_scanbuild.py	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,34 @@
+From f7431fd5dba1f59ce70b07d7074999d1e7442887 Mon Sep 17 00:00:00 2001
+From: Jussi Pakkanen <jpakkane@gmail.com>
+Date: Wed, 9 Nov 2016 15:46:40 +0200
+Subject: [PATCH] Can specify scan-build executable with an environment
+ variable. Closes #1015.
+
+--- mesonbuild/scripts/scanbuild.py.orig	2016-10-17 17:38:14 UTC
++++ mesonbuild/scripts/scanbuild.py
+@@ -17,10 +17,10 @@ import subprocess
+ import shutil
+ import tempfile
+ 
+-def scanbuild(srcdir, blddir, privdir, logdir, args):
++def scanbuild(exename, srcdir, blddir, privdir, logdir, args):
+     with tempfile.TemporaryDirectory(dir=privdir) as scandir:
+-        meson_cmd = ['scan-build'] + args
+-        build_cmd = ['scan-build', '-o', logdir, 'ninja']
++        meson_cmd = [exename] + args
++        build_cmd = [exename, '-o', logdir, 'ninja']
+         rc = subprocess.call(meson_cmd + [srcdir, scandir])
+         if rc != 0:
+             return rc
+@@ -33,7 +33,8 @@ def run(args):
+     privdir = os.path.join(blddir, 'meson-private')
+     logdir = os.path.join(blddir, 'meson-logs/scanbuild')
+     shutil.rmtree(logdir, ignore_errors=True)
+-    if not shutil.which('scan-build'):
+-        print('Scan-build not installed')
++    exename = os.environ.get('SCANBUILD', 'scan-build')
++    if not shutil.which(exename):
++        print('Scan-build not installed.')
+         return 1
+-    return scanbuild(srcdir, blddir, privdir, logdir, meson_cmd)
++    return scanbuild(exename, srcdir, blddir, privdir, logdir, meson_cmd)

Added: head/devel/meson/files/patch-setup.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/files/patch-setup.py	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,60 @@
+From 999669e8501501d4618588008e4bf4353a1ace2a Mon Sep 17 00:00:00 2001
+From: Patrick Griffis <tingping@tingping.se>
+Date: Fri, 30 Sep 2016 23:28:40 -0400
+Subject: [PATCH] setup.py: On Unix install scripts without .py suffix
+
+--- setup.py.orig	2016-10-17 17:38:14 UTC
++++ setup.py
+@@ -14,7 +14,9 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
++import os
+ import sys
++from os import path
+ 
+ if sys.version_info[0] < 3:
+     print('Tried to install with Python 2, Meson only supports Python 3.')
+@@ -25,8 +27,32 @@ if sys.version_info[0] < 3:
+ # plain distutils when setuptools is not available.
+ try:
+     from setuptools import setup
++    from setuptools.command.install_scripts import install_scripts as orig
+ except ImportError:
+     from distutils.core import setup
++    from distutils.command.install_scripts import install_scripts as orig
++
++from distutils.file_util import copy_file
++from distutils.dir_util import mkpath
++from stat import ST_MODE
++
++class install_scripts(orig):
++    def run(self):
++        if sys.platform == 'win32':
++            super().run()
++            return
++
++        self.outfiles = []
++        if not self.dry_run:
++            mkpath(self.install_dir)
++
++        # We want the files to be installed without a suffix on Unix
++        for infile in self.get_inputs():
++            in_stripped = infile[:-3] if infile.endswith('.py') else infile
++            outfile = path.join(self.install_dir, in_stripped)
++            # NOTE: Mode is preserved by default
++            copy_file(infile, outfile, dry_run=self.dry_run)
++            self.outfiles.append(outfile)
+ 
+ from mesonbuild.coredata import version
+ 
+@@ -46,7 +72,8 @@ setup(name='meson',
+                'mesonconf.py',
+                'mesonintrospect.py',
+                'wraptool.py'],
+-      data_files=[('share/man/man1', ['man/meson.1',
++      cmdclass={'install_scripts': install_scripts},
++      data_files=[('man/man1'      , ['man/meson.1',
+                                       'man/mesonconf.1',
+                                       'man/mesonintrospect.1',
+                                       'man/wraptool.1'])],

Added: head/devel/meson/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/meson/pkg-descr	Sun Nov 13 13:06:00 2016	(r426047)
@@ -0,0 +1,9 @@
+Meson is a cross-platform build system designed to be both as fast and as
+user friendly as possible. It supports many languages and compilers, including
+GCC, Clang and Visual Studio. Its build definitions are written in a simple
+non-turing complete DSL. The main design point of Meson is that every moment
+a developer spends writing or debugging build definitions is a second wasted.
+So is every second spent waiting for the build system to actually start
+compiling code.
+
+WWW: http://mesonbuild.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611131306.uADD61qq005805>