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