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 a library of the Graphics Gems code
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, 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 birdfont_export(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 169 # birdfont-export 170 run("mkdir -p build/birdfont-export") 171 172 experimentalNonNull = "" 173 if nonNull: 174 experimentalNonNull = "--enable-experimental-non-null" 175 176 run(valac + """ \ 177 -C \ 178 """ + valaflags + """ \ 179 """ + experimentalNonNull + """ \ 180 --enable-experimental \ 181 --define=MAC \ 182 birdfont-export/*.vala \ 183 --vapidir=./ \ 184 --pkg """ + config.GEE + """ \ 185 --pkg gio-2.0 \ 186 --pkg cairo \ 187 --pkg libbirdfont""") 188 run("mv birdfont-export/*.c build/birdfont-export/") 189 190 run(cc + " " + cflags + """ \ 191 -c ./build/libbirdfont/birdfont.h build/birdfont-export/*.c \ 192 -D 'GETTEXT_PACKAGE="birdfont"' \ 193 $(pkg-config --cflags """ + config.GEE + """) \ 194 $(pkg-config --cflags gio-2.0) \ 195 $(pkg-config --cflags cairo) \ 196 $(pkg-config --cflags glib-2.0) \ 197 -I ./build/libbirdfont/""") 198 run("mv ./*.o build/birdfont-export/") 199 200 run(cc + " " + ldflags + " \ 201 build/birdfont-export/*.o \ 202 -Lbuild/bin/ -lbirdfont \ 203 -lm \ 204 $(pkg-config --libs """ + config.GEE + """) \ 205 $(pkg-config --libs gio-2.0) \ 206 $(pkg-config --libs cairo) \ 207 $(pkg-config --libs glib-2.0) \ 208 -L./build -L./build/bin -l birdxml \ 209 -o ./build/bin/birdfont-export""") 210 211 run("rm -f build/birdfont.1.gz") 212 run("cp resources/linux/birdfont.1 build/") 213 run("gzip -9 build/birdfont.1") 214 215 run("rm -f build/birdfont-autotrace.1.gz") 216 run("cp resources/linux/birdfont-autotrace.1 build/") 217 run("gzip -9 build/birdfont-autotrace.1") 218 219 run("rm -f build/birdfont-export.1.gz") 220 run("cp resources/linux/birdfont-export.1 build/") 221 run("gzip -9 build/birdfont-export.1") 222 223 run("touch build/installed") 224 run("touch build/configured") 225 226 def birdfont_import(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 227 # birdfont-import 228 run("mkdir -p build/birdfont-import") 229 230 experimentalNonNull = "" 231 if nonNull: 232 experimentalNonNull = "--enable-experimental-non-null" 233 234 run(valac + """ \ 235 -C \ 236 """ + valaflags + """ \ 237 """ + experimentalNonNull + """ \ 238 --enable-experimental \ 239 --define=MAC birdfont-import/*.vala \ 240 --vapidir=./ \ 241 --pkg """ + config.GEE + """ \ 242 --pkg gio-2.0 \ 243 --pkg cairo \ 244 --pkg libbirdfont""") 245 run("mv birdfont-import/*.c build/birdfont-import/") 246 247 run(cc + " " + cflags + """ \ 248 -c ./build/libbirdfont/birdfont.h build/birdfont-import/*.c \ 249 -D 'GETTEXT_PACKAGE="birdfont"' \ 250 $(pkg-config --cflags """ + config.GEE + """) \ 251 $(pkg-config --cflags gio-2.0) \ 252 $(pkg-config --cflags cairo) \ 253 $(pkg-config --cflags glib-2.0) \ 254 -I ./build/libbirdfont/""") 255 run("mv ./*.o build/birdfont-import/") 256 257 run(cc + " " + ldflags + " \ 258 build/birdfont-import/*.o \ 259 -Lbuild/bin/ -lbirdfont \ 260 -lm \ 261 $(pkg-config --libs """ + config.GEE + """) \ 262 $(pkg-config --libs gio-2.0) \ 263 $(pkg-config --libs cairo) \ 264 $(pkg-config --libs glib-2.0) \ 265 -L./build -L./build/bin -l birdxml \ 266 -o ./build/bin/birdfont-import""") 267 268 def birdfont_autotrace(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 269 # birdfont-autotrace 270 run("mkdir -p build/birdfont-autotrace") 271 272 experimentalNonNull = "" 273 if nonNull: 274 experimentalNonNull = "--enable-experimental-non-null" 275 276 run(valac + """ \ 277 -C \ 278 """ + experimentalNonNull + """ \ 279 --enable-experimental \ 280 --define=MAC \ 281 birdfont-autotrace/*.vala \ 282 --vapidir=./ \ 283 --pkg """ + config.GEE + """ \ 284 --pkg gio-2.0 \ 285 --pkg cairo \ 286 --pkg gdk-pixbuf-2.0 \ 287 --pkg libbirdfont""") 288 run("mv birdfont-autotrace/*.c build/birdfont-autotrace/") 289 290 run(cc + " " + cflags + """ \ 291 -c ./build/libbirdfont/birdfont.h build/birdfont-autotrace/*.c \ 292 -D 'GETTEXT_PACKAGE="birdfont"' \ 293 $(pkg-config --cflags """ + config.GEE + """) \ 294 $(pkg-config --cflags gio-2.0) \ 295 $(pkg-config --cflags cairo) \ 296 $(pkg-config --cflags glib-2.0) \ 297 $(pkg-config --cflags gdk-pixbuf-2.0) \ 298 -I ./build/libbirdfont/""") 299 run("mv ./*.o build/birdfont-autotrace/") 300 301 run(cc + " " + ldflags + " \ 302 build/birdfont-autotrace/*.o \ 303 -Lbuild/bin/ -lbirdfont \ 304 -lm \ 305 $(pkg-config --libs """ + config.GEE + """) \ 306 $(pkg-config --libs gio-2.0) \ 307 $(pkg-config --libs cairo) \ 308 $(pkg-config --libs glib-2.0) \ 309 $(pkg-config --libs gdk-pixbuf-2.0) \ 310 -L./build -L./build/bin -l birdxml \ 311 -o ./build/bin/birdfont-autotrace""") 312 313 314 def birdfont_gtk(prefix, cc, cflags, ldflags, valac, valaflags, nonNull = True): 315 # birdfont 316 run("mkdir -p build/birdfont") 317 318 experimentalNonNull = "" 319 if nonNull: 320 experimentalNonNull = "--enable-experimental-non-null" 321 322 run(valac + " " + valaflags + """\ 323 -C \ 324 birdfont/*.vala \ 325 """ + experimentalNonNull + """ \ 326 --enable-experimental \ 327 --vapidir=./ \ 328 --pkg """ + config.GEE + """ \ 329 --pkg gio-2.0 \ 330 --pkg cairo \ 331 --pkg libsoup-2.4 \ 332 --pkg gdk-pixbuf-2.0 \ 333 --pkg webkitgtk-3.0 \ 334 --pkg libnotify\ 335 --pkg libbirdfont""") 336 run("mv birdfont/*.c build/birdfont/") 337 338 run(cc + " " + cflags + """\ 339 -c ./build/libbirdfont/birdfont.h build/birdfont/*.c \ 340 -D 'GETTEXT_PACKAGE="birdfont"' \ 341 $(pkg-config --cflags """ + config.GEE + """) \ 342 $(pkg-config --cflags gio-2.0) \ 343 $(pkg-config --cflags cairo) \ 344 $(pkg-config --cflags glib-2.0) \ 345 $(pkg-config --cflags gdk-pixbuf-2.0) \ 346 $(pkg-config --cflags webkitgtk-3.0) \ 347 $(pkg-config --cflags libnotify) \ 348 -I ./build/libbirdfont/""") 349 run("mv ./*.o build/birdfont/") 350 351 run(cc + " " + ldflags + """ \ 352 build/birdfont/*.o \ 353 -Lbuild/bin/ -lbirdfont \ 354 $(pkg-config --libs """ + config.GEE + """) \ 355 $(pkg-config --libs gio-2.0) \ 356 $(pkg-config --libs cairo) \ 357 $(pkg-config --libs glib-2.0) \ 358 $(pkg-config --libs gdk-pixbuf-2.0) \ 359 $(pkg-config --libs webkitgtk-3.0) \ 360 $(pkg-config --libs gtk+-2.0) \ 361 $(pkg-config --libs libnotify) \ 362 -L./build -L./build/bin -l birdxml \ 363 -o ./build/bin/birdfont""") 364 365