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