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 sqlite) \ 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 sqlite) \ 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 """ + config.GEE + """) \ 260 $(pkg-config --cflags gio-2.0) \ 261 $(pkg-config --cflags cairo) \ 262 $(pkg-config --cflags glib-2.0) \ 263 -I ./build/libbirdfont/""") 264 run("mv ./*.o build/birdfont-export/") 265 266 run(cc + " " + ldflags + " \ 267 build/birdfont-export/*.o \ 268 -Lbuild/bin/ -lbirdfont \ 269 -lm \ 270 $(pkg-config --libs """ + config.GEE + """) \ 271 $(pkg-config --libs gio-2.0) \ 272 $(pkg-config --libs cairo) \ 273 $(pkg-config --libs glib-2.0) \ 274 -L./build -L./build/bin -l birdxml -l birdgems\ 275 -o ./build/bin/birdfont-export""") 276 277 run("rm -f build/birdfont.1.gz") 278 run("cp resources/linux/birdfont.1 build/") 279 run("gzip -9 build/birdfont.1") 280 281 run("rm -f build/birdfont-autotrace.1.gz") 282 run("cp resources/linux/birdfont-autotrace.1 build/") 283 run("gzip -9 build/birdfont-autotrace.1") 284 285 run("rm -f build/birdfont-export.1.gz") 286 run("cp resources/linux/birdfont-export.1 build/") 287 run("gzip -9 build/birdfont-export.1") 288 289 run("touch build/installed") 290 run("touch build/configured") 291 292 def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 293 # birdfont-import 294 run("mkdir -p build/birdfont-import") 295 296 experimentalNonNull = "" 297 if nonNull: 298 experimentalNonNull = "--enable-experimental-non-null" 299 300 run(valac + """ \ 301 -C \ 302 """ + valaflags + """ \ 303 """ + experimentalNonNull + """ \ 304 --enable-experimental \ 305 --define=MAC birdfont-import/*.vala \ 306 --vapidir=./ \ 307 --pkg """ + config.GEE + """ \ 308 --pkg gio-2.0 \ 309 --pkg cairo \ 310 --pkg libbirdfont""") 311 run("mv birdfont-import/*.c build/birdfont-import/") 312 313 run(cc + " " + cflags + """ \ 314 -c ./build/libbirdfont/birdfont.h build/birdfont-import/*.c \ 315 -D 'GETTEXT_PACKAGE="birdfont"' \ 316 $(pkg-config --cflags """ + config.GEE + """) \ 317 $(pkg-config --cflags gio-2.0) \ 318 $(pkg-config --cflags cairo) \ 319 $(pkg-config --cflags glib-2.0) \ 320 -I ./build/libbirdfont/""") 321 run("mv ./*.o build/birdfont-import/") 322 323 run(cc + " " + ldflags + " \ 324 build/birdfont-import/*.o \ 325 -Lbuild/bin/ -lbirdfont \ 326 -lm \ 327 -fPIC \ 328 $(pkg-config --libs """ + config.GEE + """) \ 329 $(pkg-config --libs gio-2.0) \ 330 $(pkg-config --libs cairo) \ 331 $(pkg-config --libs glib-2.0) \ 332 -L./build -L./build/bin -l birdxml -l birdgems\ 333 -o ./build/bin/birdfont-import""") 334 335 def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 336 # birdfont-autotrace 337 run("mkdir -p build/birdfont-autotrace") 338 339 experimentalNonNull = "" 340 if nonNull: 341 experimentalNonNull = "--enable-experimental-non-null" 342 343 run(valac + """ \ 344 -C \ 345 """ + experimentalNonNull + """ \ 346 --enable-experimental \ 347 --define=MAC \ 348 birdfont-autotrace/*.vala \ 349 --vapidir=./ \ 350 --pkg """ + config.GEE + """ \ 351 --pkg gio-2.0 \ 352 --pkg cairo \ 353 --pkg gdk-pixbuf-2.0 \ 354 --pkg libbirdfont""") 355 run("mv birdfont-autotrace/*.c build/birdfont-autotrace/") 356 357 run(cc + " " + cflags + """ \ 358 -c ./build/libbirdfont/birdfont.h build/birdfont-autotrace/*.c \ 359 -D 'GETTEXT_PACKAGE="birdfont"' \ 360 $(pkg-config --cflags """ + config.GEE + """) \ 361 $(pkg-config --cflags gio-2.0) \ 362 $(pkg-config --cflags cairo) \ 363 $(pkg-config --cflags glib-2.0) \ 364 $(pkg-config --cflags gdk-pixbuf-2.0) \ 365 -I ./build/libbirdfont/""") 366 run("mv ./*.o build/birdfont-autotrace/") 367 368 run(cc + " " + ldflags + " \ 369 build/birdfont-autotrace/*.o \ 370 -Lbuild/bin/ -lbirdfont \ 371 -lm \ 372 $(pkg-config --libs """ + config.GEE + """) \ 373 $(pkg-config --libs gio-2.0) \ 374 $(pkg-config --libs cairo) \ 375 $(pkg-config --libs glib-2.0) \ 376 $(pkg-config --libs gdk-pixbuf-2.0) \ 377 -L./build -L./build/bin -l birdxml -l birdgems\ 378 -o ./build/bin/birdfont-autotrace""") 379 380 381 def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 382 # birdfont 383 run("mkdir -p build/birdfont") 384 385 experimentalNonNull = "" 386 if nonNull: 387 experimentalNonNull = "--enable-experimental-non-null" 388 389 run(valac + " " + valaflags + """\ 390 -C \ 391 birdfont/*.vala \ 392 """ + experimentalNonNull + """ \ 393 --enable-experimental \ 394 --vapidir=./ \ 395 --pkg """ + config.GEE + """ \ 396 --pkg gio-2.0 \ 397 --pkg cairo \ 398 --pkg libsoup-2.4 \ 399 --pkg gdk-pixbuf-2.0 \ 400 --pkg webkitgtk-3.0 \ 401 --pkg libnotify\ 402 --pkg libbirdfont""") 403 run("mv birdfont/*.c build/birdfont/") 404 405 run(cc + " " + cflags + """\ 406 -c ./build/libbirdfont/birdfont.h build/birdfont/*.c \ 407 -D 'GETTEXT_PACKAGE="birdfont"' \ 408 $(pkg-config --cflags """ + config.GEE + """) \ 409 $(pkg-config --cflags gio-2.0) \ 410 $(pkg-config --cflags cairo) \ 411 $(pkg-config --cflags glib-2.0) \ 412 $(pkg-config --cflags gdk-pixbuf-2.0) \ 413 $(pkg-config --cflags webkitgtk-3.0) \ 414 $(pkg-config --cflags libnotify) \ 415 -I ./build/libbirdfont/""") 416 run("mv ./*.o build/birdfont/") 417 418 run(cc + " " + ldflags + """ \ 419 build/birdfont/*.o \ 420 -Lbuild/bin/ -lbirdfont \ 421 $(pkg-config --libs """ + config.GEE + """) \ 422 $(pkg-config --libs gio-2.0) \ 423 $(pkg-config --libs cairo) \ 424 $(pkg-config --libs glib-2.0) \ 425 $(pkg-config --libs gdk-pixbuf-2.0) \ 426 $(pkg-config --libs webkitgtk-3.0) \ 427 $(pkg-config --libs gtk+-2.0) \ 428 $(pkg-config --libs libnotify) \ 429 -L./build -L./build/bin -l birdxml -l birdgems\ 430 -o ./build/bin/birdfont""") 431 432