def _generate_unified(self): script = self._get_generate_unified_sources_script() if not script: return with tempfile.NamedTemporaryFile(dir=self._get_temp_dir()) as output: # We need to define BUILD_SCRIPTS_DIR so that the bash script we're # invoking can find the ruby script that it invokes. If we don't # define BUILD_SCRIPTS_DIR, the bash script we're invoking with try # to define its own value for BUILD_SCRIPTS_DIR, but it will do so # incorrectly for our purposes, leading to dire results. env = os.environ.copy() env["BUILD_SCRIPTS_DIR"] = self.application.get_build_scripts_dir() util.subprocess_run([ script, "--generate-xcfilelists", "--output-xcfilelist-path", output.name ], env=env) input_lines = None output_lines = self._get_file_lines(output.name) output_lines = self._unexpand(output_lines, "BUILT_PRODUCTS_DIR") self.added_lines_input_unified = self._find_added_lines( input_lines, self._get_input_unified_xcfilelist_project_path()) self.added_lines_output_unified = self._find_added_lines( output_lines, self._get_output_unified_xcfilelist_project_path())
def _generate_derived(self): script = self._get_generate_derived_sources_script() if not script: return with tempfile.NamedTemporaryFile(dir=self._get_temp_dir()) as input, \ tempfile.NamedTemporaryFile(dir=self._get_temp_dir()) as output: (stdout, stderr) = util.subprocess_run([ script, "NO_SUPPLEMENTAL_FILES=1", "--no-builtin-rules", "--dry-run", "--always-make", "--debug=abvijm", "all" ]) stdout = stdout.encode() if isinstance(stdout, str) else stdout (stdout, stderr) = util.subprocess_run([ self.application.get_extract_dependencies_from_makefile_script( ), "--input", input.name, "--output", output.name ], input=stdout) # TODO: Make this generator-specific (there's no need to reference # WebCore, for example, when processing the JavaScriptCore # project). input_lines = self._get_file_lines(input.name) output_lines = self._get_file_lines(output.name) input_lines = self._replace(input_lines, "^JavaScriptCore/", "$(PROJECT_DIR)/") input_lines = self._replace( input_lines, "^JavaScriptCorePrivateHeaders/", "$(JAVASCRIPTCORE_PRIVATE_HEADERS_DIR)/") input_lines = self._replace(input_lines, "^WebCore/", "$(PROJECT_DIR)/") input_lines = self._replace(input_lines, "^WebKit2PrivateHeaders/", "$(WEBKIT2_PRIVATE_HEADERS_DIR)/") input_lines = self._unexpand(input_lines, "JAVASCRIPTCORE_PRIVATE_HEADERS_DIR") input_lines = self._unexpand(input_lines, "PROJECT_DIR") input_lines = self._unexpand(input_lines, "WEBCORE_PRIVATE_HEADERS_DIR") input_lines = self._unexpand(input_lines, "WEBKIT2_PRIVATE_HEADERS_DIR") input_lines = self._unexpand( input_lines, "WEBKITADDITIONS_HEADERS_FOLDER_PATH") input_lines = self._unexpand( input_lines, "BUILT_PRODUCTS_DIR" ) # Do this last, since it's a prefix of some other variables and will "intercept" them if executed earlier than them. output_lines = self._replace(output_lines, "^", self._get_derived_sources_dir() + "/") output_lines = self._unexpand(output_lines, "BUILT_PRODUCTS_DIR") self.added_lines_input_derived = self._find_added_lines( input_lines, self._get_input_derived_xcfilelist_project_path()) self.added_lines_output_derived = self._find_added_lines( output_lines, self._get_output_derived_xcfilelist_project_path())
def _sublaunch_under_xcode(self, sublaunch_args): xcode_parameters = [ "xcodebuild", "-project", self._get_project_file_path(), "-sdk", SDK.get_preferred_sdk_for_platform(self.platform).as_xcode_specification(), "-configuration", self.configuration, "-target", "Apply Configuration to XCFileLists", "SYMROOT={}".format(self._get_sym_root()), "OBJROOT={}".format(self._get_obj_root()), "SHARED_PRECOMPS_DIR={}".format(self._get_shared_precomps_dir())] # TODO: sublaunch_args will contain the path to the script to # sublaunch. There might be a problem if there's a space in that path. util.subprocess_run(xcode_parameters, env={"WK_SUBLAUNCH_SCRIPT_PARAMETERS": " ".join(sublaunch_args)})
def read_xcode_user_default(key): try: (stdout, stderr) = util.subprocess_run( ["defaults", "read", "com.apple.dt.Xcode", key]) return stdout.strip() except util.CalledProcessError: return None