From b89e3cf8a066d04b35f17000026ab1c6ea4156b5 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 3 Apr 2017 17:55:50 +0200 Subject: [PATCH] [objc] Add support for building the native library with debug information. (#53) --- .gitignore | 2 ++ objcgen/driver.cs | 8 ++++++-- tests/objc-cli/Makefile | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8f3531e..98a74fd 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ bindings.m /tests/**/gen/objc /tests/**/gen/java packages +*.dSYM + diff --git a/objcgen/driver.cs b/objcgen/driver.cs index 8e894a7..9194039 100644 --- a/objcgen/driver.cs +++ b/objcgen/driver.cs @@ -36,12 +36,14 @@ namespace Embeddinator { { bool shared = true; // dylib var action = Action.None; + var debug = false; var os = new OptionSet { { "o|out|outdir=", "output directory", v => OutputDirectory = v }, { "h|?|help", "Displays the help", v => action = Action.Help }, { "v|verbose", "generates diagnostic verbose output", v => ErrorHelper.Verbosity++ }, { "version", "Display the version information.", v => action = Action.Version }, + { "debug", "Build the native library with debug information.", v => debug = true }, }; var assemblies = os.Parse (args); @@ -64,7 +66,7 @@ namespace Embeddinator { return 0; case Action.Generate: try { - return Generate (assemblies, shared); + return Generate (assemblies, shared, debug); } catch (NotImplementedException e) { throw new EmbeddinatorException (1000, $"The feature `{e.Message}` is not currently supported by the tool"); } @@ -90,7 +92,7 @@ namespace Embeddinator { } } - static int Generate (List args, bool shared) + static int Generate (List args, bool shared, bool debug) { Console.WriteLine ("Parsing assemblies..."); @@ -126,6 +128,8 @@ namespace Embeddinator { } StringBuilder options = new StringBuilder ("clang "); + if (debug) + options.Append ("-g -O0 "); options.Append ("-DMONO_EMBEDDINATOR_DLL_EXPORT "); options.Append ("-framework CoreFoundation "); options.Append ("-framework Foundation "); diff --git a/tests/objc-cli/Makefile b/tests/objc-cli/Makefile index ead9600..9c48429 100644 --- a/tests/objc-cli/Makefile +++ b/tests/objc-cli/Makefile @@ -8,7 +8,7 @@ managed.dll: libmanaged.dylib: managed.dll xbuild ../../objcgen/objcgen.csproj - mono ../../objcgen/bin/Debug/objcgen.exe managed.dll + mono ../../objcgen/bin/Debug/objcgen.exe --debug managed.dll test: libmanaged.dylib clang test-managed.m -lmanaged -L. -framework Foundation -o test-cli