From 7eca787571aab982acaadee79abb0f40f9f14b6a Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 27 Jun 2017 13:47:46 +0200 Subject: 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. --- waftools/dependencies.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'waftools/dependencies.py') 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 -- cgit v1.2.3