1 /** 2 Copyright: Copyright (c) 2017, Joakim Brännström. All rights reserved. 3 License: MPL-2 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 This Source Code Form is subject to the terms of the Mozilla Public License, 7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 8 one at http://mozilla.org/MPL/2.0/. 9 */ 10 module dextool.plugin.cpptestdouble.backend.generate_xml; 11 12 import dextool.compilation_db : CompileCommandFilter; 13 14 /** Store the input in a configuration file to make it easy to regenerate the 15 * test double. 16 */ 17 ref AppT makeXmlConfig(AppT)(ref AppT app, CompileCommandFilter compiler_flag_filter) { 18 import std.algorithm : joiner, copy; 19 import std.conv : to; 20 import std.xml; 21 import dextool.utility : dextoolVersion; 22 import dextool.xml : makePrelude; 23 24 auto doc = new Document(new Tag("dextool")); 25 doc.tag.attr["version"] = dextoolVersion; 26 { 27 auto compiler_tag = new Element("compiler_flag_filter"); 28 compiler_tag.tag.attr["skip_compiler_args"] 29 = compiler_flag_filter.skipCompilerArgs.to!string(); 30 foreach (value; compiler_flag_filter.filter) { 31 auto tag = new Element("exclude"); 32 tag ~= new Text(value); 33 compiler_tag ~= tag; 34 } 35 doc ~= compiler_tag; 36 } 37 38 makePrelude(app); 39 doc.pretty(4).joiner("\n").copy(app); 40 41 return app; 42 }