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.
Link to sqlite
1 #!/usr/bin/python 2 """ 3 Copyright (C) 2013, 2014 2015 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, usePixbuf = 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 libbirdfont/Renderer/*.vala \ 47 --pkg """ + config.GEE + """ \ 48 --pkg gio-2.0 \ 49 --pkg cairo \ 50 --pkg libbirdxml \ 51 --pkg libbirdgems \ 52 --pkg sqlite3 \ 53 """) 54 55 #copy c sources 56 run("cp libbirdfont/OpenFontFormat/*.c build/libbirdfont/") 57 58 if cc == "": 59 print ("Skipping compilation"); 60 else: 61 run(cc + " " + cflags + """ \ 62 -c build/libbirdfont/*.c \ 63 -fPIC \ 64 -D 'GETTEXT_PACKAGE="birdfont"' \ 65 $(pkg-config --cflags sqlite3) \ 66 $(pkg-config --cflags """ + config.GEE + """) \ 67 $(pkg-config --cflags gio-2.0) \ 68 $(pkg-config --cflags cairo) \ 69 $(pkg-config --cflags glib-2.0) \ 70 -I ./build/libbirdxml \ 71 -I ./build/libbirdgems""") 72 run("mv ./*.o build/libbirdfont/ ") 73 74 if library.endswith (".dylib"): 75 sonameparam = "" # gcc on mac os does not have the soname parameter 76 else: 77 sonameparam = "-Wl,-soname," + library 78 79 run(cc + " " + ldflags + """ \ 80 -shared \ 81 """ + sonameparam + """ \ 82 build/libbirdfont/*.o \ 83 $(pkg-config --libs sqlite3) \ 84 $(freetype-config --libs) \ 85 $(pkg-config --libs """ + config.GEE + """) \ 86 $(pkg-config --libs gio-2.0) \ 87 $(pkg-config --libs cairo) \ 88 $(pkg-config --libs glib-2.0) \ 89 -L./build -L./build/bin -l birdxml -l birdgems\ 90 -o """ + library) 91 run("mv " + library + " build/bin/") 92 93 if os.path.exists("build/bin/libbirdfont.so"): 94 run ("cd build/bin && unlink libbirdfont.so") 95 96 # create link to the versioned library 97 if library.find ('.so') > -1: 98 run ("""cd build/bin && ln -sf """ + library + " libbirdfont.so") 99 elif library.find ('.dylib') > -1: 100 run ("""cd build/bin && ln -sf """ + library + " libbirdfont.dylib") 101 102 run("rm -f build/birdfont.1.gz") 103 run("cp resources/linux/birdfont.1 build/") 104 run("gzip build/birdfont.1") 105 106 run("rm -f build/birdfont-export.1.gz") 107 run("cp resources/linux/birdfont-export.1 build/") 108 run("gzip build/birdfont-export.1") 109 110 run("rm -f build/birdfont-import.1.gz") 111 run("cp resources/linux/birdfont-import.1 build/") 112 run("gzip build/birdfont-import.1") 113 114 115 def libbirdxml(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True): 116 #libbirdfont 117 run("mkdir -p build/libbirdxml") 118 run("mkdir -p build/bin") 119 120 experimentalNonNull = "" 121 if nonNull: 122 experimentalNonNull = "--enable-experimental-non-null" 123 124 run(valac + """\ 125 -C \ 126 """ + valaflags + """ \ 127 --pkg posix \ 128 --vapidir=./ \ 129 --basedir build/libbirdxml/ \ 130 """ + experimentalNonNull + """ \ 131 --enable-experimental \ 132 --library libbirdxml \ 133 -H build/libbirdxml/birdxml.h \ 134 libbirdxml/*.vala \ 135 """) 136 137 if cc == "": 138 print ("Skipping compilation"); 139 else: 140 run(cc + " " + cflags + """ \ 141 -c build/libbirdxml/*.c \ 142 -fPIC \ 143 $(pkg-config --cflags glib-2.0) \ 144 $(pkg-config --cflags gobject-2.0) \ 145 """) 146 147 run("mv ./*.o build/libbirdxml/ ") 148 149 if library.endswith (".dylib"): 150 sonameparam = "" # gcc on mac os does not have the soname parameter 151 else: 152 sonameparam = "-Wl,-soname," + library 153 154 run(cc + " " + ldflags + """ \ 155 -shared \ 156 """ + sonameparam + """ \ 157 build/libbirdxml/*.o \ 158 $(pkg-config --libs glib-2.0) \ 159 $(pkg-config --libs gobject-2.0) \ 160 -o """ + library) 161 run("mv " + library + " build/bin/") 162 163 if os.path.exists("build/bin/libbirdxml.so"): 164 run ("cd build/bin && unlink libbirdxml.so") 165 166 # create link to the versioned library 167 if library.find ('.so') > -1: 168 run ("""cd build/bin && ln -sf """ + library + " libbirdxml.so") 169 elif library.find ('.dylib') > -1: 170 run ("""cd build/bin && ln -sf """ + library + " libbirdxml.dylib") 171 172 173 def libbirdgems(prefix, cc, cflags, ldflags, valac, valaflags, library, nonNull = True): 174 print ('Compiling libbirdgems') 175 run("mkdir -p build/libbirdgems") 176 run("mkdir -p build/bin") 177 178 experimentalNonNull = "" 179 if nonNull: 180 experimentalNonNull = "--enable-experimental-non-null" 181 182 run(valac + """\ 183 -C \ 184 """ + valaflags + """ \ 185 -H build/libbirdgems/birdgems.h \ 186 --pkg posix \ 187 --vapidir=./ \ 188 --basedir build/libbirdgems/ \ 189 """ + experimentalNonNull + """ \ 190 --enable-experimental \ 191 --library libbirdgems \ 192 libbirdgems/*.vala \ 193 """) 194 195 run("cp libbirdgems/*.c build/libbirdgems/") 196 run("cp libbirdgems/*.h build/libbirdgems/") 197 198 if cc == "": 199 print ("Skipping compilation"); 200 else: 201 run(cc + " " + cflags + """ \ 202 -fPIC \ 203 $(pkg-config --cflags glib-2.0) \ 204 -c build/libbirdgems/*.c \ 205 """) 206 207 run("mv ./*.o build/libbirdgems/ ") 208 209 if library.endswith (".dylib"): 210 sonameparam = "" # gcc on mac os does not have the soname parameter 211 else: 212 sonameparam = "-Wl,-soname," + library 213 214 run(cc + " " + ldflags + """ \ 215 -shared \ 216 """ + sonameparam + """ \ 217 -fPIC \ 218 build/libbirdgems/*.o \ 219 $(pkg-config --libs glib-2.0) \ 220 $(pkg-config --libs gobject-2.0) \ 221 -o """ + library) 222 run("mv " + library + " build/bin/") 223 224 if os.path.exists("build/bin/libbirdgems.so"): 225 run ("cd build/bin && unlink libbirdgems.so") 226 227 # create link to the versioned library 228 if library.find ('.so') > -1: 229 run ("""cd build/bin && ln -sf """ + library + " libbirdgems.so") 230 elif library.find ('.dylib') > -1: 231 run ("""cd build/bin && ln -sf """ + library + " libbirdgems.dylib") 232 233 234 def birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 235 # birdfont-export 236 run("mkdir -p build/birdfont-export") 237 238 experimentalNonNull = "" 239 if nonNull: 240 experimentalNonNull = "--enable-experimental-non-null" 241 242 run(valac + """ \ 243 -C \ 244 """ + valaflags + """ \ 245 """ + experimentalNonNull + """ \ 246 --enable-experimental \ 247 --define=MAC \ 248 birdfont-export/*.vala \ 249 --vapidir=./ \ 250 --pkg """ + config.GEE + """ \ 251 --pkg gio-2.0 \ 252 --pkg cairo \ 253 --pkg libbirdfont""") 254 run("mv birdfont-export/*.c build/birdfont-export/") 255 256 run(cc + " " + cflags + """ \ 257 -c ./build/libbirdfont/birdfont.h build/birdfont-export/*.c \ 258 -D 'GETTEXT_PACKAGE="birdfont"' \ 259 $(pkg-config --cflags sqlite3) \ 260 $(pkg-config --cflags """ + config.GEE + """) \ 261 $(pkg-config --cflags gio-2.0) \ 262 $(pkg-config --cflags cairo) \ 263 $(pkg-config --cflags glib-2.0) \ 264 -I ./build/libbirdfont/""") 265 run("mv ./*.o build/birdfont-export/") 266 267 run(cc + " " + ldflags + " \ 268 build/birdfont-export/*.o \ 269 -Lbuild/bin/ -lbirdfont \ 270 -lm \ 271 $(pkg-config --libs sqlite3) \ 272 $(pkg-config --libs """ + config.GEE + """) \ 273 $(pkg-config --libs gio-2.0) \ 274 $(pkg-config --libs cairo) \ 275 $(pkg-config --libs glib-2.0) \ 276 -L./build -L./build/bin -l birdxml -l birdgems\ 277 -o ./build/bin/birdfont-export""") 278 279 run("rm -f build/birdfont.1.gz") 280 run("cp resources/linux/birdfont.1 build/") 281 run("gzip -9 build/birdfont.1") 282 283 run("rm -f build/birdfont-autotrace.1.gz") 284 run("cp resources/linux/birdfont-autotrace.1 build/") 285 run("gzip -9 build/birdfont-autotrace.1") 286 287 run("rm -f build/birdfont-export.1.gz") 288 run("cp resources/linux/birdfont-export.1 build/") 289 run("gzip -9 build/birdfont-export.1") 290 291 run("touch build/installed") 292 run("touch build/configured") 293 294 def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 295 # birdfont-import 296 run("mkdir -p build/birdfont-import") 297 298 experimentalNonNull = "" 299 if nonNull: 300 experimentalNonNull = "--enable-experimental-non-null" 301 302 run(valac + """ \ 303 -C \ 304 """ + valaflags + """ \ 305 """ + experimentalNonNull + """ \ 306 --enable-experimental \ 307 --define=MAC birdfont-import/*.vala \ 308 --vapidir=./ \ 309 --pkg """ + config.GEE + """ \ 310 --pkg gio-2.0 \ 311 --pkg cairo \ 312 --pkg libbirdfont""") 313 run("mv birdfont-import/*.c build/birdfont-import/") 314 315 run(cc + " " + cflags + """ \ 316 -c ./build/libbirdfont/birdfont.h build/birdfont-import/*.c \ 317 -D 'GETTEXT_PACKAGE="birdfont"' \ 318 $(pkg-config --cflags sqlite3) \ 319 $(pkg-config --cflags """ + config.GEE + """) \ 320 $(pkg-config --cflags gio-2.0) \ 321 $(pkg-config --cflags cairo) \ 322 $(pkg-config --cflags glib-2.0) \ 323 -I ./build/libbirdfont/""") 324 run("mv ./*.o build/birdfont-import/") 325 326 run(cc + " " + ldflags + " \ 327 build/birdfont-import/*.o \ 328 -Lbuild/bin/ -lbirdfont \ 329 -lm \ 330 -fPIC \ 331 $(pkg-config --libs sqlite3) \ 332 $(pkg-config --libs """ + config.GEE + """) \ 333 $(pkg-config --libs gio-2.0) \ 334 $(pkg-config --libs cairo) \ 335 $(pkg-config --libs glib-2.0) \ 336 -L./build -L./build/bin -l birdxml -l birdgems\ 337 -o ./build/bin/birdfont-import""") 338 339 def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 340 # birdfont-autotrace 341 run("mkdir -p build/birdfont-autotrace") 342 343 experimentalNonNull = "" 344 if nonNull: 345 experimentalNonNull = "--enable-experimental-non-null" 346 347 run(valac + """ \ 348 -C \ 349 """ + experimentalNonNull + """ \ 350 --enable-experimental \ 351 --define=MAC \ 352 birdfont-autotrace/*.vala \ 353 --vapidir=./ \ 354 --pkg """ + config.GEE + """ \ 355 --pkg gio-2.0 \ 356 --pkg cairo \ 357 --pkg gdk-pixbuf-2.0 \ 358 --pkg libbirdfont""") 359 run("mv birdfont-autotrace/*.c build/birdfont-autotrace/") 360 361 run(cc + " " + cflags + """ \ 362 -c ./build/libbirdfont/birdfont.h build/birdfont-autotrace/*.c \ 363 -D 'GETTEXT_PACKAGE="birdfont"' \ 364 $(pkg-config --cflags sqlite3) \ 365 $(pkg-config --cflags """ + config.GEE + """) \ 366 $(pkg-config --cflags gio-2.0) \ 367 $(pkg-config --cflags cairo) \ 368 $(pkg-config --cflags glib-2.0) \ 369 $(pkg-config --cflags gdk-pixbuf-2.0) \ 370 -I ./build/libbirdfont/""") 371 run("mv ./*.o build/birdfont-autotrace/") 372 373 run(cc + " " + ldflags + " \ 374 build/birdfont-autotrace/*.o \ 375 -Lbuild/bin/ -lbirdfont \ 376 -lm \ 377 $(pkg-config --libs sqlite3) \ 378 $(pkg-config --libs """ + config.GEE + """) \ 379 $(pkg-config --libs gio-2.0) \ 380 $(pkg-config --libs cairo) \ 381 $(pkg-config --libs glib-2.0) \ 382 $(pkg-config --libs gdk-pixbuf-2.0) \ 383 -L./build -L./build/bin -l birdxml -l birdgems\ 384 -o ./build/bin/birdfont-autotrace""") 385 386 387 def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 388 # birdfont 389 run("mkdir -p build/birdfont") 390 391 experimentalNonNull = "" 392 if nonNull: 393 experimentalNonNull = "--enable-experimental-non-null" 394 395 run(valac + " " + valaflags + """\ 396 -C \ 397 birdfont/*.vala \ 398 """ + experimentalNonNull + """ \ 399 --enable-experimental \ 400 --vapidir=./ \ 401 --pkg """ + config.GEE + """ \ 402 --pkg gio-2.0 \ 403 --pkg cairo \ 404 --pkg libsoup-2.4 \ 405 --pkg gdk-pixbuf-2.0 \ 406 --pkg webkitgtk-3.0 \ 407 --pkg libnotify\ 408 --pkg libbirdfont""") 409 run("mv birdfont/*.c build/birdfont/") 410 411 run(cc + " " + cflags + """\ 412 -c ./build/libbirdfont/birdfont.h build/birdfont/*.c \ 413 -D 'GETTEXT_PACKAGE="birdfont"' \ 414 $(pkg-config --cflags sqlite3) \ 415 $(pkg-config --cflags """ + config.GEE + """) \ 416 $(pkg-config --cflags gio-2.0) \ 417 $(pkg-config --cflags cairo) \ 418 $(pkg-config --cflags glib-2.0) \ 419 $(pkg-config --cflags gdk-pixbuf-2.0) \ 420 $(pkg-config --cflags webkitgtk-3.0) \ 421 $(pkg-config --cflags libnotify) \ 422 -I ./build/libbirdfont/""") 423 run("mv ./*.o build/birdfont/") 424 425 run(cc + " " + ldflags + """ \ 426 build/birdfont/*.o \ 427 -Lbuild/bin/ -lbirdfont \ 428 $(pkg-config --libs sqlite3) \ 429 $(pkg-config --libs """ + config.GEE + """) \ 430 $(pkg-config --libs gio-2.0) \ 431 $(pkg-config --libs cairo) \ 432 $(pkg-config --libs glib-2.0) \ 433 $(pkg-config --libs gdk-pixbuf-2.0) \ 434 $(pkg-config --libs webkitgtk-3.0) \ 435 $(pkg-config --libs gtk+-2.0) \ 436 $(pkg-config --libs libnotify) \ 437 -L./build -L./build/bin -l birdxml -l birdgems\ 438 -o ./build/bin/birdfont""") 439 440