It is a wrapper around LLVM.
//! A helper class for dealing with static archives
-use llvm::{ArchiveRef, llvm};
-
-use libc;
use std::io::process::{Command, ProcessOutput};
use std::io::{fs, TempDir};
use std::io;
-use std::mem;
use std::os;
-use std::raw;
use std::str;
use syntax::abi;
use ErrorHandler = syntax::diagnostic::Handler;
maybe_ar_prog: Option<String>
}
-pub struct ArchiveRO {
- ptr: ArchiveRef,
-}
-
fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
args: &str, cwd: Option<&Path>,
paths: &[&Path]) -> ProcessOutput {
}
}
-impl ArchiveRO {
- /// Opens a static archive for read-only purposes. This is more optimized
- /// than the `open` method because it uses LLVM's internal `Archive` class
- /// rather than shelling out to `ar` for everything.
- ///
- /// If this archive is used with a mutable method, then an error will be
- /// raised.
- pub fn open(dst: &Path) -> Option<ArchiveRO> {
- unsafe {
- let ar = dst.with_c_str(|dst| {
- llvm::LLVMRustOpenArchive(dst)
- });
- if ar.is_null() {
- None
- } else {
- Some(ArchiveRO { ptr: ar })
- }
- }
- }
-
- /// Reads a file in the archive
- pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> {
- unsafe {
- let mut size = 0 as libc::size_t;
- let ptr = file.with_c_str(|file| {
- llvm::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
- });
- if ptr.is_null() {
- None
- } else {
- Some(mem::transmute(raw::Slice {
- data: ptr,
- len: size as uint,
- }))
- }
- }
- }
-}
-
-impl Drop for ArchiveRO {
- fn drop(&mut self) {
- unsafe {
- llvm::LLVMRustDestroyArchive(self.ptr);
- }
- }
-}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use super::archive::ArchiveRO;
use super::link;
use driver::session;
use driver::config;
+use llvm::archive_ro::ArchiveRO;
use llvm::{ModuleRef, TargetMachineRef, llvm, True, False};
use metadata::cstore;
use util::common::time;
//! no means all of the necessary details. Take a look at the rest of
//! metadata::loader or metadata::creader for all the juicy details!
-use back::archive::{ArchiveRO, METADATA_FILENAME};
+use back::archive::{METADATA_FILENAME};
use back::svh::Svh;
use driver::session::Session;
use lib::llvm::{False, llvm, ObjectFile, mk_section_iter};
+use lib::llvm::archive_ro::ArchiveRO;
use metadata::cstore::{MetadataBlob, MetadataVec, MetadataArchive};
use metadata::decoder;
use metadata::encoder;
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! A wrapper around LLVM's archive (.a) code
+
+use libc;
+use ArchiveRef;
+use llvm;
+
+use std::raw;
+use std::mem;
+
+pub struct ArchiveRO {
+ ptr: ArchiveRef,
+}
+
+impl ArchiveRO {
+ /// Opens a static archive for read-only purposes. This is more optimized
+ /// than the `open` method because it uses LLVM's internal `Archive` class
+ /// rather than shelling out to `ar` for everything.
+ ///
+ /// If this archive is used with a mutable method, then an error will be
+ /// raised.
+ pub fn open(dst: &Path) -> Option<ArchiveRO> {
+ unsafe {
+ let ar = dst.with_c_str(|dst| {
+ llvm::LLVMRustOpenArchive(dst)
+ });
+ if ar.is_null() {
+ None
+ } else {
+ Some(ArchiveRO { ptr: ar })
+ }
+ }
+ }
+
+ /// Reads a file in the archive
+ pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> {
+ unsafe {
+ let mut size = 0 as libc::size_t;
+ let ptr = file.with_c_str(|file| {
+ llvm::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
+ });
+ if ptr.is_null() {
+ None
+ } else {
+ Some(mem::transmute(raw::Slice {
+ data: ptr,
+ len: size as uint,
+ }))
+ }
+ }
+ }
+}
+
+impl Drop for ArchiveRO {
+ fn drop(&mut self) {
+ unsafe {
+ llvm::LLVMRustDestroyArchive(self.ptr);
+ }
+ }
+}
use std::c_str::ToCStr;
use libc::{c_uint, c_ushort, uint64_t, c_int, size_t};
+pub mod archive_ro;
+
pub type Opcode = u32;
pub type Bool = c_uint;