Skip to content

Commit

Permalink
Merge pull request rust-lang#142 from MarkMcCaskey/master
Browse files Browse the repository at this point in the history
Store LLVM version info directly in internal_macros
  • Loading branch information
TheDan64 authored Dec 14, 2019
2 parents 885b487 + d9efd66 commit 0a864eb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 56 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ edition = "2018"

[features]
default = ["target-all"]
# Please update internal_macros::FEATURE_VERSIONS when adding a new LLVM version
llvm3-6 = []
llvm3-7 = []
llvm3-8 = []
Expand Down
5 changes: 0 additions & 5 deletions internal_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.1.0"
authors = ["Daniel Kolsoi <thadan64@gmail.com>"]
description = "Internal macro crate for inkwell"
edition = "2018"
build = "build.rs"
repository = "https://github.com/TheDan64/inkwell"
readme = "README.md"
license = "Apache-2.0"
Expand All @@ -14,9 +13,5 @@ quote = "0.6"
syn = { version = "0.15", features = ["full", "fold"] }
proc-macro2 = "0.4"

[build-dependencies]
cargo_toml = "0.8"
reqwest = "0.9"

[lib]
proc-macro = true
41 changes: 0 additions & 41 deletions internal_macros/build.rs

This file was deleted.

15 changes: 5 additions & 10 deletions internal_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ use syn::fold::Fold;
use syn::spanned::Spanned;
use syn::{Token, LitFloat, Ident, Item, Field, Variant, Attribute};

const FEATURES_ENV: &str = env!("INKWELL_FEATURES");

/// Fetches a vector of feature version strings, e.g. llvm8-0
fn get_feature_versions() -> Vec<&'static str> {
FEATURES_ENV
.split(',')
.collect()
}
// This array should match the LLVM features in the top level Cargo manifest
const FEATURE_VERSIONS: [&str; 9] =
["llvm3-6", "llvm3-7", "llvm3-8", "llvm3-9", "llvm4-0", "llvm5-0", "llvm6-0", "llvm7-0", "llvm8-0"];

/// Gets the index of the feature version that represents `latest`
fn get_latest_feature_index(features: &[&str]) -> usize {
Expand All @@ -43,7 +38,7 @@ fn get_feature_index(features: &[&str], feature: String, span: Span) -> Result<u

/// Gets a vector of feature versions represented by the given VersionType
fn get_features(vt: VersionType) -> Result<Vec<&'static str>> {
let features = get_feature_versions();
let features = FEATURE_VERSIONS;
let latest = get_latest_feature_index(&features);
match vt {
VersionType::Specific(version, span) => {
Expand Down Expand Up @@ -189,7 +184,7 @@ struct FeatureSet(Vec<&'static str>, Option<Error>);
impl Default for FeatureSet {
fn default() -> Self {
// Default to all versions
Self(get_feature_versions(), None)
Self(FEATURE_VERSIONS.to_vec(), None)
}
}
impl Parse for FeatureSet {
Expand Down

0 comments on commit 0a864eb

Please sign in to comment.