The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

configfile.py in scripts

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of scripts/configfile.py.
Write program version and OS to .birdfont file
1 #!/usr/bin/python3 2 """ 3 Copyright (C) 2012, 2013 Eduardo Naufel Schettino and Johan Mattsson 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 """ 18 19 from . import version 20 21 VERSION = version.VERSION 22 23 def write_config (prefix): 24 print ("Writing Config.vala") 25 26 vars = (('VERSION', VERSION), 27 ('PREFIX', prefix), 28 ) 29 30 f = open('./libbirdfont/Config.vala', 'w+') 31 f.write("// Don't edit this file -- it is generated by the build script\n") 32 f.write("namespace BirdFont {\n") 33 34 var_line = ' internal const string %s = "%s";\n' 35 for name, value in vars: 36 f.write(var_line % (name, value)) 37 38 f.write("}") 39 40 def write_compile_parameters(prefix, dest, cc, gee, valac, pkg_config, 41 non_null, valacflags, cflags, ldflags): 42 settings = { 43 'prefix': prefix, 44 'dest': dest, 45 'cc': cc, 46 'cflags': cflags, 47 'ldflags': ldflags, 48 'valac': valac, 49 'valacflags': valacflags, 50 'pkg-config': pkg_config, 51 'non_null': '--enable-experimental-non-null' if non_null else '', 52 'gee': gee, 53 } 54 def autoquote(v): 55 if isinstance(v, str): 56 return '"' + v + '"' 57 else: 58 return str(v) 59 60 f = open('./scripts/config.py', 'w+') 61 f.write("#!/usr/bin/python3\n") 62 for k, v in settings.items(): 63 f.write("%s = %s\n" % (k.upper().replace('-', '_'), autoquote(v))) 64 65 f.write("SETTINGS = {\n") 66 for k, v in settings.items(): 67 f.write(' "%s": %s,\n' % (k, autoquote(v))) 68 f.write("}\n") 69