Skip to content

Commit 35d43f2

Browse files
committed
Move macros into their own crate
In preparation for procedural macros.
1 parent 3040b49 commit 35d43f2

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Makefile.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ LIB_TOP_SRC = $(VPATH)/src/html5.rs
99
LIB_ALL_SRC = $(GEN_LIB_SRC) $(shell find $(VPATH)/src -type f -name '*.rs')
1010
LIB = $(shell $(RUSTC) --crate-file-name "$(LIB_TOP_SRC)")
1111

12+
MACROS_TOP_SRC = $(VPATH)/macros/mod.rs
13+
MACROS_ALL_SRC = $(shell find $(VPATH)/macros -type f -name '*.rs')
14+
MACROS = $(shell $(RUSTC) --crate-file-name "$(MACROS_TOP_SRC)")
15+
1216
EXT_TEST_TOP_SRC = $(VPATH)/test/mod.rs
1317
EXT_TEST_ALL_SRC = $(shell find $(VPATH)/test -type f -name '*.rs')
1418

@@ -21,7 +25,10 @@ $(VPATH)/generated/char_ref_data.rs: $(VPATH)/codegen/gen-char-ref-data.py
2125
mkdir -p $(dir $@)
2226
$< $(VPATH) > $@
2327

24-
$(LIB): $(LIB_ALL_SRC)
28+
$(MACROS): $(MACROS_ALL_SRC)
29+
$(RUSTC) $(RUSTFLAGS) $(MACROS_TOP_SRC)
30+
31+
$(LIB): $(MACROS) $(LIB_ALL_SRC)
2532
$(RUSTC) $(RUSTFLAGS) $(LIB_TOP_SRC)
2633

2734
tokenize-example: $(VPATH)/examples/tokenize-example.rs $(LIB)

src/macros.rs renamed to macros/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
#[macro_escape];
5+
#[crate_id="html5-macros"];
6+
#[crate_type="dylib"];
67

8+
#[feature(macro_rules)];
9+
10+
#[macro_export]
711
macro_rules! unwrap_or_return( ($opt:expr, $retval:expr) => (
812
match $opt {
913
None => return $retval,
1014
Some(x) => x,
1115
}
1216
))
1317

18+
#[macro_export]
1419
macro_rules! test_eq( ($name:ident, $left:expr, $right:expr) => (
1520
#[test]
1621
fn $name() {

src/html5.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
#[phase(syntax)]
1111
extern crate phf_mac;
1212

13+
#[phase(syntax)]
14+
extern crate macros = "html5-macros";
15+
1316
extern crate phf;
1417
extern crate collections;
1518

16-
mod macros;
17-
1819
mod util {
1920
pub mod ascii;
2021
pub mod buffer_queue;

0 commit comments

Comments
 (0)