From 0badf8179ebc57c3ea07eaf64fb73f235daf0c19 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 12 Jun 2014 13:36:50 +1000 Subject: [PATCH 1/5] Modify makefile and configure to work with servo build system. --- Makefile.in | 62 ++++++++++++++++------------------------------------- configure | 20 ++--------------- 2 files changed, 21 insertions(+), 61 deletions(-) diff --git a/Makefile.in b/Makefile.in index 20fd0bd..ad4f38b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,53 +1,29 @@ -RUSTC := rustc -BUILDDIR := build -RUSTFLAGS := -O --cfg ndebug -INSTALL_DIR := %PREFIX% +VPATH=%VPATH% -PHF_LIB := src/phf.rs -PHF := $(foreach file,$(shell $(RUSTC) --crate-file-name $(PHF_LIB)),$(BUILDDIR)/$(file)) -PHF_MAC_LIB := src/phf_mac.rs -PHF_MAC := $(BUILDDIR)/$(shell $(RUSTC) --crate-file-name $(PHF_MAC_LIB)) -PHF_TEST_MAIN := src/test.rs -PHF_TEST := $(BUILDDIR)/$(shell $(RUSTC) --crate-file-name $(PHF_TEST_MAIN)) +RUSTC ?= rustc +RUSTDOC ?= rustdoc +RUSTFLAGS ?= -O -all: $(PHF) $(PHF_MAC) +PHF_SRC := $(VPATH)/src/phf.rs +PHF_MAC_SRC := $(VPATH)/src/phf_mac.rs +PHF_TEST_SRC := $(VPATH)/src/test.rs --include $(BUILDDIR)/phf.d --include $(BUILDDIR)/phf_mac.d --include $(BUILDDIR)/phf_test.d +all: phf.dummy phf_mac.dummy -$(BUILDDIR): - mkdir -p $@ +phf.dummy: $(PHF_SRC) + $(RUSTC) $(RUSTFLAGS) $< --out-dir . + touch $@ -$(PHF): $(PHF_LIB) | $(BUILDDIR) - $(RUSTC) $(RUSTFLAGS) --dep-info $(BUILDDIR)/phf.d --out-dir $(@D) $< +phf_mac.dummy: $(PHF_MAC_SRC) + $(RUSTC) $(RUSTFLAGS) -L . $< --out-dir . + touch $@ -$(PHF_MAC): $(PHF_MAC_LIB) $(PHF) | $(BUILDDIR) - $(RUSTC) $(RUSTFLAGS) --dep-info $(BUILDDIR)/phf_mac.d --out-dir $(@D) \ - -L $(BUILDDIR) $< +check: phf_test.dummy -$(PHF_TEST): $(PHF_TEST_MAIN) $(PHF) $(PHF_MAC) | $(BUILDDIR) - $(RUSTC) --test $(RUSTFLAGS) -L $(BUILDDIR) \ - --dep-info $(BUILDDIR)/phf_test.d --out-dir $(@D) $< - -doc-test: $(PHF) $(PHF_MAC) - rustdoc -L $(BUILDDIR) --test $(PHF_LIB) - -check: $(PHF_TEST) doc-test - $(PHF_TEST) - -doc: $(PHF) - rustdoc $(PHF_LIB) - rustdoc -L $(BUILDDIR) $(PHF_MAC_LIB) - -install: $(PHF) $(PHF_MAC) - install $(PHF) $(INSTALL_DIR) - install $(PHF_MAC) $(INSTALL_DIR) +phf_test.dummy: $(PHF_TEST_SRC) + $(RUSTC) --test $(RUSTFLAGS) -L . $< --out-dir . clean: - rm -rf $(BUILDDIR) - -print-targets: - @echo $(PHF_MAC) $(PHF) + rm -f *.o *.a *.so *.dylib *.rlib *.dll *.dummy *.exe *-test -.PHONY: all doc-test check doc install clean print-targets +.PHONY: all check clean diff --git a/configure b/configure index 7fe7f2b..62a0f4c 100755 --- a/configure +++ b/configure @@ -1,20 +1,4 @@ #!/bin/bash -cd $(dirname $0) - -TEMP=`getopt -o "" --long prefix: -n "$0" -- "$@"` - -if [ $? != 0 ]; then exit 1; fi - -eval set -- "$TEMP" - -PREFIX=/usr/lib - -while true ; do - case "$1" in - --prefix) PREFIX=$2; shift 2;; - --) shift; break;; - esac -done - -sed -e "s|%PREFIX%|$PREFIX|" < Makefile.in > Makefile +SRCDIR="$(cd $(dirname $0) && pwd)" +sed "s#%VPATH%#${SRCDIR}#" ${SRCDIR}/Makefile.in > Makefile From 2ba1755a235339f8cad45d4db1fecc2fe17e7fbf Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 12 Jun 2014 15:10:02 +1000 Subject: [PATCH 2/5] Revert "Update for plugin changes" This reverts commit 3e6048c9ca4c959d4bc7f9ff6313ee76146c7171. --- src/phf_mac.rs | 34 ++++++++++++++++++++++------------ src/test.rs | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/phf_mac.rs b/src/phf_mac.rs index dea3b67..bc25b6a 100644 --- a/src/phf_mac.rs +++ b/src/phf_mac.rs @@ -4,39 +4,49 @@ #![crate_id="github.com/sfackler/rust-phf/phf_mac"] #![crate_type="dylib"] #![doc(html_root_url="http://sfackler.github.io/rust-phf/doc")] -#![feature(managed_boxes, plugin_registrar, quote)] +#![feature(managed_boxes, macro_registrar, quote)] extern crate rand; extern crate syntax; extern crate time; extern crate phf; -extern crate rustc; use std::collections::HashMap; use std::os; use syntax::ast; -use syntax::ast::{TokenTree, LitStr, Expr, ExprVec, ExprLit}; +use syntax::ast::{Name, TokenTree, LitStr, Expr, ExprVec, ExprLit}; use syntax::codemap::Span; -use syntax::ext::base::{DummyResult, +use syntax::ext::base::{SyntaxExtension, + DummyResult, ExtCtxt, MacResult, - MacExpr}; + MacExpr, + NormalTT, + BasicMacroExpander}; use syntax::parse; +use syntax::parse::token; use syntax::parse::token::{InternedString, COMMA, EOF, FAT_ARROW}; use rand::{Rng, SeedableRng, XorShiftRng}; -use rustc::plugin::Registry; static DEFAULT_LAMBDA: uint = 5; static FIXED_SEED: [u32, ..4] = [3141592653, 589793238, 462643383, 2795028841]; -#[plugin_registrar] +#[macro_registrar] #[doc(hidden)] -pub fn macro_registrar(reg: &mut Registry) { - reg.register_macro("phf_map", expand_phf_map); - reg.register_macro("phf_set", expand_phf_set); - reg.register_macro("phf_ordered_map", expand_phf_ordered_map); - reg.register_macro("phf_ordered_set", expand_phf_ordered_set); +pub fn macro_registrar(register: |Name, SyntaxExtension|) { + let reg = |name, fn_| { + register(token::intern(name), + NormalTT(box BasicMacroExpander { + expander: fn_, + span: None + }, + None)); + }; + reg("phf_map", expand_phf_map); + reg("phf_set", expand_phf_set); + reg("phf_ordered_map", expand_phf_ordered_map); + reg("phf_ordered_set", expand_phf_ordered_set); } struct Entry { diff --git a/src/test.rs b/src/test.rs index d75869b..446e7de 100644 --- a/src/test.rs +++ b/src/test.rs @@ -1,6 +1,6 @@ #![feature(phase)] -#[phase(plugin)] +#[phase(syntax)] extern crate phf_mac; extern crate phf; From cfab2fca44be46927261261372db19e3b47480fe Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 12 Jun 2014 15:10:42 +1000 Subject: [PATCH 3/5] Revert "Upgrade to rustc 0.11.0-pre (e55f64f 2014-06-09 01:11:58 -0700)" This reverts commit 4a6c17cf9bf11e9a8911fe20fb8ae7ab0a011881. --- src/phf.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/phf.rs b/src/phf.rs index d657f92..cf7cfad 100644 --- a/src/phf.rs +++ b/src/phf.rs @@ -9,7 +9,6 @@ use std::fmt; use std::hash::Hasher; use std::hash::sip::SipHasher; use std::slice; -use std::collections::Collection; /// An immutable map constructed at compile time. /// @@ -69,7 +68,7 @@ pub fn displace(f1: uint, f2: uint, d1: uint, d2: uint) -> uint { d2 + f1 * d1 + f2 } -impl Collection for PhfMap { +impl Container for PhfMap { fn len(&self) -> uint { self.entries.len() } @@ -229,7 +228,7 @@ impl fmt::Show for PhfSet { } } -impl Collection for PhfSet { +impl Container for PhfSet { #[inline] fn len(&self) -> uint { self.map.len() @@ -345,7 +344,7 @@ impl fmt::Show for PhfOrderedMap { } } -impl Collection for PhfOrderedMap { +impl Container for PhfOrderedMap { fn len(&self) -> uint { self.entries.len() } @@ -554,7 +553,7 @@ impl fmt::Show for PhfOrderedSet { } } -impl Collection for PhfOrderedSet { +impl Container for PhfOrderedSet { #[inline] fn len(&self) -> uint { self.map.len() From c6e2f2047496e959e7decbfb66b999cd20d7fd28 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 12 Jun 2014 15:14:04 +1000 Subject: [PATCH 4/5] Fixes for servo rustc version --- src/phf_mac.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/phf_mac.rs b/src/phf_mac.rs index bc25b6a..a8c6190 100644 --- a/src/phf_mac.rs +++ b/src/phf_mac.rs @@ -10,8 +10,9 @@ extern crate rand; extern crate syntax; extern crate time; extern crate phf; +extern crate collections; -use std::collections::HashMap; +use collections::HashMap; use std::os; use syntax::ast; use syntax::ast::{Name, TokenTree, LitStr, Expr, ExprVec, ExprLit}; From 9191c7f3f178d20b09614138f3df0b9081a55ab7 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 12 Jun 2014 15:20:06 +1000 Subject: [PATCH 5/5] Fix make check for servo rustc version --- src/test.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test.rs b/src/test.rs index 446e7de..89d6d1d 100644 --- a/src/test.rs +++ b/src/test.rs @@ -3,9 +3,10 @@ #[phase(syntax)] extern crate phf_mac; extern crate phf; +extern crate collections; mod map { - use std::collections::{HashMap, HashSet}; + use collections::{HashMap, HashSet}; use phf::PhfMap; #[allow(dead_code)] @@ -118,7 +119,7 @@ mod map { } mod set { - use std::collections::HashSet; + use collections::HashSet; use phf::PhfSet; #[allow(dead_code)]