forked from v3ss0n/komodoedit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Construct
1526 lines (1386 loc) · 56.9 KB
/
Construct
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
#!/usr/local/bin/perl
# ***** 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 *****
# Construct file for Komodo
#
# XXX cons -r does not get everything (.pyc files in the components dir, does
# not unregister chrome, ...)
use File::Find;
use File::Basename;
use File::Spec::Functions;
use Cwd;
use bkconfig; # Komodo configuration Perl module created by "bk configure"
#---- all the variables that the Komodo Conscripts need to know about
my @toExport = (
'cons',
'platform', # the platform on which Komodo is built
'architecture',
'build', 'install', 'export', 'packages',
'installAbsDir', 'buildAbsDir',
'withSymbols', # should include debug syms for C/C++ comps
'withCrashReportSymbols', # should include crash report syms for C/C++
'withTests',
'withCasper',
'withJSLib',
'withWatchdogFSNotifications',
'withDocs',
'withKomodoCix',
'withStackato',
'xulrunner', # xulrunner based builds
'xulrunnerBuildId',
'universal', # universal binary builds for osx
'ludditeVersion',
'isGTK2Siloed', # boolean: are the GTK2 libs siloed in this build?
'komodoDevDir',
'buildFlavour',
'updateChannel',
'komodoLicensingType',
'ranRegxpcomStateFileName', # junk output file for the target which
#runs 'regxpcom' as necessary
'buildType',
'supportDir',
'sdkDir',
'stubDir',
'docChromeDir',
'docDir',
'readmeDir',
'sysdllsDir',
'installSupportDir',
'userDataDir',
'compiler',
'idlExportDir',
'mozMake',
'mozGcc',
'mozGxx',
'mozCFlags',
'mozCxxFlags',
'mozLdFlags',
'mozGreMilestone',
'mozSrc',
'mozObjDir',
'mozResourcesDir',
'mozBin', 'mozDevelBin',
'mozDist', 'mozDevelDist',
'mozApp',
'mozExe',
'mozVersion', 'mozVersionNumber',
'mozComponentsDir',
'mozChromeDir',
'mozPluginsDir',
'mozExtensionDir',
'mozIncludePath',
'mozIdlIncludePath',
'mozLibPath',
'mozSrc',
'envScriptName',
'nsprIncludePath',
'nsprPrivateIncludePath',
'scintillaBuildDir', # for the SciMoz build
'siloedPythonVersion', # e.g. "2.4.1"
'siloedPyVer', # e.g. "2.4"
'siloedPython', # e.g. /full/path/to/siloed/bin/python
'siloedDistutilsLibDirName', # e.g. "lib.win32-2.4"
'havePy2to3',
'unsiloedPythonExe',
# for building PyDBGP binary bits for all supported Python's
'pythonInstallDir',
'unsiloedPerlExe',
'unsiloedPerlBinDir',
'perlVersion',
'komodoPythonUtilsDir',
'komodoDefaultUserInstallDir',
# Komodo version forms
'komodoVersion', # 3.10.0-alpha1
'productType', # ide
'prettyProductType', # IDE
'productTagLine',
'buildNum', # 123456
'komodoShortVersion', # 3.10
'komodoMarketingVersion', # 3.X-alpha1
'komodoMarketingShortVersion', # 3.X
'komodoPrettyVersion', # 3.X Alpha 1
'komodoFullPrettyVersion', # Komodo IDE 3.X Alpha 1 (Build 123456)
'komodoTitleBarName', # ActiveState Komodo IDE 3.X
'komodoAppDataDirName', # KomodoIDE or komodoide (plat-dep)
'version', # alias for 'komodoVersion' for compatibility
'msiProductName', # ActiveState Komodo IDE 3.X Alpha 1
'msiInstallName', # ActiveState Komodo 3.X
'msiKomodoVersion', # 3.10.0
'msiKomodoId',
'msiRegistryId',
'msiKomodoPrettyId',
'msiVccrtMsmPath',
'msiVccrtPolicyMsmPath',
'komodoUpdateManualURL',
'macKomodoAppInstallName',
'macKomodoAppBuildName',
'gnomeDesktopName',
'gnomeDesktopGenericName',
'gnomeDesktopCategories',
'gnomeDesktopShortcutName',
'jarring', # TODO rename to "withJarring"
'buildTime',
'buildASCTime',
'buildPlatform',
'platformPathSep',
);
$mozMake = join(" ", @mozMake);
if ($platform eq "linux") {
push(@toExport, (
"linuxDistro",
));
}
Export( @toExport );
#--- print any build system message of the day
print <<HERE if 0;
*** KOMODO MESSAGE OF THE DAY ***
*** END OF MESSAGE ***
HERE
#---- directory layout
$export = $exportRelDir_ForCons;
$build = $buildRelDir_ForCons;
$contribBuild = $contribBuildRelDir_ForCons;
$testBuild = $testBuildRelDir_ForCons;
$install = $installRelDir_ForCons;
$packages = "#".$packagesRelDir;
# export directory structure
$idlExportDir = $idlExportRelDir_ForCons;
# mozilla directories
$mozSrc = $ENV{'MOZ_SRC'};
$mozSrc or die "There was a problem determining MOZ_SRC. Please run 'ko configure'\n";
$mozBin or die "There was a problem determining the Mozilla bin directory. Please ".
"run 'ko configure'\n";
$mozDevelBin or die "There was a problem determining the Mozilla devel bin directory. Please ".
"run 'ko configure'\n";
$mozDevelDist or die "There was a problem determining the Mozilla devel dist directory. Please ".
"run 'ko configure'\n";
if ($platform eq "win") {
$platformPathSep = ";";
} else {
$platformPathSep = ":";
}
$mozIncludeDir = "$mozDevelDist/include";
$mozIncludePath = join($platformPathSep,
("$mozIncludeDir",
"$mozIncludeDir/nspr",
"$mozIncludeDir/mozilla",
"$mozIncludeDir/mozilla/dom",
"$mozIncludeDir/mozilla/plugins"));
$mozLibPath = "$mozDevelDist/lib";
$mozIdlIncludePath = "$mozDevelDist/idl";
$nsprIncludePath="$mozSrc/mozilla/nsprpub/pr/include";
$nsprPrivateIncludePath="$mozSrc/mozilla/nsprpub/pr/include/private";
# other stuff
$ranRegxpcomStateFileName = "$build/ranregxpcom.consjunk";
$komodoPythonUtilsDir or die "There was a problem determining the Komodo Python ".
"utils directory. Please run 'ko configure'\n";
#---- Setup construction environment
my %environ = (
'PATH' => $ENV{PATH},
'CC' => $ENV{CC},
'CXX' => $ENV{CXX},
'CFLAGS' => $ENV{CFLAGS},
'CXXFLAGS' => $ENV{CXXFLAGS},
'LDFLAGS' => $ENV{LDFLAGS},
'TEMP' => $ENV{TEMP} || "/tmp",
'TMP' => $ENV{TMP} || $ENV{TEMP} || "/tmp",
'MOZ_SRC' => $ENV{MOZ_SRC}, #XXX required for perldbglistener, goes away when that makefile goes. (but now I am scared too --TM :)
'PYTHONPATH' => $ENV{PYTHONPATH}, # needed for 'regxpcom'
'MOZILLA_FIVE_HOME' => $ENV{MOZILLA_FIVE_HOME}, # needed for 'regxpcom' on Linux
# Needed for when XPCOM stuff is invoked, so our patched Mozilla
# appdata dir determination code can use it.
'KOMODO_HOSTNAME' => $ENV{KOMODO_HOSTNAME},
'HOME' => $ENV{HOME},
'PKG_CONFIG_PATH' => $ENV{PKG_CONFIG_PATH},
'PROCESSOR_ARCHITECTURE' => $ENV{PROCESSOR_ARCHITECTURE},
# Nmake chokes without, at least, the "SystemRoot" environment variable.
'SystemRoot' => $ENV{SystemRoot},
'SystemDrive' => $ENV{SystemDrive},
);
if ($platform eq "win") {
# Ensure to use any custom cl and link flags.
$environ{INCLUDE} = $ENV{INCLUDE};
$environ{LIB} = $ENV{LIB};
$environ{LINK} = $ENV{LINK};
# Nmake chokes without, at least, the "SystemRoot" environment variable.
$environ{SystemRoot} = $ENV{SystemRoot};
$environ{SystemDrive} = $ENV{SystemDrive};
# VSnnCOMNTOOLS is needed to let Python distutils figure out where MSVC
# lives; this is used to build Python modules using the correct compiler.
# http://bugs.activestate.com/show_bug.cgi?id=99294
while (my ($key, $value) = each %ENV) {
if ($key =~ m/^VS\d+COMNTOOLS$/) {
$environ{$key} = $value;
}
}
} else {
# Set compiler when not already set via the users environment.
if (!$environ{CC} and $mozGcc) {
$environ{CC} = $mozGcc;
}
if (!$environ{CXX} and $mozGxx) {
$environ{CXX} = $mozGxx;
}
}
# Global compiler flags.
$environ{CFLAGS} .= " $mozCFlags";
$environ{CXXFLAGS} .= " $mozCxxFlags";
$environ{LDFLAGS} .= " $mozLdFlags";
if ($platform eq "linux") {
$environ{LD_LIBRARY_PATH} = $ENV{LD_LIBRARY_PATH}; # needed for 'regxpcom'
$environ{CFLAGS} .= " -fPIC";
$environ{CXXFLAGS} .= " -fPIC";
}
elsif ($platform eq "darwin") {
$environ{DYLD_LIBRARY_PATH} = $ENV{DYLD_LIBRARY_PATH}; # needed for 'regxpcom'
# we only want x86_64
$environ{CXXFLAGS} .= " -arch x86_64";
$environ{LDFLAGS} .= " -arch x86_64";
# Use 10.6 as the minimum required version.
$environ{CFLAGS} .= ' -mmacosx-version-min=10.6';
$environ{CXXFLAGS} .= ' -mmacosx-version-min=10.6';
$environ{LDFLAGS} .= ' -mmacosx-version-min=10.6';
}
# Needed for p4 calls in processes kicked off by Cons.
foreach my $envvar (keys %ENV) {
if ($envvar =~ /^P4/) {
$environ{$envvar} = $ENV{$envvar};
}
}
$cons = new cons(
'ENV' => \%environ,
'CFLAGS' => $environ{'CFLAGS'},
'CXXFLAGS' => $environ{'CXXFLAGS'},
'LDFLAGS' => $environ{'LDFLAGS'},
);
my %cons = $cons->copy();
$cons{'CC'} = $environ{'CC'} if defined($environ{'CC'});
$cons{'CXX'} = $environ{'CXX'} if defined($environ{'CXX'});
$cons = new cons(%cons);
#---- what to build
Default(
".",
"$mozSrc/mozilla",
);
Link $build => 'src';
Link $contribBuild => 'contrib';
Link $testBuild => 'test';
# these items are in ALL BUILDS
Build(
"$build/Conscript",
"$build/chrome/xtk/Conscript",
"$build/chrome/komodo/locale/en-US/Conscript",
"$build/chrome/komodo/content/Conscript",
"$build/chrome/komodo/content/bindings/Conscript",
"$build/chrome/komodo/content/codeintel/Conscript",
"$build/chrome/komodo/content/colorpicker/Conscript",
"$build/chrome/komodo/content/dialogs/Conscript",
"$build/chrome/komodo/content/dialogs/filebrowser/Conscript",
"$build/chrome/komodo/content/extmgr/Conscript",
"$build/chrome/komodo/content/library/Conscript",
"$build/chrome/komodo/content/lint/Conscript",
"$build/chrome/komodo/content/keybindings/Conscript",
"$build/chrome/komodo/content/find/Conscript",
"$build/chrome/komodo/content/pref/Conscript",
"$build/chrome/komodo/content/project/Conscript",
"$build/chrome/komodo/content/startpage/Conscript",
"$build/chrome/komodo/content/tail/Conscript",
"$build/chrome/komodo/content/templates/Conscript",
"$build/chrome/komodo/content/toolbox/Conscript",
"$build/chrome/komodo/content/update/Conscript",
"$build/chrome/komodo/skin/Conscript",
"$build/chrome/komodo/skin/bindings/Conscript",
"$build/chrome/komodo/skin/global/Conscript",
"$build/chrome/komodo/skin/global/images/Conscript",
"$build/chrome/komodo/skin/images/Conscript",
"$build/chrome/komodo/skin/startpage/Conscript",
"$build/chrome/komodo/skin/startpage/images/Conscript",
"$build/chrome/komodo/content/run/Conscript",
"$build/chrome/komodo/content/hyperlinks/Conscript",
"$build/chrome/komodo/content/morekomodo/Conscript",
"$build/chrome/komodo/content/notifications/Conscript",
"$build/commandments/Conscript",
"$build/license_text/Conscript",
"$build/codeintel/Conscript",
"$build/editor/Conscript",
"$build/editor/catalogs/Conscript",
"$build/find/Conscript",
"$build/history/Conscript",
"$build/images/Conscript",
"$build/images/crystal/Conscript",
"$build/images/fugue/Conscript",
"$build/install/Conscript",
"$build/languages/Conscript",
"$build/lint/Conscript",
"$build/lint/CSS/Conscript",
"$build/lint/javascript/Conscript",
"$build/lint/perl/Conscript",
"$build/main/Conscript",
"$build/components/Conscript",
"$build/components/contentUtils/Conscript",
"$build/components/notifications/Conscript",
"$build/filesystem/Conscript",
"$build/projects/Conscript",
"$build/python-sitelib/Conscript",
"$build/python-sitelib/koWndWrapper/Conscript",
"$build/run/Conscript",
"$build/samples/Conscript",
"$build/samples/tools/Conscript",
"$build/schemes/Conscript",
"$build/SciMoz/Conscript",
"$build/silvercity/Conscript",
"$build/toolbox/Conscript",
"$build/udl/Conscript",
"$build/prefs/Conscript",
"$build/templates/Conscript",
"$build/updater/Conscript",
"$build/views/Conscript",
"prebuilt/Conscript",
"$build/modules/fastopen/Conscript",
"$build/modules/koextgen/Conscript",
"$build/modules/places/Conscript",
"$build/modules/breadcrumbs/Conscript",
"$build/modules/openfiles/Conscript",
"$build/modules/rails/Conscript",
"$build/modules/spellcheck/Conscript",
"$build/modules/zendframework/Conscript",
"$build/modules/abyss_skin/Conscript",
"$build/modules/iconset_ambiance/Conscript",
"$build/modules/iconset_blue/Conscript",
"$build/modules/iconset_classic/Conscript",
"$build/modules/iconset_cupertino/Conscript",
"$build/modules/iconset_cupertino_blue/Conscript",
"$build/modules/iconset_dark/Conscript",
"$build/modules/iconset_light/Conscript",
"$build/modules/iconset_orange/Conscript",
"$build/modules/iconset_radiance/Conscript",
# 3rd-party contributed code in contrib/...
"$contribBuild/Conscript",
);
if ($platform eq "linux") {
Build(
"$build/modules/gtk_adwaita/Conscript",
"$build/modules/gtk_ambiance/Conscript",
"$build/modules/gtk_dark/Conscript",
"$build/modules/gtk_elementary/Conscript",
"$build/modules/gtk_radiance/Conscript",
);
}
if ($withTests) {
Build(
"$testBuild/pyxpcom/Conscript",
"$testBuild/jstest/Conscript",
);
}
if ($withCasper) {
Build(
"$build/modules/casper/Conscript",
"$build/modules/casper/components/Conscript",
"$build/modules/casper/skin/Conscript",
"$build/modules/casper/content/Conscript",
"$build/modules/casper/content/test/Conscript",
);
}
Build(
"$build/modules/klint/Conscript",
);
if ($buildFlavour ne "full") {
# for now these will only be in dev builds
Build(
"$build/chrome/komodo/content/test/Conscript",
"$build/chrome/komodo/content/test/jsdb/Conscript",
);
# Add the gtkstock icons for Komodo Linux dev builds.
if ($platform eq "linux") {
Build(
"$build/images/gtkstock/Conscript",
);
}
}
if ($withStackato) {
Build(
"$build/modules/stackato/Conscript",
);
}
if ($platform eq "win") {
Build(
"$build/scintilla/win32/Conscript",
);
} elsif ($platform eq "linux") {
Build(
"$build/scintilla/gtk/Conscript",
);
} elsif ($platform eq "solaris") {
Build(
"$build/scintilla/gtk/Conscript",
);
} elsif ($platform eq "darwin") {
Build(
"$build/scintilla/cocoa/Conscript",
);
} else {
die "Unexpected platform '$platform'.\n"
}
#---- Cons method extensions
# Run the Python 2 -> 3 syntax converter on the given path.
sub cons::Py2To3 {
my ($env, $srcPath, $dstPath, @fixerNames) = @_;
# die if required elements are not defined
defined($platform) or
die "*** 'platform' is not defined for " .
"Py2To3(). You need to 'Import' it.\n";
defined($siloedPython) or
die "*** 'siloedPython' is not defined for " .
"Py2To3(). You need to 'Import' it.\n";
my $fixersOpts = "";
foreach my $fixerName (@fixerNames) {
$fixersOpts .= " --fixer=$fixerName";
}
# - lib2to3.main doesn't have a "-o OUTPUT-PATH" option, so we have to
# copy to the target and transform there
# - lib2to3.main unconditionally makes a .bak file which we have to clean
# up.
my $CP = ($platform eq "win" ? "copy /Y" : "cp -f");
my $RM = ($platform eq "win" ? "del /F" : "rm -f");
$cons->Command($dstPath, $srcPath, qq(
$CP %1 %0
$siloedPython -c "from lib2to3.main import main; main('lib2to3.fixes')" $fixersOpts -w %0
$RM %0.bak
));
}
sub cons::KoExt {
# Run the given 'koext' command (koext is in the Komodo SDK).
my ($env, $args, @toSkip) = @_;
if (! scalar(@toSkip)) {
@toSkip = (".svn", "*.xpi", "build"); # default skips
}
# Die if required elements are not defined.
defined($sdkDir) or die "*** sdkDir is not defined for KoExt\n";
defined($build) or die "*** build is not defined for KoExt\n";
defined($mozBin) or die "*** mozBin is not defined for KoExt\n";
defined($unsiloedPythonExe) or die "*** unsiloedPythonExe is not defined for KoExt\n";
# Add commonly used preprocessor values - only when they are imported/defined.
my $pp_defines = "";
defined($platform) and $pp_defines .= " --define PLATFORM=$platform";
defined($productType) and $pp_defines .= " --define PRODUCT_TYPE=$productType";
defined($buildFlavour) and $pp_defines .= " --define BUILD_FLAVOUR=$buildFlavour";
defined($mozVersion) and $pp_defines .= " --define MOZILLA_VERSION=$mozVersion";
my $mozDevelDist = $build::install::mozDevelDist;
my $scriptExt = ($^O eq "MSWin32" ? ".py" : "");
my $exeExt = ($^O eq "MSWin32" ? ".exe" : "");
$cons->Command(
"koext.consjunk", # fake target to make Cons happy
"$sdkDir/bin/koext$scriptExt",
"$sdkDir/pylib/koextlib.py",
"$sdkDir/pylib/cmdln.py",
"$sdkDir/pylib/preprocess.py",
"$build/ranregxpcom.consjunk",
"$mozBin/is_dev_tree.txt",
qq(
$unsiloedPythonExe $sdkDir/bin/koext$scriptExt -v $args -d %0:d $pp_defines
touch %0
)
);
$cons->DependsRecursive("koext.consjunk", ".", @toSkip);
$cons->DependsRecursive2("koext.consjunk", "$mozDevelDist/sdk/bin", "$sdkDir/pylib", ('\.svn', '\.consign'));
}
sub cons::KoExtUnpack {
# Run "koext unpack <xpiPath>" to unpack and install an xpi file into the
# Komodo build.
my ($env, $xpiFile, @toSkip) = @_;
if (! scalar(@toSkip)) {
@toSkip = (".svn", "*.xpi", "build"); # default skips
}
# Die if required elements are not defined.
defined($sdkDir) or die "*** sdkDir is not defined for KoExtUnpack\n";
defined($build) or die "*** build is not defined for KoExtUnpack\n";
defined($mozBin) or die "*** mozBin is not defined for KoExtUnpack\n";
defined($unsiloedPythonExe) or die "*** unsiloedPythonExe is not defined for KoExtUnpack\n";
my $mozDevelDist = $build::install::mozDevelDist;
my $scriptExt = ($^O eq "MSWin32" ? ".py" : "");
my $exeExt = ($^O eq "MSWin32" ? ".exe" : "");
my $xpiBasename = basename($xpiFile);
$cons->Command(
"$xpiBasename.landmark",
"$sdkDir/bin/koext$scriptExt",
"$sdkDir/pylib/koextlib.py",
"$sdkDir/pylib/cmdln.py",
"$sdkDir/pylib/preprocess.py",
"$build/ranregxpcom.consjunk",
"$mozBin/is_dev_tree.txt",
qq(
$unsiloedPythonExe $sdkDir/bin/koext$scriptExt -v kounpack $xpiFile
touch %0
)
);
$cons->DependsRecursive("$xpiBasename.landmark", ".", @toSkip);
$cons->DependsRecursive2("$xpiBasename.landmark", "$mozDevelDist/sdk/bin", "$sdkDir/pylib", ('\.svn', '\.consign'));
}
sub cons::KoExtSourceDevInstall {
# Run "koext devinstall -f -d $extensionDirInSourceArea" to setup a link for
# quick dev of a Komodo extension. Note that this will not work if there are
# any *built* bits of the extension because the link it to the *source* area.
my ($env, @toSkip) = @_;
if (! scalar(@toSkip)) {
@toSkip = (".svn", "*.xpi", "build"); # default skips
}
# Die if required elements are not defined.
defined($sdkDir) or die "*** sdkDir is not defined for KoExtSourceDevInstall\n";
defined($build) or die "*** build is not defined for KoExtSourceDevInstall\n";
defined($mozBin) or die "*** mozBin is not defined for KoExtSourceDevInstall\n";
defined($unsiloedPythonExe) or die "*** unsiloedPythonExe is not defined for KoExtSourceDevInstall\n";
my $mozDevelDist = $build::install::mozDevelDist;
my $scriptExt = ($^O eq "MSWin32" ? ".py" : "");
my $exeExt = ($^O eq "MSWin32" ? ".exe" : "");
my $extSrcDir = dirname(SourcePath('install.rdf'));
$cons->Command(
"koextsourcedevinstall.consjunk", # fake target to make Cons happy
"$sdkDir/bin/koext$scriptExt",
"$sdkDir/pylib/koextlib.py",
"$sdkDir/pylib/chromereg.py",
"$sdkDir/pylib/chromereg.py",
"$sdkDir/pylib/chromereg.py",
"$sdkDir/pylib/cmdln.py",
"$sdkDir/pylib/preprocess.py",
"$build/ranregxpcom.consjunk",
"$mozBin/is_dev_tree.txt",
qq(
$unsiloedPythonExe $sdkDir/bin/koext$scriptExt -v devinstall -f -d $extSrcDir
touch %0
)
);
$cons->DependsRecursive("koextsourcedevinstall.consjunk", ".", @toSkip);
$cons->DependsRecursive2("koextsourcedevinstall.consjunk", "$mozDevelDist/sdk/bin", "$sdkDir/pylib", ('\.svn', '\.consign'));
}
# Headless scintilla for testing.
if ($platform eq "linux") {
Build(
"$build/scintilla/headless/Conscript",
);
}
sub cons::Preprocess {
# Runs the given file through Komodo's preprocessor (currently
# preprocess.py) using the second argument as the output file name.
#
# NOTES FOR "bk build quick":
# - Komodo quick build mechanism will reproduce preprocessing done
# here, so any changes to the default set of defines MUST also
# be carried over to Blackfile.py::QuickBuild().
# - Komodo's quick build preprocessing cannot pick up 'subsref'
# usage so be very careful when using this feature. If you do,
# you might want to add something like the following:
# # #ifndef MY_SUBS_VARIABLE
# # #error "this file cannot be preprocessed by 'bk build quick'"
# # #endif
my ($env, $srcFile, $dstFile, $subsref, $doNotKeepLines) = @_;
my $substStr = "";
if ($subsref && %$subsref) {
$substStr .= "-s";
foreach my $subkey (keys %$subsref) {
my $value = $$subsref{$subkey};
# Quote arguments with spaces or shell meta chars.
if ($value =~ /[ ;]/) {
$value = "\"$value\"";
}
$substStr .= " -D $subkey=$value";
}
}
# die if required elements are not defined
defined($platform) or
die "*** 'platform' is not defined for " .
"Preprocess(). You need to 'Import' it.\n";
$substStr .= " -D PLATFORM=$platform";
defined($productType) or
die "*** 'productType' is not defined for " .
"Preprocess(). You need to 'Import' it.\n";
$substStr .= " -D PRODUCT_TYPE=$productType";
defined($buildFlavour) or
die "*** 'buildFlavour' is not defined for " .
"Preprocess(). You need to 'Import' it.\n";
$substStr .= " -D BUILD_FLAVOUR=$buildFlavour";
defined($unsiloedPythonExe) or
die "*** 'unsiloedPythonExe' is not defined. for " .
"Preprocess(). You need to 'Import' it.\n";
$substStr .= " -D UNSILOED_PYTHON=$unsiloedPythonExe";
defined($mozVersion) or
die "*** 'mozVersion' is not defined for " .
"Preprocess(). You need to 'Import' it.\n";
$substStr .= " -D MOZILLA_VERSION=$mozVersion";
#XXX Would prefer that each of these grow the checking that the other
# vars have to _require_ that they be defined. This will avoid
# accidentally forgetting to Import one of these in a needed
# Conscript.
$substStr .= " -D WITH_CASPER=$withCasper" if defined($withCasper);
$substStr .= " -D WITH_JSLIB=$withJSLib" if defined($withJSLib);
# Run the file through the preprocessor.
my $opts = "";
if (! $doNotKeepLines) {
$opts .= " -k"
}
$cons->Command($dstFile, $srcFile, qq(
$unsiloedPythonExe util/preprocess.py $opts -o %0 -f $substStr %1
));
}
# Preprocess the given $src file (to $src.preprocessed) and then install the
# preprocessed file to the $dstDir.
sub cons::PreprocessAndInstall {
my ($env, $dstDir, $src, $ppdata) = @_;
$env->Preprocess($src, "$src.preprocessed", $ppdata);
$env->InstallAs("$dstDir/".basename($src), "$src.preprocessed");
}
sub cons::PreprocessAndInstallAs {
my ($env, $dstPath, $src, $ppdata) = @_;
$env->Preprocess($src, "$src.preprocessed", $ppdata);
$env->InstallAs("$dstPath", "$src.preprocessed");
}
sub cons::BuildXpt {
# use mozilla SDK xpidl.py to build .h from .idl, and
# install it in Mozilla components directory.
my ($env, $idlFileName) = @_;
# die if required elements are not defined
defined($mozComponentsDir) or
die "*** mozComponentsDir is not defined for $idlFileName\n";
defined($mozIdlIncludePath) or
die "*** mozIdlIncludePath is not defined for $idlFileName\n";
defined($idlExportDir) or
die "*** idlExportDir is not defined for $idlFileName\n";
defined($unsiloedPythonExe) or \
die "When building rule for $xptFileName: Unsiloed Python not found, please Import 'unsiloedPythonExe'";
defined($ranRegxpcomStateFileName) or
die "*** ranRegxpcomStateFileName is not ".
"defined for $idlFileName\n";
# die if the mozIdlIncludePath does not exist
-d $mozIdlIncludePath or die "*** The Mozilla idl include directory ".
"($mozIdlIncludePath) does not exist. Is your MOZ_SRC correct?\n";
my $mozDevelDist = $build::install::mozDevelDist;
my $mozSdkDir = "$mozDevelDist/sdk";
# construct the typelib filename
my $xptFileName = $idlFileName;
$xptFileName =~ s/\.idl$/\.xpt/;
$xptPath = FilePath($xptFileName);
my $xIdlExportDir = DirPath($idlExportDir);
# scan for included .idl files and add dependency for each
# I presume that QuickScan should be used like this:
# $env->QuickScan(sub { /^#include\s+\"(\S+?)\"/g; if ($1) { my $retval = $1; return $retval;}},
# $idlFileName, "$myidlExportDir");
# to generate these dependencies but it seems that QuickScan does
# not result in normal deps but instead make deps that must be satisfied
# at Conscript-scan time, rather than build time. As well, scanning occurs
# in alphabetical order so we get the situation where .idl includes
# of alphabetically lower file work but don't for greater files: Cons bug.
# Solution: Do my own scanning and make real deps of the results.
my @idlDeps = $env->GenerateIdlDependencies($idlFileName, $idlExportDir, $mozIdlIncludePath);
# Tweak env to point PYTHONPATH at the sdk dir.
my %envLocal = $env->copy();
my $platformPathSep = ($^O eq "MSWin32" ? ";" : ":");
$envLocal{'PYTHONPATH'} = $ENV{'PYTHONPATH'} . "$platformPathSep$mozSdkDir/bin";
$envLocal{'SystemRoot'} = $ENV{'SystemRoot'}; # Needed to avoid runtime DLL problems.
$envLocal = new cons(ENV => \%envLocal);
# compile the .idl file to a typelib
# XXX handling of mozIdlIncludePath is not robust (breaks if more than one element)
$envLocal->Command($xptFileName, $idlFileName, @idlDeps,
"$unsiloedPythonExe $mozSdkDir/bin/typelib.py -I $mozIdlIncludePath -I $xIdlExportDir -o $xptPath --cachedir $mozSdkDir/cache %1");
return $xptFileName;
}
sub cons::BuildAndInstallXpt {
my ($env, $idlFileName) = (shift, shift);
# Die if required elements are not defined.
defined($sdkDir) or die "*** sdkDir is not defined for $idlFileName\n";
# install the .xpt file
my $xptFileName = $env->BuildXpt($idlFileName);
defined($xptFileName) or
die "*** BuildXpt failed for $idlFileName\n";
my $xptBaseName = basename($xptFileName);
$env->Install($mozComponentsDir, $xptFileName);
my $idlBaseName = basename($idlFileName);
$env->Install("$sdkDir/idl", $idlFileName);
my @idlDeps = $env->GenerateIdlDependencies($idlFileName, $idlExportDir, $mozIdlIncludePath);
$env->Depends("$idlExportDir/$idlBaseName", @idlDeps);
$env->Install("$idlExportDir", $idlFileName);
defined($mozVersion) or \
die "When building rule for $idlFileName: Mozilla version unknown, please Import 'mozVersion'";
defined($unsiloedPythonExe) or \
die "When building rule for $idlFileName: Unsiloed Python not found, please Import 'unsiloedPythonExe'";
defined($mozComponentsDir) or \
die "When building rule for $idlFileName: Component directory not found, please Import 'mozComponentsDir'";
$env->Command("$xptFileName.manifest.landmark",
"$mozComponentsDir/$xptBaseName",
"$mozComponentsDir/komodo.manifest",
"$sdkDir/pylib/chromereg.py",
qq(
$unsiloedPythonExe %3 %2 %1
touch %>
));
# make sure to export the file to the sdk
# depending on $ranRegxpcomStateFileName here is wrong, but is used
# to make sure all the koext consumers have a flag for it
$env->Depends($ranRegxpcomStateFileName, "$sdkDir/idl/$idlBaseName");
$env->Depends($ranRegxpcomStateFileName, "$xptFileName.manifest.landmark");
}
sub cons::GenerateIdlDependencies {
# return a list of .idl files upon which the given .idl file depends
# NOTE: this does not recursively search deps (in fact, I don't know
# how it generally could because who knows where the included .idl
# file exist before they are exported to the idl include dir)
# HACK: This does hacky processing to prefix the deps with the Komodo
# idl include directory.
my ($env, $idlName, $preferedIdlIncludeDir, @otherIdlIncludeDirs) = @_;
# Die if required elements are not defined.
defined($build) or die "*** build is not defined for $idlName\n";
# Skip out if the idl file name does not exist, it might be generated.
# We *do* try the common unprocessed-names.
my $idlPathInSrc = catfile( DirPath(dirname($idlName)), basename($idlName) );
my $xBuildDir = DirPath($build);
$xBuildDir =~ s/\\/\\\\/;
$idlPathInSrc =~ s/^$xBuildDir/src/;
my $idlPathInSrc_p = $idlPathInSrc;
$idlPathInSrc_p =~ s/\.idl$/.p.idl/;
my $idlPathInSrc_unprocessed = $idlPathInSrc;
$idlPathInSrc_unprocessed =~ s/\.idl$/.unprocessed.idl/;
if (-f $idlPathInSrc) {
} elsif (-f $idlPathInSrc_p) {
$idlPathInSrc = $idlPathInSrc_p;
} elsif (-f $idlPathInSrc_unprocessed) {
$idlPathInSrc = $idlPathInSrc_unprocessed;
} else {
use Carp;
# Skip the warning for some well-known IDL files where there is no
# harm.
if ($idlName ne "ISciMoz.idl" &&
$idlName ne "koITest.idl" &&
$idlName ne "koIJSTest.idl") {
carp("warning: not generating IDL depenencies for '$idlName': none "
. "of the following exist: $idlPathInSrc, $idlPathInSrc_p, "
. "$idlPathInSrc_unprocessed\n");
}
return ();
}
# Process the .idl path in the source area (can't rely on it having been
# copied to the build area yet).
my %idlDeps;
my @includes;
open(FIN, $idlPathInSrc) or die "cannot open $idlPathInSrc\n";
while (<FIN>) {
if (/^#include\s+\"(\S+?)\"/g) {
# If the include is not found in the "otherIdlIncludeDirs" then
# prefix the Komodo idl include dir and register it as a dep.
my $foundIt = 0;
foreach $incDir (@otherIdlIncludeDirs) {
if (-f "$incDir/$1") {
$foundIt = 1;
last;
}
}
if (! $foundIt) {
my $dep = "$preferedIdlIncludeDir/$1";
$dep =~ s/\\/\//;
push(@includes, $dep);
}
}
}
return @includes;
}
sub cons::BuildHeaderFromIdl {
# use mozilla SDK xpidl.py to build .h from .idl
my ($env, $idlFileName) = @_;
# die if required elements are not defined
defined($build) or die "*** build is not defined for BuildHeaderFromIdl\n";
defined($mozBin) or die "*** mozBin is not defined for BuildHeaderFromIdl\n";
defined($unsiloedPythonExe) or die "*** unsiloedPythonExe is not defined for BuildHeaderFromIdl\n";
defined($mozIdlIncludePath) or
die "*** mozIdlIncludePath is not defined for $idlFileName\n";
defined($idlExportDir) or
die "*** idlExportDir is not defined for $idlFileName\n";
my $mozDevelDist = $build::install::mozDevelDist;
my $mozSdkDir = "$mozDevelDist/sdk";
# construct the header filename
my $headerFileName = $idlFileName;
$headerFileName =~ s/\.idl$/\.h/;
my $headerPath = FilePath($headerFileName);
my $xIdlExportDir = DirPath($idlExportDir);
# scan for included .idl files and add dependency for each
my @idlDeps = $env->GenerateIdlDependencies($idlFileName, $idlExportDir,
$mozIdlIncludePath);
# Tweak env to point PYTHONPATH at the sdk dir.
my %envLocal = $env->copy();
my $platformPathSep = ($^O eq "MSWin32" ? ";" : ":");
$envLocal{'PYTHONPATH'} = $ENV{'PYTHONPATH'} . "$platformPathSep$mozSdkDir/bin";
$envLocal{'SystemRoot'} = $ENV{'SystemRoot'}; # Needed to avoid runtime DLL problems.
$envLocal = new cons(ENV => \%envLocal);
# compile the .idl file to a C header
# XXX handling of mozIdlIncludePath is not robust (breaks if
# XXX more than one element)
$envLocal->Command($headerFileName, $idlFileName, @idlDeps,
"$unsiloedPythonExe $mozSdkDir/bin/header.py -I $mozIdlIncludePath -I $xIdlExportDir -o $headerPath --cachedir $mozSdkDir/cache %1");
}
sub cons::ChromePath {
# return the chrome relative path to the given fileName in Komodo's build/src directory
my ($env, $fileName) = @_;
my $projRootedFileName = FilePath($fileName);
my @chromePathDirs = File::Spec->splitdir($projRootedFileName);
$_ = '';
$_ = shift @chromePathDirs while $_ ne 'chrome'; # drop dir up to 'chrome'
my $chromePath = File::Spec->catdir(@chromePathDirs);
return $chromePath;
}
sub cons::InstallWriteable {
my ($env, $dstDir, $src) = @_;
my $dst;
if ($^O eq "MSWin32") {
$dst = "$dstDir\\" . basename($src);
$env->Command($dst,
$src,
qq(
copy /y %1 %0
attrib -R %0
));
} else {
$dst = "$dstDir/" . basename($src);
$env->Command($dst,
$src,
qq(
cp -f %1 %0
chmod +w %0
));
}
}
# JSCheck needs these variables.
$build::install::mozDevelBin = $mozDevelBin;
$build::install::mozDevelDist = $mozDevelDist;
$build::install::mozBin = $mozBin;
$build::install::platform = $platform;
$build::install::architecture = $architecture;
sub build::install::JSCheck {
my ($self, $fileName) = @_;
#print "JSCheck: debug: fileName=$fileName\n";
my $escaped_sep = ($^O eq "MSWin32" ? '\\\\' : '\/');
if ($fileName =~ /\.js$/
and ($fileName =~ /chrome${escaped_sep}komodo/
or $fileName =~ /components/))
{
my $mozDevelBin = $build::install::mozDevelBin;
my $mozDevelDist = $build::install::mozDevelDist;