@Test public void testAppleDynamicLibraryWithDsym() throws Exception { assumeTrue(Platform.detect() == Platform.MACOS); assumeTrue(AppleNativeIntegrationTestUtils.isApplePlatformAvailable(ApplePlatform.MACOSX)); ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_library_shared", tmp); workspace.setUp(); ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath()); ProjectWorkspace.ProcessResult result = workspace.runBuckCommand( "build", "//Libraries/TestLibrary:TestLibrary#shared,macosx-x86_64,dwarf-and-dsym", "--config", "cxx.cflags=-g"); result.assertSuccess(); Path output = tmp.getRoot() .resolve(filesystem.getBuckPaths().getGenDir()) .resolve("Libraries/TestLibrary/TestLibrary#macosx-x86_64,shared") .resolve("libLibraries_TestLibrary_TestLibrary.dylib"); assertThat(Files.exists(output), is(true)); Path dsymPath = tmp.getRoot() .resolve(filesystem.getBuckPaths().getGenDir()) .resolve("Libraries/TestLibrary") .resolve("TestLibrary#apple-dsym,macosx-x86_64,shared.dSYM"); assertThat(Files.exists(dsymPath), is(true)); AppleDsymTestUtil.checkDsymFileHasDebugSymbol("+[TestClass answer]", workspace, dsymPath); }
private ImmutableList<String> getExtraFlagsForHeaderMaps(ProjectFilesystem filesystem) throws IOException { // This works around OS X being amusing about the location of temp directories. return PREPROCESSOR_SUPPORTS_HEADER_MAPS ? ImmutableList.of("-I", filesystem.getBuckPaths().getBuckOut().toString()) : ImmutableList.<String>of(); }
private int handleGet(Request baseRequest, HttpServletResponse response) throws IOException { if (!artifactCache.isPresent()) { response.getWriter().write("Serving local cache is disabled for this instance."); return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } String path = baseRequest.getUri().getPath(); String[] pathElements = path.split("/"); if (pathElements.length != 4 || !pathElements[2].equals("key")) { response.getWriter().write("Incorrect url format."); return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } RuleKey ruleKey = new RuleKey(pathElements[3]); Path temp = null; try { projectFilesystem.mkdirs(projectFilesystem.getBuckPaths().getScratchDir()); temp = projectFilesystem.createTempFile( projectFilesystem.getBuckPaths().getScratchDir(), "outgoing_rulekey", ".tmp"); CacheResult fetchResult = artifactCache.get().fetch(ruleKey, LazyPath.ofInstance(temp)); if (!fetchResult.getType().isSuccess()) { return HttpServletResponse.SC_NOT_FOUND; } final Path tempFinal = temp; HttpArtifactCacheBinaryProtocol.FetchResponse fetchResponse = new HttpArtifactCacheBinaryProtocol.FetchResponse( ImmutableSet.of(ruleKey), fetchResult.getMetadata(), new ByteSource() { @Override public InputStream openStream() throws IOException { return projectFilesystem.newFileInputStream(tempFinal); } }); fetchResponse.write(response.getOutputStream()); response.setContentLengthLong(fetchResponse.getContentLength()); return HttpServletResponse.SC_OK; } finally { if (temp != null) { projectFilesystem.deleteFileAtPathIfExists(temp); } } }
private int handlePut(Request baseRequest, HttpServletResponse response) throws IOException { if (!artifactCache.isPresent()) { response.getWriter().write("Serving local cache is disabled for this instance."); return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } Path temp = null; try { projectFilesystem.mkdirs(projectFilesystem.getBuckPaths().getScratchDir()); temp = projectFilesystem.createTempFile( projectFilesystem.getBuckPaths().getScratchDir(), "incoming_upload", ".tmp"); StoreResponseReadResult storeRequest; try (DataInputStream requestInputData = new DataInputStream(baseRequest.getInputStream()); OutputStream tempFileOutputStream = projectFilesystem.newFileOutputStream(temp)) { storeRequest = HttpArtifactCacheBinaryProtocol.readStoreRequest( requestInputData, tempFileOutputStream); } if (!storeRequest.getActualHashCode().equals(storeRequest.getExpectedHashCode())) { response.getWriter().write("Checksum mismatch."); return HttpServletResponse.SC_NOT_ACCEPTABLE; } artifactCache .get() .store( ArtifactInfo.builder() .setRuleKeys(storeRequest.getRuleKeys()) .setMetadata(storeRequest.getMetadata()) .build(), BorrowablePath.notBorrowablePath(temp)); return HttpServletResponse.SC_ACCEPTED; } finally { if (temp != null) { projectFilesystem.deleteFileAtPathIfExists(temp); } } }