def _fetch_jdk(self, jdk_distribution, paths): if not self._mx_path: self._mx_path = mx.get_jdk().home mx._opts.quiet = True tmp_dir = tempfile.gettempdir() _, repo_path = VC.get_vc_root(paths[0]) common_location = os.path.join(repo_path, 'common.json') fetch_args = [ '--to', tmp_dir, '--java-distribution', jdk_distribution, '--configuration', common_location ] JdkDistribution._jdk_distributions = [] args = mx_fetchjdk._parse_fetchsettings(fetch_args) distribution = args["java-distribution"] base_path = args["base-path"] jdk_home = distribution.get_final_path(base_path) if mx.is_darwin(): jdk_home = os.join(jdk_home, 'Contents', 'Home') if jdk_home != self._jdk_home: try: mx_fetchjdk.fetch_jdk(fetch_args) self._jdk_home = jdk_home os.environ['JAVA_HOME'] = jdk_home except (OSError, IOError) as err: mx.log(str(err)) self._jdk_home = mx.get_jdk().home mx._opts.quiet = False
def add_ext_suffix(name): """ Adds the platform specific C extension suffix to a name """ if mx.is_darwin(): return name + '.bundle' else: return name + '.so'
def intellij_read_sdks(): sdks = dict() if mx.is_linux() or mx.is_openbsd() or mx.is_sunos() or mx.is_windows(): xmlSdks = glob.glob(os.path.expanduser("~/.IdeaIC*/config/options/jdk.table.xml")) + \ glob.glob(os.path.expanduser("~/.IntelliJIdea*/config/options/jdk.table.xml")) + \ glob.glob(os.path.expanduser("~/.config/JetBrains/IdeaIC*/options/jdk.table.xml")) + \ glob.glob(os.path.expanduser("~/.config/JetBrains/IntelliJIdea*/options/jdk.table.xml")) elif mx.is_darwin(): xmlSdks = \ glob.glob(os.path.expanduser("~/Library/Application Support/JetBrains/IdeaIC*/options/jdk.table.xml")) + \ glob.glob(os.path.expanduser("~/Library/Application Support/JetBrains/IntelliJIdea*/options/jdk.table.xml")) + \ glob.glob(os.path.expanduser("~/Library/Preferences/IdeaIC*/options/jdk.table.xml")) + \ glob.glob(os.path.expanduser("~/Library/Preferences/IntelliJIdea*/options/jdk.table.xml")) else: mx.warn("Location of IntelliJ SDK definitions on {} is unknown".format(mx.get_os())) return sdks if len(xmlSdks) == 0: mx.warn("IntelliJ SDK definitions not found") return sdks verRE = re.compile(r'^.*[/\\]\.?(IntelliJIdea|IdeaIC)([^/\\]+)[/\\].*$') def verSort(path): match = verRE.match(path) return match.group(2) + (".a" if match.group(1) == "IntellijIC" else ".b") xmlSdks.sort(key=verSort) xmlSdk = xmlSdks[-1] # Pick the most recent IntelliJ version, preferring Ultimate over Community edition. mx.log("Using SDK definitions from {}".format(xmlSdk)) versionRegexes = {} versionRegexes[intellij_java_sdk_type] = re.compile(r'^java\s+version\s+"([^"]+)"$|^version\s+(.+)$|^([\d._]+)$') versionRegexes[intellij_python_sdk_type] = re.compile(r'^Python\s+(.+)$') # Examples: # truffleruby 19.2.0-dev-2b2a7f81, like ruby 2.6.2, Interpreted JVM [x86_64-linux] # ver.2.2.4p230 ( revision 53155) p230 versionRegexes[intellij_ruby_sdk_type] = re.compile(r'^\D*(\d[^ ,]+)') for sdk in etreeParse(xmlSdk).getroot().findall("component[@name='ProjectJdkTable']/jdk[@version='2']"): name = sdk.find("name").get("value") kind = sdk.find("type").get("value") home = realpath(os.path.expanduser(sdk.find("homePath").get("value").replace('$USER_HOME$', '~'))) if home.find('$APPLICATION_HOME_DIR$') != -1: # Don't know how to convert this into a real path so ignore it continue versionRE = versionRegexes.get(kind) if not versionRE or sdk.find("version") is None: # ignore unknown kinds continue match = versionRE.match(sdk.find("version").get("value")) if match: version = match.group(1) sdks[home] = {'name': name, 'type': kind, 'version': version} mx.logv("Found SDK {} with values {}".format(home, sdks[home])) else: mx.warn(u"Couldn't understand Java version specification \"{}\" for {} in {}".format(sdk.find("version").get("value"), home, xmlSdk)) return sdks
def makejdk(args): """create a JDK directory based on the Maxine VM Create a JDK directory by replicating the file structure of $JAVA_HOME and replacing the 'java' executable with the Maxine VM executable. This produces a Maxine VM based JDK for applications (such as NetBeans) which expect a certain directory structure and executable names in a JDK installation.""" if mx.is_darwin(): mx.log('mx makejdk is not supported on Darwin') mx.abort(1) if len(args) == 0: maxjdk = join(_maxine_home, 'maxjdk') else: maxjdk = args[0] if maxjdk[0] != '/': maxjdk = join(os.getcwd(), maxjdk) if exists(maxjdk): mx.log( 'The destination directory already exists -- it will be deleted') shutil.rmtree(maxjdk) jdk = mx.get_jdk().home if not isdir(jdk): mx.log(jdk + " does not exist or is not a directory") mx.abort(1) mx.log('Replicating ' + jdk + ' in ' + maxjdk + '...') shutil.copytree(jdk, maxjdk, symlinks=True) jreExists = exists(join(maxjdk, 'jre')) for f in os.listdir(_vmdir): fpath = join(_vmdir, f) if isfile(fpath): shutil.copy(fpath, join(maxjdk, 'bin')) if jreExists: shutil.copy(fpath, join(maxjdk, 'jre', 'bin')) os.unlink(join(maxjdk, 'bin', 'java')) if jreExists: os.unlink(join(maxjdk, 'jre', 'bin', 'java')) if (mx.os == 'windows'): shutil.copy(join(maxjdk, 'bin', 'maxvm'), join(maxjdk, 'bin', 'java')) shutil.copy(join(maxjdk, 'jre', 'bin', 'maxvm'), join(maxjdk, 'jre', 'bin', 'java')) else: os.symlink(join(maxjdk, 'bin', 'maxvm'), join(maxjdk, 'bin', 'java')) if jreExists: os.symlink(join(maxjdk, 'jre', 'bin', 'maxvm'), join(maxjdk, 'jre', 'bin', 'java')) mx.log('Created Maxine based JDK in ' + maxjdk)
def _lib_versioned(arg): name, version = arg.split('.') if mx.is_darwin(): return "lib" + name + "." + version + ".dylib" elif mx.is_linux() or mx.is_openbsd() or mx.is_sunos(): return "lib" + name + ".so." + version elif mx.is_windows(): return name + ".dll" else: mx.abort('unsupported os')
def cflags(self): default_cflags = [] if self._kind == self._kinds['shared_lib']: default_cflags += dict(windows=['-MD' ], ).get(mx.get_os(), ['-fPIC']) if mx.is_linux() or mx.is_darwin(): # Do not leak host paths via dwarf debuginfo def add_debug_prefix(prefix_dir): return '-fdebug-prefix-map={}={}'.format( prefix_dir, mx.basename(prefix_dir)) default_cflags += [add_debug_prefix(self.suite.vc_dir)] default_cflags += [add_debug_prefix(NinjaProject.get_jdk().home)] default_cflags += ['-gno-record-gcc-switches'] return default_cflags + super(DefaultNativeProject, self).cflags
def cflags(self): default_cflags = [] if mx.is_windows() and mx.get_jdk( tag=mx.DEFAULT_JDK_TAG).javaCompliance >= '11': default_cflags += ['-FS'] # necessary until GR-16572 is resolved if self._kind == self._kinds['shared_lib']: default_cflags += dict(windows=['-MD' ], ).get(mx.get_os(), ['-fPIC']) if mx.is_linux() or mx.is_darwin(): # Do not leak host paths via dwarf debuginfo def add_debug_prefix(prefix_dir): return '-fdebug-prefix-map={}={}'.format( prefix_dir, mx.basename(prefix_dir)) default_cflags += [add_debug_prefix(self.suite.vc_dir)] default_cflags += [add_debug_prefix(NinjaProject.get_jdk().home)] default_cflags += ['-gno-record-gcc-switches'] return default_cflags + super(DefaultNativeProject, self).cflags
def inspectoragent(args): """launch the Inspector agent Launch the Inspector agent. The agent listens on a given port for an incoming connection from a remote Inspector process.""" cmd = [mx.get_jdk().java] cmd += mx.get_jdk().processArgs([ '-cp', mx.classpath(), 'com.sun.max.tele.channel.agent.InspectorAgent' ] + args) if mx.is_darwin(): # The -E option propagates the environment variables into the sudo process mx.run([ 'sudo', '-E', '-p', 'Debugging is a privileged operation on Mac OS X.\nPlease enter your "sudo" password:' ] + cmd) else: mx.run(cmd, env=ldenv)
def fetch_jdk(args): """fetches required JDK version If mx is not passed the --quiet flag, menu will be printed for available JDK selection. """ args = _parse_fetchsettings(args) distribution = args["java-distribution"] base_path = args["base-path"] artifact = distribution.get_folder_name() final_path = distribution.get_final_path(base_path) url = mx_urlrewrites.rewriteurl(distribution.get_url()) sha_url = url + ".sha1" archive_name = distribution.get_archive_name() archive_target_location = join(base_path, archive_name) if not is_quiet(): if not mx.ask_yes_no("Install {} to {}".format(artifact, final_path), default='y'): mx.abort("JDK installation canceled") if exists(final_path): if args["keep-archive"]: mx.warn( "The --keep-archive option is ignored when the JDK is already installed." ) mx.log("Requested JDK is already installed at {}".format(final_path)) else: # Try to extract on the same file system as the target to be able to atomically move the result. with mx.TempDir(parent_dir=base_path) as temp_dir: mx.log("Fetching {} archive from {}...".format(artifact, url)) archive_location = join(temp_dir, archive_name) mx._opts.no_download_progress = is_quiet() sha1_hash = mx._hashFromUrl(sha_url).decode('utf-8') mx.download_file_with_sha1(artifact, archive_location, [url], sha1_hash, archive_location + '.sha1', resolve=True, mustExist=True, sources=False) untar = mx.TarExtractor(archive_location) mx.log("Installing {} to {}...".format(artifact, final_path)) extracted_path = join(temp_dir, 'extracted') try: untar.extract(extracted_path) except: mx.rmtree(temp_dir, ignore_errors=True) mx.abort("Error parsing archive. Please try again") jdk_root_folder = get_extracted_jdk_archive_root_folder( extracted_path) if args["keep-archive"]: atomic_file_move_with_fallback(archive_location, archive_target_location) atomic_file_move_with_fallback( archive_location + '.sha1', archive_target_location + ".sha1") mx.log( "Archive is located at {}".format(archive_target_location)) atomic_file_move_with_fallback( join(extracted_path, jdk_root_folder), final_path) curr_path = final_path if mx.is_darwin() and exists(join(final_path, 'Contents', 'Home')): if args["strip-contents-home"]: with mx.TempDir(parent_dir=final_path) as tmp_path: shutil.move(final_path, tmp_path) shutil.move(join(tmp_path, 'Contents', 'Home'), final_path) else: final_path = join(final_path, 'Contents', 'Home') if "alias" in args: alias_full_path = join(base_path, args["alias"]) if exists(alias_full_path): mx.rmtree(alias_full_path) if not (mx.is_windows() or mx.is_cygwin()): os.symlink(abspath(curr_path), alias_full_path) else: mx.copytree(curr_path, alias_full_path, symlinks=True) # fallback for windows final_path = alias_full_path mx.log("Run the following to set JAVA_HOME in your shell:") shell = os.environ.get("SHELL") if shell is None: shell = '' print(get_setvar_format(shell) % ("JAVA_HOME", abspath(final_path)))
def _parse_fetchsettings(args): settings = {} settings["keep-archive"] = False settings["base-path"] = default_base_path() common_location = join(_mx_home, 'common.json') parser = ArgumentParser(prog='mx fetch-jdk') parser.add_argument( '--java-distribution', action='store', help= 'JDK distribution that should be downloaded (e.g., "labsjdk-ce-11" or "openjdk8")' ) parser.add_argument( '--configuration', action='store', help='location of configuration json file (default: \'{}\')'.format( common_location)) parser.add_argument( '--to', action='store', help='location where JDK would be downloaded (default: \'{}\')'.format( settings["base-path"])) parser.add_argument('--alias', action='store', help='name of symlink to JDK') parser.add_argument('--keep-archive', action='store_true', help='keep downloaded JDK archive') if mx.is_darwin(): parser.add_argument('--strip-contents-home', action='store_true', help='strip Contents/Home') parser.add_argument('remainder', nargs=REMAINDER, metavar='...') args = parser.parse_args(args) if args.to is not None: settings["base-path"] = args.to if not check_write_access(settings["base-path"]): mx.abort( "JDK installation directory {} is not writeable.".format( settings["base-path"]) + os.linesep + "Either re-run with elevated privileges (e.g. sudo) or specify a writeable directory with the --to option." ) if args.configuration is not None: common_location = args.configuration else: if mx.primary_suite() is not None: common_location = join(mx.primary_suite().vc_dir, 'common.json') # Try fetching suite config else: common_location = join(os.getcwd(), 'common.json') # Fallback to same folder if not exists(common_location): common_location = join(_mx_home, 'common.json') # Fallback to mx mx.warn( "Selected `{}` as configuration location, since no location is provided" .format(common_location)) if not exists(common_location): mx.abort("Configuration file doesn't exist") parse_common_json(common_location) if args.java_distribution is not None: settings["java-distribution"] = JdkDistribution.by_name( args.java_distribution) else: settings["java-distribution"] = JdkDistribution.choose_dist(is_quiet()) if args.alias is not None: settings["alias"] = args.alias if args.keep_archive is not None: settings["keep-archive"] = args.keep_archive if mx.is_darwin() and (args.strip_contents_home is not None): settings["strip-contents-home"] = args.strip_contents_home return settings
def _intellij_suite(args, s, declared_modules, referenced_modules, sdks, refreshOnly=False, mx_python_modules=False, generate_external_projects=True, java_modules=True, module_files_only=False, generate_native_projects=False): libraries = set() jdk_libraries = set() project_dir = s.dir ideaProjectDirectory = join(project_dir, '.idea') modulesXml = mx.XMLDoc() if not module_files_only and not s.isBinarySuite(): mx.ensure_dir_exists(ideaProjectDirectory) nameFile = join(ideaProjectDirectory, '.name') mx.update_file(nameFile, s.name) modulesXml.open('project', attributes={'version': '4'}) modulesXml.open('component', attributes={'name': 'ProjectModuleManager'}) modulesXml.open('modules') def _intellij_exclude_if_exists(xml, p, name, output=False): root = p.get_output_root() if output else p.dir path = join(root, name) if exists(path): excludeRoot = p.get_output_root() if output else '$MODULE_DIR$' excludePath = join(excludeRoot, name) xml.element('excludeFolder', attributes={'url':'file://' + excludePath}) annotationProcessorProfiles = {} def _complianceToIntellijLanguageLevel(compliance): # they changed the name format starting with JDK_10 if compliance.value >= 10: # Lastest Idea 2018.2 only understands JDK_11 so clamp at that value return 'JDK_' + str(min(compliance.value, 11)) return 'JDK_1_' + str(compliance.value) def _intellij_external_project(externalProjects, sdks, host): if externalProjects: for project_name, project_definition in externalProjects.items(): if not project_definition.get('path', None): mx.abort("external project {} is missing path attribute".format(project_name)) if not project_definition.get('type', None): mx.abort("external project {} is missing type attribute".format(project_name)) supported = ['path', 'type', 'source', 'test', 'excluded', 'load_path'] unknown = set(project_definition.keys()) - frozenset(supported) if unknown: mx.abort("There are unsupported {} keys in {} external project".format(unknown, project_name)) path = os.path.realpath(join(host.dir, project_definition["path"])) module_type = project_definition["type"] moduleXml = mx.XMLDoc() moduleXml.open('module', attributes={'type': {'ruby': 'RUBY_MODULE', 'python': 'PYTHON_MODULE', 'web': 'WEB_MODULE'}.get(module_type, 'UKNOWN_MODULE'), 'version': '4'}) moduleXml.open('component', attributes={'name': 'NewModuleRootManager', 'inherit-compiler-output': 'true'}) moduleXml.element('exclude-output') moduleXml.open('content', attributes={'url': 'file://$MODULE_DIR$'}) for name in project_definition.get('source', []): moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + name, 'isTestSource': str(False)}) for name in project_definition.get('test', []): moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + name, 'isTestSource': str(True)}) for name in project_definition.get('excluded', []): _intellij_exclude_if_exists(moduleXml, type('', (object,), {"dir": path})(), name) moduleXml.close('content') if module_type == "ruby": moduleXml.element('orderEntry', attributes={'type': 'jdk', 'jdkType': intellij_ruby_sdk_type, 'jdkName': intellij_get_ruby_sdk_name(sdks)}) elif module_type == "python": moduleXml.element('orderEntry', attributes={'type': 'jdk', 'jdkType': intellij_python_sdk_type, 'jdkName': intellij_get_python_sdk_name(sdks)}) elif module_type == "web": # nothing to do pass else: mx.abort("External project type {} not supported".format(module_type)) moduleXml.element('orderEntry', attributes={'type': 'sourceFolder', 'forTests': 'false'}) moduleXml.close('component') load_paths = project_definition.get('load_path', []) if load_paths: if not module_type == "ruby": mx.abort("load_path is supported only for ruby type external project") moduleXml.open('component', attributes={'name': 'RModuleSettingsStorage'}) load_paths_attributes = {} load_paths_attributes['number'] = str(len(load_paths)) for i, name in enumerate(load_paths): load_paths_attributes["string" + str(i)] = "$MODULE_DIR$/" + name moduleXml.element('LOAD_PATH', load_paths_attributes) moduleXml.close('component') moduleXml.close('module') moduleFile = join(path, project_name + '.iml') mx.update_file(moduleFile, moduleXml.xml(indent=' ', newl='\n')) if not module_files_only: declared_modules.add(project_name) moduleFilePath = "$PROJECT_DIR$/" + os.path.relpath(moduleFile, s.dir) modulesXml.element('module', attributes={'fileurl': 'file://' + moduleFilePath, 'filepath': moduleFilePath}) if generate_external_projects: for p in s.projects_recursive() + mx._mx_suite.projects_recursive(): _intellij_external_project(getattr(p, 'externalProjects', None), sdks, p) max_checkstyle_version = None compilerXml = None if java_modules: if not module_files_only: compilerXml = mx.XMLDoc() compilerXml.open('project', attributes={'version': '4'}) # The IntelliJ parser seems to mishandle empty ADDITIONAL_OPTIONS_OVERRIDE elements # so only emit the section if there will be something in it. additionalOptionsOverrides = False assert not s.isBinarySuite() # create the modules (1 IntelliJ module = 1 mx project/distribution) for p in s.projects_recursive() + mx._mx_suite.projects_recursive(): if not p.isJavaProject(): continue jdk = mx.get_jdk(p.javaCompliance) assert jdk # Value of the $MODULE_DIR$ IntelliJ variable and parent directory of the .iml file. module_dir = mx.ensure_dir_exists(p.dir) processors = p.annotation_processors() if processors: annotationProcessorProfiles.setdefault((p.source_gen_dir_name(),) + tuple(processors), []).append(p) intellijLanguageLevel = _complianceToIntellijLanguageLevel(p.javaCompliance) moduleXml = mx.XMLDoc() moduleXml.open('module', attributes={'type': 'JAVA_MODULE', 'version': '4'}) moduleXml.open('component', attributes={'name': 'NewModuleRootManager', 'LANGUAGE_LEVEL': intellijLanguageLevel, 'inherit-compiler-output': 'false'}) moduleXml.element('output', attributes={'url': 'file://$MODULE_DIR$/' + os.path.relpath(p.output_dir(), module_dir)}) moduleXml.open('content', attributes={'url': 'file://$MODULE_DIR$'}) for src in p.srcDirs: srcDir = mx.ensure_dir_exists(join(p.dir, src)) moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + os.path.relpath(srcDir, module_dir), 'isTestSource': str(p.is_test_project())}) for name in ['.externalToolBuilders', '.settings', 'nbproject']: _intellij_exclude_if_exists(moduleXml, p, name) moduleXml.close('content') if processors: moduleXml.open('content', attributes={'url': 'file://' + p.get_output_root()}) genDir = p.source_gen_dir() mx.ensure_dir_exists(genDir) moduleXml.element('sourceFolder', attributes={'url':'file://' + p.source_gen_dir(), 'isTestSource': str(p.is_test_project()), 'generated': 'true'}) for name in [basename(p.output_dir())]: _intellij_exclude_if_exists(moduleXml, p, name, output=True) moduleXml.close('content') moduleXml.element('orderEntry', attributes={'type': 'sourceFolder', 'forTests': 'false'}) proj = p dependencies_project_packages = set() def should_process_dep(dep, edge): if dep.isTARDistribution() or dep.isNativeProject() or dep.isArchivableProject() or dep.isResourceLibrary(): mx.logv("Ignoring dependency from {} to {}".format(proj.name, dep.name)) return False return True def process_dep(dep, edge): if dep is proj: return if dep.isLibrary() or dep.isJARDistribution() or dep.isMavenProject(): libraries.add(dep) moduleXml.element('orderEntry', attributes={'type': 'library', 'name': dep.name, 'level': 'project'}) elif dep.isJavaProject(): dependencies_project_packages.update(dep.defined_java_packages()) referenced_modules.add(dep.name) moduleXml.element('orderEntry', attributes={'type': 'module', 'module-name': dep.name}) elif dep.isJdkLibrary(): jdk_libraries.add(dep) if jdk.javaCompliance < dep.jdkStandardizedSince: moduleXml.element('orderEntry', attributes={'type': 'library', 'name': dep.name, 'level': 'project'}) else: mx.logv("{} skipping {} for {}".format(p, dep, jdk)) #pylint: disable=undefined-loop-variable elif dep.isJreLibrary(): pass elif dep.isClasspathDependency(): moduleXml.element('orderEntry', attributes={'type': 'library', 'name': dep.name, 'level': 'project'}) else: mx.abort("Dependency not supported: {0} ({1})".format(dep, dep.__class__.__name__)) p.walk_deps(preVisit=should_process_dep, visit=process_dep, ignoredEdges=[mx.DEP_EXCLUDED]) moduleXml.element('orderEntry', attributes={'type': 'jdk', 'jdkType': intellij_java_sdk_type, 'jdkName': intellij_get_java_sdk_name(sdks, jdk)}) moduleXml.close('component') if compilerXml and jdk.javaCompliance >= '9': moduleDeps = p.get_concealed_imported_packages(jdk=jdk) if moduleDeps: exports = sorted([(m, pkgs) for m, pkgs in moduleDeps.items() if dependencies_project_packages.isdisjoint(pkgs)]) if exports: args = [] exported_modules = set() for m, pkgs in exports: args += ['--add-exports={}/{}=ALL-UNNAMED'.format(m, pkg) for pkg in pkgs] exported_modules.add(m) roots = set(jdk.get_root_modules()) observable_modules = jdk.get_modules() default_module_graph = mx_javamodules.get_transitive_closure(roots, observable_modules) module_graph = mx_javamodules.get_transitive_closure(roots | exported_modules, observable_modules) extra_modules = module_graph - default_module_graph if extra_modules: args.append('--add-modules=' + ','.join((m.name for m in extra_modules))) if not additionalOptionsOverrides: additionalOptionsOverrides = True compilerXml.open('component', {'name': 'JavacSettings'}) compilerXml.open('option', {'name': 'ADDITIONAL_OPTIONS_OVERRIDE'}) compilerXml.element('module', {'name': p.name, 'options': ' '.join(args)}) # Checkstyle csConfig, checkstyleVersion, checkstyleProj = p.get_checkstyle_config() if csConfig: max_checkstyle_version = max(max_checkstyle_version, mx.VersionSpec(checkstyleVersion)) if max_checkstyle_version else mx.VersionSpec(checkstyleVersion) moduleXml.open('component', attributes={'name': 'CheckStyle-IDEA-Module'}) moduleXml.open('option', attributes={'name': 'configuration'}) moduleXml.open('map') moduleXml.element('entry', attributes={'key': "checkstyle-version", 'value': checkstyleVersion}) moduleXml.element('entry', attributes={'key': "active-configuration", 'value': "PROJECT_RELATIVE:" + join(checkstyleProj.dir, ".checkstyle_checks.xml") + ":" + checkstyleProj.name}) moduleXml.close('map') moduleXml.close('option') moduleXml.close('component') moduleXml.close('module') moduleFile = join(module_dir, p.name + '.iml') mx.update_file(moduleFile, moduleXml.xml(indent=' ', newl='\n').rstrip()) if not module_files_only: declared_modules.add(p.name) moduleFilePath = "$PROJECT_DIR$/" + os.path.relpath(moduleFile, project_dir) modulesXml.element('module', attributes={'fileurl': 'file://' + moduleFilePath, 'filepath': moduleFilePath}) if additionalOptionsOverrides: compilerXml.close('option') compilerXml.close('component') if mx_python_modules: def _python_module(suite): """ Gets a tuple describing the IntelliJ module for the python sources of `suite`. The tuple consists of the module name, module directory and the name of the .iml in the module directory. """ name = basename(suite.mxDir) module_dir = suite.mxDir return name, mx.ensure_dir_exists(module_dir), name + '.iml' def _add_declared_module(suite): if not module_files_only: name, module_dir, iml_file = _python_module(suite) declared_modules.add(name) moduleFilePath = "$PROJECT_DIR$/" + os.path.relpath(join(module_dir, iml_file), project_dir) modulesXml.element('module', attributes={'fileurl': 'file://' + moduleFilePath, 'filepath': moduleFilePath}) # mx.<suite> python module: _, module_dir, iml_file = _python_module(s) moduleXml = mx.XMLDoc() moduleXml.open('module', attributes={'type': 'PYTHON_MODULE', 'version': '4'}) moduleXml.open('component', attributes={'name': 'NewModuleRootManager', 'inherit-compiler-output': 'true'}) moduleXml.element('exclude-output') if s.name == 'mx': # MX itself is special. Python sources are also in the parent folder. moduleXml.open('content', attributes={'url': 'file://$MODULE_DIR$/..'}) moduleXml.element('sourceFolder', attributes={'url': 'file://$MODULE_DIR$/..', 'isTestSource': 'false'}) else: moduleXml.open('content', attributes={'url': 'file://$MODULE_DIR$'}) moduleXml.element('sourceFolder', attributes={'url': 'file://$MODULE_DIR$/' + os.path.relpath(s.mxDir, module_dir), 'isTestSource': 'false'}) for d in os.listdir(s.mxDir): directory = join(s.mxDir, d) if isdir(directory) and mx.dir_contains_files_recursively(directory, r".*\.java"): moduleXml.element('excludeFolder', attributes={'url': 'file://$MODULE_DIR$/' + os.path.relpath(directory, module_dir)}) moduleXml.close('content') moduleXml.element('orderEntry', attributes={'type': 'jdk', 'jdkType': intellij_python_sdk_type, 'jdkName': intellij_get_python_sdk_name(sdks)}) moduleXml.element('orderEntry', attributes={'type': 'sourceFolder', 'forTests': 'false'}) processed_suites = {s.name} def _mx_projects_suite(visited_suite, suite_import): if suite_import.name in processed_suites: return processed_suites.add(suite_import.name) dep_suite = mx.suite(suite_import.name) dep_module_name, _, _ = _python_module(dep_suite) moduleXml.element('orderEntry', attributes={'type': 'module', 'module-name': dep_module_name}) _add_declared_module(dep_suite) dep_suite.visit_imports(_mx_projects_suite) s.visit_imports(_mx_projects_suite) if s.name != 'mx': moduleXml.element('orderEntry', attributes={'type': 'module', 'module-name': 'mx.mx'}) moduleXml.close('component') moduleXml.close('module') moduleFile = join(module_dir, iml_file) mx.update_file(moduleFile, moduleXml.xml(indent=' ', newl='\n')) _add_declared_module(s) _add_declared_module(mx._mx_suite) if generate_native_projects: _intellij_native_projects(s, module_files_only, declared_modules, modulesXml) if generate_external_projects: _intellij_external_project(s.suiteDict.get('externalProjects', None), sdks, s) if not module_files_only: modulesXml.close('modules') modulesXml.close('component') modulesXml.close('project') moduleXmlFile = join(ideaProjectDirectory, 'modules.xml') mx.update_file(moduleXmlFile, modulesXml.xml(indent=' ', newl='\n')) if java_modules and not module_files_only: unique_library_file_names = set() librariesDirectory = mx.ensure_dir_exists(join(ideaProjectDirectory, 'libraries')) mx.ensure_dir_exists(librariesDirectory) def make_library(name, path, source_path, suite_dir): libraryXml = mx.XMLDoc() libraryXml.open('component', attributes={'name': 'libraryTable'}) libraryXml.open('library', attributes={'name': name}) libraryXml.open('CLASSES') pathX = mx.relpath_or_absolute(path, suite_dir, prefix='$PROJECT_DIR$') libraryXml.element('root', attributes={'url': 'jar://' + pathX + '!/'}) libraryXml.close('CLASSES') libraryXml.element('JAVADOC') if sourcePath: libraryXml.open('SOURCES') if os.path.isdir(sourcePath): sourcePathX = mx.relpath_or_absolute(sourcePath, suite_dir, prefix='$PROJECT_DIR$') libraryXml.element('root', attributes={'url': 'file://' + sourcePathX}) else: source_pathX = mx.relpath_or_absolute(source_path, suite_dir, prefix='$PROJECT_DIR$') libraryXml.element('root', attributes={'url': 'jar://' + source_pathX + '!/'}) libraryXml.close('SOURCES') else: libraryXml.element('SOURCES') libraryXml.close('library') libraryXml.close('component') libraryFile = join(librariesDirectory, _intellij_library_file_name(name, unique_library_file_names)) return mx.update_file(libraryFile, libraryXml.xml(indent=' ', newl='\n')) # Setup the libraries that were used above for library in libraries: sourcePath = None if library.isLibrary(): path = library.get_path(True) if library.sourcePath: sourcePath = library.get_source_path(True) elif library.isMavenProject(): path = library.get_path(True) sourcePath = library.get_source_path(True) elif library.isJARDistribution(): path = library.path if library.sourcesPath: sourcePath = library.sourcesPath elif library.isClasspathDependency(): path = library.classpath_repr() else: mx.abort('Dependency not supported: {} ({})'.format(library.name, library.__class__.__name__)) make_library(library.name, path, sourcePath, s.dir) jdk = mx.get_jdk() updated = False for library in jdk_libraries: if library.classpath_repr(jdk) is not None: if make_library(library.name, library.classpath_repr(jdk), library.get_source_path(jdk), s.dir): updated = True if jdk_libraries and updated: mx.log("Setting up JDK libraries using {0}".format(jdk)) # Set annotation processor profiles up, and link them to modules in compiler.xml compilerXml.open('component', attributes={'name': 'CompilerConfiguration'}) compilerXml.element('option', attributes={'name': "DEFAULT_COMPILER", 'value': 'Javac'}) # using the --release option with javac interferes with using --add-modules which is required for some projects compilerXml.element('option', attributes={'name': "USE_RELEASE_OPTION", 'value': 'false'}) compilerXml.element('resourceExtensions') compilerXml.open('wildcardResourcePatterns') compilerXml.element('entry', attributes={'name': '!?*.java'}) compilerXml.close('wildcardResourcePatterns') if annotationProcessorProfiles: compilerXml.open('annotationProcessing') for t, modules in sorted(annotationProcessorProfiles.items()): source_gen_dir = t[0] processors = t[1:] compilerXml.open('profile', attributes={'default': 'false', 'name': '-'.join([ap.name for ap in processors]) + "-" + source_gen_dir, 'enabled': 'true'}) compilerXml.element('sourceOutputDir', attributes={'name': join(os.pardir, source_gen_dir)}) compilerXml.element('sourceTestOutputDir', attributes={'name': join(os.pardir, source_gen_dir)}) compilerXml.open('processorPath', attributes={'useClasspath': 'false'}) # IntelliJ supports both directories and jars on the annotation processor path whereas # Eclipse only supports jars. for apDep in processors: def processApDep(dep, edge): if dep.isLibrary() or dep.isJARDistribution(): compilerXml.element('entry', attributes={'name': mx.relpath_or_absolute(dep.path, s.dir, prefix='$PROJECT_DIR$')}) elif dep.isProject(): compilerXml.element('entry', attributes={'name': mx.relpath_or_absolute(dep.output_dir(), s.dir, prefix='$PROJECT_DIR$')}) apDep.walk_deps(visit=processApDep) compilerXml.close('processorPath') for module in modules: compilerXml.element('module', attributes={'name': module.name}) compilerXml.close('profile') compilerXml.close('annotationProcessing') compilerXml.close('component') if compilerXml: compilerXml.close('project') compilerFile = join(ideaProjectDirectory, 'compiler.xml') mx.update_file(compilerFile, compilerXml.xml(indent=' ', newl='\n')) if not module_files_only: # Write misc.xml for global JDK config miscXml = mx.XMLDoc() miscXml.open('project', attributes={'version' : '4'}) if java_modules: mainJdk = mx.get_jdk() miscXml.open('component', attributes={'name' : 'ProjectRootManager', 'version': '2', 'languageLevel': _complianceToIntellijLanguageLevel(mainJdk.javaCompliance), 'project-jdk-name': intellij_get_java_sdk_name(sdks, mainJdk), 'project-jdk-type': intellij_java_sdk_type}) miscXml.element('output', attributes={'url' : 'file://$PROJECT_DIR$/' + os.path.relpath(s.get_output_root(), s.dir)}) miscXml.close('component') else: miscXml.element('component', attributes={'name' : 'ProjectRootManager', 'version': '2', 'project-jdk-name': intellij_get_python_sdk_name(sdks), 'project-jdk-type': intellij_python_sdk_type}) miscXml.close('project') miscFile = join(ideaProjectDirectory, 'misc.xml') mx.update_file(miscFile, miscXml.xml(indent=' ', newl='\n')) # Generate a default configuration for debugging Graal runConfig = mx.XMLDoc() runConfig.open('component', attributes={'name' : 'ProjectRunConfigurationManager'}) runConfig.open('configuration', attributes={'default' :'false', 'name' : 'GraalDebug', 'type' : 'Remote', 'factoryName': 'Remote'}) runConfig.element('option', attributes={'name' : 'USE_SOCKET_TRANSPORT', 'value' : 'true'}) runConfig.element('option', attributes={'name' : 'SERVER_MODE', 'value' : 'false'}) runConfig.element('option', attributes={'name' : 'SHMEM_ADDRESS', 'value' : 'javadebug'}) runConfig.element('option', attributes={'name' : 'HOST', 'value' : 'localhost'}) runConfig.element('option', attributes={'name' : 'PORT', 'value' : '8000'}) runConfig.open('RunnerSettings', attributes={'RunnerId' : 'Debug'}) runConfig.element('option', attributes={'name' : 'DEBUG_PORT', 'value' : '8000'}) runConfig.element('option', attributes={'name' : 'LOCAL', 'value' : 'false'}) runConfig.close('RunnerSettings') runConfig.element('method') runConfig.close('configuration') runConfig.close('component') runConfigFile = join(ideaProjectDirectory, 'runConfigurations', 'GraalDebug.xml') mx.ensure_dir_exists(join(ideaProjectDirectory, 'runConfigurations')) mx.update_file(runConfigFile, runConfig.xml(indent=' ', newl='\n')) if java_modules: # Eclipse formatter config corePrefsSources = s.eclipse_settings_sources().get('org.eclipse.jdt.core.prefs') uiPrefsSources = s.eclipse_settings_sources().get('org.eclipse.jdt.ui.prefs') if corePrefsSources: miscXml = mx.XMLDoc() miscXml.open('project', attributes={'version' : '4'}) out = StringIO() print('# GENERATED -- DO NOT EDIT', file=out) for source in corePrefsSources: print('# Source:', source, file=out) with open(source) as fileName: for line in fileName: if line.startswith('org.eclipse.jdt.core.formatter.'): print(line.strip(), file=out) formatterConfigFile = join(ideaProjectDirectory, 'EclipseCodeFormatter.prefs') mx.update_file(formatterConfigFile, out.getvalue()) importConfigFile = None if uiPrefsSources: out = StringIO() print('# GENERATED -- DO NOT EDIT', file=out) for source in uiPrefsSources: print('# Source:', source, file=out) with open(source) as fileName: for line in fileName: if line.startswith('org.eclipse.jdt.ui.importorder') \ or line.startswith('org.eclipse.jdt.ui.ondemandthreshold') \ or line.startswith('org.eclipse.jdt.ui.staticondemandthreshold'): print(line.strip(), file=out) importConfigFile = join(ideaProjectDirectory, 'EclipseImports.prefs') mx.update_file(importConfigFile, out.getvalue()) miscXml.open('component', attributes={'name' : 'EclipseCodeFormatterProjectSettings'}) miscXml.open('option', attributes={'name' : 'projectSpecificProfile'}) miscXml.open('ProjectSpecificProfile') miscXml.element('option', attributes={'name' : 'formatter', 'value' : 'ECLIPSE'}) custom_eclipse_exe = mx.get_env('ECLIPSE_EXE') if custom_eclipse_exe: custom_eclipse = dirname(custom_eclipse_exe) if mx.is_darwin(): custom_eclipse = join(dirname(custom_eclipse), 'Eclipse') if not exists(custom_eclipse_exe): mx.abort('Custom eclipse "{}" does not exist'.format(custom_eclipse_exe)) miscXml.element('option', attributes={'name' : 'eclipseVersion', 'value' : 'CUSTOM'}) miscXml.element('option', attributes={'name' : 'pathToEclipse', 'value' : custom_eclipse}) miscXml.element('option', attributes={'name' : 'pathToConfigFileJava', 'value' : '$PROJECT_DIR$/.idea/' + basename(formatterConfigFile)}) if importConfigFile: miscXml.element('option', attributes={'name' : 'importOrderConfigFilePath', 'value' : '$PROJECT_DIR$/.idea/' + basename(importConfigFile)}) miscXml.element('option', attributes={'name' : 'importOrderFromFile', 'value' : 'true'}) miscXml.close('ProjectSpecificProfile') miscXml.close('option') miscXml.close('component') miscXml.close('project') miscFile = join(ideaProjectDirectory, 'eclipseCodeFormatter.xml') mx.update_file(miscFile, miscXml.xml(indent=' ', newl='\n')) if java_modules: # Write codestyle settings mx.ensure_dir_exists(join(ideaProjectDirectory, 'codeStyles')) codeStyleConfigXml = mx.XMLDoc() codeStyleConfigXml.open('component', attributes={'name': 'ProjectCodeStyleConfiguration'}) codeStyleConfigXml.open('state') codeStyleConfigXml.element('option', attributes={'name': 'USE_PER_PROJECT_SETTINGS', 'value': 'true'}) codeStyleConfigXml.close('state') codeStyleConfigXml.close('component') codeStyleConfigFile = join(ideaProjectDirectory, 'codeStyles', 'codeStyleConfig.xml') mx.update_file(codeStyleConfigFile, codeStyleConfigXml.xml(indent=' ', newl='\n')) codeStyleProjectXml = mx.XMLDoc() codeStyleProjectXml.open('component', attributes={'name': 'ProjectCodeStyleConfiguration'}) codeStyleProjectXml.open('code_scheme', attributes={'name': 'Project', 'version': '173'}) codeStyleProjectXml.open('JavaCodeStyleSettings') # We cannot entirely disable wildcards import, but we can set the threshold to an insane number. codeStyleProjectXml.element('option', attributes={'name': 'CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND', 'value': '65536'}) codeStyleProjectXml.element('option', attributes={'name': 'NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND', 'value': '65536'}) codeStyleProjectXml.close('JavaCodeStyleSettings') codeStyleProjectXml.close('code_scheme') codeStyleProjectXml.close('component') codeStyleProjectFile = join(ideaProjectDirectory, 'codeStyles', 'Project.xml') mx.update_file(codeStyleProjectFile, codeStyleProjectXml.xml(indent=' ', newl='\n')) # Write checkstyle-idea.xml for the CheckStyle-IDEA checkstyleXml = mx.XMLDoc() checkstyleXml.open('project', attributes={'version': '4'}) checkstyleXml.open('component', attributes={'name': 'CheckStyle-IDEA'}) checkstyleXml.open('option', attributes={'name' : "configuration"}) checkstyleXml.open('map') if max_checkstyle_version: checkstyleXml.element('entry', attributes={'key': "checkstyle-version", 'value': str(max_checkstyle_version)}) # Initialize an entry for each style that is used checkstyleConfigs = set([]) for p in s.projects_recursive(): if not p.isJavaProject(): continue csConfig, checkstyleVersion, checkstyleProj = p.get_checkstyle_config() if not csConfig or csConfig in checkstyleConfigs: continue checkstyleConfigs.add(csConfig) checkstyleXml.element('entry', attributes={'key' : "location-" + str(len(checkstyleConfigs)), 'value': "PROJECT_RELATIVE:" + join(checkstyleProj.dir, ".checkstyle_checks.xml") + ":" + checkstyleProj.name}) checkstyleXml.close('map') checkstyleXml.close('option') checkstyleXml.close('component') checkstyleXml.close('project') checkstyleFile = join(ideaProjectDirectory, 'checkstyle-idea.xml') mx.update_file(checkstyleFile, checkstyleXml.xml(indent=' ', newl='\n')) # mx integration def antTargetName(dist): return 'archive_' + dist.name def artifactFileName(dist): return dist.name.replace('.', '_').replace('-', '_') + '.xml' validDistributions = [dist for dist in mx.sorted_dists() if not dist.suite.isBinarySuite() and not dist.isTARDistribution()] # 1) Make an ant file for archiving the distributions. antXml = mx.XMLDoc() antXml.open('project', attributes={'name': s.name, 'default': 'archive'}) for dist in validDistributions: antXml.open('target', attributes={'name': antTargetName(dist)}) antXml.open('exec', attributes={'executable': sys.executable}) antXml.element('arg', attributes={'value': join(mx._mx_home, 'mx.py')}) antXml.element('arg', attributes={'value': 'archive'}) antXml.element('arg', attributes={'value': '@' + dist.name}) antXml.close('exec') antXml.close('target') antXml.close('project') antFile = join(ideaProjectDirectory, 'ant-mx-archive.xml') mx.update_file(antFile, antXml.xml(indent=' ', newl='\n')) # 2) Tell IDEA that there is an ant-build. ant_mx_archive_xml = 'file://$PROJECT_DIR$/.idea/ant-mx-archive.xml' metaAntXml = mx.XMLDoc() metaAntXml.open('project', attributes={'version': '4'}) metaAntXml.open('component', attributes={'name': 'AntConfiguration'}) metaAntXml.open('buildFile', attributes={'url': ant_mx_archive_xml}) metaAntXml.close('buildFile') metaAntXml.close('component') metaAntXml.close('project') metaAntFile = join(ideaProjectDirectory, 'ant.xml') mx.update_file(metaAntFile, metaAntXml.xml(indent=' ', newl='\n')) # 3) Make an artifact for every distribution validArtifactNames = {artifactFileName(dist) for dist in validDistributions} artifactsDir = join(ideaProjectDirectory, 'artifacts') mx.ensure_dir_exists(artifactsDir) for fileName in os.listdir(artifactsDir): filePath = join(artifactsDir, fileName) if os.path.isfile(filePath) and fileName not in validArtifactNames: os.remove(filePath) for dist in validDistributions: artifactXML = mx.XMLDoc() artifactXML.open('component', attributes={'name': 'ArtifactManager'}) artifactXML.open('artifact', attributes={'build-on-make': 'true', 'name': dist.name}) artifactXML.open('output-path', data='$PROJECT_DIR$/mxbuild/artifacts/' + dist.name) artifactXML.close('output-path') artifactXML.open('properties', attributes={'id': 'ant-postprocessing'}) artifactXML.open('options', attributes={'enabled': 'true'}) artifactXML.open('file', data=ant_mx_archive_xml) artifactXML.close('file') artifactXML.open('target', data=antTargetName(dist)) artifactXML.close('target') artifactXML.close('options') artifactXML.close('properties') artifactXML.open('root', attributes={'id': 'root'}) for javaProject in [dep for dep in dist.archived_deps() if dep.isJavaProject()]: artifactXML.element('element', attributes={'id': 'module-output', 'name': javaProject.name}) for javaProject in [dep for dep in dist.deps if dep.isLibrary() or dep.isDistribution()]: artifactXML.element('element', attributes={'id': 'artifact', 'artifact-name': javaProject.name}) artifactXML.close('root') artifactXML.close('artifact') artifactXML.close('component') artifactFile = join(artifactsDir, artifactFileName(dist)) mx.update_file(artifactFile, artifactXML.xml(indent=' ', newl='\n')) def intellij_scm_name(vc_kind): if vc_kind == 'git': return 'Git' elif vc_kind == 'hg': return 'hg4idea' vcsXml = mx.XMLDoc() vcsXml.open('project', attributes={'version': '4'}) vcsXml.open('component', attributes={'name': 'VcsDirectoryMappings'}) suites_for_vcs = mx.suites() + ([mx._mx_suite] if mx_python_modules else []) sourceSuitesWithVCS = [vc_suite for vc_suite in suites_for_vcs if vc_suite.isSourceSuite() and vc_suite.vc is not None] uniqueSuitesVCS = {(vc_suite.vc_dir, vc_suite.vc.kind) for vc_suite in sourceSuitesWithVCS} for vcs_dir, kind in uniqueSuitesVCS: vcsXml.element('mapping', attributes={'directory': vcs_dir, 'vcs': intellij_scm_name(kind)}) vcsXml.close('component') vcsXml.close('project') vcsFile = join(ideaProjectDirectory, 'vcs.xml') mx.update_file(vcsFile, vcsXml.xml(indent=' ', newl='\n'))
def inspect(args): """launch a given program under the Inspector Run Maxine under the Inspector. The arguments accepted by this command are those accepted by the 'mx vm' command plus the Inspector specific options. To debug a program in the Inspector, simply replace 'vm' on the command line that launches the program with 'inspect'. Use "mx inspect --help" to see what the Inspector options are. These options must be specified with a '--' prefix so that they can be distinguished from the VM options. The inspect command also accepts the same system property related options as the 'image' command except that a '--' prefix must be used (e.g. '--os Darwin --bits 32'). Use "mx help image" for more detail. Use "mx vm -help" to see what the VM options are.""" saveClassDir = join(_vmdir, 'inspected_classes') maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split() vmArgs = ['-XX:SaveClassDir=' + saveClassDir, '-XX:+TrapOnError' ] + maxvmOptions insArgs = ['-vmdir=' + _vmdir] if not isdir(saveClassDir): os.makedirs(saveClassDir) sysProps = [] sysProps += ['-Xbootclasspath/a:' + mx.distribution('GRAAL').path] insCP = [] cwdArgs = check_cwd_change(args) cwd = cwdArgs[0] args = cwdArgs[1] i = 0 remote = False while i < len(args): arg = args[i] if arg.startswith('-XX:LogFile='): logFile = arg.split('=', 1)[1] vmArgs += [arg] os.environ['TELE_LOG_FILE'] = 'tele-' + logFile elif arg in ['-cp', '-classpath']: vmArgs += [arg, args[i + 1]] insCP += [mx.expand_project_in_class_path_arg(args[i + 1])] i += 1 elif arg == '-jar': vmArgs += ['-jar', args[i + 1]] insCP += [args[i + 1]] i += 1 elif arg == '--remote': remote = True elif arg in [ '--platform', '--cpu', '--isa', '--os', '--endianness', '--bits', '--page', '--nsig' ]: name = arg.lstrip('-') i += 1 value = args[i] sysProps += ['-Dmax.' + name + '=' + value] elif arg.startswith('--cp='): insCP += [arg[len('--cp='):]] elif arg.startswith('--'): # chomp leading '-' insArgs += [arg[1:]] elif arg.startswith('-XX:SaveClassDir='): vmArgs += [arg] saveClassDir = arg.split('=', 1)[1] if not isdir(saveClassDir): os.makedirs(saveClassDir) elif arg.startswith('-'): vmArgs += [arg] else: # This is the main class argument; copy it and any following # arguments to the VM verbatim vmArgs += args[i:] break i += 1 insCP += [saveClassDir] insCP = pathsep.join(insCP) insArgs += ['-cp=' + insCP] mx.expand_project_in_args(vmArgs) cmd = [mx.get_jdk().java] cmd += mx.get_jdk().processArgs(sysProps + [ '-cp', suite_classpath() + pathsep + insCP, 'com.sun.max.ins.MaxineInspector' ] + insArgs + ['-a=' + ' '.join(vmArgs)]) if mx.is_darwin() and not remote: # The -E option propagates the environment variables into the sudo process mx.run([ 'sudo', '-E', '-p', 'Debugging is a privileged operation on Mac OS X. Please enter your "sudo" password:' ] + cmd, cwd=cwd) else: mx.run(cmd, cwd=cwd, env=ldenv)
import mx_gate import mx_sdk import mx_truffle import mx_unittest _SUITE = mx.suite('trufflesqueak') LANGUAGE_ID = 'smalltalk' PACKAGE_NAME = 'de.hpi.swa.trufflesqueak' BASE_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) BASE_VM_ARGS = [ # Tweak Runtime '-Xss64M', # Increase stack size (`-XX:ThreadStackSize=64M` not working) ] if mx.is_darwin(): BASE_VM_ARGS.append('-Xdock:name=TruffleSqueak') BASE_VM_ARGS_TESTING = BASE_VM_ARGS[:] BASE_VM_ARGS_TESTING.extend([ # Tweak GC for GitHub Actions '-Xms4G', # Initial heap size '-XX:MetaspaceSize=32M', # Initial size of Metaspaces ]) IS_JDK9_AND_LATER = mx.get_jdk(tag='default').javaCompliance > '1.8' if IS_JDK9_AND_LATER: ADD_OPENS = [ # Make Truffle.getRuntime() accessible for VM introspection '--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime=ALL-UNNAMED',