path: root/waftools
diff options
authorwm4 <wm4@nowhere>2017-06-27 13:47:46 +0200
committerwm4 <wm4@nowhere>2017-06-29 10:30:16 +0200
commit7eca787571aab982acaadee79abb0f40f9f14b6a (patch)
tree250369f402ba9b45b32e0d4e78afda3043af5172 /waftools
parent70a70b9da347d7ef25a9862af83731b9b0a0d3f1 (diff)
build: change how some OS specific source files are selected
In a bunch of cases, we emulate highly platform specific APIs on a higher level across all OSes, such as IPC, terminal, subprocess handling, and more. We have source files for each OS, and they implement all the same mpv internal API. Selecting which source file to use on an OS can be tricky, because there is partially overlapping and emulated APIs (consider Cygwin on Windows). Add a pick_first_matching_dep() function to make this slightly easier and more structured. Also add dummy backends in some cases, to deal with APIs not being available. Clarify the Windows dependency identifiers, as these are the most confusing.
Diffstat (limited to 'waftools')
1 files changed, 12 insertions, 0 deletions
diff --git a/waftools/ b/waftools/
index 87f236b362..994e1d10b2 100644
--- a/waftools/
+++ b/waftools/
@@ -212,6 +212,17 @@ def filtered_sources(ctx, sources):
return [__source_file__(source) for source in sources \
if __unpack_and_check_filter__(source)]
+Like filtered_sources(), but pick only the first entry that matches, and
+return its filename.
+def pick_first_matching_dep(ctx, deps):
+ files = filtered_sources(ctx, deps)
+ if len(files) > 0:
+ return files[0]
+ else:
+ raise DependencyError
def env_fetch(tx):
def fn(ctx):
deps = ctx.env.satisfied_deps
@@ -223,6 +234,7 @@ def dependencies_use(ctx):
return [inflector.storage_key(dep) for dep in ctx.env.satisfied_deps]
BuildContext.filtered_sources = filtered_sources
+BuildContext.pick_first_matching_dep = pick_first_matching_dep
BuildContext.dependencies_use = dependencies_use
BuildContext.dependencies_includes = env_fetch(lambda x: "INCLUDES_{0}".format(x))
BuildContext.dependency_satisfied = dependency_satisfied