From 4ed0907f2d596ba66652ca6d739cc12dae7dc2a0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 1 Jan 2015 23:56:41 +0100 Subject: build: try to make examples build both in-tree and out-of-tree The examples simple.c and cocoabasic.m can be compiled without installing libmpv. But also, they didn't use the correct include path libmpv programs normally use, so they couldn't be built with a properly installed system-libmpv. That's pretty bad for examples, which are supposed to show how to use libmpv correctly. So do some bullshit that symlinks libmpv to a "mpv" include directory under the build directory. This name-mismatch is a direct consequence of the bullshit done in 499a6758 (requested in #539 for dumb reasons). (We don't want to name the client API headers directory "mpv", because that would be too unspecific, and clashes with having the mpv binary in the same directory.) If you have spaces or other "unusual" characters in your paths, the build will break, because I couldn't find out where waf hides its function to escape shell parameters (or a way to invoke programs without involving the shell). Neither does such a thing to be documented, nor do they seem to have a clear way to do this in their code. This also doesn't compile the Qt examples, because everything becomes even more terrible from there on. --- DOCS/client_api_examples/cocoa/cocoabasic.m | 2 +- DOCS/client_api_examples/simple/simple.c | 2 +- wscript | 2 ++ wscript_build.py | 15 +++++++++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/DOCS/client_api_examples/cocoa/cocoabasic.m b/DOCS/client_api_examples/cocoa/cocoabasic.m index 74f8f2e864..ea3e9c69d5 100644 --- a/DOCS/client_api_examples/cocoa/cocoabasic.m +++ b/DOCS/client_api_examples/cocoa/cocoabasic.m @@ -3,7 +3,7 @@ // but that's not quite ready yet. // You may need a basic Info.plist and MainMenu.xib to make this work. -#include "libmpv/client.h" +#include #include #include diff --git a/DOCS/client_api_examples/simple/simple.c b/DOCS/client_api_examples/simple/simple.c index 62fc9e8061..ca8699a076 100644 --- a/DOCS/client_api_examples/simple/simple.c +++ b/DOCS/client_api_examples/simple/simple.c @@ -2,7 +2,7 @@ #include #include -#include "libmpv/client.h" +#include static inline void check_error(int status) { diff --git a/wscript b/wscript index 338ded3638..98b8eab1ea 100644 --- a/wscript +++ b/wscript @@ -29,6 +29,8 @@ build_options = [ 'name': '--client-api-examples', 'desc': 'build client API examples', 'deps_any': [ 'libmpv-shared', 'libmpv-static' ], + # The build process uses symlinks (ln -s) + 'deps_neg': [ 'os-win32' ], 'func': check_true }, { 'name': '--static-build', diff --git a/wscript_build.py b/wscript_build.py index 694a65b038..2771bbbbec 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -528,15 +528,26 @@ def build(ctx): ( "cocoa/cocoabasic.m", "cocoa" ), ] + # Create a "local" include dir, so we can build the examples without + # installing the headers. + incdir = os.path.join(ctx.bldnode.abspath(), "include") + ctx( + rule = "mkdir -p {1} && ln -s {0} {1}/mpv".format( + os.path.join(ctx.srcnode.abspath(), "libmpv"), incdir), + before = ("c",), + name = "incdir", + ) + for source in ctx.filtered_sources(examples_sources): ctx( target = os.path.splitext(source)[0], source = "DOCS/client_api_examples/" + source, - includes = [ctx.bldnode.abspath(), ctx.srcnode.abspath()], - use = "mpv", + includes = [incdir, ctx.srcnode.abspath()], + use = "mpv incdir", features = "c cprogram", install_path = None ) + ctx.env.CFLAGS += ['-isystem', incdir] if ctx.dependency_satisfied("vf-dlopen-filters"): dlfilters = "telecine tile rectangle framestep ildetect".split() -- cgit v1.2.3