summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Linden <karl.j.linden@gmail.com>2018-01-01 12:06:56 +0100
committerKarl Lindén <karl.j.linden@gmail.com>2018-10-07 16:24:59 +0200
commit7fa02c2132ae72484113b7aba16ac436ac1deb82 (patch)
treeeeeae11b0fd4eab789443464fba348641c88c23b
parenta18319571ac0fc1eaa8678e6ad060556e1d6e756 (diff)
downloadjack2-7fa02c2132ae72484113b7aba16ac436ac1deb82.tar.gz
Implement a skeleton for compatibility modules
This commit introduces the skeleton needed to implement reusable operating system compatibility modules. This skeleton can then be extended with the actual compatibility modules that work around operating system specifics. For example this will be used to be able to compile files that use alloca on Windows. Also it can be used to implement replacements for functions that are missing on some systems.
-rw-r--r--compat/README.md40
-rw-r--r--compat/wscript57
-rw-r--r--wscript6
3 files changed, 103 insertions, 0 deletions
diff --git a/compat/README.md b/compat/README.md
new file mode 100644
index 00000000..c8f77374
--- /dev/null
+++ b/compat/README.md
@@ -0,0 +1,40 @@
+# Operating System Compatibility Modules for WAF
+
+This directory contains waf modules that aid compatibility across
+different operating systems. Here a module is a pluggable and reusable
+piece of code for the waf build system along with necessary
+replacements.
+
+To create a new compatibility module simply create a new subdirectory
+containing a `wscript` file and any necessary replacement files. The
+`wscript` must define the `options`, `configure` and `build` functions.
+
+To use the modules you need to call `recurse` in your `options`,
+`configure` and `build` commands. For example
+```python
+def options(opt):
+ # Do stuff...
+ opt.recurse('compat')
+ # Do other stuff...
+
+def configure(conf):
+ # Do stuff...
+ conf.recurse('compat')
+ # Do other stuff...
+
+def build(bld):
+ # Do stuff...
+ bld.recurse('compat')
+ # Do other stuff...
+```
+assuming this directory is called `compat`. After doing this you need to
+take any necessary actions described in the modules you want to use.
+
+The code in this directory is inteded to be generic and reusable. When
+writing new modules, please keep this in mind. Whenever necessary it
+should be possible to make this directory a git submodule and all the
+subdirectories other submodules, to aid reuse.
+
+If you would like to use these modules in another project, please file
+an issue so that we can join forces and maintain the compatabilitiy
+modules in a separate repository.
diff --git a/compat/wscript b/compat/wscript
new file mode 100644
index 00000000..e3ec8d33
--- /dev/null
+++ b/compat/wscript
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright (C) 2018 Karl Linden <karl.j.linden@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+import os
+
+def get_subdirs(ctx):
+ """
+ Get the compatibility module subirectories.
+
+ The compat modules are found dynamically so that this script does
+ not have to be modified if more modules are added.
+
+ :param ctx: the waf context
+ :type ctx: waflib.Context.Context
+ :returns: list of str -- the subdirectories
+ """
+ subdirs = []
+ for entry in ctx.path.listdir():
+ path = os.path.join(ctx.path.abspath(), entry)
+ if os.path.isdir(path) and not entry.startswith('.'):
+ subdirs.append(entry)
+ return subdirs
+
+def recurse_into_subdirs(ctx):
+ """
+ Recurse into compatibility module subdirectories.
+
+ :param ctx: the waf context
+ :type ctx: waflib.Context.Context
+ """
+ for x in get_subdirs(ctx):
+ ctx.recurse(x)
+
+def options(opt):
+ recurse_into_subdirs(opt)
+
+def configure(conf):
+ recurse_into_subdirs(conf)
+
+def build(bld):
+ recurse_into_subdirs(bld)
diff --git a/wscript b/wscript
index 0a927e64..9df8855f 100644
--- a/wscript
+++ b/wscript
@@ -55,6 +55,8 @@ def options(opt):
opt.load('xcode6')
+ opt.recurse('compat')
+
# install directories
opt.add_option('--htmldir', type='string', default=None, help='HTML documentation directory [Default: <prefix>/share/jack-audio-connection-kit/reference/html/')
opt.add_option('--libdir', type='string', help='Library directory [Default: <prefix>/lib]')
@@ -217,6 +219,8 @@ def configure(conf):
conf.load('autooptions')
+ conf.recurse('compat')
+
# Check for functions.
conf.check(
fragment=''
@@ -729,6 +733,8 @@ def build(bld):
# only the wscript in common/ knows how to handle variants
return
+ bld.recurse('compat')
+
if not os.access('svnversion.h', os.R_OK):
def post_run(self):
sg = Utils.h_file(self.outputs[0].abspath(self.env))