The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

build.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/build.py.
Create plugin interface for the rendering classes
1 #!/usr/bin/python 2 """ 3 Copyright (C) 2013, 2014 Johan Mattsson 4 5 This library is free software; you can redistribute it and/or modify 6 it under the terms of the GNU Lesser General Public License as 7 published by the Free Software Foundation; either version 3 of the 8 License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 """ 15 16 import os 17 import shutil 18 import subprocess 19 import sys 20 import version 21 from optparse import OptionParser 22 from run import run 23 24 import config 25 26 def libbirdfont(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True): 27 #libbirdfont 28 run("mkdir -p build/libbirdfont") 29 run("mkdir -p build/bin") 30 31 experimentalNonNull = "" 32 if nonNull: 33 experimentalNonNull = "--enable-experimental-non-null" 34 35 run(valac + """\ 36 -C \ 37 """ + valaflags + """ \ 38 --vapidir=./ \ 39 --basedir build/libbirdfont/ \ 40 """ + experimentalNonNull + """ \ 41 --enable-experimental \ 42 --library libbirdfont \ 43 -H build/libbirdfont/birdfont.h \ 44 libbirdfont/*.vala \ 45 libbirdfont/OpenFontFormat/*.vala \ 46 --pkg """ + config.GEE + """ \ 47 --pkg gio-2.0 \ 48 --pkg cairo \ 49 --pkg gdk-pixbuf-2.0 \ 50 --pkg libbirdxml \ 51 """) 52 53 #copy c sources 54 run("cp libbirdfont/OpenFontFormat/*.c build/libbirdfont/") 55 56 if cc == "": 57 print ("Skipping compilation"); 58 else: 59 run(cc + " " + cflags + """ \ 60 -c build/libbirdfont/*.c \ 61 -fPIC \ 62 -D 'GETTEXT_PACKAGE="birdfont"' \ 63 $(pkg-config --cflags """ + config.GEE + """) \ 64 $(pkg-config --cflags gio-2.0) \ 65 $(pkg-config --cflags cairo) \ 66 $(pkg-config --cflags glib-2.0) \ 67 $(pkg-config --cflags gdk-pixbuf-2.0) \ 68 -I ./build/libbirdxml""") 69 run("mv ./*.o build/libbirdfont/ ") 70 71 if library.endswith (".dylib"): 72 sonameparam = "" # gcc on mac os does not have the soname parameter 73 else: 74 sonameparam = "-Wl,-soname," + library 75 76 run(cc + " " + ldflags + """ \ 77 -shared \ 78 """ + sonameparam + """ \ 79 build/libbirdfont/*.o \ 80 $(freetype-config --libs) \ 81 $(pkg-config --libs """ + config.GEE + """) \ 82 $(pkg-config --libs gio-2.0) \ 83 $(pkg-config --libs cairo) \ 84 $(pkg-config --libs glib-2.0) \ 85 $(pkg-config --libs gdk-pixbuf-2.0) \ 86 -L./build -L./build/bin -l birdxml \ 87 -o """ + library) 88 run("mv " + library + " build/bin/") 89 90 if os.path.exists("build/bin/libbirdfont.so"): 91 run ("cd build/bin && unlink libbirdfont.so") 92 93 # create link to the versioned library 94 if library.find ('.so') > -1: 95 run ("""cd build/bin && ln -sf """ + library + " libbirdfont.so") 96 elif library.find ('.dylib') > -1: 97 run ("""cd build/bin && ln -sf """ + library + " libbirdfont.dylib") 98 99 run("rm -f build/birdfont.1.gz") 100 run("cp resources/linux/birdfont.1 build/") 101 run("gzip build/birdfont.1") 102 103 run("rm -f build/birdfont-export.1.gz") 104 run("cp resources/linux/birdfont-export.1 build/") 105 run("gzip build/birdfont-export.1") 106 107 run("rm -f build/birdfont-import.1.gz") 108 run("cp resources/linux/birdfont-import.1 build/") 109 run("gzip build/birdfont-import.1") 110 111 112 def libbirdxml(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True): 113 #libbirdfont 114 run("mkdir -p build/libbirdxml") 115 run("mkdir -p build/bin") 116 117 experimentalNonNull = "" 118 if nonNull: 119 experimentalNonNull = "--enable-experimental-non-null" 120 121 run(valac + """\ 122 -C \ 123 """ + valaflags + """ \ 124 --vapidir=./ \ 125 --basedir build/libbirdxml/ \ 126 """ + experimentalNonNull + """ \ 127 --enable-experimental \ 128 --library libbirdxml \ 129 -H build/libbirdxml/birdxml.h \ 130 libbirdxml/*.vala \ 131 """) 132 133 if cc == "": 134 print ("Skipping compilation"); 135 else: 136 run(cc + " " + cflags + """ \ 137 -c build/libbirdxml/*.c \ 138 -fPIC \ 139 $(pkg-config --cflags glib-2.0) \ 140 $(pkg-config --cflags gobject-2.0) \ 141 """) 142 143 run("mv ./*.o build/libbirdxml/ ") 144 145 if library.endswith (".dylib"): 146 sonameparam = "" # gcc on mac os does not have the soname parameter 147 else: 148 sonameparam = "-Wl,-soname," + library 149 150 run(cc + " " + ldflags + """ \ 151 -shared \ 152 """ + sonameparam + """ \ 153 build/libbirdxml/*.o \ 154 $(pkg-config --libs glib-2.0) \ 155 $(pkg-config --libs gobject-2.0) \ 156 -o """ + library) 157 run("mv " + library + " build/bin/") 158 159 if os.path.exists("build/bin/libbirdxml.so"): 160 run ("cd build/bin && unlink libbirdxml.so") 161 162 # create link to the versioned library 163 if library.find ('.so') > -1: 164 run ("""cd build/bin && ln -sf """ + library + " libbirdxml.so") 165 elif library.find ('.dylib') > -1: 166 run ("""cd build/bin && ln -sf """ + library + " libbirdxml.dylib") 167 168 169 def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 170 # birdfont-export 171 run("mkdir -p build/birdfont-export") 172 173 experimentalNonNull = "" 174 if nonNull: 175 experimentalNonNull = "--enable-experimental-non-null" 176 177 run(valac + """ \ 178 -C \ 179 """ + experimentalNonNull + """ \ 180 --enable-experimental \ 181 --define=MAC birdfont-export/* \ 182 --vapidir=./ \ 183 --pkg """ + config.GEE + """ \ 184 --pkg gio-2.0 \ 185 --pkg cairo \ 186 --pkg gdk-pixbuf-2.0 \ 187 --pkg gtk+-2.0 \ 188 --pkg libbirdfont""") 189 run("mv birdfont-export/*.c build/birdfont-export/") 190 191 run(cc + " " + cflags + """ \ 192 -c ./build/libbirdfont/birdfont.h build/birdfont-export/*.c \ 193 -D 'GETTEXT_PACKAGE="birdfont"' \ 194 $(pkg-config --cflags """ + config.GEE + """) \ 195 $(pkg-config --cflags gio-2.0) \ 196 $(pkg-config --cflags cairo) \ 197 $(pkg-config --cflags glib-2.0) \ 198 $(pkg-config --cflags gdk-pixbuf-2.0) \ 199 -I ./build/libbirdfont/""") 200 run("mv ./*.o build/birdfont-export/") 201 202 run(cc + " " + ldflags + " \ 203 build/birdfont-export/*.o \ 204 -Lbuild/bin/ -lbirdfont \ 205 -lm \ 206 $(pkg-config --libs """ + config.GEE + """) \ 207 $(pkg-config --libs gio-2.0) \ 208 $(pkg-config --libs cairo) \ 209 $(pkg-config --libs glib-2.0) \ 210 $(pkg-config --libs gdk-pixbuf-2.0) \ 211 -L./build -L./build/bin -l birdxml \ 212 -o ./build/bin/birdfont-export""") 213 214 run("rm -f build/birdfont.1.gz") 215 run("cp resources/linux/birdfont.1 build/") 216 run("gzip -9 build/birdfont.1") 217 218 run("rm -f build/birdfont-autotrace.1.gz") 219 run("cp resources/linux/birdfont-autotrace.1 build/") 220 run("gzip -9 build/birdfont-autotrace.1") 221 222 run("rm -f build/birdfont-export.1.gz") 223 run("cp resources/linux/birdfont-export.1 build/") 224 run("gzip -9 build/birdfont-export.1") 225 226 run("touch build/installed") 227 run("touch build/configured") 228 229 def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 230 # birdfont-import 231 run("mkdir -p build/birdfont-import") 232 233 experimentalNonNull = "" 234 if nonNull: 235 experimentalNonNull = "--enable-experimental-non-null" 236 237 run(valac + """ \ 238 -C \ 239 """ + experimentalNonNull + """ \ 240 --enable-experimental \ 241 --define=MAC birdfont-import/* \ 242 --vapidir=./ \ 243 --pkg """ + config.GEE + """ \ 244 --pkg gio-2.0 \ 245 --pkg cairo \ 246 --pkg gdk-pixbuf-2.0 \ 247 --pkg gtk+-2.0 \ 248 --pkg libbirdfont""") 249 run("mv birdfont-import/*.c build/birdfont-import/") 250 251 run(cc + " " + cflags + """ \ 252 -c ./build/libbirdfont/birdfont.h build/birdfont-import/*.c \ 253 -D 'GETTEXT_PACKAGE="birdfont"' \ 254 $(pkg-config --cflags """ + config.GEE + """) \ 255 $(pkg-config --cflags gio-2.0) \ 256 $(pkg-config --cflags cairo) \ 257 $(pkg-config --cflags glib-2.0) \ 258 $(pkg-config --cflags gdk-pixbuf-2.0) \ 259 -I ./build/libbirdfont/""") 260 run("mv ./*.o build/birdfont-import/") 261 262 run(cc + " " + ldflags + " \ 263 build/birdfont-import/*.o \ 264 -Lbuild/bin/ -lbirdfont \ 265 -lm \ 266 $(pkg-config --libs """ + config.GEE + """) \ 267 $(pkg-config --libs gio-2.0) \ 268 $(pkg-config --libs cairo) \ 269 $(pkg-config --libs glib-2.0) \ 270 $(pkg-config --libs gdk-pixbuf-2.0) \ 271 -L./build -L./build/bin -l birdxml \ 272 -o ./build/bin/birdfont-import""") 273 274 def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 275 # birdfont-autotrace 276 run("mkdir -p build/birdfont-autotrace") 277 278 experimentalNonNull = "" 279 if nonNull: 280 experimentalNonNull = "--enable-experimental-non-null" 281 282 run(valac + """ \ 283 -C \ 284 """ + experimentalNonNull + """ \ 285 --enable-experimental \ 286 --define=MAC birdfont-autotrace/* \ 287 --vapidir=./ \ 288 --pkg """ + config.GEE + """ \ 289 --pkg gio-2.0 \ 290 --pkg cairo \ 291 --pkg gdk-pixbuf-2.0 \ 292 --pkg gtk+-2.0 \ 293 --pkg libbirdfont""") 294 run("mv birdfont-autotrace/*.c build/birdfont-autotrace/") 295 296 run(cc + " " + cflags + """ \ 297 -c ./build/libbirdfont/birdfont.h build/birdfont-autotrace/*.c \ 298 -D 'GETTEXT_PACKAGE="birdfont"' \ 299 $(pkg-config --cflags """ + config.GEE + """) \ 300 $(pkg-config --cflags gio-2.0) \ 301 $(pkg-config --cflags cairo) \ 302 $(pkg-config --cflags glib-2.0) \ 303 $(pkg-config --cflags gdk-pixbuf-2.0) \ 304 -I ./build/libbirdfont/""") 305 run("mv ./*.o build/birdfont-autotrace/") 306 307 run(cc + " " + ldflags + " \ 308 build/birdfont-autotrace/*.o \ 309 -Lbuild/bin/ -lbirdfont \ 310 -lm \ 311 $(pkg-config --libs """ + config.GEE + """) \ 312 $(pkg-config --libs gio-2.0) \ 313 $(pkg-config --libs cairo) \ 314 $(pkg-config --libs glib-2.0) \ 315 $(pkg-config --libs gdk-pixbuf-2.0) \ 316 -L./build -L./build/bin -l birdxml \ 317 -o ./build/bin/birdfont-autotrace""") 318 319 320 def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 321 # birdfont 322 run("mkdir -p build/birdfont") 323 324 experimentalNonNull = "" 325 if nonNull: 326 experimentalNonNull = "--enable-experimental-non-null" 327 328 run(valac + " " + valaflags + """\ 329 -C \ 330 birdfont/* \ 331 """ + experimentalNonNull + """ \ 332 --enable-experimental \ 333 --vapidir=./ \ 334 --pkg """ + config.GEE + """ \ 335 --pkg gio-2.0 \ 336 --pkg cairo \ 337 --pkg libsoup-2.4 \ 338 --pkg gdk-pixbuf-2.0 \ 339 --pkg webkitgtk-3.0 \ 340 --pkg libnotify\ 341 --pkg libbirdfont""") 342 run("mv birdfont/*.c build/birdfont/") 343 344 run(cc + " " + cflags + """\ 345 -c ./build/libbirdfont/birdfont.h build/birdfont/*.c \ 346 -D 'GETTEXT_PACKAGE="birdfont"' \ 347 $(pkg-config --cflags """ + config.GEE + """) \ 348 $(pkg-config --cflags gio-2.0) \ 349 $(pkg-config --cflags cairo) \ 350 $(pkg-config --cflags glib-2.0) \ 351 $(pkg-config --cflags gdk-pixbuf-2.0) \ 352 $(pkg-config --cflags webkitgtk-3.0) \ 353 $(pkg-config --cflags libnotify) \ 354 -I ./build/libbirdfont/""") 355 run("mv ./*.o build/birdfont/") 356 357 run(cc + " " + ldflags + """ \ 358 build/birdfont/*.o \ 359 -Lbuild/bin/ -lbirdfont \ 360 $(pkg-config --libs """ + config.GEE + """) \ 361 $(pkg-config --libs gio-2.0) \ 362 $(pkg-config --libs cairo) \ 363 $(pkg-config --libs glib-2.0) \ 364 $(pkg-config --libs gdk-pixbuf-2.0) \ 365 $(pkg-config --libs webkitgtk-3.0) \ 366 $(pkg-config --libs gtk+-2.0) \ 367 $(pkg-config --libs libnotify) \ 368 -L./build -L./build/bin -l birdxml \ 369 -o ./build/bin/birdfont""") 370 371