Skip to content

Commit 9e3361b

Browse files
committed
---
yaml --- r: 123902 b: refs/heads/snap-stage3 c: 3e49647 h: refs/heads/master v: v3
1 parent d01d97a commit 9e3361b

File tree

94 files changed

+12693
-8822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+12693
-8822
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4e2da7cb79143b0e7206a684629ed942599ec8e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: f9fe251777e9f1cc557a6d5b82b45403935d0a10
4+
refs/heads/snap-stage3: 3e49647a497f728ea4283070028e8512b1bd3173
55
refs/heads/try: 296eb104620b346d88bc4a2c2ab7693e6d3db019
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/crates.mk

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,17 @@
5151

5252
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
5353
uuid serialize sync getopts collections num test time rand \
54-
url log regex graphviz core rlibc alloc debug rustrt \
55-
unicode
54+
url log regex graphviz core rlibc alloc debug rustrt
5655
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros
5756
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5857
TOOLS := compiletest rustdoc rustc
5958

6059
DEPS_core :=
6160
DEPS_rlibc :=
62-
DEPS_unicode := core
6361
DEPS_alloc := core libc native:jemalloc
6462
DEPS_debug := std
6563
DEPS_rustrt := alloc core libc collections native:rustrt_native
66-
DEPS_std := core libc rand alloc collections rustrt sync unicode \
64+
DEPS_std := core libc rand alloc collections rustrt sync \
6765
native:rust_builtin native:backtrace
6866
DEPS_graphviz := std
6967
DEPS_green := std native:context_switch
@@ -84,7 +82,7 @@ DEPS_semver := std
8482
DEPS_uuid := std serialize
8583
DEPS_sync := core alloc rustrt collections
8684
DEPS_getopts := std
87-
DEPS_collections := core alloc unicode
85+
DEPS_collections := core alloc
8886
DEPS_fourcc := rustc syntax std
8987
DEPS_hexfloat := rustc syntax std
9088
DEPS_num := std
@@ -110,7 +108,6 @@ ONLY_RLIB_rlibc := 1
110108
ONLY_RLIB_alloc := 1
111109
ONLY_RLIB_rand := 1
112110
ONLY_RLIB_collections := 1
113-
ONLY_RLIB_unicode := 1
114111

115112
################################################################################
116113
# You should not need to edit below this line

branches/snap-stage3/mk/dist.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ distcheck-tar-bins: dist-tar-bins
259259
$(Q)cd tmp/distcheck && tar -xzf ../../dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz
260260
$(Q)mkdir -p tmp/distcheck/tarbininstall
261261
$(Q)sh tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix=tmp/distcheck/tarbininstall
262-
$(Q)tmp/distcheck/tarbininstall/bin/rustc --version
263262
$(Q)sh tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix=tmp/distcheck/tarbininstall --uninstall
264263
$(Q)rm -Rf tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)
265264
$(Q)rm -Rf tmp/distcheck/tarbininstall

branches/snap-stage3/mk/target.mk

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ $(foreach host,$(CFG_HOST), \
6868
# $(4) is the crate name
6969
define RUST_TARGET_STAGE_N
7070

71+
# NOTE: after a stage0 snap this should be just EXTRA_FILENAME, not with a stage
72+
# or target bound
73+
EXTRA_FILENAME_$(1)_$(2) = -C extra-filename=-$$(CFG_FILENAME_EXTRA)
74+
ifeq ($(1),0)
75+
ifeq ($$(CFG_BUILD),$(2))
76+
EXTRA_FILENAME_$(1)_$(2) =
77+
endif
78+
endif
79+
7180
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): CFG_COMPILER_HOST_TRIPLE = $(2)
7281
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
7382
$$(CRATEFILE_$(4)) \
@@ -86,7 +95,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
8695
-L "$$(dir $$(LLVM_STDCPP_LOCATION_$(2)))" \
8796
$$(RUSTFLAGS_$(4)) \
8897
--out-dir $$(@D) \
89-
-C extra-filename=-$$(CFG_FILENAME_EXTRA) \
98+
$$(EXTRA_FILENAME_$(1)_$(2)) \
9099
$$<
91100
@touch $$@
92101
$$(call LIST_ALL_OLD_GLOB_MATCHES,\

branches/snap-stage3/mk/tests.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
# The names of crates that must be tested
1717

18-
# libcore/libunicode tests are in a separate crate
18+
# libcore tests are in a separate crate
1919
DEPS_coretest :=
2020
$(eval $(call RUST_CRATE,coretest))
2121

22-
TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) coretest
22+
TEST_TARGET_CRATES = $(filter-out core,$(TARGET_CRATES)) coretest
2323
TEST_DOC_CRATES = $(DOC_CRATES)
2424
TEST_HOST_CRATES = $(HOST_CRATES)
2525
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)

branches/snap-stage3/src/doc/guide.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,16 @@ is still a work in progress. However, it is already good enough to use for many
273273
Rust projects, and so it is assumed that Rust projects will use Cargo from the
274274
beginning.
275275

276-
Cargo manages three things: building your code, downloading the dependencies
277-
your code needs, and building the dependencies your code needs. At first, your
278-
program doesn't have any dependencies, so we'll only be using the first part of
279-
its functionality. Eventually, we'll add more. Since we started off by using
280-
Cargo, it'll be easy to add later.
276+
Programmers love car analogies, so I've got a good one for you to think about
277+
the relationship between `cargo` and `rustc`: `rustc` is like a car, and
278+
`cargo` is like a robotic driver. You can drive your car yourself, of course,
279+
but isn't it just easier to let a computer drive it for you?
280+
281+
Anyway, Cargo manages three things: building your code, downloading the
282+
dependencies your code needs, and building the dependencies your code needs.
283+
At first, your program doesn't have any dependencies, so we'll only be using
284+
the first part of its functionality. Eventually, we'll add more. Since we
285+
started off by using Cargo, it'll be easy to add later.
281286

282287
Let's convert Hello World to Cargo. The first thing we need to do to begin using Cargo
283288
is to install Cargo. To do this, we need to build it from source. There are no binaries

branches/snap-stage3/src/etc/install.sh

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,6 @@ then
285285
CFG_LIBDIR_RELATIVE=bin
286286
fi
287287

288-
if [ "$CFG_OSTYPE" = "pc-mingw32" ] || [ "$CFG_OSTYPE" = "w64-mingw32" ]
289-
then
290-
CFG_LD_PATH_VAR=PATH
291-
CFG_OLD_LD_PATH_VAR=$PATH
292-
elif [ "$CFG_OSTYPE" = "Darwin" ]
293-
then
294-
CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH
295-
CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH
296-
else
297-
CFG_LD_PATH_VAR=LD_LIBRARY_PATH
298-
CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH
299-
fi
300-
301288
flag uninstall "only uninstall from the installation prefix"
302289
opt verify 1 "verify that the installed binaries run correctly"
303290
valopt prefix "/usr/local" "set installation prefix"
@@ -325,13 +312,11 @@ then
325312
if [ -z "${CFG_UNINSTALL}" ]
326313
then
327314
msg "verifying platform can run binaries"
328-
export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib":$CFG_OLD_LD_PATH_VAR
329315
"${CFG_SRC_DIR}/bin/rustc" --version > /dev/null
330316
if [ $? -ne 0 ]
331317
then
332318
err "can't execute rustc binary on this platform"
333319
fi
334-
export $CFG_LD_PATH_VAR=$CFG_OLD_LD_PATH_VAR
335320
fi
336321
fi
337322

@@ -467,31 +452,17 @@ while read p; do
467452
done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/rustlib/manifest.in"
468453

469454
# Sanity check: can we run the installed binaries?
470-
#
471-
# As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
472-
# is in place. Try first without this variable, and if that fails try again with
473-
# the variable. If the second time tries, print a hopefully helpful message to
474-
# add something to the appropriate environment variable.
475455
if [ -z "${CFG_DISABLE_VERIFY}" ]
476456
then
477457
msg "verifying installed binaries are executable"
478-
"${CFG_PREFIX}/bin/rustc" --version 2> /dev/null 1> /dev/null
458+
"${CFG_PREFIX}/bin/rustc" --version > /dev/null
479459
if [ $? -ne 0 ]
480460
then
481-
export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib":$CFG_OLD_LD_PATH_VAR
482-
"${CFG_PREFIX}/bin/rustc" --version > /dev/null
483-
if [ $? -ne 0 ]
484-
then
485-
ERR="can't execute installed rustc binary. "
486-
ERR="${ERR}installation may be broken. "
487-
ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
488-
ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
489-
err "${ERR}"
490-
else
491-
echo
492-
echo " please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
493-
echo
494-
fi
461+
ERR="can't execute installed rustc binary. "
462+
ERR="${ERR}installation may be broken. "
463+
ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
464+
ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
465+
err "${ERR}"
495466
fi
496467
fi
497468

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
#!/usr/bin/env python2
2+
3+
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
4+
# file at the top-level directory of this distribution and at
5+
# http://rust-lang.org/COPYRIGHT.
6+
#
7+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
# option. This file may not be copied, modified, or distributed
11+
# except according to those terms.
12+
13+
from __future__ import absolute_import, division, print_function
14+
import argparse
15+
from collections import defaultdict
16+
import csv
17+
import datetime
18+
import urllib2
19+
20+
BASE_URL = 'http://www.unicode.org/Public/6.3.0/ucd/'
21+
DATA = 'UnicodeData.txt'
22+
SCRIPTS = 'Scripts.txt'
23+
24+
# Mapping taken from Table 12 from:
25+
# http://www.unicode.org/reports/tr44/#General_Category_Values
26+
expanded_categories = {
27+
'Lu': ['LC', 'L'], 'Ll': ['LC', 'L'], 'Lt': ['LC', 'L'],
28+
'Lm': ['L'], 'Lo': ['L'],
29+
'Mn': ['M'], 'Mc': ['M'], 'Me': ['M'],
30+
'Nd': ['N'], 'Nl': ['N'], 'No': ['No'],
31+
'Pc': ['P'], 'Pd': ['P'], 'Ps': ['P'], 'Pe': ['P'],
32+
'Pi': ['P'], 'Pf': ['P'], 'Po': ['P'],
33+
'Sm': ['S'], 'Sc': ['S'], 'Sk': ['S'], 'So': ['S'],
34+
'Zs': ['Z'], 'Zl': ['Z'], 'Zp': ['Z'],
35+
'Cc': ['C'], 'Cf': ['C'], 'Cs': ['C'], 'Co': ['C'], 'Cn': ['C'],
36+
}
37+
38+
39+
def as_4byte_uni(n):
40+
s = hex(n)[2:]
41+
return '\\U%s%s' % ('0' * (8 - len(s)), s)
42+
43+
44+
def expand_cat(c):
45+
return expanded_categories.get(c, []) + [c]
46+
47+
48+
def is_valid_unicode(n):
49+
return 0 <= n <= 0xD7FF or 0xE000 <= n <= 0x10FFFF
50+
51+
52+
def read_cats(f):
53+
assigned = defaultdict(list)
54+
for row in csv.reader(f, delimiter=';'):
55+
(hex, cats) = (int(row[0], 16), expand_cat(row[2]))
56+
if not is_valid_unicode(hex):
57+
continue
58+
for cat in cats:
59+
assigned[cat].append(hex)
60+
return assigned
61+
62+
63+
def read_scripts(f):
64+
assigned = defaultdict(list)
65+
for line in f:
66+
line = line.strip()
67+
if not line or line.startswith('#'):
68+
continue
69+
hexes, name = map(str.strip, line.split(';'))[:2]
70+
name = name[:name.index('#')].strip()
71+
if '..' not in hexes:
72+
hex = int(hexes, 16)
73+
if is_valid_unicode(hex):
74+
assigned[name].append(hex)
75+
else:
76+
hex1, hex2 = map(lambda s: int(s, 16), hexes.split('..'))
77+
for hex in xrange(hex1, hex2 + 1):
78+
if is_valid_unicode(hex):
79+
assigned[name].append(hex)
80+
return assigned
81+
82+
83+
def group(letters):
84+
letters = sorted(set(letters))
85+
grouped = []
86+
cur_start = letters.pop(0)
87+
cur_end = cur_start
88+
for letter in letters:
89+
assert letter > cur_end, \
90+
'cur_end: %s, letter: %s' % (hex(cur_end), hex(letter))
91+
92+
if letter == cur_end + 1:
93+
cur_end = letter
94+
else:
95+
grouped.append((cur_start, cur_end))
96+
cur_start, cur_end = letter, letter
97+
grouped.append((cur_start, cur_end))
98+
return grouped
99+
100+
101+
def ranges_to_rust(rs):
102+
rs = ("('%s', '%s')" % (as_4byte_uni(s), as_4byte_uni(e)) for s, e in rs)
103+
return ',\n '.join(rs)
104+
105+
106+
def groups_to_rust(groups):
107+
rust_groups = []
108+
for group_name in sorted(groups):
109+
rust_groups.append('("%s", &[\n %s\n ]),'
110+
% (group_name, ranges_to_rust(groups[group_name])))
111+
return '\n'.join(rust_groups)
112+
113+
114+
if __name__ == '__main__':
115+
parser = argparse.ArgumentParser(
116+
description='Generate Unicode character class tables.')
117+
aa = parser.add_argument
118+
aa('--local', action='store_true',
119+
help='When set, Scripts.txt and UnicodeData.txt will be read from '
120+
'the CWD.')
121+
aa('--base-url', type=str, default=BASE_URL,
122+
help='The base URL to use for downloading Unicode data files.')
123+
args = parser.parse_args()
124+
125+
if args.local:
126+
cats = read_cats(open(DATA))
127+
scripts = read_scripts(open(SCRIPTS))
128+
else:
129+
cats = read_cats(urllib2.urlopen(args.base_url + '/' + DATA))
130+
scripts = read_scripts(urllib2.urlopen(args.base_url + '/' + SCRIPTS))
131+
132+
# Get Rust code for all Unicode general categories and scripts.
133+
combined = dict(cats, **scripts)
134+
unigroups = groups_to_rust({k: group(letters)
135+
for k, letters in combined.items()})
136+
137+
# Now get Perl character classes that are Unicode friendly.
138+
perld = range(ord('0'), ord('9') + 1)
139+
dgroups = ranges_to_rust(group(perld + cats['Nd'][:]))
140+
141+
perls = map(ord, ['\t', '\n', '\x0C', '\r', ' '])
142+
sgroups = ranges_to_rust(group(perls + cats['Z'][:]))
143+
144+
low, up = (range(ord('a'), ord('z') + 1), range(ord('A'), ord('Z') + 1))
145+
perlw = [ord('_')] + perld + low + up
146+
wgroups = ranges_to_rust(group(perlw + cats['L'][:]))
147+
148+
tpl = '''// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
149+
// file at the top-level directory of this distribution and at
150+
// http://rust-lang.org/COPYRIGHT.
151+
//
152+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
153+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
154+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
155+
// option. This file may not be copied, modified, or distributed
156+
// except according to those terms.
157+
158+
// DO NOT EDIT. Automatically generated by 'src/etc/regexp-unicode-tables'
159+
// on {date}.
160+
161+
use parse::{{Class, NamedClasses}};
162+
163+
pub static UNICODE_CLASSES: NamedClasses = &[
164+
165+
{groups}
166+
167+
];
168+
169+
pub static PERLD: Class = &[
170+
{dgroups}
171+
];
172+
173+
pub static PERLS: Class = &[
174+
{sgroups}
175+
];
176+
177+
pub static PERLW: Class = &[
178+
{wgroups}
179+
];
180+
'''
181+
now = datetime.datetime.now()
182+
print(tpl.format(date=str(now), groups=unigroups,
183+
dgroups=dgroups, sgroups=sgroups, wgroups=wgroups))

0 commit comments

Comments
 (0)