diff options
author | wm4 <wm4@nowhere> | 2017-06-27 13:47:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-06-29 10:30:16 +0200 |
commit | 7eca787571aab982acaadee79abb0f40f9f14b6a (patch) | |
tree | 250369f402ba9b45b32e0d4e78afda3043af5172 /waftools | |
parent | 70a70b9da347d7ef25a9862af83731b9b0a0d3f1 (diff) | |
download | mpv-7eca787571aab982acaadee79abb0f40f9f14b6a.tar.bz2 mpv-7eca787571aab982acaadee79abb0f40f9f14b6a.tar.xz |
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')
-rw-r--r-- | waftools/dependencies.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/waftools/dependencies.py b/waftools/dependencies.py index 87f236b362..994e1d10b2 100644 --- a/waftools/dependencies.py +++ b/waftools/dependencies.py @@ -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 |