Skip to content

Guarded imports with a NO_SWIFTPM macro #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ build.
Once you do that, you can add LLVMSwift as a dependency for your own Swift
compiler projects!

### Installation without Swift Package Manager

We really recommend using SwiftPM with LLVMSwift, but if your project is
structured in such a way that makes using SwiftPM impractical or impossible,
you can still use LLVMSwift by passing the `-DNO_SWIFTPM` to swift when
compiling.

- Xcode:
- Add this repository as a git submodule
- Add the files in `Sources/` to your Xcode project.
- Under `Other Swift Flags`, add `-DNO_SWIFTPM`.
- Under `Library Search Paths` add the output of `llvm-config --libdir`
- Under `Header Search Paths` add the output of `llvm-config --includedir`
- Under `Link Target with Libraries` drag in
`/path/to/your/llvm/lib/libLLVM.dylib`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental automatic fold?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, intentional respecting 80-characters


This project is used by [Trill](https://github.com/harlanhaskins/trill) for
all its code generation.

Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Alias.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// An `Alias` represents a global alias in an LLVM module - a new symbol and
/// corresponding metadata for an existing position
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/ArrayType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `ArrayType` is a very simple derived type that arranges elements
/// sequentially in memory. `ArrayType` requires a size (number of elements) and
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/BasicBlock.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A `BasicBlock` represents a basic block in an LLVM IR program. A basic
/// block contains a sequence of instructions, a pointer to its parent block and
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/FloatType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `FloatType` enumerates representations of a floating value of a particular
/// bit width and semantics.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Function.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// Enumerates the calling conventions supported by LLVM.
///
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/FunctionType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `FunctionType` represents a function's type signature. It consists of a
/// return type and a list of formal parameter types. The return type of a
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Global.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A `Global` represents a region of memory allocated at compile time instead
/// of at runtime. A global variable must either have an initializer, or make
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/IRBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// Species the behavior that should occur on overflow during mathematical
/// operations.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/IRGlobal.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// An `IRGlobal` is a value, alias, or function that exists at the top level of
/// an LLVM module.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/IRType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// An `IRType` is a type that is capable of lowering itself to an `LLVMTypeRef`
/// object for use with LLVM's C API.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/IRValue+Kinds.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

// Automatically generated from the macros in llvm/Core.h

Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/IRValue.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// An `IRValue` is a type that is capable of lowering itself to an
/// `LLVMValueRef` object for use with LLVM's C API.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Initialization.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// Lazy static initializer that calls LLVM initialization functions only once.
let llvmInitializer: Void = {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Instruction.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// An `Instruction` represents an instruction residing in a basic block.
public struct Instruction: IRValue {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/IntType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// The `IntType` represents an integral value of a specified bit width.
///
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/JIT.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// JITError represents the different kinds of errors the JIT compiler can
/// throw.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/LabelType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `LabelType` represents code labels.
public struct LabelType: IRType {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Linkage.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `Visibility` enumerates available visibility styles.
public enum Visibility {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/MemoryBuffer.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// Enumerates the possible failures that can be thrown initializing
/// a MemoryBuffer.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/MetadataType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// The `MetadataType` type represents embedded metadata. No derived types may
/// be created from metadata except for function arguments.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Module.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A `Context` represents execution states for the core LLVM IR system.
public class Context {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/OpCode.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// Enumerates the opcodes of instructions available in the LLVM IR language.
///
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/PassManager.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A subset of supported LLVM IR optimizer passes.
public enum FunctionPass {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/PhiNode.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A `PhiNode` object represents a PHI node.
///
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/PointerType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `PointerType` is used to specify memory locations. Pointers are commonly
/// used to reference objects in memory.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/StructType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `StructType` is used to represent a collection of data members together in
/// memory. The elements of a structure may be any type that has a size.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Switch.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A `Switch` represents a `switch` instruction. A `switch` instruction
/// defines a jump table of values and destination basic blocks to pass the flow
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/TargetData.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A `TargetData` encapsulates information about the data requirements of a
/// particular target architecture and can be used to retrieve information about
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/TargetMachine.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// The supported types of files codegen can produce.
public enum CodegenFileType {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/TokenType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `TokenType` is used when a value is associated with an instruction but all
/// uses of the value must not attempt to introspect or obscure it. As such, it
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/Use.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `Use` represents an iterator over the uses and users of a particular value
/// in an LLVM program.
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/VectorType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// A `VectorType` is a simple derived type that represents a vector of
/// elements. `VectorType`s are used when multiple primitive data are operated
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/VoidType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// The `Void` type represents any value and has no size.
public struct VoidType: IRType {
Expand Down
2 changes: 2 additions & 0 deletions Sources/LLVM/X86MMXType.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if !NO_SWIFTPM
import cllvm
#endif

/// `X86MMXType` represents a value held in an MMX register on an x86 machine.
///
Expand Down