|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 |
|
| 17 | +from __future__ import print_function |
| 18 | + |
17 | 19 | import argparse |
18 | 20 | import multiprocessing |
19 | 21 | import os |
|
30 | 32 |
|
31 | 33 | def default_toolchain(): |
32 | 34 | (sysname, _, _, _, machine) = os.uname() |
33 | | - toolchain = os.path.join(settings.PROJECT_DIR, 'cmake', 'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower())) |
| 35 | + toolchain = os.path.join(settings.PROJECT_DIR, |
| 36 | + 'cmake', |
| 37 | + 'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower())) |
34 | 38 | return toolchain if os.path.isfile(toolchain) else None |
35 | 39 |
|
36 | 40 | def get_arguments(): |
37 | 41 | devhelp_preparser = argparse.ArgumentParser(add_help=False) |
38 | | - devhelp_preparser.add_argument('--devhelp', action='store_true', default=False, help='show help with all options (including those, which are useful for developers only)') |
| 42 | + devhelp_preparser.add_argument('--devhelp', action='store_true', default=False, |
| 43 | + help='show help with all options ' |
| 44 | + '(including those, which are useful for developers only)') |
39 | 45 |
|
40 | 46 | devhelp_arguments, args = devhelp_preparser.parse_known_args() |
41 | 47 | if devhelp_arguments.devhelp: |
42 | 48 | args.append('--devhelp') |
43 | 49 |
|
44 | | - def devhelp(help): |
45 | | - return help if devhelp_arguments.devhelp else argparse.SUPPRESS |
| 50 | + def devhelp(helpstring): |
| 51 | + return helpstring if devhelp_arguments.devhelp else argparse.SUPPRESS |
46 | 52 |
|
47 | 53 | parser = argparse.ArgumentParser(parents=[devhelp_preparser]) |
48 | | - parser.add_argument('--all-in-one', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='all-in-one build (%(choices)s; default: %(default)s)') |
49 | | - parser.add_argument('--builddir', metavar='DIR', action='store', default=BUILD_DIR, help='specify output directory (default: %(default)s)') |
| 54 | + parser.add_argument('--all-in-one', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 55 | + help='all-in-one build (%(choices)s; default: %(default)s)') |
| 56 | + parser.add_argument('--builddir', metavar='DIR', action='store', default=BUILD_DIR, |
| 57 | + help='specify output directory (default: %(default)s)') |
50 | 58 | parser.add_argument('--clean', action='store_true', default=False, help='clean build') |
51 | | - parser.add_argument('--cmake-param', metavar='OPT', action='append', default=[], help='add custom argument to CMake') |
52 | | - parser.add_argument('--compile-flag', metavar='OPT', action='append', default=[], help='add custom compile flag') |
53 | | - parser.add_argument('--cpointer-32bit', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable 32 bit compressed pointers (%(choices)s; default: %(default)s)') |
54 | | - parser.add_argument('--debug', action='store_const', const='Debug', default='MinSizeRel', dest='build_type', help='debug build') |
55 | | - parser.add_argument('--error-messages', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable error messages (%(choices)s; default: %(default)s)') |
56 | | - parser.add_argument('-j', '--jobs', metavar='N', action='store', type=int, default=multiprocessing.cpu_count() + 1, help='Allowed N build jobs at once (default: %(default)s)') |
57 | | - parser.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build jerry command line tool (%(choices)s; default: %(default)s)') |
58 | | - parser.add_argument('--jerry-cmdline-minimal', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='build minimal version of the jerry command line tool (%(choices)s; default: %(default)s)') |
59 | | - parser.add_argument('--jerry-debugger', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable the jerry debugger (%(choices)s; default: %(default)s)') |
60 | | - parser.add_argument('--jerry-debugger-port', metavar='N', action='store', type=int, default=5001, help='add custom port number (default: %(default)s)') |
61 | | - parser.add_argument('--jerry-libc', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libc (%(choices)s; default: %(default)s)') |
62 | | - parser.add_argument('--jerry-libm', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libm (%(choices)s; default: %(default)s)') |
63 | | - parser.add_argument('--js-parser', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable js-parser (%(choices)s; default: %(default)s)') |
64 | | - parser.add_argument('--link-lib', metavar='OPT', action='append', default=[], help='add custom library to be linked') |
65 | | - parser.add_argument('--linker-flag', metavar='OPT', action='append', default=[], help='add custom linker flag') |
66 | | - parser.add_argument('--lto', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable link-time optimizations (%(choices)s; default: %(default)s)') |
67 | | - parser.add_argument('--mem-heap', metavar='SIZE', action='store', type=int, default=512, help='size of memory heap, in kilobytes (default: %(default)s)') |
68 | | - parser.add_argument('--port-dir', metavar='DIR', action='store', default=DEFAULT_PORT_DIR, help='add port directory (default: %(default)s)') |
69 | | - parser.add_argument('--profile', metavar='FILE', action='store', default=DEFAULT_PROFILE, help='specify profile file (default: %(default)s)') |
70 | | - parser.add_argument('--snapshot-exec', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable executing snapshot files (%(choices)s; default: %(default)s)') |
71 | | - parser.add_argument('--snapshot-save', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable saving snapshot files (%(choices)s; default: %(default)s)') |
72 | | - parser.add_argument('--system-allocator', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable system allocator (%(choices)s; default: %(default)s)') |
73 | | - parser.add_argument('--static-link', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable static linking of binaries (%(choices)s; default: %(default)s)') |
74 | | - parser.add_argument('--strip', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='strip release binaries (%(choices)s; default: %(default)s)') |
75 | | - parser.add_argument('--toolchain', metavar='FILE', action='store', default=default_toolchain(), help='add toolchain file (default: %(default)s)') |
76 | | - parser.add_argument('--unittests', action='store_const', const='ON', default='OFF', help='build unittests') |
77 | | - parser.add_argument('-v', '--verbose', action='store_const', const='ON', default='OFF', help='increase verbosity') |
| 59 | + parser.add_argument('--cmake-param', metavar='OPT', action='append', default=[], |
| 60 | + help='add custom argument to CMake') |
| 61 | + parser.add_argument('--compile-flag', metavar='OPT', action='append', default=[], |
| 62 | + help='add custom compile flag') |
| 63 | + parser.add_argument('--cpointer-32bit', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 64 | + help='enable 32 bit compressed pointers (%(choices)s; default: %(default)s)') |
| 65 | + parser.add_argument('--debug', action='store_const', const='Debug', default='MinSizeRel', dest='build_type', |
| 66 | + help='debug build') |
| 67 | + parser.add_argument('--error-messages', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 68 | + help='enable error messages (%(choices)s; default: %(default)s)') |
| 69 | + parser.add_argument('-j', '--jobs', metavar='N', action='store', type=int, default=multiprocessing.cpu_count() + 1, |
| 70 | + help='Allowed N build jobs at once (default: %(default)s)') |
| 71 | + parser.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, |
| 72 | + help='build jerry command line tool (%(choices)s; default: %(default)s)') |
| 73 | + parser.add_argument('--jerry-cmdline-minimal', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 74 | + help='build minimal version of the jerry command line tool (%(choices)s; default: %(default)s)') |
| 75 | + parser.add_argument('--jerry-debugger', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 76 | + help='enable the jerry debugger (%(choices)s; default: %(default)s)') |
| 77 | + parser.add_argument('--jerry-debugger-port', metavar='N', action='store', type=int, default=5001, |
| 78 | + help='add custom port number (default: %(default)s)') |
| 79 | + parser.add_argument('--jerry-libc', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, |
| 80 | + help='build and use jerry-libc (%(choices)s; default: %(default)s)') |
| 81 | + parser.add_argument('--jerry-libm', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, |
| 82 | + help='build and use jerry-libm (%(choices)s; default: %(default)s)') |
| 83 | + parser.add_argument('--js-parser', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, |
| 84 | + help='enable js-parser (%(choices)s; default: %(default)s)') |
| 85 | + parser.add_argument('--link-lib', metavar='OPT', action='append', default=[], |
| 86 | + help='add custom library to be linked') |
| 87 | + parser.add_argument('--linker-flag', metavar='OPT', action='append', default=[], |
| 88 | + help='add custom linker flag') |
| 89 | + parser.add_argument('--lto', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, |
| 90 | + help='enable link-time optimizations (%(choices)s; default: %(default)s)') |
| 91 | + parser.add_argument('--mem-heap', metavar='SIZE', action='store', type=int, default=512, |
| 92 | + help='size of memory heap, in kilobytes (default: %(default)s)') |
| 93 | + parser.add_argument('--port-dir', metavar='DIR', action='store', default=DEFAULT_PORT_DIR, |
| 94 | + help='add port directory (default: %(default)s)') |
| 95 | + parser.add_argument('--profile', metavar='FILE', action='store', default=DEFAULT_PROFILE, |
| 96 | + help='specify profile file (default: %(default)s)') |
| 97 | + parser.add_argument('--snapshot-exec', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 98 | + help='enable executing snapshot files (%(choices)s; default: %(default)s)') |
| 99 | + parser.add_argument('--snapshot-save', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 100 | + help='enable saving snapshot files (%(choices)s; default: %(default)s)') |
| 101 | + parser.add_argument('--system-allocator', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 102 | + help='enable system allocator (%(choices)s; default: %(default)s)') |
| 103 | + parser.add_argument('--static-link', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, |
| 104 | + help='enable static linking of binaries (%(choices)s; default: %(default)s)') |
| 105 | + parser.add_argument('--strip', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, |
| 106 | + help='strip release binaries (%(choices)s; default: %(default)s)') |
| 107 | + parser.add_argument('--toolchain', metavar='FILE', action='store', default=default_toolchain(), |
| 108 | + help='add toolchain file (default: %(default)s)') |
| 109 | + parser.add_argument('--unittests', action='store_const', const='ON', default='OFF', |
| 110 | + help='build unittests') |
| 111 | + parser.add_argument('-v', '--verbose', action='store_const', const='ON', default='OFF', |
| 112 | + help='increase verbosity') |
78 | 113 |
|
79 | 114 | devgroup = parser.add_argument_group('developer options') |
80 | | - devgroup.add_argument('--link-map', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable the generation of a link map file for jerry command line tool (%(choices)s; default: %(default)s)')) |
81 | | - devgroup.add_argument('--mem-stats', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable memory statistics (%(choices)s; default: %(default)s)')) |
82 | | - devgroup.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable mem-stress test (%(choices)s; default: %(default)s)')) |
83 | | - devgroup.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable parser byte-code dumps (%(choices)s; default: %(default)s)')) |
84 | | - devgroup.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable regexp byte-code dumps (%(choices)s; default: %(default)s)')) |
85 | | - devgroup.add_argument('--valgrind', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable Valgrind support (%(choices)s; default: %(default)s)')) |
86 | | - devgroup.add_argument('--valgrind-freya', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable Valgrind-Freya support (%(choices)s; default: %(default)s)')) |
| 115 | + devgroup.add_argument('--link-map', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 116 | + help=devhelp('enable the generation of a link map file for jerry command line tool ' |
| 117 | + '(%(choices)s; default: %(default)s)')) |
| 118 | + devgroup.add_argument('--mem-stats', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 119 | + help=devhelp('enable memory statistics (%(choices)s; default: %(default)s)')) |
| 120 | + devgroup.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 121 | + help=devhelp('enable mem-stress test (%(choices)s; default: %(default)s)')) |
| 122 | + devgroup.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 123 | + help=devhelp('enable parser byte-code dumps (%(choices)s; default: %(default)s)')) |
| 124 | + devgroup.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 125 | + help=devhelp('enable regexp byte-code dumps (%(choices)s; default: %(default)s)')) |
| 126 | + devgroup.add_argument('--valgrind', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 127 | + help=devhelp('enable Valgrind support (%(choices)s; default: %(default)s)')) |
| 128 | + devgroup.add_argument('--valgrind-freya', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, |
| 129 | + help=devhelp('enable Valgrind-Freya support (%(choices)s; default: %(default)s)')) |
87 | 130 |
|
88 | 131 | arguments = parser.parse_args(args) |
89 | 132 | if arguments.devhelp: |
@@ -113,11 +156,11 @@ def generate_build_options(arguments): |
113 | 156 | build_options.append('-DPORT_DIR=%s' % arguments.port_dir) |
114 | 157 |
|
115 | 158 | if os.path.isabs(arguments.profile): |
116 | | - PROFILE = arguments.profile |
| 159 | + profile = arguments.profile |
117 | 160 | else: |
118 | | - PROFILE = os.path.join(PROFILE_DIR, arguments.profile + '.profile') |
| 161 | + profile = os.path.join(PROFILE_DIR, arguments.profile + '.profile') |
119 | 162 |
|
120 | | - build_options.append('-DFEATURE_PROFILE=%s' % PROFILE) |
| 163 | + build_options.append('-DFEATURE_PROFILE=%s' % profile) |
121 | 164 |
|
122 | 165 | build_options.append('-DFEATURE_DEBUGGER=%s' % arguments.jerry_debugger) |
123 | 166 | build_options.append('-DFEATURE_DEBUGGER_PORT=%d' % arguments.jerry_debugger_port) |
|
0 commit comments