63 |
63 |
64 def run_process(args, cwd=None): |
64 def run_process(args, cwd=None): |
65 code = 0 |
65 code = 0 |
66 output = "" |
66 output = "" |
67 if os.name == "nt": |
67 if os.name == "nt": |
|
68 env = os.environ.copy() |
|
69 epocroot = env.get("EPOCROOT") |
|
70 if epocroot: |
|
71 if not epocroot.endswith("\\") or epocroot.endswith("/"): |
|
72 env["EPOCROOT"] = "%s/" % epocroot |
|
73 |
68 args = ["cmd.exe", "/C"] + args |
74 args = ["cmd.exe", "/C"] + args |
|
75 |
69 try: |
76 try: |
70 if cwd != None: |
77 if cwd != None: |
71 oldcwd = os.getcwd() |
78 oldcwd = os.getcwd() |
72 os.chdir(cwd) |
79 os.chdir(cwd) |
73 if sys.version_info[0] == 2 and sys.version_info[1] < 4: |
80 if sys.version_info[0] == 2 and sys.version_info[1] < 4: |
74 process = popen2.Popen4(args) |
81 process = popen2.Popen4(args) |
75 code = process.wait() |
82 code = process.wait() |
76 output = process.fromchild.read() |
83 output = process.fromchild.read() |
77 else: |
84 else: |
78 process = subprocess.Popen(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
85 if os.name == "nt": |
79 (stdout, stderr) = process.communicate() |
86 process = subprocess.Popen(args, env=env, stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
80 code = process.returncode |
87 (stdout, stderr) = process.communicate() |
81 output = stdout + stderr |
88 code = process.returncode |
|
89 output = stdout + stderr |
|
90 else: |
|
91 process = subprocess.Popen(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
|
92 (stdout, stderr) = process.communicate() |
|
93 code = process.returncode |
|
94 output = stdout + stderr |
|
95 |
82 if cwd != None: |
96 if cwd != None: |
83 os.chdir(oldcwd) |
97 os.chdir(oldcwd) |
84 except: |
98 except: |
85 code = -1 |
99 code = -1 |
86 return [code, output] |
100 return [code, output] |
602 else: |
616 else: |
603 options.prefix = prefixes.get(platform.name(), currentdir) |
617 options.prefix = prefixes.get(platform.name(), currentdir) |
604 basedir = options.prefix |
618 basedir = options.prefix |
605 if platform.name() != "symbian": |
619 if platform.name() != "symbian": |
606 basedir = os.path.abspath(basedir) |
620 basedir = os.path.abspath(basedir) |
607 |
|
608 local = os.path.isdir(basedir) and (basedir == currentdir) |
621 local = os.path.isdir(basedir) and (basedir == currentdir) |
609 |
|
610 # generate local build wrapper headers |
|
611 synchb = "bin/synchb.py" |
|
612 if options.verbose: |
|
613 synchb = "%s -v" % synchb |
|
614 print("INFO: Running %s" % synchb) |
|
615 os.system("python %s/%s -i %s -o %s" % (sourcedir, synchb, sourcedir, currentdir)) |
|
616 |
|
617 # generate a qrc for resources |
|
618 args = [os.path.join(sourcedir, "bin/resourcifier.py")] |
|
619 args += ["-i", "%s" % os.path.join(sys.path[0], "src/hbcore/resources")] |
|
620 # TODO: make it currentdir |
|
621 args += ["-o", "%s" % os.path.join(sourcedir, "src/hbcore/resources/resources.qrc")] |
|
622 args += ["--exclude", "\"*distribution.policy.s60\""] |
|
623 args += ["--exclude", "\"*readme.txt\""] |
|
624 args += ["--exclude", "\"*.pr?\""] |
|
625 args += ["--exclude", "\"*.qrc\""] |
|
626 args += ["--exclude", "\"*~\""] |
|
627 args += ["--exclude", "variant/*"] |
|
628 if options.verbose: |
|
629 print("INFO: Running %s" % " ".join(args)) |
|
630 os.system("python %s" % " ".join(args)) |
|
631 |
622 |
632 # compilation tests to detect available features |
623 # compilation tests to detect available features |
633 config = ConfigFile() |
624 config = ConfigFile() |
634 test = ConfigTest(platform) |
625 test = ConfigTest(platform) |
635 test.setup(sourcedir, currentdir) |
626 test.setup(sourcedir, currentdir) |
692 config.set_value("HB_INCLUDE_DIR", ConfigFile.format_dir(options.includedir)) |
683 config.set_value("HB_INCLUDE_DIR", ConfigFile.format_dir(options.includedir)) |
693 config.set_value("HB_PLUGINS_DIR", ConfigFile.format_dir(options.plugindir)) |
684 config.set_value("HB_PLUGINS_DIR", ConfigFile.format_dir(options.plugindir)) |
694 config.set_value("HB_RESOURCES_DIR", ConfigFile.format_dir(options.resourcedir)) |
685 config.set_value("HB_RESOURCES_DIR", ConfigFile.format_dir(options.resourcedir)) |
695 config.set_value("HB_FEATURES_DIR", ConfigFile.format_dir(options.featuredir)) |
686 config.set_value("HB_FEATURES_DIR", ConfigFile.format_dir(options.featuredir)) |
696 |
687 |
697 |
|
698 if os.name == "posix" or os.name == "mac": |
|
699 sharedmem = test.compile("config.tests/unix/sharedmemory") |
|
700 if sharedmem: |
|
701 (code, output) = run_process(["./hbconftest_sharedmemory"], "config.tests/unix/sharedmemory") |
|
702 sharedmem = (code == 0) |
|
703 if not sharedmem: |
|
704 print("DEBUG:%s" % output) |
|
705 print("INFO: Shared Memory:\t\t\t%s" % sharedmem) |
|
706 if not sharedmem: |
|
707 print("WARNING:The amount of available shared memory is too low!") |
|
708 print "\tTry adjusting the shared memory configuration", |
|
709 if os.path.exists("/proc/sys/kernel/shmmax"): |
|
710 print "(/proc/sys/kernel/shmmax)" |
|
711 elif os.path.exists("/etc/sysctl.conf"): |
|
712 print "(/etc/sysctl.conf)" |
|
713 |
|
714 |
|
715 |
|
716 # TODO: get rid of this! |
688 # TODO: get rid of this! |
717 if platform.name() == "symbian": |
689 if platform.name() == "symbian": |
718 config.set_value("HB_PLUGINS_EXPORT_DIR", ConfigFile.format_dir("$${EPOCROOT}epoc32/winscw/c/resource/qt/plugins/hb")) |
690 config.set_value("HB_PLUGINS_EXPORT_DIR", ConfigFile.format_dir("$${EPOCROOT}epoc32/winscw/c/resource/qt/plugins/hb")) |
719 |
691 |
720 if options.gestures: |
692 if options.gestures: |
796 # - debug |
768 # - debug |
797 # - enabled by default |
769 # - enabled by default |
798 # - can be disabled by passing --no_debug_output option |
770 # - can be disabled by passing --no_debug_output option |
799 config._lines.append("CONFIG(release, debug|release) {\n") |
771 config._lines.append("CONFIG(release, debug|release) {\n") |
800 config._lines.append(" debug_output|developer {\n") |
772 config._lines.append(" debug_output|developer {\n") |
801 config._lines.append(" # debug/warning output enabled {\n") |
773 config._lines.append(" # debug/warning output enabled\n") |
802 config._lines.append(" } else {\n") |
774 config._lines.append(" } else {\n") |
803 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
775 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
804 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
776 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
805 config._lines.append(" }\n") |
777 config._lines.append(" }\n") |
806 config._lines.append("} else {\n") |
778 config._lines.append("} else {\n") |
808 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
780 config._lines.append(" DEFINES += QT_NO_DEBUG_OUTPUT\n") |
809 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
781 config._lines.append(" DEFINES += QT_NO_WARNING_OUTPUT\n") |
810 config._lines.append(" }\n") |
782 config._lines.append(" }\n") |
811 config._lines.append("}\n") |
783 config._lines.append("}\n") |
812 |
784 |
|
785 # ensure that no QString(0) -like constructs slip in |
|
786 config.add_value("DEFINES", "QT_QCHAR_CONSTRUCTOR") |
|
787 |
813 # TODO: is there any better way to expose functions to the whole source tree? |
788 # TODO: is there any better way to expose functions to the whole source tree? |
814 config._lines.append("include(%s)\n" % (os.path.splitdrive(sourcedir)[1] + "/mkspecs/hb_functions.prf")) |
789 config._lines.append("include(%s)\n" % (os.path.splitdrive(sourcedir)[1] + "/mkspecs/hb_functions.prf")) |
815 |
790 |
816 if options.verbose: |
791 if options.verbose: |
817 print("INFO: Writing .qmake.cache") |
792 print("INFO: Writing .qmake.cache") |
818 if not config.write(".qmake.cache"): |
793 if not config.write(".qmake.cache"): |
819 print("ERROR: Unable to write .qmake.cache.") |
794 print("ERROR: Unable to write .qmake.cache.") |
820 return |
795 return |
|
796 |
|
797 if os.name == "posix" or os.name == "mac": |
|
798 sharedmem = test.compile("config.tests/unix/sharedmemory") |
|
799 if sharedmem: |
|
800 (code, output) = run_process(["./hbconftest_sharedmemory"], "config.tests/unix/sharedmemory") |
|
801 sharedmem = (code == 0) |
|
802 if not sharedmem: |
|
803 print("DEBUG:%s" % output) |
|
804 print("INFO: Shared Memory:\t\t\t%s" % sharedmem) |
|
805 if not sharedmem: |
|
806 print("WARNING:The amount of available shared memory is too low!") |
|
807 print "\tTry adjusting the shared memory configuration", |
|
808 if os.path.exists("/proc/sys/kernel/shmmax"): |
|
809 print "(/proc/sys/kernel/shmmax)" |
|
810 elif os.path.exists("/etc/sysctl.conf"): |
|
811 print "(/etc/sysctl.conf)" |
|
812 |
|
813 # generate local build wrapper headers |
|
814 print("\nGenerating files...") |
|
815 print("INFO: Wrapper headers") |
|
816 synchb = "bin/synchb.py" |
|
817 if options.verbose: |
|
818 print("INFO: Running %s" % synchb) |
|
819 synchb = "%s -v" % synchb |
|
820 os.system("python %s/%s -i %s -o %s" % (sourcedir, synchb, sourcedir, currentdir)) |
|
821 |
|
822 # generate a qrc for resources |
|
823 print("INFO: Qt resource collection") |
|
824 args = [os.path.join(sourcedir, "bin/resourcifier.py")] |
|
825 args += ["-i", "%s" % os.path.join(sys.path[0], "src/hbcore/resources")] |
|
826 # TODO: make it currentdir |
|
827 args += ["-o", "%s" % os.path.join(sourcedir, "src/hbcore/resources/resources.qrc")] |
|
828 args += ["--exclude", "\"*distribution.policy.s60\""] |
|
829 args += ["--exclude", "\"*readme.txt\""] |
|
830 args += ["--exclude", "\"*.pr?\""] |
|
831 args += ["--exclude", "\"*.qrc\""] |
|
832 args += ["--exclude", "\"*~\""] |
|
833 args += ["--exclude", "variant/*"] |
|
834 if options.verbose: |
|
835 print("INFO: Running %s" % " ".join(args)) |
|
836 os.system("python %s" % " ".join(args)) |
821 |
837 |
822 # build host tools |
838 # build host tools |
823 if platform.name() == "symbian" or options.hostqmakebin != None or options.hostmakebin != None: |
839 if platform.name() == "symbian" or options.hostqmakebin != None or options.hostmakebin != None: |
824 print("\nBuilding host tools...") |
840 print("\nBuilding host tools...") |
825 if options.hostqmakebin != None and options.hostmakebin != None: |
841 if options.hostqmakebin != None and options.hostmakebin != None: |
838 print(" tools from PATH.") |
854 print(" tools from PATH.") |
839 |
855 |
840 # run qmake |
856 # run qmake |
841 if options.qmakebin: |
857 if options.qmakebin: |
842 qmake = options.qmakebin |
858 qmake = options.qmakebin |
|
859 |
|
860 # modify epocroot for symbian to have compatibility between qmake and raptor |
|
861 epocroot = os.environ.get("EPOCROOT") |
|
862 replace_epocroot = epocroot |
|
863 if epocroot: |
|
864 if epocroot.endswith("\\") or epocroot.endswith("/"): |
|
865 replace_epocroot = epocroot |
|
866 else: |
|
867 replace_epocroot = "%s/" % epocroot |
|
868 |
843 profile = os.path.join(sourcedir, "hb.pro") |
869 profile = os.path.join(sourcedir, "hb.pro") |
844 cachefile = os.path.join(currentdir, ".qmake.cache") |
870 cachefile = os.path.join(currentdir, ".qmake.cache") |
845 if options.msvc: |
871 if options.msvc: |
846 qmake = "%s -tp vc" % qmake |
872 qmake = "%s -tp vc" % qmake |
847 if not options.fast: |
873 if not options.fast: |
853 if options.verbose: |
879 if options.verbose: |
854 print("\nRunning %s -cache %s %s" % (qmake, cachefile, profile)) |
880 print("\nRunning %s -cache %s %s" % (qmake, cachefile, profile)) |
855 else: |
881 else: |
856 print("\nRunning qmake...") |
882 print("\nRunning qmake...") |
857 try: |
883 try: |
|
884 # replace the epocroot for the qmake runtime |
|
885 if replace_epocroot: |
|
886 os.putenv("EPOCROOT", replace_epocroot) |
858 ret = os.system("%s -cache %s %s" % (qmake, cachefile, profile)) |
887 ret = os.system("%s -cache %s %s" % (qmake, cachefile, profile)) |
|
888 if replace_epocroot: |
|
889 os.putenv("EPOCROOT", epocroot) |
859 except KeyboardInterrupt: |
890 except KeyboardInterrupt: |
860 ret = -1 |
891 ret = -1 |
861 if ret != 0: |
892 if ret != 0: |
862 print("") |
893 print("") |
863 print("ERROR: Aborted!") |
894 print("ERROR: Aborted!") |