80 os.chdir(oldcwd) |
81 os.chdir(oldcwd) |
81 except: |
82 except: |
82 code = -1 |
83 code = -1 |
83 return [code, output] |
84 return [code, output] |
84 |
85 |
|
86 def read_file(filepath): |
|
87 content = "" |
|
88 try: |
|
89 file = open(filepath, "r") |
|
90 content = file.read() |
|
91 file.close() |
|
92 except IOError, e: |
|
93 print(e) |
|
94 return content |
|
95 |
|
96 def grep(path, pattern, include = [], exclude = []): |
|
97 result = {} |
|
98 expr = re.compile(pattern) |
|
99 for root, dirs, files in os.walk(path): |
|
100 for filename in files: |
|
101 accept = True |
|
102 for ipattern in include: |
|
103 if not fnmatch.fnmatch(filename, ipattern): |
|
104 accept = False |
|
105 for epattern in exclude: |
|
106 if fnmatch.fnmatch(filename, epattern): |
|
107 accept = False |
|
108 if accept: |
|
109 filepath = os.path.normpath(os.path.join(root, filename)) |
|
110 content = read_file(filepath) |
|
111 for match in expr.finditer(content): |
|
112 if match.group(1): |
|
113 if filename not in result: |
|
114 result[filename] = [] |
|
115 result[filename].append(match.group(1)) |
|
116 return result |
|
117 |
85 # ============================================================================ |
118 # ============================================================================ |
86 # OptionParser |
119 # OptionParser |
87 # ============================================================================ |
120 # ============================================================================ |
88 class OptionParser(optparse.OptionParser): |
121 class OptionParser(optparse.OptionParser): |
89 def __init__(self, platform, make, prefix): |
122 def __init__(self, platform, make, prefix): |
117 help="Build in release mode.") |
150 help="Build in release mode.") |
118 group.add_option("--debug", action="store_const", dest="config", const="debug", |
151 group.add_option("--debug", action="store_const", dest="config", const="debug", |
119 help="Build in debug mode.") |
152 help="Build in debug mode.") |
120 group.add_option("--debug_and_release", action="store_const", dest="config", const="debug_and_release", |
153 group.add_option("--debug_and_release", action="store_const", dest="config", const="debug_and_release", |
121 help="Build in both debug and release modes.") |
154 help="Build in both debug and release modes.") |
|
155 group.add_option("--debug-output", action="store_false", dest="debug_output", |
|
156 help="Do not suppress debug and warning output (suppressed by default in release mode).") |
|
157 group.add_option("--no-debug-output", action="store_true", dest="no_debug_output", |
|
158 help="Suppress debug and warning output (not supporessed by default in debug mode).") |
122 if platform != "symbian": |
159 if platform != "symbian": |
123 group.add_option("--silent", action="store_true", dest="silent", |
160 group.add_option("--silent", action="store_true", dest="silent", |
124 help="Suppress verbose compiler output.") |
161 help="Suppress verbose compiler output.") |
125 group.add_option("--fast", action="store_true", dest="fast", |
162 group.add_option("--fast", action="store_true", dest="fast", |
126 help="Run qmake in non-recursive mode. Running qmake " |
163 help="Run qmake in non-recursive mode. Running qmake " |
198 if platform == "symbian" or platform == None: |
235 if platform == "symbian" or platform == None: |
199 group.add_option("--qt-symbian-eventfilter", action="store_false", dest="s60eventfilter", |
236 group.add_option("--qt-symbian-eventfilter", action="store_false", dest="s60eventfilter", |
200 help="DEPRECATED: Qt 4.6 includes QApplication::symbianEventFilter().") |
237 help="DEPRECATED: Qt 4.6 includes QApplication::symbianEventFilter().") |
201 group.add_option("--qt-s60-eventfilter", action="store_true", dest="s60eventfilter", |
238 group.add_option("--qt-s60-eventfilter", action="store_true", dest="s60eventfilter", |
202 help="DEPRECATED: Qt 4.6 includes QApplication::symbianEventFilter().") |
239 help="DEPRECATED: Qt 4.6 includes QApplication::symbianEventFilter().") |
|
240 group.add_option("--dui", action="store_true", dest="dui", |
|
241 help="Assumes that Maemo Direct UI is available without performing a compilation test.") |
|
242 group.add_option("--no-dui", action="store_false", dest="dui", |
|
243 help="Assumes that Maemo Direct UI is not available without performing a compilation test.") |
203 self.add_option_group(group) |
244 self.add_option_group(group) |
204 self.set_defaults(qtmobility=None) |
245 self.set_defaults(qtmobility=None) |
205 self.set_defaults(qtanimation=None) |
246 self.set_defaults(qtanimation=None) |
206 self.set_defaults(qtgestures=None) |
247 self.set_defaults(qtgestures=None) |
207 self.set_defaults(qts60eventfilter=None) |
248 self.set_defaults(qts60eventfilter=None) |
532 # compilation tests to detect available features |
573 # compilation tests to detect available features |
533 test = ConfigTest(platform) |
574 test = ConfigTest(platform) |
534 test.setup(sourcedir, currentdir) |
575 test.setup(sourcedir, currentdir) |
535 print("INFO: Detecting available features...") |
576 print("INFO: Detecting available features...") |
536 patterns = { "symbian" : ["\\*\\*\\*", "Errors caused tool to abort"], |
577 patterns = { "symbian" : ["\\*\\*\\*", "Errors caused tool to abort"], |
|
578 "maemo" : ["\\*\\*\\*"], |
537 "unix" : ["\\*\\*\\*"], |
579 "unix" : ["\\*\\*\\*"], |
538 "win32" : ["\\*\\*\\*"] } |
580 "win32" : ["\\*\\*\\*"] } |
539 if options.qtmobility == None: |
581 if options.qtmobility == None: |
540 options.qtmobility = test.compile("config.tests/all/mobility", patterns.get(platform.name(), None)) |
582 options.qtmobility = test.compile("config.tests/all/mobility", patterns.get(platform.name(), None)) |
541 print("INFO:\tQt Mobility:\t\t\t%s" % options.qtmobility) |
583 print("INFO:\tQt Mobility:\t\t\t%s" % options.qtmobility) |
542 if options.qtmobility: |
584 if options.qtmobility: |
543 config.add_value("DEFINES", "HB_HAVE_QT_MOBILITY") |
585 config.add_value("DEFINES", "HB_HAVE_QT_MOBILITY") |
544 if platform.name() == "symbian": |
586 if platform.name() == "symbian": |
545 advanced_tactile_result = test.compile("config.tests/symbian/advancedtactile", patterns.get(platform.name(), None)) |
587 sgimagelite_result = test.compile("config.tests/symbian/sgimagelite", patterns.get(platform.name(), None)) |
546 if advanced_tactile_result: |
588 if sgimagelite_result: |
547 config.add_value("CONFIG", "advanced_tactile_support") |
589 config.add_value("CONFIG", "sgimagelite_support") |
548 print("INFO:\tAdvanced Tactile:\t\t%s" % advanced_tactile_result) |
590 print("INFO:\tSgImage-Lite:\t\t\t%s" % sgimagelite_result) |
549 #sgimagelite_result = test.compile("config.tests/symbian/sgimagelite", patterns.get(platform.name(), None)) |
591 if options.dui == None: |
550 #if sgimagelite_result: |
592 options.dui = test.compile("config.tests/maemo/dui", patterns.get(platform.name(), None)) |
551 # config.add_value("CONFIG", "sgimage") |
593 print("INFO:\tDirect UI:\t\t\t%s" % options.dui) |
552 #print("INFO:\tSgImage-Lite:\t\t\t%s" % sgimagelite_result) |
594 if options.dui: |
553 print("NOTE:\t(For SgImage-Lite support, pass --qmake-options \"CONFIG+=sgimage\")") |
595 config.add_value("CONFIG", "hb_maemo_dui") |
|
596 config.add_value("DEFINES", "HB_MAEMO_DUI") |
554 |
597 |
555 config.set_value("HB_BIN_DIR", ConfigFile.format_dir(basedir + "/bin")) |
598 config.set_value("HB_BIN_DIR", ConfigFile.format_dir(basedir + "/bin")) |
556 config.set_value("HB_LIB_DIR", ConfigFile.format_dir(basedir + "/lib")) |
599 config.set_value("HB_LIB_DIR", ConfigFile.format_dir(basedir + "/lib")) |
557 config.set_value("HB_DOC_DIR", ConfigFile.format_dir(basedir + "/doc")) |
600 config.set_value("HB_DOC_DIR", ConfigFile.format_dir(basedir + "/doc")) |
558 if not options.developer and platform.name() == "symbian": |
601 if not options.developer and platform.name() == "symbian": |
572 config.add_value("DEFINES", "HB_GESTURE_FW") |
615 config.add_value("DEFINES", "HB_GESTURE_FW") |
573 if options.effects: |
616 if options.effects: |
574 config.add_value("DEFINES", "HB_EFFECTS") |
617 config.add_value("DEFINES", "HB_EFFECTS") |
575 if options.textMeasurement: |
618 if options.textMeasurement: |
576 config.add_value("DEFINES", "HB_TEXT_MEASUREMENT_UTILITY") |
619 config.add_value("DEFINES", "HB_TEXT_MEASUREMENT_UTILITY") |
|
620 if platform.name() != "symbian" and options.developer: |
|
621 config.add_value("DEFINES", "HB_CSS_INSPECTOR") |
577 if options.defines: |
622 if options.defines: |
578 config.add_value("DEFINES", " ".join(options.defines.split(","))) |
623 config.add_value("DEFINES", " ".join(options.defines.split(","))) |
|
624 if options.developer: |
|
625 config.add_value("DEFINES", "HB_DEVELOPER") |
579 |
626 |
580 if options.verbose: |
627 if options.verbose: |
581 print("INFO: Writing hb_install.prf") |
628 print("INFO: Writing hb_install.prf") |
582 if not config.write("hb_install.prf"): |
629 if not config.write("hb_install.prf"): |
583 print("ERROR: Unable to write hb_install_prf.") |
630 print("ERROR: Unable to write hb_install_prf.") |
624 config.add_value("CONFIG", "developer") |
671 config.add_value("CONFIG", "developer") |
625 if options.coverage: |
672 if options.coverage: |
626 config.add_value("CONFIG", "coverage") |
673 config.add_value("CONFIG", "coverage") |
627 if options.config: |
674 if options.config: |
628 config.add_value("CONFIG", options.config) |
675 config.add_value("CONFIG", options.config) |
629 |
676 if options.debug_output != None: |
630 # disable debug & warning outputs for non-developer symbian-armv5-release builds |
677 config.add_value("CONFIG", "debug_output") |
631 if not options.developer and platform.name() == "symbian": |
678 if options.no_debug_output != None: |
632 config._lines.append("no_output = \\ \n") |
679 config.add_value("CONFIG", "no_debug_output") |
633 config._lines.append("\"$${LITERAL_HASH}if defined(ARMV5) && defined(UREL)\" \\ \n") |
680 |
634 config._lines.append("\"MACRO\tQT_NO_DEBUG_OUTPUT\" \\ \n") |
681 # debug & warning outputs: |
635 config._lines.append("\"MACRO\tQT_NO_WARNING_OUTPUT\" \\ \n") |
682 # - release |
636 config._lines.append("\"$${LITERAL_HASH}endif\" \n") |
683 # - disabled by default |
637 config._lines.append("MMP_RULES += no_output \n") |
684 # - can be enabled by passing --debug_output option |
|
685 # - debug |
|
686 # - enabled by default |
|
687 # - can be disabled by passing --no_debug_output option |
|
688 config._lines.append("CONFIG(release, debug|release) {\n") |
|
689 config._lines.append(" debug_output|developer {\n") |
|
690 config._lines.append(" # debug/warning output enabled {\n") |
|
691 config._lines.append(" } else {\n") |
|
692 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
|
693 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
|
694 config._lines.append(" }\n") |
|
695 config._lines.append("} else {\n") |
|
696 config._lines.append(" no_debug_output {\n") |
|
697 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
|
698 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
|
699 config._lines.append(" }\n") |
|
700 config._lines.append("}\n") |
638 |
701 |
639 # TODO: is there any better way to expose functions to the whole source tree? |
702 # TODO: is there any better way to expose functions to the whole source tree? |
640 config._lines.append("include(%s)\n" % (os.path.splitdrive(sourcedir)[1] + "/src/functions.prf")) |
703 config._lines.append("include(%s)\n" % (os.path.splitdrive(sourcedir)[1] + "/src/hbfunctions.prf")) |
641 |
704 |
642 if options.verbose: |
705 if options.verbose: |
643 print("INFO: Writing .qmake.cache") |
706 print("INFO: Writing .qmake.cache") |
644 if not config.write(".qmake.cache"): |
707 if not config.write(".qmake.cache"): |
645 print("ERROR: Unable to write .qmake.cache.") |
708 print("ERROR: Unable to write .qmake.cache.") |
686 if not os.path.exists(outputdir): |
749 if not os.path.exists(outputdir): |
687 os.makedirs(outputdir) |
750 os.makedirs(outputdir) |
688 outputdir = os.path.join(currentdir, "coverage") |
751 outputdir = os.path.join(currentdir, "coverage") |
689 if not os.path.exists(outputdir): |
752 if not os.path.exists(outputdir): |
690 os.makedirs(outputdir) |
753 os.makedirs(outputdir) |
|
754 # nag about tests that are commented out |
|
755 result = grep(sourcedir + "/tsrc", "#\s*SUBDIRS\s*\+=\s*(\S+)", ["*.pr?"]) |
|
756 maxlen = 0 |
|
757 for profile in result: |
|
758 maxlen = max(maxlen, len(profile)) |
|
759 if len(result): |
|
760 print "" |
|
761 print "###############################################################################" |
|
762 print "%s THE FOLLOWING TESTS ARE COMMENTED OUT:" % "WARNING:".ljust(maxlen + 1) |
|
763 for profile, subdirs in result.iteritems(): |
|
764 line = (profile + ":").ljust(maxlen + 2) |
|
765 init = len(line) |
|
766 while len(subdirs): |
|
767 if len(line) > init: |
|
768 line += ", " |
|
769 if len(line) + len(subdirs[-1]) < 80: |
|
770 line += subdirs.pop() |
|
771 elif len(line) == init and init + len(subdirs[-1]) >= 79: |
|
772 line += subdirs.pop() |
|
773 else: |
|
774 print line |
|
775 line = "".ljust(maxlen + 2) |
|
776 if len(line) > init: |
|
777 print line |
|
778 print "###############################################################################" |
691 |
779 |
692 # print summary |
780 # print summary |
693 print("") |
781 print("") |
694 if platform.make() == "nmake" and options.msvc: |
782 if platform.make() == "nmake" and options.msvc: |
695 conf = "MSVC" |
783 conf = "MSVC" |