Skip to content

Commit 306ad5f

Browse files
Guarded imports with a NO_SWIFTPM macro (#41)
* Guarded imports with a NO_SWIFTPM macro * Added non-swiftpm installation isntructions * fixed code voice
1 parent 2f9e98a commit 306ad5f

35 files changed

+84
-0
lines changed

Diff for: README.md

+16
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ build.
5858
Once you do that, you can add LLVMSwift as a dependency for your own Swift
5959
compiler projects!
6060

61+
### Installation without Swift Package Manager
62+
63+
We really recommend using SwiftPM with LLVMSwift, but if your project is
64+
structured in such a way that makes using SwiftPM impractical or impossible,
65+
you can still use LLVMSwift by passing the `-DNO_SWIFTPM` to swift when
66+
compiling.
67+
68+
- Xcode:
69+
- Add this repository as a git submodule
70+
- Add the files in `Sources/` to your Xcode project.
71+
- Under `Other Swift Flags`, add `-DNO_SWIFTPM`.
72+
- Under `Library Search Paths` add the output of `llvm-config --libdir`
73+
- Under `Header Search Paths` add the output of `llvm-config --includedir`
74+
- Under `Link Target with Libraries` drag in
75+
`/path/to/your/llvm/lib/libLLVM.dylib`
76+
6177
This project is used by [Trill](https://github.com/harlanhaskins/trill) for
6278
all its code generation.
6379

Diff for: Sources/LLVM/Alias.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// An `Alias` represents a global alias in an LLVM module - a new symbol and
46
/// corresponding metadata for an existing position

Diff for: Sources/LLVM/ArrayType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `ArrayType` is a very simple derived type that arranges elements
46
/// sequentially in memory. `ArrayType` requires a size (number of elements) and

Diff for: Sources/LLVM/BasicBlock.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A `BasicBlock` represents a basic block in an LLVM IR program. A basic
46
/// block contains a sequence of instructions, a pointer to its parent block and

Diff for: Sources/LLVM/FloatType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `FloatType` enumerates representations of a floating value of a particular
46
/// bit width and semantics.

Diff for: Sources/LLVM/Function.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// Enumerates the calling conventions supported by LLVM.
46
///

Diff for: Sources/LLVM/FunctionType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `FunctionType` represents a function's type signature. It consists of a
46
/// return type and a list of formal parameter types. The return type of a

Diff for: Sources/LLVM/Global.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A `Global` represents a region of memory allocated at compile time instead
46
/// of at runtime. A global variable must either have an initializer, or make

Diff for: Sources/LLVM/IRBuilder.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// Species the behavior that should occur on overflow during mathematical
46
/// operations.

Diff for: Sources/LLVM/IRGlobal.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// An `IRGlobal` is a value, alias, or function that exists at the top level of
46
/// an LLVM module.

Diff for: Sources/LLVM/IRType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// An `IRType` is a type that is capable of lowering itself to an `LLVMTypeRef`
46
/// object for use with LLVM's C API.

Diff for: Sources/LLVM/IRValue+Kinds.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

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

Diff for: Sources/LLVM/IRValue.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// An `IRValue` is a type that is capable of lowering itself to an
46
/// `LLVMValueRef` object for use with LLVM's C API.

Diff for: Sources/LLVM/Initialization.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// Lazy static initializer that calls LLVM initialization functions only once.
46
let llvmInitializer: Void = {

Diff for: Sources/LLVM/Instruction.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// An `Instruction` represents an instruction residing in a basic block.
46
public struct Instruction: IRValue {

Diff for: Sources/LLVM/IntType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// The `IntType` represents an integral value of a specified bit width.
46
///

Diff for: Sources/LLVM/JIT.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// JITError represents the different kinds of errors the JIT compiler can
46
/// throw.

Diff for: Sources/LLVM/LabelType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `LabelType` represents code labels.
46
public struct LabelType: IRType {

Diff for: Sources/LLVM/Linkage.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `Visibility` enumerates available visibility styles.
46
public enum Visibility {

Diff for: Sources/LLVM/MemoryBuffer.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// Enumerates the possible failures that can be thrown initializing
46
/// a MemoryBuffer.

Diff for: Sources/LLVM/MetadataType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// The `MetadataType` type represents embedded metadata. No derived types may
46
/// be created from metadata except for function arguments.

Diff for: Sources/LLVM/Module.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A `Context` represents execution states for the core LLVM IR system.
46
public class Context {

Diff for: Sources/LLVM/OpCode.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// Enumerates the opcodes of instructions available in the LLVM IR language.
46
///

Diff for: Sources/LLVM/PassManager.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A subset of supported LLVM IR optimizer passes.
46
public enum FunctionPass {

Diff for: Sources/LLVM/PhiNode.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A `PhiNode` object represents a PHI node.
46
///

Diff for: Sources/LLVM/PointerType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `PointerType` is used to specify memory locations. Pointers are commonly
46
/// used to reference objects in memory.

Diff for: Sources/LLVM/StructType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `StructType` is used to represent a collection of data members together in
46
/// memory. The elements of a structure may be any type that has a size.

Diff for: Sources/LLVM/Switch.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A `Switch` represents a `switch` instruction. A `switch` instruction
46
/// defines a jump table of values and destination basic blocks to pass the flow

Diff for: Sources/LLVM/TargetData.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A `TargetData` encapsulates information about the data requirements of a
46
/// particular target architecture and can be used to retrieve information about

Diff for: Sources/LLVM/TargetMachine.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// The supported types of files codegen can produce.
46
public enum CodegenFileType {

Diff for: Sources/LLVM/TokenType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `TokenType` is used when a value is associated with an instruction but all
46
/// uses of the value must not attempt to introspect or obscure it. As such, it

Diff for: Sources/LLVM/Use.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `Use` represents an iterator over the uses and users of a particular value
46
/// in an LLVM program.

Diff for: Sources/LLVM/VectorType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// A `VectorType` is a simple derived type that represents a vector of
46
/// elements. `VectorType`s are used when multiple primitive data are operated

Diff for: Sources/LLVM/VoidType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// The `Void` type represents any value and has no size.
46
public struct VoidType: IRType {

Diff for: Sources/LLVM/X86MMXType.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if !NO_SWIFTPM
12
import cllvm
3+
#endif
24

35
/// `X86MMXType` represents a value held in an MMX register on an x86 machine.
46
///

0 commit comments

Comments
 (0)