The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

macport_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/macport_build.py.
Create plugin interface for the rendering classes
1 #!/usr/bin/python 2 """ 3 Copyright (C) 2013 Johan Mattsson 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 """ 18 19 import os 20 import shutil 21 import subprocess 22 import sys 23 from optparse import OptionParser 24 from translations import compile_translations 25 from run import run 26 27 import configfile 28 29 def build(prefix, cc, cflags, ldflags, valac): 30 compile_translations () 31 32 #libbirdfont 33 run("mkdir -p build/libbirdfont") 34 run("mkdir -p build/bin") 35 36 run(valac + """\ 37 -C \ 38 --basedir build/libbirdfont/ \ 39 --enable-experimental-non-null \ 40 --enable-experimental \ 41 --define=MAC \ 42 --library libbirdfont \ 43 -H build/libbirdfont/birdfont.h \ 44 libbirdfont/*.vala \ 45 libbirdfont/OpenFontFormat/*.vala \ 46 --pkg libxml-2.0 \ 47 --pkg gio-2.0 \ 48 --pkg cairo \ 49 --pkg libsoup-2.4 \ 50 --pkg gdk-pixbuf-2.0""") 51 52 #copy c sources 53 run("cp libbirdfont/OpenFontFormat/*.c build/libbirdfont/") 54 55 run(cc + " " + cflags + """ \ 56 -c build/libbirdfont/*.c \ 57 -fno-common \ 58 -fPIC \ 59 -D 'GETTEXT_PACKAGE="birdfont"' \ 60 $(pkg-config --cflags libxml-2.0) \ 61 $(pkg-config --cflags gio-2.0) \ 62 $(pkg-config --cflags cairo) \ 63 $(pkg-config --cflags glib-2.0) \ 64 $(pkg-config --cflags gdk-pixbuf-2.0) \ 65 -I ./build/mac/birdfont""") 66 run("mv ./*.o build/libbirdfont/ ") 67 68 run(cc + " " + ldflags + """ \ 69 -dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,""" + prefix + """/lib/libbirdfont.dylib -shared build/libbirdfont/*.o \ 70 $(pkg-config --libs libxml-2.0) \ 71 $(pkg-config --libs gio-2.0) \ 72 $(pkg-config --libs cairo) \ 73 $(pkg-config --libs glib-2.0) \ 74 $(pkg-config --libs gdk-pixbuf-2.0) \ 75 -shared -o libbirdfont.dylib""") 76 run("mv libbirdfont.dylib build/bin/") 77 78 # birdfont 79 run("mkdir -p build/birdfont") 80 81 run(valac + """\ 82 -C \ 83 --enable-experimental-non-null \ 84 --enable-experimental \ 85 --define=MAC birdfont/* \ 86 --vapidir=./ \ 87 --pkg libxml-2.0 \ 88 --pkg gio-2.0 \ 89 --pkg cairo \ 90 --pkg libsoup-2.4 \ 91 --pkg gdk-pixbuf-2.0 \ 92 --pkg webkit-1.0 \ 93 --pkg gtk+-2.0\ 94 --pkg libbirdfont""") 95 run("mv birdfont/*.c build/birdfont/") 96 97 run(cc + " " + cflags + """\ 98 -c ./build/libbirdfont/birdfont.h build/birdfont/*.c \ 99 -D 'GETTEXT_PACKAGE="birdfont"' \ 100 $(pkg-config --cflags libxml-2.0) \ 101 $(pkg-config --cflags gio-2.0) \ 102 $(pkg-config --cflags cairo) \ 103 $(pkg-config --cflags glib-2.0) \ 104 $(pkg-config --cflags gdk-pixbuf-2.0) \ 105 $(pkg-config --cflags webkit-1.0) \ 106 -I ./build/libbirdfont/""") 107 run("mv ./*.o build/birdfont/") 108 109 run(cc + " " + ldflags + """ \ 110 build/birdfont/*.o ./build/bin/libbirdfont.dylib \ 111 $(pkg-config --libs libxml-2.0) \ 112 $(pkg-config --libs gio-2.0) \ 113 $(pkg-config --libs cairo) \ 114 $(pkg-config --libs glib-2.0) \ 115 $(pkg-config --libs gdk-pixbuf-2.0) \ 116 $(pkg-config --libs webkit-1.0) \ 117 $(pkg-config --libs gtk+-2.0) \ 118 -o ./build/bin/birdfont""") 119 120 # birdfont-export 121 run("mkdir -p build/birdfont-export") 122 123 run(valac + """ \ 124 -C \ 125 --enable-experimental-non-null \ 126 --enable-experimental \ 127 --define=MAC birdfont-export/* \ 128 --vapidir=./ \ 129 --pkg libxml-2.0 \ 130 --pkg gio-2.0 \ 131 --pkg cairo \ 132 --pkg gdk-pixbuf-2.0 \ 133 --pkg gtk+-2.0 \ 134 --pkg libbirdfont""") 135 run("mv birdfont-export/*.c build/birdfont-export/") 136 137 run(cc + " " + cflags + """ \ 138 -c ./build/libbirdfont/birdfont.h build/birdfont-export/*.c \ 139 -D 'GETTEXT_PACKAGE="birdfont"' \ 140 $(pkg-config --cflags libxml-2.0) \ 141 $(pkg-config --cflags gio-2.0) \ 142 $(pkg-config --cflags cairo) \ 143 $(pkg-config --cflags glib-2.0) \ 144 $(pkg-config --cflags gdk-pixbuf-2.0) \ 145 -I ./build/libbirdfont/""") 146 run("mv ./*.o build/birdfont-export/") 147 148 run(cc + " " + ldflags + " \ 149 build/birdfont-export/*.o \ 150 ./build/bin/libbirdfont.dylib \ 151 $(pkg-config --libs libxml-2.0) \ 152 $(pkg-config --libs gio-2.0) \ 153 $(pkg-config --libs cairo) \ 154 $(pkg-config --libs glib-2.0) \ 155 $(pkg-config --libs gdk-pixbuf-2.0) \ 156 -o ./build/bin/birdfont-export") 157 158 run("touch build/installed") 159 run("touch build/configured") 160 161 162 def build_app (prefix): 163 # application launcher 164 run("mkdir -p build/BirdFont.app") 165 run("mkdir -p build/BirdFont.app/Contents") 166 run("mkdir -p build/BirdFont.app/Contents/MacOS") 167 run("mkdir -p build/BirdFont.app/Contents/Resources") 168 169 startup = open ('build/BirdFont.app/Contents/MacOS/birdfont.sh', 'w+') 170 startup.write ("#!/bin/bash\n") 171 startup.write (prefix + "/bin/birdfont\n") 172 173 run("chmod 755 build/BirdFont.app/Contents/MacOS/birdfont.sh") 174 175 run("cp -R -p resources/mac/Info.plist build/BirdFont.app/Contents/") 176 run("cp -R -p resources/mac/birdfont.icns build/BirdFont.app/Contents/Resources") 177 178 parser = OptionParser() 179 parser.add_option("-p", "--prefix", dest="prefix", help="install prefix", metavar="PREFIX") 180 parser.add_option("-d", "--dest", dest="dest", help="install to this directory", metavar="DEST") 181 parser.add_option("-c", "--cc", dest="cc", help="select the C compiler", metavar="CC") 182 parser.add_option("-f", "--cflags", dest="cflags", help="set compiler flags", metavar="CFLAGS") 183 parser.add_option("-l", "--ldflags", dest="ldflags", help="set linker flags", metavar="LDFLAGS") 184 parser.add_option("-v", "--valac", dest="valac", help="select vala compiler", metavar="VALAC") 185 186 (options, args) = parser.parse_args() 187 188 if not options.prefix: 189 options.prefix = "/opt/local" 190 if not options.cc: 191 options.cc = "gcc" 192 if not options.cflags: 193 options.cflags = "" 194 if not options.ldflags: 195 options.ldflags = "" 196 if not options.valac: 197 options.valac = "valac" 198 199 build_app (options.prefix) 200 build (options.prefix, options.cc, options.cflags, options.ldflags, options.valac) 201 202 203 204