-
Notifications
You must be signed in to change notification settings - Fork 304
/
bklocal.py
4078 lines (3542 loc) · 158 KB
/
bklocal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!python
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is Komodo code.
#
# The Initial Developer of the Original Code is ActiveState Software Inc.
# Portions created by ActiveState Software Inc are Copyright (C) 2000-2007
# ActiveState Software Inc. All Rights Reserved.
#
# Contributor(s):
# ActiveState Software Inc
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# The local set of Black configuration items for Komodo-devel.
import os
from os.path import join, exists, expanduser, dirname, basename, \
abspath, normpath, isdir, isfile
import sys
import glob
import re
import time
from pprint import pprint
import warnings
import socket
import subprocess
if sys.platform.startswith('win'):
import _winreg
import black.configure
from black.configure import ConfigureError
import tmShUtil
sys.path.insert(0, os.path.join("src", "python-sitelib"))
import which
sys.path.pop(0)
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "util"))
import platinfo
import gitutils
del sys.path[0]
#---- output control (use black's output stream if available)
out = black.configure.out
#---- configuration (i.e. info that might need to change for new Komodo versions)
#---- utils
def _getLinuxDistro():
assert sys.platform.startswith("linux")
return platinfo.platname("distro+distro_ver")
def _getPrettyVersion(version):
"""Transform the given version to a "pretty" form
"pretty" representation as used for the "Product Name" in the MSI
installer.
Examples:
2.0.0 2.0.0
2.0.1-beta 2.0.1 Beta
2.3.0-beta1 2.3.0 Beta 1
"""
parts = version.split('-')
if len(parts) == 1:
return version
elif len(parts) == 2:
ver, quality = parts
match = re.match("([a-z]+)(\d+)?", quality)
qualityType, qualityVer = match.groups()
if qualityVer is None:
return "%s %s" % (ver, qualityType.capitalize())
else:
return "%s %s %s" % (ver, qualityType.capitalize(), qualityVer)
else:
raise "Invalid version string: '%s'. Can only be one hyphen."\
% version
def _capture_stdout(argv, ignore_retval=False, cwd=None, env=None):
# Only available on python 2.4 and above
import subprocess
p = subprocess.Popen(argv, cwd=cwd, stdout=subprocess.PIPE, env=env)
stdout = p.stdout.read()
retval = p.wait()
if retval and not ignore_retval:
raise RuntimeError("error running '%s' in %s" % (' '.join(argv), cwd))
return stdout
def _getValidPlatforms(linuxDistro=False, macUniversal=True):
"""Return a list of platforms for which Mozilla can be built from
the current machine.
@param linuxDistro {bool} Indicates if linux distro should be included
in the name.
@param macUniversal {bool} Indicates if the package/whatever using this
platform name is universal (i.e. shouldn't include the arch).
"""
validPlats = []
if sys.platform == "win32":
validPlats = ["win32-x86"]
elif sys.platform.startswith("linux"):
uname = os.uname()
if uname[4] == "ia64":
validPlats = []
elif re.match("i\d86", uname[4]):
config = ""
if linuxDistro:
config += "-" + _getLinuxDistro()
validPlats = ["linux%s-x86" % config]
elif uname[4] == "x86_64":
config = ""
if linuxDistro:
config += "-" + _getLinuxDistro()
validPlats = ["linux%s-x86_64" % config]
else:
raise ConfigureError("unknown Linux architecture: '%s'"
% uname[4])
elif sys.platform.startswith("sunos"):
#XXX Note that we don't really support Solaris builds yet.
uname = os.uname()
if uname[4].startswith("sun4"):
if uname[2] == "5.6":
validPlats = ["solaris-sparc"]
elif uname[2] == "5.8":
validPlats = ["solaris8-sparc", "solaris8-sparc64"]
else:
raise ConfigureError("unknown Solaris version: '%s'"
% uname[2])
else:
raise ConfigureError("unknown Solaris architecture: '%s'"
% uname[4])
elif sys.platform == "darwin":
if macUniversal:
validPlats = ["macosx"]
else:
uname = os.uname()
if uname[-1] == 'i386':
validPlats = ["macosx-x86"]
elif uname[-1] == 'x86_64':
validPlats = ["macosx-x86_64"]
else:
raise ConfigureError("unexpected macosx architecture: '%s'"
% uname[4])
return validPlats
def _getDefaultPlatform(linuxDistro=False, macUniversal=True):
"""Return an appropriate default target platform for the current machine.
@param linuxDistro {bool} Indicates if linux distro should be included
in the name.
@param macUniversal {bool} Indicates if the package/whatever using this
platform name is universal (i.e. shouldn't include the arch).
A "platform" is a string of the form "<os>[-<config>][-<arch>]".
"""
try:
return _getValidPlatforms(linuxDistro=linuxDistro,
macUniversal=macUniversal)[0]
except IndexError, ex:
raise ConfigureError("cannot build mozilla on this platform: '%s'"
% sys.platform)
gMozDefines = None
gMozSubsts = None
def _getMozDefinesAndSubsts(mozObjDir):
"""Load Mozilla's config.status Python file."""
# TODO: This should eventually use Mozilla's ConfigStatus.py file.
global gMozDefines
global gMozSubsts
if gMozDefines is None:
mozconfig = join(mozObjDir, "config.status")
cfg_globals = {"__file__": mozconfig}
cfg_locals = {}
execfile(mozconfig, cfg_globals, cfg_locals)
gMozDefines = dict(cfg_locals.get("defines"))
gMozSubsts = dict(cfg_locals.get("substs"))
return gMozDefines, gMozSubsts
#---- particular Data for the Komodo world
class SiloedPythonExeName(black.configure.std.Datum):
def __init__(self):
black.configure.std.Datum.__init__(self, "siloedPythonExeName",
desc="the name of the siloed Python executable")
def _Determine_Do(self):
self.applicable = 1
if sys.platform.startswith("win"):
buildType = black.configure.items["buildType"].Get()
if buildType == "debug":
self.value = "python_d.exe"
else:
self.value = "python.exe"
else:
self.value = "python"
self.determined = 1
class SiloedPythonInstallDir(black.configure.std.Datum):
"""The full path to the siloed Python bin directory.
The first thing the Komodo build system does is copy the siloed
Python (from its location in prebuilt/...) to the appropriate place
in the mozilla/dist/... area.
Windows dev build:
$mozSrc/dist/
bin/
komodo.exe
python/ # PyXPCOM site lib (can't use this dir)
python/ # proposed siloed Python base install dir
Windows installer build:
<installdir>/
Mozilla/
komodo.exe
python/ # proposed siloed Python base install dir
python.exe
Mac OS X dev build:
$mozSrc/dist/
bin/
komodo
komodo-bin
python/ # PyXPCOM site lib (can't use this dir)
Komodo.app/Contents/
MacOS/
komodo # same as the one above in bin/
komodo-bin # same as the one above in bin/
Frameworks/
Python.framework/... # siloed Python base install dir
Mac OS X installer build:
<install-.app-dir>/Contents/
MacOS/
komodo
komodo-bin
Frameworks/
Python.framework/... # siloed Python base install dir
Linux/Solaris dev build:
$mozSrc/dist/
bin/
komodo.exe
python/ # PyXPCOM site lib (can't use this dir)
python/ # siloed Python base install dir
Linux/Solaris installer build:
<installdir>/
lib/
mozilla/
komodo
komodo-bin
komodo.exe
python/ # siloed Python base install dir
Basically the above makes this config var easy: the siloed Python in
dev trees is always in $mozSrc/mozilla/dist/python/... except on Mac
OS X.
Note: It would be nice if this "appropriate" place worked with how
Firefox is current distributed (e.g. so that a separate PyXPCOM
Firefox extension and/or Komodo that installs as an add on to a
xulrunner install or something like that could work.) No guarantees
this time around.
"""
def __init__(self):
black.configure.std.Datum.__init__(self, "siloedPythonInstallDir",
desc="the siloed Python bin directory")
def _Determine_Sufficient(self):
if self.value is None:
siloedPythonExeName = black.configure.items['siloedPythonExeName'].Get()
raise black.configure.ConfigureError(\
"Could not determine %s (something bad happened)" % self.desc)
def _Determine_Do(self):
from os.path import join
self.applicable = 1
mozDist = black.configure.items["mozDist"].Get()
if sys.platform == "darwin":
macKomodoAppBuildName = black.configure.items['macKomodoAppBuildName'].Get()
self.value = join(mozDist, macKomodoAppBuildName,
"Contents", "Frameworks")
else:
self.value = join(mozDist, "python")
self.determined = 1
class SiloedPythonBinDir(black.configure.std.Datum):
def __init__(self):
black.configure.std.Datum.__init__(self, "siloedPythonBinDir",
desc="the siloed Python bin directory")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s (something bad happened)" % self.desc)
def _Determine_Do(self):
from os.path import join
self.applicable = 1
siloedPythonInstallDir = black.configure.items["siloedPythonInstallDir"].Get()
if sys.platform == "darwin":
siloedPyVer = black.configure.items["siloedPyVer"].Get()
self.value = join(siloedPythonInstallDir, "Python.framework",
"Versions", siloedPyVer, "bin")
else:
self.value = siloedPythonInstallDir
if sys.platform != "win32":
self.value = join(self.value, "bin")
self.determined = 1
class SiloedPython(black.configure.std.Datum):
def __init__(self):
black.configure.std.Datum.__init__(self, "siloedPython",
desc="path to the siloed Python executable")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s (something bad happened)" % self.desc)
def _Determine_Do(self):
from os.path import join
self.applicable = 1
siloedPythonBinDir = black.configure.items["siloedPythonBinDir"].Get()
siloedPythonExeName = black.configure.items["siloedPythonExeName"].Get()
self.value = join(siloedPythonBinDir, siloedPythonExeName)
self.determined = 1
class SiloedPythonVersion(black.configure.std.Datum):
def __init__(self):
black.configure.std.Datum.__init__(self, "siloedPythonVersion",
desc="the python version")
def _Determine_Do(self):
from os.path import join
self.applicable = 1
siloedPythonExeName = black.configure.items["siloedPythonExeName"].Get()
siloedPythonInstallDir = black.configure.items["siloedPythonInstallDir"].Get()
if sys.platform == "win32":
env = ""
pythonExe = join(siloedPythonInstallDir, siloedPythonExeName)
elif sys.platform == "darwin":
env = ""
pythonExe = join(siloedPythonInstallDir, "Python.framework",
"Versions", "*", "bin",
siloedPythonExeName)
try:
pythonExe = glob.glob(pythonExe)[0]
except IndexError, ex:
raise black.configure.ConfigureError(
"Could not determine %s: `%s' doesn't exist" % (
self.desc, pythonExe))
else:
pythonExe = join(siloedPythonInstallDir, "bin",
siloedPythonExeName)
env = "LD_LIBRARY_PATH=%s/lib" % siloedPythonInstallDir
cmd = '%s %s -c "import sys; sys.stdout.write(\'.\'.join(map(str, sys.version_info[:3])))"'\
% (env, pythonExe)
o = os.popen(cmd)
self.value = o.read()
self.determined = 1
class SiloedPyVer(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "siloedPyVer",
desc="the siloed Python <major>.<minor> version")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
siloedPythonVersion = black.configure.items["siloedPythonVersion"].Get()
self.value = '.'.join(siloedPythonVersion.split('.',2)[:2])
self.determined = 1
class SiloedDistutilsLibDirName(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "siloedDistutilsLibDirName",
desc="the platform-specific lib dir name that a distutils build will use")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
import distutils.util
self.applicable = 1
siloedPyVer = black.configure.items["siloedPyVer"].Get()
siloedPython = black.configure.items["siloedPython"].Get()
ld_path_list = black.configure.items["LD_LIBRARY_PATH"].Get()
# the distutils platform name
cmd = [siloedPython, '-c', "from distutils.util import get_platform; print get_platform()"]
# Ensure we use the correct LD_LIBRARY_PATH required by the siloed
# Python executable.
env = os.environ.copy()
if sys.platform.startswith("linux"):
if 'LD_LIBRARY_PATH' in env:
ld_path_list.append(env['LD_LIBRARY_PATH'])
env["LD_LIBRARY_PATH"] = os.path.pathsep.join(ld_path_list)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env)
status = p.wait()
platname = p.stdout.read().strip()
assert status == 0 and platname, \
"empty distutils platname: running the cmd must have failed: %s" % cmd
self.value = "lib.%s-%s" % (platname, siloedPyVer)
self.determined = 1
class HavePy2to3(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "havePy2to3",
desc="whether the siloed Python has a sufficient 2to3 library for the Komodo build")
def _Determine_Do(self):
self.applicable = 1
siloedPython = black.configure.items["siloedPython"].Get()
argv = [siloedPython, "-c", "from lib2to3.main import main"]
p = subprocess.Popen(argv, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
status = p.wait()
if status:
self.value = False
else:
self.value = True
self.determined = 1
class SetMozTools(black.configure.SetEnvVar):
def __init__(self):
black.configure.SetEnvVar.__init__(self, "MOZ_TOOLS",
acceptedOptions=("", ["moz-tools="]))
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine value for MOZ_TOOLS. "\
"Either manually set MOZ_TOOLS or use the --moz-tools "\
"option.\n")
# Have to make sure this is the NEW MOZ_TOOLS.
# - ensure that MOZ_TOOLS/bin/gmake.exe is of version 3.79.1 or greater
# (In the old wintools.zip it was version 3.74)
gmakeExe = os.path.join(self.value, "bin", "gmake.exe")
if not os.path.isfile(gmakeExe):
raise black.configure.ConfigureError(\
"MOZ_TOOLS is bogus, there is no gmake "\
"executable (%s) there.\n" % gmakeExe)
cmd = '"%s" --version' % gmakeExe
o = os.popen(cmd)
outputLines = o.readlines()
o.close()
versionRe = re.compile("^GNU Make version (?P<version>[0-9.]+)")
minVersion = "3.79.1"
versionMatch = versionRe.search(outputLines[0])
if not versionMatch:
raise black.configure.ConfigureError(\
"The first line of running '%s' did not "\
"return a recognized version string syntax." % cmd)
else:
version = versionMatch.group("version")
if version < minVersion:
raise black.configure.ConfigureError(\
"The current version of gmake.exe in "\
"your MOZ_TOOLS bin directory is %s. It must be at "\
"least version %s. This probably indicates that you have "\
"the old wintools.zip package from mozilla.org. You "\
"need to get the new one from "\
"ftp://ftp.mozilla.org/pub/mozilla/source/wintools.zip "\
"and install it SEPARATELY from your Cygwin "\
"installation. Alternatively, main/Apps/Mozilla comes "\
"with the build tools that it needs (under bin/...) so "\
"you should only have to undefine MOZ_TOOLS and rerun "\
"the configure step." % (version, minVersion))
def _Determine_Do(self):
if sys.platform.startswith("win"):
self.applicable = 1
for opt, optarg in self.chosenOptions:
if opt == "--moz-tools":
self.value = os.path.abspath(os.path.normpath(optarg))
break
else:
if os.environ.has_key(self.name):
self.value = os.environ[self.name]
else:
self.value = None
else:
self.applicable = 0
self.determined = 1
class SetKomodoHostname(black.configure.SetEnvVar):
"""A Mozilla patch now requires that KOMODO_HOSTNAME be set when
Mozilla is run. This is just the hostname of the current machine.
"""
def __init__(self):
black.configure.SetEnvVar.__init__(self, "KOMODO_HOSTNAME",
"the hostname of the current machine")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s.\n" % self.desc)
def _Determine_Do(self):
self.applicable = 1
self.value = socket.gethostname()
self.determined = 1
class KomodoDevDir(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "komodoDevDir",\
desc="the root Komodo development directory")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s. You must run 'bk configure' in "\
"the dir containing the 'Construct' file.\n" % self.desc)
def _Determine_Do(self):
self.applicable = 1
# use the current working directory if it has a Construct file
if os.path.isfile("Construct"):
self.value = os.getcwd()
else:
self.value = None
self.determined = 1
class MozillaDevDir(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "mozillaDevDir",\
desc="the root Mozilla development directory")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s." % self.desc)
elif not exists(self.value):
raise black.configure.ConfigureError(
"%s (%s) does not exist" % (self.desc, self.value))
def _Determine_Do(self):
self.applicable = 1
komodoDevDir = black.configure.items["komodoDevDir"].Get()
candidates = [
join(abspath(komodoDevDir), "mozilla"),
]
for candidate in candidates:
if isdir(candidate):
self.value = candidate
break
else:
self.value = None
self.determined = 1
class ProductType(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "productType",
desc="the Komodo product type")
def _Determine_Do(self):
self.applicable = 1
prettyProductType = black.configure.items["prettyProductType"].Get()
self.value = prettyProductType.lower()
assert ' ' not in self.value
self.determined = 1
class MacKomodoAppInstallName(black.configure.Datum):
"""The .app directory name for the *installed* Komodo on Mac OS X.
Note that this is different than the *build* name: for both Komodo
IDE and Edit the .app dir name during the build doesn't include the
product-type (see `macKomodoAppBuildName`).
"""
def __init__(self):
black.configure.Datum.__init__(self, "macKomodoAppInstallName",
desc="the Komodo .app dir name on Mac OS X (for installation)")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
prettyProductType = black.configure.items["prettyProductType"].Get()
productType = black.configure.items["productType"].Get()
komodoVersion = black.configure.items["komodoVersion"].Get()
majorVer = komodoVersion.split('.', 1)[0]
name = (productType == "openkomodo" and prettyProductType
or "Komodo %s %s" % (prettyProductType, majorVer))
self.value = name + ".app"
self.determined = 1
class MacKomodoAppBuildName(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "macKomodoAppBuildName",
desc="the Komodo .app dir name on Mac OS X (during the build)")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
buildType = black.configure.items["buildType"].Get()
if buildType == "release":
self.value = "Komodo.app"
elif buildType == "debug":
self.value = "KomodoDebug.app"
else:
raise ValueError("unexpected value of buildType: %r" % buildType)
self.determined = 1
class ProductType(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "productType",
desc="the Komodo product type",
acceptedOptions=("", ["product-type="]))
self.knownValues = ["edit", "openkomodo"]
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s. Use the "\
"--product-type configure option to specify this. "\
"The currently valid values for this are %s\n" %\
(self.desc, self.knownValues))
else:
if self.value not in self.knownValues:
raise black.configure.ConfigureError(\
"The specified product type '%s' is "\
"not one of the known values: %s" %\
(self.value, self.knownValues))
def _Determine_Do(self):
self.applicable = 1
self.value = "edit" # default
for opt, optarg in self.chosenOptions:
if opt == "--product-type":
self.value = optarg
self.determined = 1
class PrettyProductType(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "prettyProductType",
desc="the Komodo product type with proper capitalization")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
productType = black.configure.items["productType"].Get()
self.value = {"openkomodo": "OpenKomodo",
"edit": "Edit",
}[productType]
self.determined = 1
class ProductTagLine(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "productTagLine",
desc="the Komodo product tag line",
acceptedOptions=("", ["product-tag-line="]))
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
productType = black.configure.items["productType"].Get()
self.value = {
"edit": "Free multi-platform editor that makes it easy to write quality code.",
"openkomodo": "The IDE for the Open Web",
}[productType]
for opt, optarg in self.chosenOptions:
if opt == "--product-tag-line":
self.value = optarg
self.determined = 1
class GnomeDesktopShortcutName(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "gnomeDesktopShortcutName",
desc="Gnome desktop shortcut filename for Komodo")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
productType = black.configure.items["productType"].Get()
name = (productType == "openkomodo" and "openkomodo"
or "komodo-"+productType)
komodoVersion = black.configure.items["komodoVersion"].Get()
majorVer = komodoVersion.split('.', 1)[0]
updateChannel = black.configure.items["updateChannel"].Get()
self.value = "%s-%s%s.desktop" % (name, majorVer,
updateChannel == "nightly" and "-nightly" or "")
self.determined = 1
class GnomeDesktopName(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "gnomeDesktopName",
desc="'Name' field for Gnome desktop entry for Komodo")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
productType = black.configure.items["productType"].Get()
prettyProductType = black.configure.items["prettyProductType"].Get()
name = (productType == "openkomodo" and prettyProductType
or "Komodo %s" % prettyProductType)
komodoVersion = black.configure.items["komodoVersion"].Get()
majorVer = komodoVersion.split('.', 1)[0]
updateChannel = black.configure.items["updateChannel"].Get()
self.value = "%s %s%s" % (name, majorVer,
updateChannel == "nightly" and " nightly" or "")
self.determined = 1
class GnomeDesktopGenericName(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "gnomeDesktopGenericName",
desc="'GenericName' field for Gnome desktop entry for Komodo")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
productType = black.configure.items["productType"].Get()
self.value = {
"edit": "Editor",
}.get(productType, "IDE")
self.determined = 1
class GnomeDesktopCategories(black.configure.Datum):
def __init__(self):
black.configure.Datum.__init__(self, "gnomeDesktopCategories",
desc="'Categories' field for Gnome desktop entry for Komodo")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(
"Could not determine %s." % self.desc)
def _Determine_Do(self):
self.applicable = 1
productType = black.configure.items["productType"].Get()
self.value = "ActiveState;Application;Development;Editor;Utility;TextEditor;"
self.determined = 1
class SetMozBinDir(black.configure.SetEnvVar):
def __init__(self):
black.configure.SetEnvVar.__init__(self, "KOMODO_MOZBINDIR",
desc="the Mozilla build's binaries dir (only set for dev builds)")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s. This probably "\
"means that the Mozilla bin directory could not be "\
"determined.\n" % self.desc)
def _Determine_Do(self):
self.applicable = 1
self.value = black.configure.items["mozBin"].Get()
self.determined = 1
class PrebuiltPaths(black.configure.Datum):
# See discussion for "UnsiloedPythonBinDir".
def __init__(self):
black.configure.Datum.__init__(self, "prebuiltPaths",
desc="the full path to the prebuilt directory")
def _Determine_Sufficient(self):
if self.value is None:
raise black.configure.ConfigureError(\
"Could not determine %s.\n" % self.desc)
def _Determine_Do(self):
self.applicable = 1
platform = black.configure.items["platform"].Get()
buildType = black.configure.items["buildType"].Get()
if sys.platform.startswith("linux"):
candidates = [os.path.abspath(os.path.join(
"prebuilt", platform, buildType))]
self.value = [c for c in candidates if os.path.exists(c)]
elif sys.platform.startswith("darwin"):
platName = _getDefaultPlatform()
self.value = [os.path.abspath(os.path.join(
"prebuilt", "%s" % (platName), buildType))]
else:
self.value = [os.path.abspath(os.path.join(
"prebuilt", platform, buildType))]
self.determined = 1
class PerlExe(black.configure.Datum):
"""Determine the full path to a Perl of the given version. The Perl used
is found as follows:
- if the "--perlXY" option is specified, then that value is used
- the first Perl of the correct version on the PATH is used
- some platform-specific well-known locations are checked
"""
def __init__(self, version):
self.version = version # 2-tuple (<major>, <minor>)
self.longopt = "perl%s%s" % self.version
black.configure.Datum.__init__(self, "perl%s%s" % self.version,
desc="the full path to an unsiloed Perl %s.%s executable" % self.version,
acceptedOptions=("", [self.longopt + "="]))
def _getVersion(self, perl):
ver_pat = re.compile(r"\(revision (\d+)(?:\.\d+)? version (\d+) subversion \d+\)")
ver_output = _capture_stdout([perl, "-V"]).strip()
ver_match = ver_pat.search(ver_output)
if ver_match is None:
raise black.configure.ConfigureError("""\
could not determine Perl version for '%s':
/%s/ does not match `perl -V` output:
-------------------------------------------------
%s
-------------------------------------------------
""" % (perl, ver_pat.pattern, ver_output))
ver = (int(ver_match.group(1)), int(ver_match.group(2)))
return ver
def _Determine_Sufficient(self):
buildFlavour = black.configure.items["buildFlavour"].Get()
if buildFlavour == "full":
ver = "%s.%s" % self.version
if not self.value:
raise black.configure.ConfigureError(
"Could not find a Perl %s executable. You must (1) "
"identify one with the --%s configure option; or (2) "
"put one on your PATH (doesn't have to be first); or "
"(3) install one in one of the 'well-known' locations: "
"%s" % (ver, self.longopt, self.candidates))
actualVersion = self._getVersion(self.value)
if actualVersion != self.version:
raise black.configure.ConfigureError(\
"'%s' is not Perl version %s" % (self.value, ver))
def _Determine_Do(self):
# Only applicable for Komodo installer builds, but to deal with
# limited Perl+Cons variable Import/Export we define empty values
# for non-installer-build configurations.
self.applicable = 1
buildFlavour = black.configure.items["buildFlavour"].Get()
if buildFlavour == "full":
#XXX Might have to follow symlinks for any values.
# First see if the Perl was specified with a command argument.
for opt, optarg in self.chosenOptions:
if opt == "--"+self.longopt:
self.value = optarg
return
# Else, check each Perl on the PATH.
perl_exe_name = (sys.platform == "win32" and "perl.exe" or "perl")
for perl in which.whichall(perl_exe_name):
try:
version = self._getVersion(perl)
except ValueError:
pass
else:
if version == self.version:
self.value = perl
return
# Else, look in some well-known install locations.
if sys.platform.startswith("win"):
systemDrive = os.environ.get("SystemDrive", "C:")
self.candidates = [
os.path.join(systemDrive, os.sep, "Perl%s%s" % self.version),
os.path.join(systemDrive, os.sep, "Perl"),
]
else:
self.candidates = []
basenames = [
"ActivePerl-%s.%s*" % self.version,
"ActivePerl",
"perl-%s.%s*" % self.version,
"perl",
]
dirnames = [
os.path.expanduser("~/local"),
os.path.expanduser("~/opt"),
"/opt",
"/usr/local",
"/usr",
]
for dirname in dirnames:
for basename in basenames:
self.candidates += glob.glob(os.path.join(dirname, basename, "bin"))
for bindir in self.candidates:
perl = os.path.join(bindir, perl_exe_name)
if not os.path.isfile(perl): continue
version = self._getVersion(perl)
if version == self.version:
self.value = perl
return
else:
self.value = ""
self.determined = 1
class NonMsysPerlExe(black.configure.Datum):
"""The full path to a Perl on Windows that isn't msys Perl.
The reason is we need a Perl with MD5 (for Cons) and the Perl in
the MozillaBuild package (likely to be first on a builders PATH)
doesn't have it -- and I don't have the time to build one for it
now (gcc on Windows build "fun").
Note that even with the MD5 module, I'm not certain the unix-y msys
Perl build would work with Komodo build system which is why this
config var is "nonMsysPerl" rather than just "perlWithMD5".
"""
def __init__(self):
black.configure.Datum.__init__(self, "nonMsysPerl",
desc="non MSYS Perl executable")
def _isNotMsysPerl(self, perl):
ver_output = _capture_stdout([perl, "-V"]).strip()
msys_pat = re.compile(r'Built under msys')
if msys_pat.search(ver_output):
return False
return True
def _Determine_Sufficient(self):
if self.applicable and not self.value:
raise black.configure.ConfigureError(
"Could not find a non-msys Perl executable. The "
"current Komodo Cons-based build system needs a Perl "
"with the MD5 module and the msys Perl from the "
"MozillaBuild package doesn't have this module. Please "
"install ActivePerl. If you know that it does, please "
"report a Komodo bug to fix 'bk configure'.")
def _Determine_Do(self):