third_party/cargo: add flatbuffers, bump

ecs
q3k 2020-05-29 03:22:15 +02:00
parent b9aeafd921
commit b137b16600
1503 changed files with 166042 additions and 16414 deletions

305
third_party/cargo/Cargo.lock generated vendored
View File

@ -30,10 +30,10 @@ dependencies = [
]
[[package]]
name = "android_glue"
version = "0.2.3"
name = "android_log-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"
checksum = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e"
[[package]]
name = "approx"
@ -44,12 +44,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "arrayvec"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]]
name = "atty"
version = "0.2.14"
@ -110,9 +104,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.50"
version = "1.0.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
[[package]]
name = "cfg-if"
@ -142,9 +136,9 @@ dependencies = [
[[package]]
name = "cmake"
version = "0.1.42"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62"
checksum = "0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb"
dependencies = [
"cc",
]
@ -166,9 +160,9 @@ dependencies = [
[[package]]
name = "cocoa"
version = "0.20.0"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a4736c86d51bd878b474400d9ec888156f4037015f5d09794fab9f26eab1ad4"
checksum = "8f7b6f3f7f4f0b3ec5c5039aaa9e8c3cef97a7a480a400fd62944841314f293d"
dependencies = [
"bitflags",
"block",
@ -191,6 +185,7 @@ version = "1.33.7"
dependencies = [
"cgmath",
"env_logger",
"flatbuffers",
"image",
"log",
"openvr",
@ -257,13 +252,13 @@ dependencies = [
[[package]]
name = "core-video-sys"
version = "0.1.3"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dc065219542086f72d1e9f7aadbbab0989e980263695d129d502082d063a9d0"
checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
dependencies = [
"cfg-if",
"core-foundation-sys 0.6.2",
"core-graphics 0.17.3",
"core-foundation-sys 0.7.0",
"core-graphics 0.19.0",
"libc",
"objc",
]
@ -329,9 +324,9 @@ dependencies = [
[[package]]
name = "crossbeam-queue"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
checksum = "ab6bffe714b6bb07e42f201352c34f51fefd355ace793f9e638ebd52d23f98d2"
dependencies = [
"cfg-if",
"crossbeam-utils",
@ -350,14 +345,25 @@ dependencies = [
[[package]]
name = "deflate"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "050ef6de42a33903b30a7497b76b40d3d58691d4d3eec355348c122444a388f0"
checksum = "e7e5d2a2273fed52a7f947ee55b092c4057025d7a3e04e5ecdbd25d6c3fb1bd7"
dependencies = [
"adler32",
"byteorder",
]
[[package]]
name = "derivative"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f"
dependencies = [
"proc-macro2 1.0.17",
"quote 1.0.6",
"syn",
]
[[package]]
name = "dispatch"
version = "0.2.0"
@ -366,9 +372,9 @@ checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
[[package]]
name = "dlib"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
dependencies = [
"libloading",
]
@ -399,10 +405,19 @@ dependencies = [
]
[[package]]
name = "fnv"
version = "1.0.6"
name = "flatbuffers"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
checksum = "a788f068dd10687940565bf4b5480ee943176cbd114b12e811074bcf7c04e4b9"
dependencies = [
"smallvec",
]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
@ -453,15 +468,15 @@ dependencies = [
[[package]]
name = "half"
version = "1.5.0"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36b5f248235f45773d4944f555f83ea61fe07b18b561ccf99d7483d7381e54d"
checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177"
[[package]]
name = "hermit-abi"
version = "0.1.8"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71"
dependencies = [
"libc",
]
@ -477,9 +492,9 @@ dependencies = [
[[package]]
name = "image"
version = "0.23.1"
version = "0.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "403f0c29211dc50a78eb53eeeae87945d44cb63071881834212f36677fccb2b4"
checksum = "9117f4167a8f21fa2bb3f17a652a760acd7572645281c98e3b612a26242c96ee"
dependencies = [
"bytemuck",
"byteorder",
@ -504,9 +519,9 @@ dependencies = [
[[package]]
name = "instant"
version = "0.1.2"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c346c299e3fe8ef94dc10c2c0253d858a69aac1245157a3bf4125915d528caf"
checksum = "7777a24a1ce5de49fcdde84ec46efa487c3af49d5b6e6e0a50367cc5c1096182"
[[package]]
name = "iovec"
@ -518,10 +533,16 @@ dependencies = [
]
[[package]]
name = "jpeg-decoder"
version = "0.1.18"
name = "jni-sys"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0256f0aec7352539102a9efbcb75543227b7ab1117e0f95450023af730128451"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jpeg-decoder"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b47b4c4e017b01abdc5bcc126d2d1002e5a75bbe3ce73f9f4f311a916363704"
dependencies = [
"byteorder",
"rayon",
@ -551,17 +572,16 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
[[package]]
name = "libc"
version = "0.2.67"
version = "0.2.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
[[package]]
name = "libloading"
version = "0.5.2"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
checksum = "2cadb8e769f070c45df05c78c7520eb4cd17061d4ab262e43cfc68b4d00ac71c"
dependencies = [
"cc",
"winapi 0.3.8",
]
@ -576,9 +596,9 @@ dependencies = [
[[package]]
name = "lock_api"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b"
checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
dependencies = [
"scopeguard",
]
@ -664,9 +684,9 @@ dependencies = [
[[package]]
name = "mio"
version = "0.6.21"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430"
dependencies = [
"cfg-if",
"fuchsia-zircon",
@ -706,10 +726,41 @@ dependencies = [
]
[[package]]
name = "net2"
version = "0.2.33"
name = "ndk"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
checksum = "95a356cafe20aee088789830bfea3a61336e84ded9e545e00d3869ce95dcb80c"
dependencies = [
"jni-sys",
"ndk-sys",
"num_enum",
]
[[package]]
name = "ndk-glue"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1730ee2e3de41c3321160a6da815f008c4006d71b095880ea50e17cf52332b8"
dependencies = [
"android_log-sys",
"lazy_static",
"libc",
"log",
"ndk",
"ndk-sys",
]
[[package]]
name = "ndk-sys"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2820aca934aba5ed91c79acc72b6a44048ceacc5d36c035ed4e051f12d887d"
[[package]]
name = "net2"
version = "0.2.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7"
dependencies = [
"cfg-if",
"libc",
@ -752,9 +803,9 @@ dependencies = [
[[package]]
name = "num-rational"
version = "0.2.3"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da4dc79f9e6c81bef96148c8f6b8e72ad4541caa4a24373e900a36da07de03a3"
checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
dependencies = [
"autocfg 1.0.0",
"num-integer",
@ -772,14 +823,36 @@ dependencies = [
[[package]]
name = "num_cpus"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "num_enum"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4"
dependencies = [
"derivative",
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d"
dependencies = [
"proc-macro-crate",
"proc-macro2 1.0.17",
"quote 1.0.6",
"syn",
]
[[package]]
name = "objc"
version = "0.2.7"
@ -829,9 +902,9 @@ dependencies = [
[[package]]
name = "parking_lot"
version = "0.10.0"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc"
checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
dependencies = [
"lock_api",
"parking_lot_core",
@ -839,9 +912,9 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.7.0"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1"
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
dependencies = [
"cfg-if",
"cloudabi",
@ -865,9 +938,9 @@ checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
[[package]]
name = "png"
version = "0.16.1"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46060468187c21c00ffa2a920690b29997d7fd543f5a4d400461e4a7d4fccde8"
checksum = "2c68a431ed29933a4eb5709aca9800989758c97759345860fa5db3cfced0b65d"
dependencies = [
"bitflags",
"crc32fast",
@ -875,13 +948,31 @@ dependencies = [
"inflate",
]
[[package]]
name = "proc-macro-crate"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e"
dependencies = [
"toml",
]
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid",
"unicode-xid 0.1.0",
]
[[package]]
name = "proc-macro2"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101"
dependencies = [
"unicode-xid 0.2.0",
]
[[package]]
@ -896,7 +987,16 @@ version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2",
"proc-macro2 0.4.30",
]
[[package]]
name = "quote"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
dependencies = [
"proc-macro2 1.0.17",
]
[[package]]
@ -1055,9 +1155,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "regex"
version = "1.3.5"
version = "1.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8900ebc1363efa7ea1c399ccc32daed870b4002651e0bed86e72d501ebbe0048"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
dependencies = [
"aho-corasick",
"memchr",
@ -1067,9 +1167,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.17"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
[[package]]
name = "rusttype"
@ -1077,17 +1177,16 @@ version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5"
dependencies = [
"rusttype 0.8.2",
"rusttype 0.8.3",
]
[[package]]
name = "rusttype"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14a911032fb5791ccbeec9f28fdcb9bf0983b81f227bafdfd227c658d0731c8a"
checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0"
dependencies = [
"approx",
"arrayvec",
"ordered-float",
"stb_truetype",
]
@ -1113,6 +1212,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e7b308464d16b56eba9964e4972a3eee817760ab60d88c3f86e1fecb08204c"
[[package]]
name = "shared_library"
version = "0.1.9"
@ -1131,9 +1236,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]]
name = "smallvec"
version = "1.2.0"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4"
[[package]]
name = "smithay-client-toolkit"
@ -1160,6 +1265,17 @@ dependencies = [
"byteorder",
]
[[package]]
name = "syn"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef781e621ee763a2a40721a8861ec519cb76966aee03bb5d00adb6a31dc1c1de"
dependencies = [
"proc-macro2 1.0.17",
"quote 1.0.6",
"unicode-xid 0.2.0",
]
[[package]]
name = "termcolor"
version = "1.1.0"
@ -1189,12 +1305,27 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "toml"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
dependencies = [
"serde",
]
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "vk-sys"
version = "0.5.1"
@ -1228,7 +1359,7 @@ version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc7e4c74bbf33d0c6b9f7e98f47068c62dc65d6a0721c0cb4b05fe4776c9af80"
dependencies = [
"cocoa 0.20.0",
"cocoa 0.20.1",
"metal",
"objc",
"vulkano",
@ -1291,8 +1422,8 @@ version = "0.23.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93b02247366f395b9258054f964fe293ddd019c3237afba9be2ccbe9e1651c3d"
dependencies = [
"proc-macro2",
"quote",
"proc-macro2 0.4.30",
"quote 0.6.13",
"xml-rs",
]
@ -1336,9 +1467,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.3"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi 0.3.8",
]
@ -1351,15 +1482,14 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "winit"
version = "0.22.0"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e9092b71b48ad6a0d98835a786308d10760cc09369d02e4a166608327f1f26"
checksum = "1e4ccbf7ddb6627828eace16cacde80fc6bf4dbb3469f88487262a02cf8e7862"
dependencies = [
"android_glue",
"bitflags",
"cocoa 0.19.1",
"core-foundation 0.6.4",
"core-graphics 0.17.3",
"cocoa 0.20.1",
"core-foundation 0.7.0",
"core-graphics 0.19.0",
"core-video-sys",
"dispatch",
"instant",
@ -1368,6 +1498,9 @@ dependencies = [
"log",
"mio",
"mio-extras",
"ndk",
"ndk-glue",
"ndk-sys",
"objc",
"parking_lot",
"percent-encoding",
@ -1408,6 +1541,6 @@ checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
[[package]]
name = "xml-rs"
version = "0.8.0"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5"
checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"

View File

@ -15,6 +15,7 @@ vulkano-win = "0.18.0"
winit = "0.22.0"
cgmath = "0.17.0"
openvr = "0.6.0"
flatbuffers = "0.6.1"
[raze]
workspace_path = "//third_party/cargo"
@ -22,7 +23,7 @@ target = "x86_64-unknown-linux-gnu"
[raze.crates.andrew.'0.2.1']
skipped_deps = ['rusttype-0.7.9']
additional_deps = ['//third_party/cargo/vendor/rusttype-0.8.2:rusttype']
additional_deps = ['//third_party/cargo/vendor/rusttype-0.8.3:rusttype']
[raze.crates.x11-dl.'2.18.5']
gen_buildrs = true
@ -38,11 +39,11 @@ additional_flags = [
"--cfg=atomic_cas"
]
[raze.crates.libloading.'0.5.2']
[raze.crates.libloading.'0.6.2']
additional_deps = ['//third_party/cargo/patches:libloading_global_static']
[raze.crates.cgmath.'0.17.0']
gen_buildrs = true
[raze.crates.image.'0.23.1']
[raze.crates.image.'0.23.4']
gen_buildrs = true

View File

@ -2,5 +2,5 @@ cc_library(
name = "libloading_global_static",
srcs = ["libloading/global_static.c"],
copts = ["-fPIC"],
visibility = ["//third_party/cargo/vendor/libloading-0.5.2:__pkg__"],
visibility = ["//third_party/cargo/vendor/libloading-0.6.2:__pkg__"],
)

View File

@ -1,7 +1,7 @@
diff --git a/third_party/cargo/vendor/image-0.23.1/src/jpeg/decoder.rs b/third_party/cargo/vendor/image-0.23.1/src/jpeg/decoder.rs
diff --git a/third_party/cargo/vendor/image-0.23.4/src/jpeg/decoder.rs b/third_party/cargo/vendor/image-0.23.4/src/jpeg/decoder.rs
index 0abe266..1fcd2f2 100644
--- a/third_party/cargo/vendor/image-0.23.1/src/jpeg/decoder.rs
+++ b/third_party/cargo/vendor/image-0.23.1/src/jpeg/decoder.rs
--- a/third_party/cargo/vendor/image-0.23.4/src/jpeg/decoder.rs
+++ b/third_party/cargo/vendor/image-0.23.4/src/jpeg/decoder.rs
@@ -11,21 +11,21 @@ use crate::image::{ImageDecoder, ImageFormat};
/// JPEG decoder

View File

@ -35,8 +35,8 @@ rust_library(
"//third_party/cargo/vendor/line_drawing-0.7.0:line_drawing",
"//third_party/cargo/vendor/walkdir-2.3.1:walkdir",
"//third_party/cargo/vendor/xdg-2.2.0:xdg",
"//third_party/cargo/vendor/xml-rs-0.8.0:xml_rs",
"//third_party/cargo/vendor/rusttype-0.8.2:rusttype",
"//third_party/cargo/vendor/xml-rs-0.8.3:xml_rs",
"//third_party/cargo/vendor/rusttype-0.8.3:rusttype",
],
rustc_flags = [
"--cap-lints=allow",

View File

@ -1 +0,0 @@
{"files":{"Cargo.toml":"dbe01d8dfe2ea291ca94d56acfe3a401bbaf81d960be2d2afc5e916f755a9ab7","src/lib.rs":"d364185fd66b549a70b935fdfec041b55a10cdc0dd901fd95b38554f08cf0923"},"package":"000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"}

View File

@ -1,8 +0,0 @@
[package]
name = "android_glue"
version = "0.2.3"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
license = "MIT"
description = "Glue for the Android JNI"
repository = "https://github.com/tomaka/android-rs-glue"

View File

@ -1,152 +0,0 @@
#![cfg(target_os = "android")]
extern {
fn cargo_apk_injected_glue_get_native_window() -> *const c_void;
fn cargo_apk_injected_glue_add_sender(sender: *mut ());
fn cargo_apk_injected_glue_add_sender_missing(sender: *mut ());
fn cargo_apk_injected_glue_add_sync_event_handler(sender: *mut ());
fn cargo_apk_injected_glue_remove_sync_event_handler(sender: *mut ());
fn cargo_apk_injected_glue_set_multitouch(multitouch: bool);
fn cargo_apk_injected_glue_write_log(ptr: *const (), len: usize);
fn cargo_apk_injected_glue_load_asset(ptr: *const (), len: usize) -> *mut c_void;
fn cargo_apk_injected_glue_wake_event_loop();
}
use std::mem;
use std::os::raw::c_void;
use std::sync::mpsc::Sender;
/// An event triggered by the Android environment.
#[derive(Clone, Copy, Debug)]
pub enum Event {
EventMotion(Motion),
EventKeyUp,
EventKeyDown,
InitWindow,
SaveState,
TermWindow,
GainedFocus,
LostFocus,
InputChanged,
WindowResized,
WindowRedrawNeeded,
ContentRectChanged,
ConfigChanged,
LowMemory,
Start,
Resume,
Pause,
Stop,
Destroy,
Wake
}
/// Data about a motion event.
#[derive(Clone, Copy, Debug)]
pub struct Motion {
pub action: MotionAction,
pub pointer_id: i32,
pub x: f32,
pub y: f32,
}
/// The type of pointer action in a motion event.
#[derive(Clone, Copy, Debug)]
pub enum MotionAction {
Down,
Move,
Up,
Cancel,
}
pub enum AssetError {
AssetMissing,
EmptyBuffer,
}
// Trait used to dispatch sync events from the polling loop thread.
pub trait SyncEventHandler {
fn handle(&mut self, event: &Event);
}
/// Adds a sender where events will be sent to.
#[inline]
pub fn add_sender(sender: Sender<Event>) {
unsafe {
let sender = Box::into_raw(Box::new(sender)) as *mut _;
cargo_apk_injected_glue_add_sender(sender);
}
}
/// Adds a SyncEventHandler which will receive sync events from the polling loop.
#[inline]
pub fn add_sync_event_handler(handler: Box<SyncEventHandler>) {
unsafe {
let handler = Box::into_raw(Box::new(handler)) as *mut _;
cargo_apk_injected_glue_add_sync_event_handler(handler);
}
}
/// Removes a SyncEventHandler.
#[inline]
pub fn remove_sync_event_handler(handler: *const SyncEventHandler) {
unsafe {
let handler = Box::into_raw(Box::new(handler)) as *mut _;
cargo_apk_injected_glue_remove_sync_event_handler(handler);
}
}
#[inline]
pub fn set_multitouch(multitouch: bool) {
unsafe {
cargo_apk_injected_glue_set_multitouch(multitouch);
}
}
/// Adds a sender where events will be sent to, but also sends
/// any missing events to the sender object.
///
/// The missing events happen when the application starts, but before
/// any senders are registered. Since these might be important to certain
/// applications, this function provides that support.
#[inline]
pub fn add_sender_missing(sender: Sender<Event>) {
unsafe {
let sender = Box::into_raw(Box::new(sender)) as *mut _;
cargo_apk_injected_glue_add_sender_missing(sender);
}
}
/// Returns a handle to the native window.
#[inline]
pub unsafe fn get_native_window() -> *const c_void {
cargo_apk_injected_glue_get_native_window()
}
///
#[inline]
pub fn write_log(message: &str) {
unsafe {
let (message_ptr, message_len) = mem::transmute(message);
cargo_apk_injected_glue_write_log(message_ptr, message_len);
}
}
#[inline]
pub fn load_asset(filename: &str) -> Result<Vec<u8>, AssetError> {
unsafe {
let (filename_ptr, filename_len) = mem::transmute(filename);
let data = cargo_apk_injected_glue_load_asset(filename_ptr, filename_len);
let data: Box<Result<Vec<u8>, AssetError>> = Box::from_raw(data as *mut _);
*data
}
}
// Wakes the event poll asynchronously and sends a Event::Wake event to the senders.
// This method can be called on any thread. This method returns immediately.
#[inline]
pub fn wake_event_loop() {
unsafe {
cargo_apk_injected_glue_wake_event_loop();
}
}

View File

@ -0,0 +1 @@
{"files":{"Cargo.toml":"18788b5d8b84916aedc7c85961a8c99f748969e9562663dbfc9704d2263df23d","LICENSE-APACHE":"4d4c32b31308f5a992434c2cf948205852bb2c7bb85cea4c1ab051f41a3eefb3","LICENSE-MIT":"bb3c0c388d2e5efc777ee1a7bc4671188447d5fbbad130aecac9fd52e0010b76","README.md":"56808f9f272c6fad922f23033591464c1403bb5d1f716ee224b6933b90d62e86","src/lib.rs":"ff810c7e6fe722309ea46f9f2a87c10a857f7c6b3563a5986d2d235cdc2109e2"},"package":"b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e"}

View File

@ -0,0 +1,42 @@
"""
cargo-raze crate build file.
DO NOT EDIT! Replaced on runs of cargo-raze
"""
package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//third_party/cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])
licenses([
"restricted", # "MIT OR Apache-2.0"
])
load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_library",
"rust_binary",
"rust_test",
)
rust_library(
name = "android_log_sys",
crate_root = "src/lib.rs",
crate_type = "lib",
edition = "2015",
srcs = glob(["**/*.rs"]),
deps = [
],
rustc_flags = [
"--cap-lints=allow",
],
version = "0.1.2",
crate_features = [
],
)

View File

@ -0,0 +1,26 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "android_log-sys"
version = "0.1.2"
authors = ["Nerijus Arlauskas <nercury@gmail.com>"]
description = "FFI bindings to Android log Library.\n"
documentation = "https://docs.rs/android_log-sys"
readme = "README.md"
keywords = ["ffi", "android", "log"]
categories = ["external-ffi-bindings"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/nercury/android_log-sys-rs"
[lib]
name = "android_log_sys"

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2016 The android_log_sys Developers
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,19 @@
Copyright (c) 2016 The android_log_sys Developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,17 @@
# Bindings to Android log Library
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.

View File

@ -0,0 +1,53 @@
// Copyright 2016 The android_log_sys Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use std::os::raw;
#[allow(non_camel_case_types)]
pub type c_va_list = raw::c_void;
#[allow(non_camel_case_types)]
pub type c_int = raw::c_int;
#[allow(non_camel_case_types)]
pub type c_char = raw::c_char;
// automatically generated by rust-bindgen
#[derive(Clone, Copy)]
#[repr(isize)]
pub enum LogPriority {
UNKNOWN = 0,
DEFAULT = 1,
VERBOSE = 2,
DEBUG = 3,
INFO = 4,
WARN = 5,
ERROR = 6,
FATAL = 7,
SILENT = 8,
}
#[link(name = "log")]
extern "C" {
pub fn __android_log_write(prio: c_int,
tag: *const c_char,
text: *const c_char)
-> c_int;
pub fn __android_log_print(prio: c_int,
tag: *const c_char,
fmt: *const c_char,
...)
-> c_int;
pub fn __android_log_vprint(prio: c_int,
tag: *const c_char,
fmt: *const c_char,
ap: *mut c_va_list)
-> c_int;
pub fn __android_log_assert(cond: *const c_char,
tag: *const c_char,
fmt: *const c_char,
...);
}

View File

@ -1 +0,0 @@
{"files":{"Cargo.toml":"e7405a91fea075bb4fedb0e76e2039af27d6c380beaa31150f37655d79a7a3ab","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0245ee104228a100ce5fceecf43e25faae450494d9173f43fd94c27d69fdac13","README.rst":"8fab86c3c759d153a1a8a48e5f7f48546c898f0ec91433001c57fe0002af6455","benches/arraystring.rs":"f12b890977117ebde4ca42bcd6b91f2a6a087f2b235aaca6d15e30d125ae9f67","benches/extend.rs":"c3d69cc488ec5341b019cfed545ebbfea252f98718037b413f6a349da9489d1b","custom.css":"e6f2cd299392337b4e2959c52f422e5b7be11920ea98d10db44d10ddef5ed47c","src/array.rs":"8a42b3ff7a5a0713e8ee22462f303b0ce15bdc49a9fd5eb64f58e56855bdf944","src/array_string.rs":"fdcc24f0fd07e781b378f5d0190279e6d9c89b422f67e546ae443c602f967896","src/char.rs":"40af597d93895f206abcd33953b5d3d5a512d3b16ff5f96e492e659d9cca4209","src/errors.rs":"dde99bffaddfd45396aab7e07642cc018ef5435fe60c4f26a2c05a36555be18c","src/lib.rs":"4c00e50b532aec68b52fde4a737b7b5980b0cfb28f5c09ab8408d04896895a87","src/maybe_uninit.rs":"00659a86e8f84852d4355077a16beceaad0440ac0e81851fbac712fdb1850622","tests/serde.rs":"18c165cf6024f04a25b19aa139657d7c59f72d1541c9b24b44f9eaea01f507db","tests/tests.rs":"9633b92fe6c650b9b816cecac23b9c9e6a0365b1f67d4f0bfaad9e645e2bdc49"},"package":"cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"}

View File

@ -1,62 +0,0 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
edition = "2018"
name = "arrayvec"
version = "0.5.1"
authors = ["bluss"]
description = "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString."
documentation = "https://docs.rs/arrayvec/"
keywords = ["stack", "vector", "array", "data-structure", "no_std"]
categories = ["data-structures", "no-std"]
license = "MIT/Apache-2.0"
repository = "https://github.com/bluss/arrayvec"
[package.metadata.docs.rs]
features = ["serde"]
[package.metadata.release]
no-dev-version = true
tag-name = "{{version}}"
[profile.bench]
debug = true
[profile.release]
debug = true
[[bench]]
name = "extend"
harness = false
[[bench]]
name = "arraystring"
harness = false
[dependencies.serde]
version = "1.0"
optional = true
default-features = false
[dev-dependencies.bencher]
version = "0.1.4"
[dev-dependencies.matches]
version = "0.1"
[dev-dependencies.serde_test]
version = "1.0"
[build-dependencies]
[features]
array-sizes-129-255 = []
array-sizes-33-128 = []
default = ["std"]
std = []

View File

@ -1,259 +0,0 @@
arrayvec
========
A vector with fixed capacity.
Please read the `API documentation here`__
__ https://docs.rs/arrayvec
|build_status|_ |crates|_ |crates2|_
.. |build_status| image:: https://travis-ci.org/bluss/arrayvec.svg
.. _build_status: https://travis-ci.org/bluss/arrayvec
.. |crates| image:: http://meritbadge.herokuapp.com/arrayvec
.. _crates: https://crates.io/crates/arrayvec
.. |crates2| image:: http://meritbadge.herokuapp.com/nodrop
.. _crates2: https://crates.io/crates/nodrop
Recent Changes (arrayvec)
-------------------------
- 0.5.1
- Add ``as_ptr``, ``as_mut_ptr`` accessors directly on the ``ArrayVec`` by @tbu-
(matches the same addition to ``Vec`` which happened in Rust 1.37).
- Add method ``ArrayString::len`` (now available directly, not just through deref to str).
- Use raw pointers instead of ``&mut [u8]`` for encoding chars into ``ArrayString``
(uninit best practice fix).
- Use raw pointers instead of ``get_unchecked_mut`` where the target may be
uninitialized a everywhere relevant in the ArrayVec implementation
(uninit best practice fix).
- Changed inline hints on many methods, mainly removing inline hints
- ``ArrayVec::dispose`` is now deprecated (it has no purpose anymore)
- 0.4.12
- Use raw pointers instead of ``get_unchecked_mut`` where the target may be
uninitialized a everywhere relevant in the ArrayVec implementation.
- 0.5.0
- Use ``MaybeUninit`` (now unconditionally) in the implementation of
``ArrayVec``
- Use ``MaybeUninit`` (now unconditionally) in the implementation of
``ArrayString``
- The crate feature for serde serialization is now named ``serde``.
- Updated the ``Array`` trait interface, and it is now easier to use for
users outside the crate.
- Add ``FromStr`` impl for ``ArrayString`` by @despawnerer
- Add method ``try_extend_from_slice`` to ``ArrayVec``, which is always
effecient by @Thomasdezeeuw.
- Add method ``remaining_capacity`` by @Thomasdezeeuw
- Improve performance of the ``extend`` method.
- The index type of zero capacity vectors is now itself zero size, by
@clarfon
- Use ``drop_in_place`` for truncate and clear methods. This affects drop order
and resume from panic during drop.
- Use Rust 2018 edition for the implementation
- Require Rust 1.36 or later, for the unconditional ``MaybeUninit``
improvements.
- 0.4.11
- In Rust 1.36 or later, use newly stable MaybeUninit. This extends the
soundness work introduced in 0.4.9, we are finally able to use this in
stable. We use feature detection (build script) to enable this at build
time.
- 0.4.10
- Use ``repr(C)`` in the ``union`` version that was introduced in 0.4.9, to
allay some soundness concerns.
- 0.4.9
- Use ``union`` in the implementation on when this is detected to be supported
(nightly only for now). This is a better solution for treating uninitialized
regions correctly, and we'll use it in stable Rust as soon as we are able.
When this is enabled, the ``ArrayVec`` has no space overhead in its memory
layout, although the size of the vec should not be relied upon. (See `#114`_)
- ``ArrayString`` updated to not use uninitialized memory, it instead zeros its
backing array. This will be refined in the next version, since we
need to make changes to the user visible API.
- The ``use_union`` feature now does nothing (like its documentation foretold).
.. _`#114`: https://github.com/bluss/arrayvec/pull/114
- 0.4.8
- Implement Clone and Debug for ``IntoIter`` by @clarcharr
- Add more array sizes under crate features. These cover all in the range
up to 128 and 129 to 255 respectively (we have a few of those by default):
- ``array-size-33-128``
- ``array-size-129-255``
- 0.4.7
- Fix future compat warning about raw pointer casts
- Use ``drop_in_place`` when dropping the arrayvec by-value iterator
- Decrease mininum Rust version (see docs) by @jeehoonkang
- 0.3.25
- Fix future compat warning about raw pointer casts
- 0.4.6
- Fix compilation on 16-bit targets. This means, the 65536 array size is not
included on these targets.
- 0.3.24
- Fix compilation on 16-bit targets. This means, the 65536 array size is not
included on these targets.
- Fix license files so that they are both included (was fixed in 0.4 before)
- 0.4.5
- Add methods to ``ArrayString`` by @DenialAdams:
- ``.pop() -> Option<char>``
- ``.truncate(new_len)``
- ``.remove(index) -> char``
- Remove dependency on crate odds
- Document debug assertions in unsafe methods better
- 0.4.4
- Add method ``ArrayVec::truncate()`` by @niklasf
- 0.4.3
- Improve performance for ``ArrayVec::extend`` with a lower level
implementation (#74)
- Small cleanup in dependencies (use no std for crates where we don't need more)
- 0.4.2
- Add constructor method ``new`` to ``CapacityError``.
- 0.4.1
- Add ``Default`` impl to ``ArrayString`` by @tbu-
- 0.4.0
- Reformed signatures and error handling by @bluss and @tbu-:
- ``ArrayVec``'s ``push, insert, remove, swap_remove`` now match ``Vec``'s
corresponding signature and panic on capacity errors where applicable.
- Add fallible methods ``try_push, insert`` and checked methods
``pop_at, swap_pop``.
- Similar changes to ``ArrayString``'s push methods.
- Use a local version of the ``RangeArgument`` trait
- Add array sizes 50, 150, 200 by @daboross
- Support serde 1.0 by @daboross
- New method ``.push_unchecked()`` by @niklasf
- ``ArrayString`` implements ``PartialOrd, Ord`` by @tbu-
- Require Rust 1.14
- crate feature ``use_generic_array`` was dropped.
- 0.3.23
- Implement ``PartialOrd, Ord`` as well as ``PartialOrd<str>`` for
``ArrayString``.
- 0.3.22
- Implement ``Array`` for the 65536 size
- 0.3.21
- Use ``encode_utf8`` from crate odds
- Add constructor ``ArrayString::from_byte_string``
- 0.3.20
- Simplify and speed up ``ArrayString``s ``.push(char)``-
- 0.3.19
- Add new crate feature ``use_generic_array`` which allows using their
``GenericArray`` just like a regular fixed size array for the storage
of an ``ArrayVec``.
- 0.3.18
- Fix bounds check in ``ArrayVec::insert``!
It would be buggy if ``self.len() < index < self.capacity()``. Take note of
the push out behavior specified in the docs.
- 0.3.17
- Added crate feature ``use_union`` which forwards to the nodrop crate feature
- Added methods ``.is_full()`` to ``ArrayVec`` and ``ArrayString``.
- 0.3.16
- Added method ``.retain()`` to ``ArrayVec``.
- Added methods ``.as_slice(), .as_mut_slice()`` to ``ArrayVec`` and ``.as_str()``
to ``ArrayString``.
- 0.3.15
- Add feature std, which you can opt out of to use ``no_std`` (requires Rust 1.6
to opt out).
- Implement ``Clone::clone_from`` for ArrayVec and ArrayString
- 0.3.14
- Add ``ArrayString::from(&str)``
- 0.3.13
- Added ``DerefMut`` impl for ``ArrayString``.
- Added method ``.simplify()`` to drop the element for ``CapacityError``.
- Added method ``.dispose()`` to ``ArrayVec``
- 0.3.12
- Added ArrayString, a fixed capacity analogy of String
- 0.3.11
- Added trait impls Default, PartialOrd, Ord, Write for ArrayVec
- 0.3.10
- Go back to using external NoDrop, fixing a panic safety bug (issue #3)
- 0.3.8
- Inline the non-dropping logic to remove one drop flag in the
ArrayVec representation.
- 0.3.7
- Added method .into_inner()
- Added unsafe method .set_len()
License
=======
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0 or the MIT license
http://opensource.org/licenses/MIT, at your
option. This file may not be copied, modified, or distributed
except according to those terms.

View File

@ -1,90 +0,0 @@
extern crate arrayvec;
#[macro_use] extern crate bencher;
use arrayvec::ArrayString;
use bencher::Bencher;
fn try_push_c(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
b.iter(|| {
v.clear();
while v.try_push('c').is_ok() {
}
v.len()
});
b.bytes = v.capacity() as u64;
}
fn try_push_alpha(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
b.iter(|| {
v.clear();
while v.try_push('α').is_ok() {
}
v.len()
});
b.bytes = v.capacity() as u64;
}
// Yes, pushing a string char-by-char is slow. Use .push_str.
fn try_push_string(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let input = "abcαβγ“”";
b.iter(|| {
v.clear();
for ch in input.chars().cycle() {
if !v.try_push(ch).is_ok() {
break;
}
}
v.len()
});
b.bytes = v.capacity() as u64;
}
fn push_c(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
b.iter(|| {
v.clear();
while !v.is_full() {
v.push('c');
}
v.len()
});
b.bytes = v.capacity() as u64;
}
fn push_alpha(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
b.iter(|| {
v.clear();
while !v.is_full() {
v.push('α');
}
v.len()
});
b.bytes = v.capacity() as u64;
}
fn push_string(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let input = "abcαβγ“”";
b.iter(|| {
v.clear();
for ch in input.chars().cycle() {
if !v.is_full() {
v.push(ch);
} else {
break;
}
}
v.len()
});
b.bytes = v.capacity() as u64;
}
benchmark_group!(benches, try_push_c, try_push_alpha, try_push_string, push_c,
push_alpha, push_string);
benchmark_main!(benches);

View File

@ -1,78 +0,0 @@
extern crate arrayvec;
#[macro_use] extern crate bencher;
use std::io::Write;
use arrayvec::ArrayVec;
use bencher::Bencher;
use bencher::black_box;
fn extend_with_constant(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let cap = v.capacity();
b.iter(|| {
v.clear();
let constant = black_box(1);
v.extend((0..cap).map(move |_| constant));
v[511]
});
b.bytes = v.capacity() as u64;
}
fn extend_with_range(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let cap = v.capacity();
b.iter(|| {
v.clear();
let range = 0..cap;
v.extend(range.map(|x| black_box(x as _)));
v[511]
});
b.bytes = v.capacity() as u64;
}
fn extend_with_slice(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
let iter = data.iter().map(|&x| x);
v.extend(iter);
v[511]
});
b.bytes = v.capacity() as u64;
}
fn extend_with_write(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
v.write(&data[..]).ok();
v[511]
});
b.bytes = v.capacity() as u64;
}
fn extend_from_slice(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
v.try_extend_from_slice(&data).ok();
v[511]
});
b.bytes = v.capacity() as u64;
}
benchmark_group!(benches,
extend_with_constant,
extend_with_range,
extend_with_slice,
extend_with_write,
extend_from_slice
);
benchmark_main!(benches);

View File

@ -1,25 +0,0 @@
.docblock pre.rust { background: #eeeeff; }
pre.trait, pre.fn, pre.struct, pre.enum, pre.typedef { background: #fcfefc; }
/* Small “example” label for doc examples */
.docblock pre.rust::before {
content: "example";
float: right;
font-style: italic;
font-size: 0.8em;
margin-top: -10px;
margin-right: -5px;
}
/* Fixup where display in trait listing */
pre.trait .where::before {
content: '\a ';
}
.docblock code {
background-color: inherit;
font-weight: bold;
padding: 0 0.1em;
}

View File

@ -1,144 +0,0 @@
/// Trait for fixed size arrays.
///
/// This trait is implemented for some specific array sizes, see
/// the implementor list below. At the current state of Rust we can't
/// make this fully general for every array size.
///
/// The following crate features add more array sizes (and they are not
/// enabled by default due to their impact on compliation speed).
///
/// - `array-sizes-33-128`: All sizes 33 to 128 are implemented
/// (a few in this range are included by default).
/// - `array-sizes-129-255`: All sizes 129 to 255 are implemented
/// (a few in this range are included by default).
///
/// ## Safety
///
/// This trait can *only* be implemented by fixed-size arrays or types with
/// *exactly* the representation of a fixed size array (of the right element
/// type and capacity).
///
/// Normally this trait is an implementation detail of arrayvec and doesnt
/// need implementing.
pub unsafe trait Array {
/// The arrays element type
type Item;
/// The smallest type that can index and tell the length of the array.
#[doc(hidden)]
type Index: Index;
/// The array's element capacity
const CAPACITY: usize;
fn as_slice(&self) -> &[Self::Item];
fn as_mut_slice(&mut self) -> &mut [Self::Item];
}
pub trait Index : PartialEq + Copy {
fn to_usize(self) -> usize;
fn from(_: usize) -> Self;
}
impl Index for () {
#[inline(always)]
fn to_usize(self) -> usize { 0 }
#[inline(always)]
fn from(_ix: usize) -> Self { () }
}
impl Index for bool {
#[inline(always)]
fn to_usize(self) -> usize { self as usize }
#[inline(always)]
fn from(ix: usize) -> Self { ix != 0 }
}
impl Index for u8 {
#[inline(always)]
fn to_usize(self) -> usize { self as usize }
#[inline(always)]
fn from(ix: usize) -> Self { ix as u8 }
}
impl Index for u16 {
#[inline(always)]
fn to_usize(self) -> usize { self as usize }
#[inline(always)]
fn from(ix: usize) -> Self { ix as u16 }
}
impl Index for u32 {
#[inline(always)]
fn to_usize(self) -> usize { self as usize }
#[inline(always)]
fn from(ix: usize) -> Self { ix as u32 }
}
impl Index for usize {
#[inline(always)]
fn to_usize(self) -> usize { self }
#[inline(always)]
fn from(ix: usize) -> Self { ix }
}
macro_rules! fix_array_impl {
($index_type:ty, $len:expr ) => (
unsafe impl<T> Array for [T; $len] {
type Item = T;
type Index = $index_type;
const CAPACITY: usize = $len;
#[doc(hidden)]
fn as_slice(&self) -> &[Self::Item] { self }
#[doc(hidden)]
fn as_mut_slice(&mut self) -> &mut [Self::Item] { self }
}
)
}
macro_rules! fix_array_impl_recursive {
($index_type:ty, ) => ();
($index_type:ty, $($len:expr,)*) => (
$(fix_array_impl!($index_type, $len);)*
);
}
fix_array_impl_recursive!((), 0,);
fix_array_impl_recursive!(bool, 1,);
fix_array_impl_recursive!(u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, );
#[cfg(not(feature="array-sizes-33-128"))]
fix_array_impl_recursive!(u8, 32, 40, 48, 50, 56, 64, 72, 96, 100, 128, );
#[cfg(feature="array-sizes-33-128")]
fix_array_impl_recursive!(u8,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
125, 126, 127, 128,
);
#[cfg(not(feature="array-sizes-129-255"))]
fix_array_impl_recursive!(u8, 160, 192, 200, 224,);
#[cfg(feature="array-sizes-129-255")]
fix_array_impl_recursive!(u8,
129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236,
237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252,
253, 254, 255,
);
fix_array_impl_recursive!(u16, 256, 384, 512, 768, 1024, 2048, 4096, 8192, 16384, 32768,);
// This array size doesn't exist on 16-bit
#[cfg(any(target_pointer_width="32", target_pointer_width="64"))]
fix_array_impl_recursive!(u32, 1 << 16,);

View File

@ -1,567 +0,0 @@
use std::borrow::Borrow;
use std::cmp;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::ptr;
use std::ops::{Deref, DerefMut};
use std::str;
use std::str::FromStr;
use std::str::Utf8Error;
use std::slice;
use crate::array::Array;
use crate::array::Index;
use crate::CapacityError;
use crate::char::encode_utf8;
#[cfg(feature="serde")]
use serde::{Serialize, Deserialize, Serializer, Deserializer};
use super::MaybeUninit as MaybeUninitCopy;
/// A string with a fixed capacity.
///
/// The `ArrayString` is a string backed by a fixed size array. It keeps track
/// of its length.
///
/// The string is a contiguous value that you can store directly on the stack
/// if needed.
#[derive(Copy)]
pub struct ArrayString<A>
where A: Array<Item=u8> + Copy
{
xs: MaybeUninitCopy<A>,
len: A::Index,
}
impl<A> Default for ArrayString<A>
where A: Array<Item=u8> + Copy
{
/// Return an empty `ArrayString`
fn default() -> ArrayString<A> {
ArrayString::new()
}
}
impl<A> ArrayString<A>
where A: Array<Item=u8> + Copy
{
/// Create a new empty `ArrayString`.
///
/// Capacity is inferred from the type parameter.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 16]>::new();
/// string.push_str("foo");
/// assert_eq!(&string[..], "foo");
/// assert_eq!(string.capacity(), 16);
/// ```
pub fn new() -> ArrayString<A> {
unsafe {
ArrayString {
xs: MaybeUninitCopy::uninitialized(),
len: Index::from(0),
}
}
}
/// Return the length of the string.
#[inline]
pub fn len(&self) -> usize { self.len.to_usize() }
/// Create a new `ArrayString` from a `str`.
///
/// Capacity is inferred from the type parameter.
///
/// **Errors** if the backing array is not large enough to fit the string.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 3]>::from("foo").unwrap();
/// assert_eq!(&string[..], "foo");
/// assert_eq!(string.len(), 3);
/// assert_eq!(string.capacity(), 3);
/// ```
pub fn from(s: &str) -> Result<Self, CapacityError<&str>> {
let mut arraystr = Self::new();
arraystr.try_push_str(s)?;
Ok(arraystr)
}
/// Create a new `ArrayString` from a byte string literal.
///
/// **Errors** if the byte string literal is not valid UTF-8.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let string = ArrayString::from_byte_string(b"hello world").unwrap();
/// ```
pub fn from_byte_string(b: &A) -> Result<Self, Utf8Error> {
let len = str::from_utf8(b.as_slice())?.len();
debug_assert_eq!(len, A::CAPACITY);
Ok(ArrayString {
xs: MaybeUninitCopy::from(*b),
len: Index::from(A::CAPACITY),
})
}
/// Return the capacity of the `ArrayString`.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let string = ArrayString::<[_; 3]>::new();
/// assert_eq!(string.capacity(), 3);
/// ```
#[inline(always)]
pub fn capacity(&self) -> usize { A::CAPACITY }
/// Return if the `ArrayString` is completely filled.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 1]>::new();
/// assert!(!string.is_full());
/// string.push_str("A");
/// assert!(string.is_full());
/// ```
pub fn is_full(&self) -> bool { self.len() == self.capacity() }
/// Adds the given char to the end of the string.
///
/// ***Panics*** if the backing array is not large enough to fit the additional char.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 2]>::new();
///
/// string.push('a');
/// string.push('b');
///
/// assert_eq!(&string[..], "ab");
/// ```
pub fn push(&mut self, c: char) {
self.try_push(c).unwrap();
}
/// Adds the given char to the end of the string.
///
/// Returns `Ok` if the push succeeds.
///
/// **Errors** if the backing array is not large enough to fit the additional char.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 2]>::new();
///
/// string.try_push('a').unwrap();
/// string.try_push('b').unwrap();
/// let overflow = string.try_push('c');
///
/// assert_eq!(&string[..], "ab");
/// assert_eq!(overflow.unwrap_err().element(), 'c');
/// ```
pub fn try_push(&mut self, c: char) -> Result<(), CapacityError<char>> {
let len = self.len();
unsafe {
let ptr = self.xs.ptr_mut().add(len);
let remaining_cap = self.capacity() - len;
match encode_utf8(c, ptr, remaining_cap) {
Ok(n) => {
self.set_len(len + n);
Ok(())
}
Err(_) => Err(CapacityError::new(c)),
}
}
}
/// Adds the given string slice to the end of the string.
///
/// ***Panics*** if the backing array is not large enough to fit the string.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 2]>::new();
///
/// string.push_str("a");
/// string.push_str("d");
///
/// assert_eq!(&string[..], "ad");
/// ```
pub fn push_str(&mut self, s: &str) {
self.try_push_str(s).unwrap()
}
/// Adds the given string slice to the end of the string.
///
/// Returns `Ok` if the push succeeds.
///
/// **Errors** if the backing array is not large enough to fit the string.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 2]>::new();
///
/// string.try_push_str("a").unwrap();
/// let overflow1 = string.try_push_str("bc");
/// string.try_push_str("d").unwrap();
/// let overflow2 = string.try_push_str("ef");
///
/// assert_eq!(&string[..], "ad");
/// assert_eq!(overflow1.unwrap_err().element(), "bc");
/// assert_eq!(overflow2.unwrap_err().element(), "ef");
/// ```
pub fn try_push_str<'a>(&mut self, s: &'a str) -> Result<(), CapacityError<&'a str>> {
if s.len() > self.capacity() - self.len() {
return Err(CapacityError::new(s));
}
unsafe {
let dst = self.xs.ptr_mut().offset(self.len() as isize);
let src = s.as_ptr();
ptr::copy_nonoverlapping(src, dst, s.len());
let newl = self.len() + s.len();
self.set_len(newl);
}
Ok(())
}
/// Removes the last character from the string and returns it.
///
/// Returns `None` if this `ArrayString` is empty.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut s = ArrayString::<[_; 3]>::from("foo").unwrap();
///
/// assert_eq!(s.pop(), Some('o'));
/// assert_eq!(s.pop(), Some('o'));
/// assert_eq!(s.pop(), Some('f'));
///
/// assert_eq!(s.pop(), None);
/// ```
pub fn pop(&mut self) -> Option<char> {
let ch = match self.chars().rev().next() {
Some(ch) => ch,
None => return None,
};
let new_len = self.len() - ch.len_utf8();
unsafe {
self.set_len(new_len);
}
Some(ch)
}
/// Shortens this `ArrayString` to the specified length.
///
/// If `new_len` is greater than the strings current length, this has no
/// effect.
///
/// ***Panics*** if `new_len` does not lie on a `char` boundary.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<[_; 6]>::from("foobar").unwrap();
/// string.truncate(3);
/// assert_eq!(&string[..], "foo");
/// string.truncate(4);
/// assert_eq!(&string[..], "foo");
/// ```
pub fn truncate(&mut self, new_len: usize) {
if new_len <= self.len() {
assert!(self.is_char_boundary(new_len));
unsafe {
// In libstd truncate is called on the underlying vector,
// which in turns drops each element.
// As we know we don't have to worry about Drop,
// we can just set the length (a la clear.)
self.set_len(new_len);
}
}
}
/// Removes a `char` from this `ArrayString` at a byte position and returns it.
///
/// This is an `O(n)` operation, as it requires copying every element in the
/// array.
///
/// ***Panics*** if `idx` is larger than or equal to the `ArrayString`s length,
/// or if it does not lie on a `char` boundary.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut s = ArrayString::<[_; 3]>::from("foo").unwrap();
///
/// assert_eq!(s.remove(0), 'f');
/// assert_eq!(s.remove(1), 'o');
/// assert_eq!(s.remove(0), 'o');
/// ```
pub fn remove(&mut self, idx: usize) -> char {
let ch = match self[idx..].chars().next() {
Some(ch) => ch,
None => panic!("cannot remove a char from the end of a string"),
};
let next = idx + ch.len_utf8();
let len = self.len();
unsafe {
ptr::copy(self.xs.ptr().offset(next as isize),
self.xs.ptr_mut().offset(idx as isize),
len - next);
self.set_len(len - (next - idx));
}
ch
}
/// Make the string empty.
pub fn clear(&mut self) {
unsafe {
self.set_len(0);
}
}
/// Set the stringss length.
///
/// This function is `unsafe` because it changes the notion of the
/// number of “valid” bytes in the string. Use with care.
///
/// This method uses *debug assertions* to check the validity of `length`
/// and may use other debug assertions.
pub unsafe fn set_len(&mut self, length: usize) {
debug_assert!(length <= self.capacity());
self.len = Index::from(length);
}
/// Return a string slice of the whole `ArrayString`.
pub fn as_str(&self) -> &str {
self
}
}
impl<A> Deref for ArrayString<A>
where A: Array<Item=u8> + Copy
{
type Target = str;
#[inline]
fn deref(&self) -> &str {
unsafe {
let sl = slice::from_raw_parts(self.xs.ptr(), self.len.to_usize());
str::from_utf8_unchecked(sl)
}
}
}
impl<A> DerefMut for ArrayString<A>
where A: Array<Item=u8> + Copy
{
#[inline]
fn deref_mut(&mut self) -> &mut str {
unsafe {
let sl = slice::from_raw_parts_mut(self.xs.ptr_mut(), self.len.to_usize());
str::from_utf8_unchecked_mut(sl)
}
}
}
impl<A> PartialEq for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn eq(&self, rhs: &Self) -> bool {
**self == **rhs
}
}
impl<A> PartialEq<str> for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn eq(&self, rhs: &str) -> bool {
&**self == rhs
}
}
impl<A> PartialEq<ArrayString<A>> for str
where A: Array<Item=u8> + Copy
{
fn eq(&self, rhs: &ArrayString<A>) -> bool {
self == &**rhs
}
}
impl<A> Eq for ArrayString<A>
where A: Array<Item=u8> + Copy
{ }
impl<A> Hash for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn hash<H: Hasher>(&self, h: &mut H) {
(**self).hash(h)
}
}
impl<A> Borrow<str> for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn borrow(&self) -> &str { self }
}
impl<A> AsRef<str> for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn as_ref(&self) -> &str { self }
}
impl<A> fmt::Debug for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) }
}
impl<A> fmt::Display for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) }
}
/// `Write` appends written data to the end of the string.
impl<A> fmt::Write for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn write_char(&mut self, c: char) -> fmt::Result {
self.try_push(c).map_err(|_| fmt::Error)
}
fn write_str(&mut self, s: &str) -> fmt::Result {
self.try_push_str(s).map_err(|_| fmt::Error)
}
}
impl<A> Clone for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn clone(&self) -> ArrayString<A> {
*self
}
fn clone_from(&mut self, rhs: &Self) {
// guaranteed to fit due to types matching.
self.clear();
self.try_push_str(rhs).ok();
}
}
impl<A> PartialOrd for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn partial_cmp(&self, rhs: &Self) -> Option<cmp::Ordering> {
(**self).partial_cmp(&**rhs)
}
fn lt(&self, rhs: &Self) -> bool { **self < **rhs }
fn le(&self, rhs: &Self) -> bool { **self <= **rhs }
fn gt(&self, rhs: &Self) -> bool { **self > **rhs }
fn ge(&self, rhs: &Self) -> bool { **self >= **rhs }
}
impl<A> PartialOrd<str> for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn partial_cmp(&self, rhs: &str) -> Option<cmp::Ordering> {
(**self).partial_cmp(rhs)
}
fn lt(&self, rhs: &str) -> bool { &**self < rhs }
fn le(&self, rhs: &str) -> bool { &**self <= rhs }
fn gt(&self, rhs: &str) -> bool { &**self > rhs }
fn ge(&self, rhs: &str) -> bool { &**self >= rhs }
}
impl<A> PartialOrd<ArrayString<A>> for str
where A: Array<Item=u8> + Copy
{
fn partial_cmp(&self, rhs: &ArrayString<A>) -> Option<cmp::Ordering> {
self.partial_cmp(&**rhs)
}
fn lt(&self, rhs: &ArrayString<A>) -> bool { self < &**rhs }
fn le(&self, rhs: &ArrayString<A>) -> bool { self <= &**rhs }
fn gt(&self, rhs: &ArrayString<A>) -> bool { self > &**rhs }
fn ge(&self, rhs: &ArrayString<A>) -> bool { self >= &**rhs }
}
impl<A> Ord for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn cmp(&self, rhs: &Self) -> cmp::Ordering {
(**self).cmp(&**rhs)
}
}
impl<A> FromStr for ArrayString<A>
where A: Array<Item=u8> + Copy
{
type Err = CapacityError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::from(s).map_err(CapacityError::simplify)
}
}
#[cfg(feature="serde")]
/// Requires crate feature `"serde"`
impl<A> Serialize for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer
{
serializer.serialize_str(&*self)
}
}
#[cfg(feature="serde")]
/// Requires crate feature `"serde"`
impl<'de, A> Deserialize<'de> for ArrayString<A>
where A: Array<Item=u8> + Copy
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>
{
use serde::de::{self, Visitor};
use std::marker::PhantomData;
struct ArrayStringVisitor<A: Array<Item=u8>>(PhantomData<A>);
impl<'de, A: Copy + Array<Item=u8>> Visitor<'de> for ArrayStringVisitor<A> {
type Value = ArrayString<A>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a string no more than {} bytes long", A::CAPACITY)
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where E: de::Error,
{
ArrayString::from(v).map_err(|_| E::invalid_length(v.len(), &self))
}
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
where E: de::Error,
{
let s = str::from_utf8(v).map_err(|_| E::invalid_value(de::Unexpected::Bytes(v), &self))?;
ArrayString::from(s).map_err(|_| E::invalid_length(s.len(), &self))
}
}
deserializer.deserialize_str(ArrayStringVisitor::<A>(PhantomData))
}
}

View File

@ -1,98 +0,0 @@
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//
// Original authors: alexchrichton, bluss
use std::ptr;
// UTF-8 ranges and tags for encoding characters
const TAG_CONT: u8 = 0b1000_0000;
const TAG_TWO_B: u8 = 0b1100_0000;
const TAG_THREE_B: u8 = 0b1110_0000;
const TAG_FOUR_B: u8 = 0b1111_0000;
const MAX_ONE_B: u32 = 0x80;
const MAX_TWO_B: u32 = 0x800;
const MAX_THREE_B: u32 = 0x10000;
/// Placeholder
pub struct EncodeUtf8Error;
#[inline]
unsafe fn write(ptr: *mut u8, index: usize, byte: u8) {
ptr::write(ptr.add(index), byte)
}
/// Encode a char into buf using UTF-8.
///
/// On success, return the byte length of the encoding (1, 2, 3 or 4).<br>
/// On error, return `EncodeUtf8Error` if the buffer was too short for the char.
///
/// Safety: `ptr` must be writable for `len` bytes.
#[inline]
pub unsafe fn encode_utf8(ch: char, ptr: *mut u8, len: usize) -> Result<usize, EncodeUtf8Error>
{
let code = ch as u32;
if code < MAX_ONE_B && len >= 1 {
write(ptr, 0, code as u8);
return Ok(1);
} else if code < MAX_TWO_B && len >= 2 {
write(ptr, 0, (code >> 6 & 0x1F) as u8 | TAG_TWO_B);
write(ptr, 1, (code & 0x3F) as u8 | TAG_CONT);
return Ok(2);
} else if code < MAX_THREE_B && len >= 3 {
write(ptr, 0, (code >> 12 & 0x0F) as u8 | TAG_THREE_B);
write(ptr, 1, (code >> 6 & 0x3F) as u8 | TAG_CONT);
write(ptr, 2, (code & 0x3F) as u8 | TAG_CONT);
return Ok(3);
} else if len >= 4 {
write(ptr, 0, (code >> 18 & 0x07) as u8 | TAG_FOUR_B);
write(ptr, 1, (code >> 12 & 0x3F) as u8 | TAG_CONT);
write(ptr, 2, (code >> 6 & 0x3F) as u8 | TAG_CONT);
write(ptr, 3, (code & 0x3F) as u8 | TAG_CONT);
return Ok(4);
};
Err(EncodeUtf8Error)
}
#[test]
fn test_encode_utf8() {
// Test that all codepoints are encoded correctly
let mut data = [0u8; 16];
for codepoint in 0..=(std::char::MAX as u32) {
if let Some(ch) = std::char::from_u32(codepoint) {
for elt in &mut data { *elt = 0; }
let ptr = data.as_mut_ptr();
let len = data.len();
unsafe {
let res = encode_utf8(ch, ptr, len).ok().unwrap();
assert_eq!(res, ch.len_utf8());
}
let string = std::str::from_utf8(&data).unwrap();
assert_eq!(string.chars().next(), Some(ch));
}
}
}
#[test]
fn test_encode_utf8_oob() {
// test that we report oob if the buffer is too short
let mut data = [0u8; 16];
let chars = ['a', 'α', '<27>', '𐍈'];
for (len, &ch) in (1..=4).zip(&chars) {
assert_eq!(len, ch.len_utf8(), "Len of ch={}", ch);
let ptr = data.as_mut_ptr();
unsafe {
assert!(matches::matches!(encode_utf8(ch, ptr, len - 1), Err(_)));
assert!(matches::matches!(encode_utf8(ch, ptr, len), Ok(_)));
}
}
}

View File

@ -1,53 +0,0 @@
use std::fmt;
#[cfg(feature="std")]
use std::any::Any;
#[cfg(feature="std")]
use std::error::Error;
/// Error value indicating insufficient capacity
#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
pub struct CapacityError<T = ()> {
element: T,
}
impl<T> CapacityError<T> {
/// Create a new `CapacityError` from `element`.
pub fn new(element: T) -> CapacityError<T> {
CapacityError {
element: element,
}
}
/// Extract the overflowing element
pub fn element(self) -> T {
self.element
}
/// Convert into a `CapacityError` that does not carry an element.
pub fn simplify(self) -> CapacityError {
CapacityError { element: () }
}
}
const CAPERROR: &'static str = "insufficient capacity";
#[cfg(feature="std")]
/// Requires `features="std"`.
impl<T: Any> Error for CapacityError<T> {
fn description(&self) -> &str {
CAPERROR
}
}
impl<T> fmt::Display for CapacityError<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", CAPERROR)
}
}
impl<T> fmt::Debug for CapacityError<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}: {}", "CapacityError", CAPERROR)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
use crate::array::Array;
use std::mem::MaybeUninit as StdMaybeUninit;
#[derive(Copy)]
pub struct MaybeUninit<T> {
inner: StdMaybeUninit<T>,
}
impl<T> Clone for MaybeUninit<T>
where T: Copy
{
fn clone(&self) -> Self { *self }
}
impl<T> MaybeUninit<T> {
/// Create a new MaybeUninit with uninitialized interior
pub unsafe fn uninitialized() -> Self {
MaybeUninit { inner: StdMaybeUninit::uninit() }
}
/// Create a new MaybeUninit from the value `v`.
pub fn from(v: T) -> Self {
MaybeUninit { inner: StdMaybeUninit::new(v) }
}
// Raw pointer casts written so that we don't reference or access the
// uninitialized interior value
/// Return a raw pointer to the start of the interior array
pub fn ptr(&self) -> *const T::Item
where T: Array
{
self.inner.as_ptr() as *const T::Item
}
/// Return a mut raw pointer to the start of the interior array
pub fn ptr_mut(&mut self) -> *mut T::Item
where T: Array
{
self.inner.as_mut_ptr() as *mut T::Item
}
}

View File

@ -1,79 +0,0 @@
#![cfg(feature = "serde")]
extern crate arrayvec;
extern crate serde_test;
mod array_vec {
use arrayvec::ArrayVec;
use serde_test::{Token, assert_tokens, assert_de_tokens_error};
#[test]
fn test_ser_de_empty() {
let vec = ArrayVec::<[u32; 0]>::new();
assert_tokens(&vec, &[
Token::Seq { len: Some(0) },
Token::SeqEnd,
]);
}
#[test]
fn test_ser_de() {
let mut vec = ArrayVec::<[u32; 3]>::new();
vec.push(20);
vec.push(55);
vec.push(123);
assert_tokens(&vec, &[
Token::Seq { len: Some(3) },
Token::U32(20),
Token::U32(55),
Token::U32(123),
Token::SeqEnd,
]);
}
#[test]
fn test_de_too_large() {
assert_de_tokens_error::<ArrayVec<[u32; 2]>>(&[
Token::Seq { len: Some(3) },
Token::U32(13),
Token::U32(42),
Token::U32(68),
], "invalid length 3, expected an array with no more than 2 items");
}
}
mod array_string {
use arrayvec::ArrayString;
use serde_test::{Token, assert_tokens, assert_de_tokens_error};
#[test]
fn test_ser_de_empty() {
let string = ArrayString::<[u8; 0]>::new();
assert_tokens(&string, &[
Token::Str(""),
]);
}
#[test]
fn test_ser_de() {
let string = ArrayString::<[u8; 9]>::from("1234 abcd")
.expect("expected exact specified capacity to be enough");
assert_tokens(&string, &[
Token::Str("1234 abcd"),
]);
}
#[test]
fn test_de_too_large() {
assert_de_tokens_error::<ArrayString<[u8; 2]>>(&[
Token::Str("afd")
], "invalid length 3, expected a string no more than 2 bytes long");
}
}

View File

@ -1,679 +0,0 @@
extern crate arrayvec;
#[macro_use] extern crate matches;
use arrayvec::ArrayVec;
use arrayvec::ArrayString;
use std::mem;
use arrayvec::CapacityError;
use std::collections::HashMap;
#[test]
fn test_simple() {
use std::ops::Add;
let mut vec: ArrayVec<[Vec<i32>; 3]> = ArrayVec::new();
vec.push(vec![1, 2, 3, 4]);
vec.push(vec![10]);
vec.push(vec![-1, 13, -2]);
for elt in &vec {
assert_eq!(elt.iter().fold(0, Add::add), 10);
}
let sum_len = vec.into_iter().map(|x| x.len()).fold(0, Add::add);
assert_eq!(sum_len, 8);
}
#[test]
fn test_capacity_left() {
let mut vec: ArrayVec<[usize; 4]> = ArrayVec::new();
assert_eq!(vec.remaining_capacity(), 4);
vec.push(1);
assert_eq!(vec.remaining_capacity(), 3);
vec.push(2);
assert_eq!(vec.remaining_capacity(), 2);
vec.push(3);
assert_eq!(vec.remaining_capacity(), 1);
vec.push(4);
assert_eq!(vec.remaining_capacity(), 0);
}
#[test]
fn test_extend_from_slice() {
let mut vec: ArrayVec<[usize; 10]> = ArrayVec::new();
vec.try_extend_from_slice(&[1, 2, 3]).unwrap();
assert_eq!(vec.len(), 3);
assert_eq!(&vec[..], &[1, 2, 3]);
assert_eq!(vec.pop(), Some(3));
assert_eq!(&vec[..], &[1, 2]);
}
#[test]
fn test_extend_from_slice_error() {
let mut vec: ArrayVec<[usize; 10]> = ArrayVec::new();
vec.try_extend_from_slice(&[1, 2, 3]).unwrap();
let res = vec.try_extend_from_slice(&[0; 8]);
assert_matches!(res, Err(_));
let mut vec: ArrayVec<[usize; 0]> = ArrayVec::new();
let res = vec.try_extend_from_slice(&[0; 1]);
assert_matches!(res, Err(_));
}
#[test]
fn test_u16_index() {
const N: usize = 4096;
let mut vec: ArrayVec<[_; N]> = ArrayVec::new();
for _ in 0..N {
assert!(vec.try_push(1u8).is_ok());
}
assert!(vec.try_push(0).is_err());
assert_eq!(vec.len(), N);
}
#[test]
fn test_iter() {
let mut iter = ArrayVec::from([1, 2, 3]).into_iter();
assert_eq!(iter.size_hint(), (3, Some(3)));
assert_eq!(iter.next_back(), Some(3));
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next_back(), Some(2));
assert_eq!(iter.size_hint(), (0, Some(0)));
assert_eq!(iter.next_back(), None);
}
#[test]
fn test_drop() {
use std::cell::Cell;
let flag = &Cell::new(0);
#[derive(Clone)]
struct Bump<'a>(&'a Cell<i32>);
impl<'a> Drop for Bump<'a> {
fn drop(&mut self) {
let n = self.0.get();
self.0.set(n + 1);
}
}
{
let mut array = ArrayVec::<[Bump; 128]>::new();
array.push(Bump(flag));
array.push(Bump(flag));
}
assert_eq!(flag.get(), 2);
// test something with the nullable pointer optimization
flag.set(0);
{
let mut array = ArrayVec::<[_; 3]>::new();
array.push(vec![Bump(flag)]);
array.push(vec![Bump(flag), Bump(flag)]);
array.push(vec![]);
let push4 = array.try_push(vec![Bump(flag)]);
assert_eq!(flag.get(), 0);
drop(push4);
assert_eq!(flag.get(), 1);
drop(array.pop());
assert_eq!(flag.get(), 1);
drop(array.pop());
assert_eq!(flag.get(), 3);
}
assert_eq!(flag.get(), 4);
// test into_inner
flag.set(0);
{
let mut array = ArrayVec::<[_; 3]>::new();
array.push(Bump(flag));
array.push(Bump(flag));
array.push(Bump(flag));
let inner = array.into_inner();
assert!(inner.is_ok());
assert_eq!(flag.get(), 0);
drop(inner);
assert_eq!(flag.get(), 3);
}
// test cloning into_iter
flag.set(0);
{
let mut array = ArrayVec::<[_; 3]>::new();
array.push(Bump(flag));
array.push(Bump(flag));
array.push(Bump(flag));
let mut iter = array.into_iter();
assert_eq!(flag.get(), 0);
iter.next();
assert_eq!(flag.get(), 1);
let clone = iter.clone();
assert_eq!(flag.get(), 1);
drop(clone);
assert_eq!(flag.get(), 3);
drop(iter);
assert_eq!(flag.get(), 5);
}
}
#[test]
fn test_drop_panics() {
use std::cell::Cell;
use std::panic::catch_unwind;
use std::panic::AssertUnwindSafe;
let flag = &Cell::new(0);
struct Bump<'a>(&'a Cell<i32>);
// Panic in the first drop
impl<'a> Drop for Bump<'a> {
fn drop(&mut self) {
let n = self.0.get();
self.0.set(n + 1);
if n == 0 {
panic!("Panic in Bump's drop");
}
}
}
// check if rust is new enough
flag.set(0);
{
let array = vec![Bump(flag), Bump(flag)];
let res = catch_unwind(AssertUnwindSafe(|| {
drop(array);
}));
assert!(res.is_err());
}
if flag.get() != 2 {
println!("test_drop_panics: skip, this version of Rust doesn't continue in drop_in_place");
return;
}
flag.set(0);
{
let mut array = ArrayVec::<[Bump; 128]>::new();
array.push(Bump(flag));
array.push(Bump(flag));
array.push(Bump(flag));
let res = catch_unwind(AssertUnwindSafe(|| {
drop(array);
}));
assert!(res.is_err());
}
// Check that all the elements drop, even if the first drop panics.
assert_eq!(flag.get(), 3);
flag.set(0);
{
let mut array = ArrayVec::<[Bump; 16]>::new();
array.push(Bump(flag));
array.push(Bump(flag));
array.push(Bump(flag));
array.push(Bump(flag));
array.push(Bump(flag));
let i = 2;
let tail_len = array.len() - i;
let res = catch_unwind(AssertUnwindSafe(|| {
array.truncate(i);
}));
assert!(res.is_err());
// Check that all the tail elements drop, even if the first drop panics.
assert_eq!(flag.get(), tail_len as i32);
}
}
#[test]
fn test_extend() {
let mut range = 0..10;
let mut array: ArrayVec<[_; 5]> = range.by_ref().collect();
assert_eq!(&array[..], &[0, 1, 2, 3, 4]);
assert_eq!(range.next(), Some(5));
array.extend(range.by_ref());
assert_eq!(range.next(), Some(6));
let mut array: ArrayVec<[_; 10]> = (0..3).collect();
assert_eq!(&array[..], &[0, 1, 2]);
array.extend(3..5);
assert_eq!(&array[..], &[0, 1, 2, 3, 4]);
}
#[test]
fn test_is_send_sync() {
let data = ArrayVec::<[Vec<i32>; 5]>::new();
&data as &dyn Send;
&data as &dyn Sync;
}
#[test]
fn test_compact_size() {
// Future rust will kill these drop flags!
// 4 elements size + 1 len + 1 enum tag + [1 drop flag]
type ByteArray = ArrayVec<[u8; 4]>;
println!("{}", mem::size_of::<ByteArray>());
assert!(mem::size_of::<ByteArray>() <= 8);
// 1 enum tag + 1 drop flag
type EmptyArray = ArrayVec<[u8; 0]>;
println!("{}", mem::size_of::<EmptyArray>());
assert!(mem::size_of::<EmptyArray>() <= 2);
// 12 element size + 1 enum tag + 3 padding + 1 len + 1 drop flag + 2 padding
type QuadArray = ArrayVec<[u32; 3]>;
println!("{}", mem::size_of::<QuadArray>());
assert!(mem::size_of::<QuadArray>() <= 24);
}
#[test]
fn test_still_works_with_option_arrayvec() {
type RefArray = ArrayVec<[&'static i32; 2]>;
let array = Some(RefArray::new());
assert!(array.is_some());
println!("{:?}", array);
}
#[test]
fn test_drain() {
let mut v = ArrayVec::from([0; 8]);
v.pop();
v.drain(0..7);
assert_eq!(&v[..], &[]);
v.extend(0..);
v.drain(1..4);
assert_eq!(&v[..], &[0, 4, 5, 6, 7]);
let u: ArrayVec<[_; 3]> = v.drain(1..4).rev().collect();
assert_eq!(&u[..], &[6, 5, 4]);
assert_eq!(&v[..], &[0, 7]);
v.drain(..);
assert_eq!(&v[..], &[]);
}
#[test]
fn test_drain_range_inclusive() {
let mut v = ArrayVec::from([0; 8]);
v.drain(0..=7);
assert_eq!(&v[..], &[]);
v.extend(0..);
v.drain(1..=4);
assert_eq!(&v[..], &[0, 5, 6, 7]);
let u: ArrayVec<[_; 3]> = v.drain(1..=2).rev().collect();
assert_eq!(&u[..], &[6, 5]);
assert_eq!(&v[..], &[0, 7]);
v.drain(..);
assert_eq!(&v[..], &[]);
}
#[test]
#[should_panic]
fn test_drain_range_inclusive_oob() {
let mut v = ArrayVec::from([0; 0]);
v.drain(0..=0);
}
#[test]
fn test_retain() {
let mut v = ArrayVec::from([0; 8]);
for (i, elt) in v.iter_mut().enumerate() {
*elt = i;
}
v.retain(|_| true);
assert_eq!(&v[..], &[0, 1, 2, 3, 4, 5, 6, 7]);
v.retain(|elt| {
*elt /= 2;
*elt % 2 == 0
});
assert_eq!(&v[..], &[0, 0, 2, 2]);
v.retain(|_| false);
assert_eq!(&v[..], &[]);
}
#[test]
#[should_panic]
fn test_drain_oob() {
let mut v = ArrayVec::from([0; 8]);
v.pop();
v.drain(0..8);
}
#[test]
#[should_panic]
fn test_drop_panic() {
struct DropPanic;
impl Drop for DropPanic {
fn drop(&mut self) {
panic!("drop");
}
}
let mut array = ArrayVec::<[DropPanic; 1]>::new();
array.push(DropPanic);
}
#[test]
#[should_panic]
fn test_drop_panic_into_iter() {
struct DropPanic;
impl Drop for DropPanic {
fn drop(&mut self) {
panic!("drop");
}
}
let mut array = ArrayVec::<[DropPanic; 1]>::new();
array.push(DropPanic);
array.into_iter();
}
#[test]
fn test_insert() {
let mut v = ArrayVec::from([]);
assert_matches!(v.try_push(1), Err(_));
let mut v = ArrayVec::<[_; 3]>::new();
v.insert(0, 0);
v.insert(1, 1);
//let ret1 = v.try_insert(3, 3);
//assert_matches!(ret1, Err(InsertError::OutOfBounds(_)));
assert_eq!(&v[..], &[0, 1]);
v.insert(2, 2);
assert_eq!(&v[..], &[0, 1, 2]);
let ret2 = v.try_insert(1, 9);
assert_eq!(&v[..], &[0, 1, 2]);
assert_matches!(ret2, Err(_));
let mut v = ArrayVec::from([2]);
assert_matches!(v.try_insert(0, 1), Err(CapacityError { .. }));
assert_matches!(v.try_insert(1, 1), Err(CapacityError { .. }));
//assert_matches!(v.try_insert(2, 1), Err(CapacityError { .. }));
}
#[test]
fn test_into_inner_1() {
let mut v = ArrayVec::from([1, 2]);
v.pop();
let u = v.clone();
assert_eq!(v.into_inner(), Err(u));
}
#[test]
fn test_into_inner_2() {
let mut v = ArrayVec::<[String; 4]>::new();
v.push("a".into());
v.push("b".into());
v.push("c".into());
v.push("d".into());
assert_eq!(v.into_inner().unwrap(), ["a", "b", "c", "d"]);
}
#[test]
fn test_into_inner_3_() {
let mut v = ArrayVec::<[i32; 4]>::new();
v.extend(1..);
assert_eq!(v.into_inner().unwrap(), [1, 2, 3, 4]);
}
#[cfg(feature="std")]
#[test]
fn test_write() {
use std::io::Write;
let mut v = ArrayVec::<[_; 8]>::new();
write!(&mut v, "\x01\x02\x03").unwrap();
assert_eq!(&v[..], &[1, 2, 3]);
let r = v.write(&[9; 16]).unwrap();
assert_eq!(r, 5);
assert_eq!(&v[..], &[1, 2, 3, 9, 9, 9, 9, 9]);
}
#[test]
fn array_clone_from() {
let mut v = ArrayVec::<[_; 4]>::new();
v.push(vec![1, 2]);
v.push(vec![3, 4, 5]);
v.push(vec![6]);
let reference = v.to_vec();
let mut u = ArrayVec::<[_; 4]>::new();
u.clone_from(&v);
assert_eq!(&u, &reference[..]);
let mut t = ArrayVec::<[_; 4]>::new();
t.push(vec![97]);
t.push(vec![]);
t.push(vec![5, 6, 2]);
t.push(vec![2]);
t.clone_from(&v);
assert_eq!(&t, &reference[..]);
t.clear();
t.clone_from(&v);
assert_eq!(&t, &reference[..]);
}
#[cfg(feature="std")]
#[test]
fn test_string() {
use std::error::Error;
let text = "hello world";
let mut s = ArrayString::<[_; 16]>::new();
s.try_push_str(text).unwrap();
assert_eq!(&s, text);
assert_eq!(text, &s);
// Make sure Hash / Eq / Borrow match up so we can use HashMap
let mut map = HashMap::new();
map.insert(s, 1);
assert_eq!(map[text], 1);
let mut t = ArrayString::<[_; 2]>::new();
assert!(t.try_push_str(text).is_err());
assert_eq!(&t, "");
t.push_str("ab");
// DerefMut
let tmut: &mut str = &mut t;
assert_eq!(tmut, "ab");
// Test Error trait / try
let t = || -> Result<(), Box<dyn Error>> {
let mut t = ArrayString::<[_; 2]>::new();
t.try_push_str(text)?;
Ok(())
}();
assert!(t.is_err());
}
#[test]
fn test_string_from() {
let text = "hello world";
// Test `from` constructor
let u = ArrayString::<[_; 11]>::from(text).unwrap();
assert_eq!(&u, text);
assert_eq!(u.len(), text.len());
}
#[test]
fn test_string_parse_from_str() {
let text = "hello world";
let u: ArrayString<[_; 11]> = text.parse().unwrap();
assert_eq!(&u, text);
assert_eq!(u.len(), text.len());
}
#[test]
fn test_string_from_bytes() {
let text = "hello world";
let u = ArrayString::from_byte_string(b"hello world").unwrap();
assert_eq!(&u, text);
assert_eq!(u.len(), text.len());
}
#[test]
fn test_string_clone() {
let text = "hi";
let mut s = ArrayString::<[_; 4]>::new();
s.push_str("abcd");
let t = ArrayString::<[_; 4]>::from(text).unwrap();
s.clone_from(&t);
assert_eq!(&t, &s);
}
#[test]
fn test_string_push() {
let text = "abcαβγ";
let mut s = ArrayString::<[_; 8]>::new();
for c in text.chars() {
if let Err(_) = s.try_push(c) {
break;
}
}
assert_eq!("abcαβ", &s[..]);
s.push('x');
assert_eq!("abcαβx", &s[..]);
assert!(s.try_push('x').is_err());
}
#[test]
fn test_insert_at_length() {
let mut v = ArrayVec::<[_; 8]>::new();
let result1 = v.try_insert(0, "a");
let result2 = v.try_insert(1, "b");
assert!(result1.is_ok() && result2.is_ok());
assert_eq!(&v[..], &["a", "b"]);
}
#[should_panic]
#[test]
fn test_insert_out_of_bounds() {
let mut v = ArrayVec::<[_; 8]>::new();
let _ = v.try_insert(1, "test");
}
/*
* insert that pushes out the last
let mut u = ArrayVec::from([1, 2, 3, 4]);
let ret = u.try_insert(3, 99);
assert_eq!(&u[..], &[1, 2, 3, 99]);
assert_matches!(ret, Err(_));
let ret = u.try_insert(4, 77);
assert_eq!(&u[..], &[1, 2, 3, 99]);
assert_matches!(ret, Err(_));
*/
#[test]
fn test_drop_in_insert() {
use std::cell::Cell;
let flag = &Cell::new(0);
struct Bump<'a>(&'a Cell<i32>);
impl<'a> Drop for Bump<'a> {
fn drop(&mut self) {
let n = self.0.get();
self.0.set(n + 1);
}
}
flag.set(0);
{
let mut array = ArrayVec::<[_; 2]>::new();
array.push(Bump(flag));
array.insert(0, Bump(flag));
assert_eq!(flag.get(), 0);
let ret = array.try_insert(1, Bump(flag));
assert_eq!(flag.get(), 0);
assert_matches!(ret, Err(_));
drop(ret);
assert_eq!(flag.get(), 1);
}
assert_eq!(flag.get(), 3);
}
#[test]
fn test_pop_at() {
let mut v = ArrayVec::<[String; 4]>::new();
let s = String::from;
v.push(s("a"));
v.push(s("b"));
v.push(s("c"));
v.push(s("d"));
assert_eq!(v.pop_at(4), None);
assert_eq!(v.pop_at(1), Some(s("b")));
assert_eq!(v.pop_at(1), Some(s("c")));
assert_eq!(v.pop_at(2), None);
assert_eq!(&v[..], &["a", "d"]);
}
#[test]
fn test_sizes() {
let v = ArrayVec::from([0u8; 1 << 16]);
assert_eq!(vec![0u8; v.len()], &v[..]);
}
#[test]
fn test_default() {
use std::net;
let s: ArrayString<[u8; 4]> = Default::default();
// Something without `Default` implementation.
let v: ArrayVec<[net::TcpStream; 4]> = Default::default();
assert_eq!(s.len(), 0);
assert_eq!(v.len(), 0);
}
#[cfg(feature="array-sizes-33-128")]
#[test]
fn test_sizes_33_128() {
ArrayVec::from([0u8; 52]);
ArrayVec::from([0u8; 127]);
}
#[cfg(feature="array-sizes-129-255")]
#[test]
fn test_sizes_129_255() {
ArrayVec::from([0u8; 237]);
ArrayVec::from([0u8; 255]);
}
#[test]
fn test_extend_zst() {
let mut range = 0..10;
#[derive(Copy, Clone, PartialEq, Debug)]
struct Z; // Zero sized type
let mut array: ArrayVec<[_; 5]> = range.by_ref().map(|_| Z).collect();
assert_eq!(&array[..], &[Z; 5]);
assert_eq!(range.next(), Some(5));
array.extend(range.by_ref().map(|_| Z));
assert_eq!(range.next(), Some(6));
let mut array: ArrayVec<[_; 10]> = (0..3).map(|_| Z).collect();
assert_eq!(&array[..], &[Z; 3]);
array.extend((3..5).map(|_| Z));
assert_eq!(&array[..], &[Z; 5]);
assert_eq!(array.len(), 5);
}

View File

@ -1 +1 @@
{"files":{"CHANGELOG.md":"70db121262d72acc472ad1a90b78c42de570820e65b566c6b9339b62e636d572","Cargo.toml":"3af88a07af6a4adb84373fc3cd4920884b0b12b338cdb55ef598fd512ee1a790","LICENSE":"99fa95ba4e4cdaf71c27d73260ea069fc4515b3d02fde3020c5b562280006cbc","README.md":"e559a69c0b2bd20bffcede64fd548df6c671b0d1504613c5e3e5d884d759caea","examples/atty.rs":"1551387a71474d9ac1b5153231f884e9e05213badcfaa3494ad2cb7ea958374a","rustfmt.toml":"8e6ea1bcb79c505490034020c98e9b472f4ac4113f245bae90f5e1217b1ec65a","src/lib.rs":"d5abf6a54e8c496c486572bdc91eef10480f6ad126c4287f039df5feff7a9bbb"},"package":"d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"}
{"files":{"CHANGELOG.md":"70db121262d72acc472ad1a90b78c42de570820e65b566c6b9339b62e636d572","Cargo.lock":"6868f02a96413bcba37a06f01c6bf87e6331dea9461681a47a561cec6acd2546","Cargo.toml":"3af88a07af6a4adb84373fc3cd4920884b0b12b338cdb55ef598fd512ee1a790","LICENSE":"99fa95ba4e4cdaf71c27d73260ea069fc4515b3d02fde3020c5b562280006cbc","README.md":"e559a69c0b2bd20bffcede64fd548df6c671b0d1504613c5e3e5d884d759caea","examples/atty.rs":"1551387a71474d9ac1b5153231f884e9e05213badcfaa3494ad2cb7ea958374a","rustfmt.toml":"8e6ea1bcb79c505490034020c98e9b472f4ac4113f245bae90f5e1217b1ec65a","src/lib.rs":"d5abf6a54e8c496c486572bdc91eef10480f6ad126c4287f039df5feff7a9bbb"},"package":"d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"}

View File

@ -32,7 +32,7 @@ rust_library(
edition = "2015",
srcs = glob(["**/*.rs"]),
deps = [
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/libc-0.2.71:libc",
],
rustc_flags = [
"--cap-lints=allow",

49
third_party/cargo/vendor/atty-0.2.14/Cargo.lock generated vendored Normal file
View File

@ -0,0 +1,49 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "atty"
version = "0.2.14"
dependencies = [
"hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hermit-abi"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772"
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"4072e465bb2d1110644171c28d1a48a8cf5e9bb85c75d39409bb719348a131f6","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"0ff4942223d94c9686f846bb0b1de12221f06e7f39c1818ecbaaec402e89e770","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"374704e933dc6263a334652144e4436a7e409f88069c2f4f8e8c4ef14f7aa76b","src/tests.rs":"0b1353344e832553d328c47f1639ced877b5dff70fd2024d84130bd1c33eee07","src/version.rs":"175727d5f02f2fe2271ddc9b041db2a5b9c6fe0f95afd17c73a4d982612764a3","tests/rustflags.rs":"a3788396e0b81a33406d06fef3bc31c5a328f323de6766570a345ebad885cbf9"},"package":"1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"}
{"files":{"Cargo.lock":"745ff40f42e9a1275945a9db2763deeac749909e81d8d91859948fab49f5c268","Cargo.toml":"4072e465bb2d1110644171c28d1a48a8cf5e9bb85c75d39409bb719348a131f6","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"0ff4942223d94c9686f846bb0b1de12221f06e7f39c1818ecbaaec402e89e770","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"374704e933dc6263a334652144e4436a7e409f88069c2f4f8e8c4ef14f7aa76b","src/tests.rs":"0b1353344e832553d328c47f1639ced877b5dff70fd2024d84130bd1c33eee07","src/version.rs":"175727d5f02f2fe2271ddc9b041db2a5b9c6fe0f95afd17c73a4d982612764a3","tests/rustflags.rs":"a3788396e0b81a33406d06fef3bc31c5a328f323de6766570a345ebad885cbf9"},"package":"1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"}

6
third_party/cargo/vendor/autocfg-0.1.7/Cargo.lock generated vendored Normal file
View File

@ -0,0 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "0.1.7"

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"9a97fd6cdf41c7b507d2d8954f99dbbae3450e9e67934c87e5cabe8fa795f6c5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"f173253f205c245806e5dd16ad1906e1a1b3f89694890236298b2126e937324a","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"4e80b48869f038be4e80e3356e4cce7e81713717ceeca095f9bb04cda2e4d224","src/tests.rs":"8197b5a6e91872d6c63731ed4b7b619068b6d13501d9aecb3652f20857edc9aa","src/version.rs":"175727d5f02f2fe2271ddc9b041db2a5b9c6fe0f95afd17c73a4d982612764a3","tests/rustflags.rs":"441fb0c6606e243c31d3817a5ae2240b65fcae0ea8ab583f80f8f6d6c267e614"},"package":"f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"}
{"files":{"Cargo.lock":"8dc9b28e55bc55e1846909cfbb169aef0ff15bef2cfa6e27eef5adb7634eed1a","Cargo.toml":"9a97fd6cdf41c7b507d2d8954f99dbbae3450e9e67934c87e5cabe8fa795f6c5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"f173253f205c245806e5dd16ad1906e1a1b3f89694890236298b2126e937324a","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"4e80b48869f038be4e80e3356e4cce7e81713717ceeca095f9bb04cda2e4d224","src/tests.rs":"8197b5a6e91872d6c63731ed4b7b619068b6d13501d9aecb3652f20857edc9aa","src/version.rs":"175727d5f02f2fe2271ddc9b041db2a5b9c6fe0f95afd17c73a4d982612764a3","tests/rustflags.rs":"441fb0c6606e243c31d3817a5ae2240b65fcae0ea8ab583f80f8f6d6c267e614"},"package":"f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"}

6
third_party/cargo/vendor/autocfg-1.0.0/Cargo.lock generated vendored Normal file
View File

@ -0,0 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "1.0.0"

View File

@ -31,7 +31,7 @@ rust_library(
edition = "2015",
srcs = glob(["**/*.rs"]),
deps = [
"//third_party/cargo/vendor/mio-0.6.21:mio",
"//third_party/cargo/vendor/mio-0.6.22:mio",
"//third_party/cargo/vendor/mio-extras-2.0.6:mio_extras",
"//third_party/cargo/vendor/nix-0.14.1:nix",
],

View File

@ -1 +0,0 @@
{"files":{"Cargo.toml":"a5de831059d43ce5a823420eae1a8b4d4ab167408c5f4d0db53ba526fa7a9303","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"7184fbdf375a057e673257348f6d7584c0dd11b66318d98f3647f69eb610b097","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"bcdaf1c28b71e6ef889c6b08d1ce9d7c0761344a677f523bc4c3cd297957f804","src/lib.rs":"081f51f4ab13b32654ae6d674fed4b423c170c5db8cfdab319e9a80db724e0c3","src/registry.rs":"3cc1b5a50879fa751572878ae1d0afbfc960c11665258492754b2c8bccb0ff5d","src/setup_config.rs":"7014103587d3382eac599cb76f016e2609b8140970861b2237982d1db24af265","src/winapi.rs":"ea8b7edbb9ff87957254f465c2334e714c5d6b3b19a8d757c48ea7ca0881c50c","src/windows_registry.rs":"388e79dcf3e84078ae0b086c6cdee9cf9eb7e3ffafdcbf3e2df26163661f5856","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"0a83e858abc4793d9f243fdc211b653a4dc7b909ac00b577acda6a677d23ed47","tests/test.rs":"1605640c9b94a77f48fc92e1dc0485bdf1960da5626e2e00279e4703691656bc"},"package":"95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"}

View File

@ -0,0 +1 @@
{"files":{"Cargo.lock":"6ceb0c97cec493a896bf37a9f6f04ea14764277ecc219ac9977199bcdded3805","Cargo.toml":"ee16287327f8bf448537e3058c2bbd17df281f52404928b9b7f50f2191dc09cd","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"7184fbdf375a057e673257348f6d7584c0dd11b66318d98f3647f69eb610b097","src/bin/gcc-shim.rs":"b77907875029494b6288841c3aed2e4939ed40708c7f597fca5c9e2570490ca6","src/com.rs":"bcdaf1c28b71e6ef889c6b08d1ce9d7c0761344a677f523bc4c3cd297957f804","src/lib.rs":"516506ab998fc0dbc82b0ebd39446f80d92f76e7937a0d7adfe1b91e12ba54b2","src/registry.rs":"3cc1b5a50879fa751572878ae1d0afbfc960c11665258492754b2c8bccb0ff5d","src/setup_config.rs":"7014103587d3382eac599cb76f016e2609b8140970861b2237982d1db24af265","src/winapi.rs":"ea8b7edbb9ff87957254f465c2334e714c5d6b3b19a8d757c48ea7ca0881c50c","src/windows_registry.rs":"2b69dd43b5d414fca7a8e50a046cb2cf4c7fe80b9eb6a2e67538a859c597a805","tests/cc_env.rs":"e02b3b0824ad039b47e4462c5ef6dbe6c824c28e7953af94a0f28f7b5158042e","tests/cflags.rs":"57f06eb5ce1557e5b4a032d0c4673e18fbe6f8d26c1deb153126e368b96b41b3","tests/cxxflags.rs":"c2c6c6d8a0d7146616fa1caed26876ee7bc9fcfffd525eb4743593cade5f3371","tests/support/mod.rs":"16274867f23871e9b07614eda4c7344da13d1751fed63d4f633857e40be86394","tests/test.rs":"65c073e0e2cf4aa0433066102788e9f57442719e6f32f5ad5248aa7132bb4597"},"package":"7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"}

View File

@ -35,7 +35,7 @@ rust_library(
rustc_flags = [
"--cap-lints=allow",
],
version = "1.0.50",
version = "1.0.54",
crate_features = [
],
)
@ -57,7 +57,7 @@ rust_binary(
rustc_flags = [
"--cap-lints=allow",
],
version = "1.0.50",
version = "1.0.54",
crate_features = [
],
)

156
third_party/cargo/vendor/cc-1.0.54/Cargo.lock generated vendored Normal file
View File

@ -0,0 +1,156 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "c2-chacha"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cc"
version = "1.0.54"
dependencies = [
"jobserver 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "getrandom"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "jobserver"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ppv-lite86"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rand"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_chacha"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_syscall"
version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "remove_dir_all"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tempfile"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
"checksum jobserver 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "230ae9adf468173aecd4176c7233bddc84a15871a586c5971ace9a55f881c075"
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412"
"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853"
"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "cc"
version = "1.0.50"
version = "1.0.54"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
exclude = ["/.travis.yml", "/appveyor.yml"]
description = "A build-time dependency for Cargo build scripts to assist in invoking the native\nC compiler to compile native C code into a static archive to be linked into Rust\ncode.\n"

View File

@ -449,11 +449,13 @@ impl Build {
let mut cmd = compiler.to_command();
let is_arm = target.contains("aarch64") || target.contains("arm");
let clang = compiler.family == ToolFamily::Clang;
command_add_output_file(
&mut cmd,
&obj,
self.cuda,
target.contains("msvc"),
clang,
false,
is_arm,
);
@ -847,7 +849,7 @@ impl Build {
/// Configures whether the compiler will emit position independent code.
///
/// This option defaults to `false` for `windows-gnu` and `riscv` targets and
/// This option defaults to `false` for `windows-gnu` and bare metal targets and
/// to `true` for all other targets.
pub fn pic(&mut self, pic: bool) -> &mut Build {
self.pic = Some(pic);
@ -1144,10 +1146,11 @@ impl Build {
let is_asm = obj.src.extension().and_then(|s| s.to_str()) == Some("asm");
let target = self.get_target()?;
let msvc = target.contains("msvc");
let compiler = self.try_get_compiler()?;
let clang = compiler.family == ToolFamily::Clang;
let (mut cmd, name) = if msvc && is_asm {
self.msvc_macro_assembler()?
} else {
let compiler = self.try_get_compiler()?;
let mut cmd = compiler.to_command();
for &(ref a, ref b) in self.env.iter() {
cmd.env(a, b);
@ -1163,7 +1166,7 @@ impl Build {
)
};
let is_arm = target.contains("aarch64") || target.contains("arm");
command_add_output_file(&mut cmd, &obj.dst, self.cuda, msvc, is_asm, is_arm);
command_add_output_file(&mut cmd, &obj.dst, self.cuda, msvc, clang, is_asm, is_arm);
// armasm and armasm64 don't requrie -c option
if !msvc || !is_asm || !is_arm {
cmd.arg("-c");
@ -1367,15 +1370,24 @@ impl Build {
cmd.push_opt_unless_duplicate(format!("-O{}", opt_level).into());
}
if cmd.family == ToolFamily::Clang && target.contains("android") {
// For compatibility with code that doesn't use pre-defined `__ANDROID__` macro.
// If compiler used via ndk-build or cmake (officially supported build methods)
// this macros is defined.
// See https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/build/cmake/android.toolchain.cmake#456
// https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/build/core/build-binary.mk#141
cmd.push_opt_unless_duplicate("-DANDROID".into());
}
if !target.contains("-ios") {
cmd.push_cc_arg("-ffunction-sections".into());
cmd.push_cc_arg("-fdata-sections".into());
}
// Disable generation of PIC on bare-metal RISC-V for now: rust-lld doesn't support this yet
if self.pic.unwrap_or(
!target.contains("windows-gnu")
&& !(target.contains("riscv") && target.contains("-none-")),
) {
// Disable generation of PIC on bare-metal for now: rust-lld doesn't support this yet
if self
.pic
.unwrap_or(!target.contains("windows") && !target.contains("-none-"))
{
cmd.push_cc_arg("-fPIC".into());
// PLT only applies if code is compiled with PIC support,
// and only for ELF targets.
@ -1403,7 +1415,11 @@ impl Build {
// Target flags
match cmd.family {
ToolFamily::Clang => {
cmd.args.push(format!("--target={}", target).into());
if !(target.contains("android")
&& android_clang_compiler_uses_target_arg_internally(&cmd.path))
{
cmd.args.push(format!("--target={}", target).into());
}
}
ToolFamily::Msvc { clang_cl } => {
// This is an undocumented flag from MSVC but helps with making
@ -1588,6 +1604,14 @@ impl Build {
cmd.args.push("-mfloat-abi=soft".into());
}
}
if target.starts_with("armv7a") {
cmd.args.push("-march=armv7-a".into());
if target.ends_with("eabihf") {
// lowest common denominator FPU
cmd.args.push("-mfpu=vfpv3-d16".into());
}
}
if target.starts_with("riscv32") || target.starts_with("riscv64") {
// get the 32i/32imac/32imc/64gc/64imac/... part
let mut parts = target.split('-');
@ -1603,6 +1627,7 @@ impl Build {
} else {
cmd.args.push("-mabi=ilp32".into());
}
cmd.args.push("-mcmodel=medany".into());
}
}
}
@ -1866,7 +1891,7 @@ impl Build {
cmd.args.push(sdk_path.trim().into());
cmd.args.push("-fembed-bitcode".into());
/*
* TODO we probably ultimatedly want the -fembed-bitcode-marker flag
* TODO we probably ultimately want the -fembed-bitcode-marker flag
* but can't have it now because of an issue in LLVM:
* https://github.com/alexcrichton/cc-rs/issues/301
* https://github.com/rust-lang/rust/pull/48896#comment-372192660
@ -1900,8 +1925,11 @@ impl Build {
("CC", "cl.exe", "gcc", "cc", "clang")
};
// On Solaris, c++/cc unlikely to exist or be correct.
let default = if host.contains("solaris") {
// On historical Solaris systems, "cc" may have been Sun Studio, which
// is not flag-compatible with "gcc". This history casts a long shadow,
// and many modern illumos distributions today ship GCC as "gcc" without
// also making it available as "cc".
let default = if host.contains("solaris") || host.contains("illumos") {
gnu
} else {
traditional
@ -1918,13 +1946,13 @@ impl Build {
.iter()
.find(|a| a.starts_with(DRIVER_MODE))
.map(|a| &a[DRIVER_MODE.len()..]);
// chop off leading/trailing whitespace to work around
// Chop off leading/trailing whitespace to work around
// semi-buggy build scripts which are shared in
// makefiles/configure scripts (where spaces are far more
// lenient)
let mut t = Tool::with_clang_driver(PathBuf::from(tool.trim()), driver_mode);
if let Some(cc) = wrapper {
t.cc_wrapper_path = Some(PathBuf::from(cc));
if let Some(cc_wrapper) = wrapper {
t.cc_wrapper_path = Some(PathBuf::from(cc_wrapper));
}
for arg in args {
t.cc_wrapper_args.push(arg.into());
@ -1959,20 +1987,7 @@ impl Build {
format!("{}.exe", gnu)
}
} else if target.contains("android") {
let target = target
.replace("armv7neon", "arm")
.replace("armv7", "arm")
.replace("thumbv7neon", "arm")
.replace("thumbv7", "arm");
let gnu_compiler = format!("{}-{}", target, gnu);
let clang_compiler = format!("{}-{}", target, clang);
// Check if gnu compiler is present
// if not, use clang
if Command::new(&gnu_compiler).spawn().is_ok() {
gnu_compiler
} else {
clang_compiler
}
autodetect_android_compiler(&target, &host, gnu, clang)
} else if target.contains("cloudabi") {
format!("{}-{}", target, traditional)
} else if target == "wasm32-wasi"
@ -1983,80 +1998,7 @@ impl Build {
} else if target.contains("vxworks") {
"wr-c++".to_string()
} else if self.get_host()? != target {
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
let cc_env = self.getenv("CROSS_COMPILE");
let cross_compile = cc_env.as_ref().map(|s| s.trim_right_matches('-'));
let prefix = cross_compile.or(match &target[..] {
"aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"),
"aarch64-unknown-linux-musl" => Some("aarch64-linux-musl"),
"aarch64-unknown-netbsd" => Some("aarch64--netbsd"),
"arm-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
"armv4t-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
"armv5te-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
"arm-frc-linux-gnueabi" => Some("arm-frc-linux-gnueabi"),
"arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"arm-unknown-linux-musleabi" => Some("arm-linux-musleabi"),
"arm-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"arm-unknown-netbsd-eabi" => Some("arm--netbsdelf-eabi"),
"armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"),
"armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"armv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"armv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"thumbv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"thumbv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"thumbv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"thumbv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"),
"i586-unknown-linux-musl" => Some("musl"),
"i686-pc-windows-gnu" => Some("i686-w64-mingw32"),
"i686-uwp-windows-gnu" => Some("i686-w64-mingw32"),
"i686-unknown-linux-musl" => Some("musl"),
"i686-unknown-netbsd" => Some("i486--netbsdelf"),
"mips-unknown-linux-gnu" => Some("mips-linux-gnu"),
"mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"),
"mips64-unknown-linux-gnuabi64" => Some("mips64-linux-gnuabi64"),
"mips64el-unknown-linux-gnuabi64" => Some("mips64el-linux-gnuabi64"),
"mipsisa32r6-unknown-linux-gnu" => Some("mipsisa32r6-linux-gnu"),
"mipsisa32r6el-unknown-linux-gnu" => Some("mipsisa32r6el-linux-gnu"),
"mipsisa64r6-unknown-linux-gnuabi64" => Some("mipsisa64r6-linux-gnuabi64"),
"mipsisa64r6el-unknown-linux-gnuabi64" => {
Some("mipsisa64r6el-linux-gnuabi64")
}
"powerpc-unknown-linux-gnu" => Some("powerpc-linux-gnu"),
"powerpc-unknown-linux-gnuspe" => Some("powerpc-linux-gnuspe"),
"powerpc-unknown-netbsd" => Some("powerpc--netbsd"),
"powerpc64-unknown-linux-gnu" => Some("powerpc-linux-gnu"),
"powerpc64le-unknown-linux-gnu" => Some("powerpc64le-linux-gnu"),
"riscv32i-unknown-none-elf" => Some("riscv32-unknown-elf"),
"riscv32imac-unknown-none-elf" => Some("riscv32-unknown-elf"),
"riscv32imc-unknown-none-elf" => Some("riscv32-unknown-elf"),
"riscv64gc-unknown-none-elf" => Some("riscv64-unknown-elf"),
"riscv64imac-unknown-none-elf" => Some("riscv64-unknown-elf"),
"riscv64gc-unknown-linux-gnu" => Some("riscv64-linux-gnu"),
"s390x-unknown-linux-gnu" => Some("s390x-linux-gnu"),
"sparc-unknown-linux-gnu" => Some("sparc-linux-gnu"),
"sparc64-unknown-linux-gnu" => Some("sparc64-linux-gnu"),
"sparc64-unknown-netbsd" => Some("sparc64--netbsd"),
"sparcv9-sun-solaris" => Some("sparcv9-sun-solaris"),
"armebv7r-none-eabi" => Some("arm-none-eabi"),
"armebv7r-none-eabihf" => Some("arm-none-eabi"),
"armv7r-none-eabi" => Some("arm-none-eabi"),
"armv7r-none-eabihf" => Some("arm-none-eabi"),
"thumbv6m-none-eabi" => Some("arm-none-eabi"),
"thumbv7em-none-eabi" => Some("arm-none-eabi"),
"thumbv7em-none-eabihf" => Some("arm-none-eabi"),
"thumbv7m-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.base-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.main-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.main-none-eabihf" => Some("arm-none-eabi"),
"x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"),
"x86_64-uwp-windows-gnu" => Some("x86_64-w64-mingw32"),
"x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"),
"x86_64-unknown-linux-musl" => Some("musl"),
"x86_64-unknown-netbsd" => Some("x86_64--netbsd"),
_ => None,
});
let prefix = self.prefix_for_target(&target);
match prefix {
Some(prefix) => format!("{}-{}", prefix, gnu),
None => default.to_string(),
@ -2064,7 +2006,12 @@ impl Build {
} else {
default.to_string()
};
Tool::new(PathBuf::from(compiler))
let mut t = Tool::new(PathBuf::from(compiler));
if let Some(cc_wrapper) = Self::rustc_wrapper_fallback() {
t.cc_wrapper_path = Some(PathBuf::from(cc_wrapper));
}
t
}
};
@ -2140,6 +2087,24 @@ impl Build {
.collect()
}
/// Returns a fallback `cc_compiler_wrapper` by introspecting `RUSTC_WRAPPER`
fn rustc_wrapper_fallback() -> Option<String> {
// No explicit CC wrapper was detected, but check if RUSTC_WRAPPER
// is defined and is a build accelerator that is compatible with
// C/C++ compilers (e.g. sccache)
let valid_wrappers = ["sccache"];
let rustc_wrapper = std::env::var_os("RUSTC_WRAPPER")?;
let wrapper_path = Path::new(&rustc_wrapper);
let wrapper_stem = wrapper_path.file_stem()?;
if valid_wrappers.contains(&wrapper_stem.to_str()?) {
Some(rustc_wrapper.to_str()?.to_owned())
} else {
None
}
}
/// Returns compiler path, optional modifier name from whitelist, and arguments vec
fn env_tool(&self, name: &str) -> Option<(String, Option<String>, Vec<String>)> {
let tool = match self.get_var(name) {
@ -2199,7 +2164,7 @@ impl Build {
Some((
maybe_wrapper.to_string(),
None,
Self::rustc_wrapper_fallback(),
parts.map(|s| s.to_string()).collect(),
))
}
@ -2243,6 +2208,7 @@ impl Build {
return Ok((self.cmd(&p), p));
}
let target = self.get_target()?;
let default_ar = "ar".to_string();
let program = if target.contains("android") {
format!("{}-ar", target.replace("armv7", "arm"))
} else if target.contains("emscripten") {
@ -2259,12 +2225,105 @@ impl Build {
Some(t) => return Ok((t, "lib.exe".to_string())),
None => "lib.exe".to_string(),
}
} else if self.get_host()? != target {
match self.prefix_for_target(&target) {
Some(p) => {
let target_ar = format!("{}-ar", p);
if Command::new(&target_ar).output().is_ok() {
target_ar
} else {
default_ar
}
}
None => default_ar,
}
} else {
"ar".to_string()
default_ar
};
Ok((self.cmd(&program), program))
}
fn prefix_for_target(&self, target: &str) -> Option<String> {
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
let cc_env = self.getenv("CROSS_COMPILE");
let cross_compile = cc_env
.as_ref()
.map(|s| s.trim_right_matches('-').to_owned());
cross_compile.or(match &target[..] {
"aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"),
"aarch64-unknown-linux-musl" => Some("aarch64-linux-musl"),
"aarch64-unknown-netbsd" => Some("aarch64--netbsd"),
"arm-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
"armv4t-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
"armv5te-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"),
"armv5te-unknown-linux-musleabi" => Some("arm-linux-gnueabi"),
"arm-frc-linux-gnueabi" => Some("arm-frc-linux-gnueabi"),
"arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"arm-unknown-linux-musleabi" => Some("arm-linux-musleabi"),
"arm-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"arm-unknown-netbsd-eabi" => Some("arm--netbsdelf-eabi"),
"armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"),
"armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"armv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"armv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"thumbv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"thumbv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"thumbv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
"thumbv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
"armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"),
"i586-unknown-linux-musl" => Some("musl"),
"i686-pc-windows-gnu" => Some("i686-w64-mingw32"),
"i686-uwp-windows-gnu" => Some("i686-w64-mingw32"),
"i686-unknown-linux-musl" => Some("musl"),
"i686-unknown-netbsd" => Some("i486--netbsdelf"),
"mips-unknown-linux-gnu" => Some("mips-linux-gnu"),
"mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"),
"mips64-unknown-linux-gnuabi64" => Some("mips64-linux-gnuabi64"),
"mips64el-unknown-linux-gnuabi64" => Some("mips64el-linux-gnuabi64"),
"mipsisa32r6-unknown-linux-gnu" => Some("mipsisa32r6-linux-gnu"),
"mipsisa32r6el-unknown-linux-gnu" => Some("mipsisa32r6el-linux-gnu"),
"mipsisa64r6-unknown-linux-gnuabi64" => Some("mipsisa64r6-linux-gnuabi64"),
"mipsisa64r6el-unknown-linux-gnuabi64" => Some("mipsisa64r6el-linux-gnuabi64"),
"powerpc-unknown-linux-gnu" => Some("powerpc-linux-gnu"),
"powerpc-unknown-linux-gnuspe" => Some("powerpc-linux-gnuspe"),
"powerpc-unknown-netbsd" => Some("powerpc--netbsd"),
"powerpc64-unknown-linux-gnu" => Some("powerpc-linux-gnu"),
"powerpc64le-unknown-linux-gnu" => Some("powerpc64le-linux-gnu"),
"riscv32i-unknown-none-elf" => Some("riscv32-unknown-elf"),
"riscv32imac-unknown-none-elf" => Some("riscv32-unknown-elf"),
"riscv32imc-unknown-none-elf" => Some("riscv32-unknown-elf"),
"riscv64gc-unknown-none-elf" => Some("riscv64-unknown-elf"),
"riscv64imac-unknown-none-elf" => Some("riscv64-unknown-elf"),
"riscv64gc-unknown-linux-gnu" => Some("riscv64-linux-gnu"),
"s390x-unknown-linux-gnu" => Some("s390x-linux-gnu"),
"sparc-unknown-linux-gnu" => Some("sparc-linux-gnu"),
"sparc64-unknown-linux-gnu" => Some("sparc64-linux-gnu"),
"sparc64-unknown-netbsd" => Some("sparc64--netbsd"),
"sparcv9-sun-solaris" => Some("sparcv9-sun-solaris"),
"armv7a-none-eabi" => Some("arm-none-eabi"),
"armv7a-none-eabihf" => Some("arm-none-eabi"),
"armebv7r-none-eabi" => Some("arm-none-eabi"),
"armebv7r-none-eabihf" => Some("arm-none-eabi"),
"armv7r-none-eabi" => Some("arm-none-eabi"),
"armv7r-none-eabihf" => Some("arm-none-eabi"),
"thumbv6m-none-eabi" => Some("arm-none-eabi"),
"thumbv7em-none-eabi" => Some("arm-none-eabi"),
"thumbv7em-none-eabihf" => Some("arm-none-eabi"),
"thumbv7m-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.base-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.main-none-eabi" => Some("arm-none-eabi"),
"thumbv8m.main-none-eabihf" => Some("arm-none-eabi"),
"x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"),
"x86_64-uwp-windows-gnu" => Some("x86_64-w64-mingw32"),
"x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"),
"x86_64-unknown-linux-musl" => Some("musl"),
"x86_64-unknown-netbsd" => Some("x86_64--netbsd"),
_ => None,
}
.map(|x| x.to_owned()))
}
fn get_target(&self) -> Result<String, Error> {
match self.target.clone() {
Some(t) => Ok(t),
@ -2352,6 +2411,21 @@ impl Tool {
Self::with_features(path, clang_driver, false)
}
#[cfg(windows)]
/// Explictly set the `ToolFamily`, skipping name-based detection.
fn with_family(path: PathBuf, family: ToolFamily) -> Self {
Self {
path: path,
cc_wrapper_path: None,
cc_wrapper_args: Vec::new(),
args: Vec::new(),
env: Vec::new(),
family: family,
cuda: false,
removed_args: Vec::new(),
}
}
fn with_features(path: PathBuf, clang_driver: Option<&str>, cuda: bool) -> Self {
// Try to detect family of the tool from its name, falling back to Gnu.
let family = if let Some(fname) = path.file_name().and_then(|p| p.to_str()) {
@ -2660,10 +2734,11 @@ fn command_add_output_file(
dst: &Path,
cuda: bool,
msvc: bool,
clang: bool,
is_asm: bool,
is_arm: bool,
) {
if msvc && !cuda && !(is_asm && is_arm) {
if msvc && !clang && !cuda && !(is_asm && is_arm) {
let mut s = OsString::from("-Fo");
s.push(&dst);
cmd.arg(s);
@ -2671,3 +2746,75 @@ fn command_add_output_file(
cmd.arg("-o").arg(&dst);
}
}
// Use by default minimum available API level
// See note about naming here
// https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/docs/BuildSystemMaintainers.md#Clang
static NEW_STANDALONE_ANDROID_COMPILERS: [&str; 4] = [
"aarch64-linux-android21-clang",
"armv7a-linux-androideabi16-clang",
"i686-linux-android16-clang",
"x86_64-linux-android21-clang",
];
// New "standalone" C/C++ cross-compiler executables from recent Android NDK
// are just shell scripts that call main clang binary (from Android NDK) with
// proper `--target` argument.
//
// For example, armv7a-linux-androideabi16-clang passes
// `--target=armv7a-linux-androideabi16` to clang.
// So to construct proper command line check if
// `--target` argument would be passed or not to clang
fn android_clang_compiler_uses_target_arg_internally(clang_path: &Path) -> bool {
NEW_STANDALONE_ANDROID_COMPILERS.iter().any(|x| {
let x: &OsStr = x.as_ref();
x == clang_path.as_os_str()
})
}
fn autodetect_android_compiler(target: &str, host: &str, gnu: &str, clang: &str) -> String {
let new_clang_key = match target {
"aarch64-linux-android" => Some("aarch64"),
"armv7-linux-androideabi" => Some("armv7a"),
"i686-linux-android" => Some("i686"),
"x86_64-linux-android" => Some("x86_64"),
_ => None,
};
let new_clang = new_clang_key
.map(|key| {
NEW_STANDALONE_ANDROID_COMPILERS
.iter()
.find(|x| x.starts_with(key))
})
.unwrap_or(None);
if let Some(new_clang) = new_clang {
if Command::new(new_clang).output().is_ok() {
return (*new_clang).into();
}
}
let target = target
.replace("armv7neon", "arm")
.replace("armv7", "arm")
.replace("thumbv7neon", "arm")
.replace("thumbv7", "arm");
let gnu_compiler = format!("{}-{}", target, gnu);
let clang_compiler = format!("{}-{}", target, clang);
// On Windows, the Android clang compiler is provided as a `.cmd` file instead
// of a `.exe` file. `std::process::Command` won't run `.cmd` files unless the
// `.cmd` is explicitly appended to the command name, so we do that here.
let clang_compiler_cmd = format!("{}-{}.cmd", target, clang);
// Check if gnu compiler is present
// if not, use clang
if Command::new(&gnu_compiler).output().is_ok() {
gnu_compiler
} else if host.contains("windows") && Command::new(&clang_compiler_cmd).output().is_ok() {
clang_compiler_cmd
} else {
clang_compiler
}
}

View File

@ -14,6 +14,11 @@
use std::process::Command;
use crate::Tool;
#[cfg(windows)]
use crate::ToolFamily;
#[cfg(windows)]
const MSVC_FAMILY: ToolFamily = ToolFamily::Msvc { clang_cl: false };
/// Attempts to find a tool within an MSVC installation using the Windows
/// registry as a point to search from.
@ -70,7 +75,7 @@ pub fn find_tool(target: &str, tool: &str) -> Option<Tool> {
.map(|p| p.join(tool))
.find(|p| p.exists())
})
.map(|path| Tool::new(path.into()));
.map(|path| Tool::with_family(path.into(), MSVC_FAMILY));
}
// Ok, if we're here, now comes the fun part of the probing. Default shells
@ -80,7 +85,7 @@ pub fn find_tool(target: &str, tool: &str) -> Option<Tool> {
// environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that
// the tool is actually usable.
return impl_::find_msvc_15(tool, target)
return impl_::find_msvc_15plus(tool, target)
.or_else(|| impl_::find_msvc_14(tool, target))
.or_else(|| impl_::find_msvc_12(tool, target))
.or_else(|| impl_::find_msvc_11(tool, target));
@ -173,7 +178,9 @@ mod impl_ {
use std::iter;
use std::mem;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use super::MSVC_FAMILY;
use crate::Tool;
struct MsvcTool {
@ -200,7 +207,7 @@ mod impl_ {
path,
include,
} = self;
let mut tool = Tool::new(tool.into());
let mut tool = Tool::with_family(tool.into(), MSVC_FAMILY);
add_env(&mut tool, "LIB", libs);
add_env(&mut tool, "PATH", path);
add_env(&mut tool, "INCLUDE", include);
@ -210,7 +217,7 @@ mod impl_ {
#[allow(bare_trait_objects)]
fn vs16_instances() -> Box<Iterator<Item = PathBuf>> {
let instances = if let Some(instances) = vs15_instances() {
let instances = if let Some(instances) = vs15plus_instances() {
instances
} else {
return Box::new(iter::empty());
@ -220,6 +227,11 @@ mod impl_ {
let installation_name = instance.installation_name().ok()?;
if installation_name.to_str()?.starts_with("VisualStudio/16.") {
Some(PathBuf::from(instance.installation_path().ok()?))
} else if installation_name
.to_str()?
.starts_with("VisualStudioPreview/16.")
{
Some(PathBuf::from(instance.installation_path().ok()?))
} else {
None
}
@ -233,7 +245,7 @@ mod impl_ {
if !path.is_file() {
return None;
}
let mut tool = Tool::new(path);
let mut tool = Tool::with_family(path, MSVC_FAMILY);
if target.contains("x86_64") {
tool.env.push(("Platform".into(), "X64".into()));
}
@ -253,24 +265,34 @@ mod impl_ {
// Note that much of this logic can be found [online] wrt paths, COM, etc.
//
// [online]: https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/
fn vs15_instances() -> Option<EnumSetupInstances> {
//
// Returns MSVC 15+ instances (15, 16 right now), the order should be consider undefined.
fn vs15plus_instances() -> Option<EnumSetupInstances> {
com::initialize().ok()?;
let config = SetupConfiguration::new().ok()?;
config.enum_all_instances().ok()
}
pub fn find_msvc_15(tool: &str, target: &str) -> Option<Tool> {
let iter = vs15_instances()?;
for instance in iter {
let instance = instance.ok()?;
let tool = tool_from_vs15_instance(tool, target, &instance);
if tool.is_some() {
return tool;
}
}
// Inspired from official microsoft/vswhere ParseVersionString
// i.e. at most four u16 numbers separated by '.'
fn parse_version(version: &str) -> Option<Vec<u16>> {
version
.split('.')
.map(|chunk| u16::from_str(chunk).ok())
.collect()
}
None
pub fn find_msvc_15plus(tool: &str, target: &str) -> Option<Tool> {
let iter = vs15plus_instances()?;
iter.filter_map(|instance| {
let instance = instance.ok()?;
let version = parse_version(instance.installation_version().ok()?.to_str()?)?;
let tool = tool_from_vs15plus_instance(tool, target, &instance)?;
Some((version, tool))
})
.max_by(|(a_version, _), (b_version, _)| a_version.cmp(b_version))
.map(|(_version, tool)| tool)
}
// While the paths to Visual Studio 2017's devenv and MSBuild could
@ -281,7 +303,7 @@ mod impl_ {
//
// [more reliable]: https://github.com/alexcrichton/cc-rs/pull/331
fn find_tool_in_vs15_path(tool: &str, target: &str) -> Option<Tool> {
let mut path = match vs15_instances() {
let mut path = match vs15plus_instances() {
Some(instances) => instances
.filter_map(|instance| {
instance
@ -304,7 +326,7 @@ mod impl_ {
}
path.map(|path| {
let mut tool = Tool::new(path);
let mut tool = Tool::with_family(path, MSVC_FAMILY);
if target.contains("x86_64") {
tool.env.push(("Platform".into(), "X64".into()));
}
@ -312,8 +334,13 @@ mod impl_ {
})
}
fn tool_from_vs15_instance(tool: &str, target: &str, instance: &SetupInstance) -> Option<Tool> {
let (bin_path, host_dylib_path, lib_path, include_path) = vs15_vc_paths(target, instance)?;
fn tool_from_vs15plus_instance(
tool: &str,
target: &str,
instance: &SetupInstance,
) -> Option<Tool> {
let (bin_path, host_dylib_path, lib_path, include_path) =
vs15plus_vc_paths(target, instance)?;
let tool_path = bin_path.join(tool);
if !tool_path.exists() {
return None;
@ -334,7 +361,7 @@ mod impl_ {
Some(tool.into_tool())
}
fn vs15_vc_paths(
fn vs15plus_vc_paths(
target: &str,
instance: &SetupInstance,
) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf)> {
@ -744,7 +771,7 @@ mod impl_ {
.map(|path| {
let mut path = PathBuf::from(path);
path.push("MSBuild.exe");
let mut tool = Tool::new(path);
let mut tool = Tool::with_family(path, MSVC_FAMILY);
if target.contains("x86_64") {
tool.env.push(("Platform".into(), "X64".into()));
}

View File

@ -22,6 +22,18 @@ pub struct Execution {
impl Test {
pub fn new() -> Test {
// This is ugly: `sccache` needs to introspect the compiler it is
// executing, as it adjusts its behavior depending on the
// language/compiler. This crate's test driver uses mock compilers that
// are obviously not supported by sccache, so the tests fail if
// RUSTC_WRAPPER is set. rust doesn't build test dependencies with
// the `test` feature enabled, so we can't conditionally disable the
// usage of `sccache` if running in a test environment, at least not
// without setting an environment variable here and testing for it
// there. Explicitly deasserting RUSTC_WRAPPER here seems to be the
// lesser of the two evils.
env::remove_var("RUSTC_WRAPPER");
let mut gcc = PathBuf::from(env::current_exe().unwrap());
gcc.pop();
if gcc.ends_with("deps") {

View File

@ -2,8 +2,18 @@ use crate::support::Test;
mod support;
// Some tests check that a flag is *not* present. These tests might fail if the flag is set in the
// CFLAGS or CXXFLAGS environment variables. This function clears the CFLAGS and CXXFLAGS
// variables to make sure that the tests can run correctly.
fn reset_env() {
std::env::set_var("CFLAGS", "");
std::env::set_var("CXXFLAGS", "");
}
#[test]
fn gnu_smoke() {
reset_env();
let test = Test::gnu();
test.gcc().file("foo.c").compile("foo");
@ -19,6 +29,8 @@ fn gnu_smoke() {
#[test]
fn gnu_opt_level_1() {
reset_env();
let test = Test::gnu();
test.gcc().opt_level(1).file("foo.c").compile("foo");
@ -27,6 +39,8 @@ fn gnu_opt_level_1() {
#[test]
fn gnu_opt_level_s() {
reset_env();
let test = Test::gnu();
test.gcc().opt_level_str("s").file("foo.c").compile("foo");
@ -56,6 +70,8 @@ fn gnu_debug_fp() {
#[test]
fn gnu_debug_nofp() {
reset_env();
let test = Test::gnu();
test.gcc()
.debug(true)
@ -100,6 +116,8 @@ fn gnu_warnings() {
#[test]
fn gnu_extra_warnings0() {
reset_env();
let test = Test::gnu();
test.gcc()
.warnings(true)
@ -113,6 +131,8 @@ fn gnu_extra_warnings0() {
#[test]
fn gnu_extra_warnings1() {
reset_env();
let test = Test::gnu();
test.gcc()
.warnings(false)
@ -126,6 +146,8 @@ fn gnu_extra_warnings1() {
#[test]
fn gnu_warnings_overridable() {
reset_env();
let test = Test::gnu();
test.gcc()
.warnings(true)
@ -154,6 +176,8 @@ fn gnu_x86_64() {
#[test]
fn gnu_x86_64_no_pic() {
reset_env();
for vendor in &["unknown-linux-gnu", "apple-darwin"] {
let target = format!("x86_64-{}", vendor);
let test = Test::gnu();
@ -215,6 +239,8 @@ fn gnu_x86_64_no_plt() {
#[test]
fn gnu_set_stdlib() {
reset_env();
let test = Test::gnu();
test.gcc()
.cpp_set_stdlib(Some("foo"))
@ -253,6 +279,8 @@ fn gnu_compile_assembly() {
#[test]
fn gnu_shared() {
reset_env();
let test = Test::gnu();
test.gcc()
.file("foo.c")
@ -265,6 +293,8 @@ fn gnu_shared() {
#[test]
fn gnu_flag_if_supported() {
reset_env();
if cfg!(windows) {
return;
}
@ -301,6 +331,8 @@ fn gnu_flag_if_supported_cpp() {
#[test]
fn gnu_static() {
reset_env();
let test = Test::gnu();
test.gcc()
.file("foo.c")
@ -313,6 +345,8 @@ fn gnu_static() {
#[test]
fn msvc_smoke() {
reset_env();
let test = Test::msvc();
test.gcc().file("foo.c").compile("foo");
@ -327,6 +361,8 @@ fn msvc_smoke() {
#[test]
fn msvc_opt_level_0() {
reset_env();
let test = Test::msvc();
test.gcc().opt_level(0).file("foo.c").compile("foo");

View File

@ -1 +0,0 @@
{"files":{"Cargo.toml":"1041ef5daf0481026b809a7f0b90de1b449d103593aa219e7c71ced776542d77","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"a4ad0b734acb4d50db72782207587552c5e33c52500318c202776cd32dbdea4a","src/lib.rs":"166e1c3f86d5b5017b88fcc9c2fa3a9b7bd59feab5c2c54b643931f6055bb608"},"package":"81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62"}

View File

@ -0,0 +1 @@
{"files":{"Cargo.toml":"0ce2c3999bc31b6e8fc5356e19c32f950e6176638aa2834c5b0d00c6c58397a0","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"a4ad0b734acb4d50db72782207587552c5e33c52500318c202776cd32dbdea4a","src/lib.rs":"45127eb441cee715f4337cfac78c9ce8ec8feb167d2814ff11a6708a9533bde7"},"package":"0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb"}

View File

@ -31,12 +31,12 @@ rust_library(
edition = "2015",
srcs = glob(["**/*.rs"]),
deps = [
"//third_party/cargo/vendor/cc-1.0.50:cc",
"//third_party/cargo/vendor/cc-1.0.54:cc",
],
rustc_flags = [
"--cap-lints=allow",
],
version = "0.1.42",
version = "0.1.44",
crate_features = [
],
)

View File

@ -12,7 +12,7 @@
[package]
name = "cmake"
version = "0.1.42"
version = "0.1.44"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
description = "A build dependency for running `cmake` to build a native library\n"
homepage = "https://github.com/alexcrichton/cmake-rs"

View File

@ -60,6 +60,7 @@ pub struct Config {
generator: Option<OsString>,
cflags: OsString,
cxxflags: OsString,
asmflags: OsString,
defines: Vec<(OsString, OsString)>,
deps: Vec<String>,
target: Option<String>,
@ -75,6 +76,7 @@ pub struct Config {
no_build_target: bool,
verbose_cmake: bool,
verbose_make: bool,
pic: Option<bool>,
}
/// Builds the native library rooted at `path` with the default cmake options.
@ -106,6 +108,7 @@ impl Config {
generator: None,
cflags: OsString::new(),
cxxflags: OsString::new(),
asmflags: OsString::new(),
defines: Vec::new(),
deps: Vec::new(),
profile: None,
@ -121,9 +124,16 @@ impl Config {
no_build_target: false,
verbose_cmake: false,
verbose_make: false,
pic: None,
}
}
/// Sets flag for PIC. Otherwise use cc::Build platform default
pub fn pic(&mut self, explicit_flag: bool) -> &mut Config {
self.pic = Some(explicit_flag);
self
}
/// Sets the build-tool generator (`-G`) for this compilation.
pub fn generator<T: AsRef<OsStr>>(&mut self, generator: T) -> &mut Config {
self.generator = Some(generator.as_ref().to_owned());
@ -146,6 +156,14 @@ impl Config {
self
}
/// Adds a custom flag to pass down to the ASM compiler, supplementing those
/// that this library already passes.
pub fn asmflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config {
self.asmflags.push(" ");
self.asmflags.push(flag.as_ref());
self
}
/// Adds a new `-D` flag to pass to cmake during the generation step.
pub fn define<K, V>(&mut self, k: K, v: V) -> &mut Config
where
@ -335,8 +353,13 @@ impl Config {
c_cfg.static_crt(static_crt);
cxx_cfg.static_crt(static_crt);
}
if let Some(explicit_flag) = self.pic {
c_cfg.pic(explicit_flag);
cxx_cfg.pic(explicit_flag);
}
let c_compiler = c_cfg.get_compiler();
let cxx_compiler = cxx_cfg.get_compiler();
let asm_compiler = c_cfg.get_compiler();
let dst = self
.out_dir
@ -650,6 +673,7 @@ impl Config {
set_compiler("C", &c_compiler, &self.cflags);
set_compiler("CXX", &cxx_compiler, &self.cxxflags);
set_compiler("ASM", &asm_compiler, &self.asmflags);
}
if !self.defined("CMAKE_BUILD_TYPE") {

View File

@ -36,7 +36,7 @@ rust_library(
"//third_party/cargo/vendor/core-foundation-0.6.4:core_foundation",
"//third_party/cargo/vendor/core-graphics-0.17.3:core_graphics",
"//third_party/cargo/vendor/foreign-types-0.3.2:foreign_types",
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/libc-0.2.71:libc",
"//third_party/cargo/vendor/objc-0.2.7:objc",
],
rustc_flags = [

View File

@ -1,95 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cocoa"
version = "0.20.0"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-foundation"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-foundation-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "core-graphics"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
"checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
"checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
"checksum core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "59e78b2e0aaf43f08e7ae0d6bc96895ef72ff0921c7d4ff4762201b2dba376dd"
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
"checksum objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"

View File

@ -1 +1 @@
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.lock":"0effdfa775e787f93cfabf50aa7039d7a4999e0dd92d57d3d5745a5f5926a962","Cargo.toml":"280ff6f510cff8a892ddbba326304fd8b16ac2eb1ad111948405abe3a6a90d51","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"29542cb34adb016506822ef78bceacf1774dbe8c27818a4d47b7d7b71ed4e1ac","examples/color.rs":"5211a85ab9ec4cbb98f8f677de50bb2f1d300400f50226ebfd714d40b9d32485","examples/fullscreen.rs":"f8719268b6eb1d19078af347e02f9993c9d29633ef2d38dcc4fac26cbd731c2d","examples/hello_world.rs":"7efe2a29de4d4dfc1d8821f469e13b1456f72de478bab55f813d08d4e5aafd5c","examples/tab_view.rs":"e6a3187eeac2f46210994293c2db7756757f4cad07e519902fa994c6d5c1a7d6","src/appkit.rs":"a21c6d612d0ec45dbbb5df45fe96d84b76c5a9982d09bdf74714ce63723da558","src/base.rs":"6c56d1758a9b0a7f8927771fe8b0bb43c6f19e4531bf9accecc786028eaad845","src/foundation.rs":"f0a8c0d2e3aee6bde64f480085025dfa92f903a39d6c15251ba392523aa153a3","src/lib.rs":"ed6164b3e0fe68579218185267d79229a2989c86efce690d7273f779c5239ec3","src/macros.rs":"0de0a8ea9a23f03cad94266a92051c3be8ff3f8f7d7d60f95dafe6c663204d48","src/quartzcore.rs":"cb4f96b4b095e9d623346a42b1e119a5299bf2af73ed81256dd548c688d525e2","tests/foundation.rs":"728eb7dcc9edbfb43dcb6aa1ebcc391658a7d47846d94a71905bcedfce833260"},"package":"0a4736c86d51bd878b474400d9ec888156f4037015f5d09794fab9f26eab1ad4"}
{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.lock":"9909380e3b48716dc2358036627337cea1a7357e0eb3e8e63b6252c074a6077e","Cargo.toml":"028039e35cdeff788575b44c5869857d10e71d7f96f5bbf6f5474acaa3e6aef5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"29542cb34adb016506822ef78bceacf1774dbe8c27818a4d47b7d7b71ed4e1ac","examples/color.rs":"5211a85ab9ec4cbb98f8f677de50bb2f1d300400f50226ebfd714d40b9d32485","examples/fullscreen.rs":"f8719268b6eb1d19078af347e02f9993c9d29633ef2d38dcc4fac26cbd731c2d","examples/hello_world.rs":"7efe2a29de4d4dfc1d8821f469e13b1456f72de478bab55f813d08d4e5aafd5c","examples/tab_view.rs":"e6a3187eeac2f46210994293c2db7756757f4cad07e519902fa994c6d5c1a7d6","src/appkit.rs":"a2ca0f7c86583be2bc5fed992bb86039bba9eca0586c981ff70091e2298e52cc","src/base.rs":"6c56d1758a9b0a7f8927771fe8b0bb43c6f19e4531bf9accecc786028eaad845","src/foundation.rs":"d3f14a7d1d20840cb00d52cc54df5c68a353b5ea925bd973d6bd27b4911d91b1","src/lib.rs":"ed6164b3e0fe68579218185267d79229a2989c86efce690d7273f779c5239ec3","src/macros.rs":"0de0a8ea9a23f03cad94266a92051c3be8ff3f8f7d7d60f95dafe6c663204d48","src/quartzcore.rs":"cb4f96b4b095e9d623346a42b1e119a5299bf2af73ed81256dd548c688d525e2","tests/foundation.rs":"728eb7dcc9edbfb43dcb6aa1ebcc391658a7d47846d94a71905bcedfce833260"},"package":"8f7b6f3f7f4f0b3ec5c5039aaa9e8c3cef97a7a480a400fd62944841314f293d"}

View File

@ -27,7 +27,7 @@ load(
rust_library(
name = "cocoa",
crate_root = "src/lib.rs",
crate_type = "rlib",
crate_type = "lib",
edition = "2015",
srcs = glob(["**/*.rs"]),
deps = [
@ -36,13 +36,13 @@ rust_library(
"//third_party/cargo/vendor/core-foundation-0.7.0:core_foundation",
"//third_party/cargo/vendor/core-graphics-0.19.0:core_graphics",
"//third_party/cargo/vendor/foreign-types-0.3.2:foreign_types",
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/libc-0.2.71:libc",
"//third_party/cargo/vendor/objc-0.2.7:objc",
],
rustc_flags = [
"--cap-lints=allow",
],
version = "0.20.0",
version = "0.20.1",
crate_features = [
],
)

93
third_party/cargo/vendor/cocoa-0.20.1/Cargo.lock generated vendored Normal file
View File

@ -0,0 +1,93 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "cocoa"
version = "0.20.1"
dependencies = [
"bitflags",
"block",
"core-foundation",
"core-graphics",
"foreign-types",
"libc",
"objc",
]
[[package]]
name = "core-foundation"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]]
name = "core-graphics"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59e78b2e0aaf43f08e7ae0d6bc96895ef72ff0921c7d4ff4762201b2dba376dd"
dependencies = [
"bitflags",
"core-foundation",
"foreign-types",
"libc",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "libc"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f"
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]

View File

@ -12,16 +12,12 @@
[package]
name = "cocoa"
version = "0.20.0"
version = "0.20.1"
authors = ["The Servo Project Developers"]
description = "Bindings to Cocoa for macOS"
homepage = "https://github.com/servo/core-foundation-rs"
license = "MIT / Apache-2.0"
repository = "https://github.com/servo/core-foundation-rs"
[lib]
name = "cocoa"
crate-type = ["rlib"]
[dependencies.bitflags]
version = "1.0"

View File

@ -987,6 +987,7 @@ pub trait NSWindow: Sized {
unsafe fn setLevel_(self, level: NSInteger);
// Managing Key Status
unsafe fn isKeyWindow(self) -> BOOL;
unsafe fn canBecomeKeyWindow(self) -> BOOL;
unsafe fn makeKeyWindow(self);
unsafe fn makeKeyAndOrderFront_(self, sender: id);
@ -1480,6 +1481,10 @@ impl NSWindow for id {
// Managing Key Status
unsafe fn isKeyWindow(self) -> BOOL {
msg_send![self, isKeyWindow]
}
unsafe fn canBecomeKeyWindow(self) -> BOOL {
msg_send![self, canBecomeKeyWindow]
}
@ -1778,6 +1783,8 @@ pub trait NSView: Sized {
unsafe fn initWithFrame_(self, frameRect: NSRect) -> id;
unsafe fn bounds(self) -> NSRect;
unsafe fn frame(self) -> NSRect;
unsafe fn setFrameSize(self, frameSize: NSSize);
unsafe fn setFrameOrigin(self, frameOrigin: NSPoint);
unsafe fn display_(self);
unsafe fn setWantsBestResolutionOpenGLSurface_(self, flag: BOOL);
unsafe fn convertPoint_fromView_(self, point: NSPoint, view: id) -> NSPoint;
@ -1813,6 +1820,14 @@ impl NSView for id {
msg_send![self, frame]
}
unsafe fn setFrameSize(self, frameSize: NSSize) {
msg_send![self, setFrameSize:frameSize]
}
unsafe fn setFrameOrigin(self, frameOrigin: NSPoint) {
msg_send![self, setFrameOrigin:frameOrigin]
}
unsafe fn display_(self) {
msg_send![self, display]
}
@ -2968,7 +2983,7 @@ pub trait NSButton: Sized {
msg_send![class!(NSButton), alloc]
}
unsafe fn initWithFrame_(self, frameRect: NSRect) -> id;
unsafe fn setTarget_(self, target: id /* Instance */);
unsafe fn setTarget_(self, target: id /* Instance */);
unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance *) */);
}
@ -3645,7 +3660,7 @@ pub trait NSTabView: Sized {
unsafe fn allowsTruncatedLabels(self) -> BOOL;
unsafe fn setAllowsTruncatedLabels_(self, allowTruncatedLabels:BOOL);
unsafe fn setDelegate_(self, delegate:id);
unsafe fn delegate(self) -> id ;
unsafe fn delegate(self) -> id;
unsafe fn tabViewAtPoint_(self, point:id) -> id;
}

View File

@ -203,18 +203,49 @@ impl NSAutoreleasePool for id {
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct NSOperatingSystemVersion {
pub majorVersion: NSUInteger,
pub minorVersion: NSUInteger,
pub patchVersion: NSUInteger,
}
impl NSOperatingSystemVersion {
#[inline]
pub fn new(majorVersion: NSUInteger, minorVersion: NSUInteger, patchVersion: NSUInteger) -> NSOperatingSystemVersion {
NSOperatingSystemVersion {
majorVersion: majorVersion,
minorVersion: minorVersion,
patchVersion: patchVersion
}
}
}
pub trait NSProcessInfo: Sized {
unsafe fn processInfo(_: Self) -> id {
msg_send![class!(NSProcessInfo), processInfo]
}
unsafe fn processName(self) -> id;
unsafe fn operatingSystemVersion(self) -> NSOperatingSystemVersion;
unsafe fn isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool;
}
impl NSProcessInfo for id {
unsafe fn processName(self) -> id {
msg_send![self, processName]
}
unsafe fn operatingSystemVersion(self) -> NSOperatingSystemVersion {
msg_send![self, operatingSystemVersion]
}
unsafe fn isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool {
msg_send![self, isOperatingSystemAtLeastVersion: version]
}
}
pub type NSTimeInterval = libc::c_double;
@ -1316,3 +1347,30 @@ bitflags! {
const NSDataSearchAnchored = 1 << 1;
}
}
pub trait NSUserDefaults {
unsafe fn standardUserDefaults() -> Self;
unsafe fn setBool_forKey_(self, value: BOOL, key: id);
unsafe fn bool_forKey_(self, key: id) -> BOOL;
unsafe fn removeObject_forKey_(self, key: id);
}
impl NSUserDefaults for id {
unsafe fn standardUserDefaults() -> id {
msg_send![class!(NSUserDefaults), standardUserDefaults]
}
unsafe fn setBool_forKey_(self, value: BOOL, key: id) {
msg_send![self, setBool:value forKey:key]
}
unsafe fn bool_forKey_(self, key: id) -> BOOL {
msg_send![self, boolForKey: key]
}
unsafe fn removeObject_forKey_(self, key: id) {
msg_send![self, removeObjectForKey:key]
}
}

View File

@ -32,7 +32,7 @@ rust_library(
srcs = glob(["**/*.rs"]),
deps = [
"//third_party/cargo/vendor/core-foundation-sys-0.6.2:core_foundation_sys",
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/libc-0.2.71:libc",
],
rustc_flags = [
"--cap-lints=allow",

View File

@ -32,7 +32,7 @@ rust_library(
srcs = glob(["**/*.rs"]),
deps = [
"//third_party/cargo/vendor/core-foundation-sys-0.7.0:core_foundation_sys",
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/libc-0.2.71:libc",
],
rustc_flags = [
"--cap-lints=allow",

View File

@ -34,7 +34,7 @@ rust_library(
"//third_party/cargo/vendor/bitflags-1.2.1:bitflags",
"//third_party/cargo/vendor/core-foundation-0.6.4:core_foundation",
"//third_party/cargo/vendor/foreign-types-0.3.2:foreign_types",
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/libc-0.2.71:libc",
],
rustc_flags = [
"--cap-lints=allow",

View File

@ -34,7 +34,7 @@ rust_library(
"//third_party/cargo/vendor/bitflags-1.2.1:bitflags",
"//third_party/cargo/vendor/core-foundation-0.7.0:core_foundation",
"//third_party/cargo/vendor/foreign-types-0.3.2:foreign_types",
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/libc-0.2.71:libc",
],
rustc_flags = [
"--cap-lints=allow",

View File

@ -1 +0,0 @@
{"files":{"Cargo.toml":"b90dee90d0900e4e1b38b183cf1c7dba49a4cd3be5e86c8da7a25745b2520c45","LICENSE":"439952354cd78da9e99d020667b01c011e89dfa57e8e091fe6e099bd7804d86b","build.rs":"d5ce402947ab6c65bd131c19def4fc1e0007d95630432988787b6dc8e4124ee6","src/base.rs":"8fb57ef931405a2effc82b09087ba54ee0224420252e0e77e5d23ded87c71d41","src/buffer.rs":"c15f89522f11c9a5fbc27cc80b36dc4a614294ede18a3048320ed0d17b08c410","src/display_link.rs":"87863c61a85dec42cb0a72f7ab33d4f37a7be6b2aee072b7982a72feb957291c","src/host_time.rs":"11ac7e6ec65c6499e620c28e167f40a60d7787c988bd42f6f89f5be1bc2203fe","src/image_buffer.rs":"aecc238c57cea8d67db2c9507d30ee425124a4bfc3adbf7770a9abb5d10a25c0","src/lib.rs":"1fac840e83b70489938063ab3e4acfa8eda80dae6c33290c1be7150d3599ec08","src/metal_texture.rs":"1e48454a983253093bb8c8f2a426043456a3ea5c7669d76998bb44ee5df8bbe9","src/metal_texture_cache.rs":"e451ca31cd68d37ff323984306196ae6c6de701e949b8261bd1967849abe90b9","src/open_gl_es_texture.rs":"57e5cddfa0de2fa6a24b166e481c0bf3a7491789f27f7e51b0614474a9dc7c5a","src/open_gl_es_texture_cache.rs":"8d9340cc63a4f0ac6b6ec4d988fdfc14e6ab0ca65f678fd86e004e92d2df712c","src/opengl_buffer.rs":"82145551623ed561c32dc206c7fd5ad57d674b3f5e0ef7753a83e8a57ff8c614","src/opengl_buffer_pool.rs":"3cb6c8c2443a567af7dfdef3b3ddda64a64536d4c46617a49ccbd905f27216db","src/opengl_texture.rs":"8369a59288e3b3a0d79725379034e71bcbfb84c10e08290028067c261e767500","src/opengl_texture_cache.rs":"dab814ba2c9b9b1319d57a2260b8283a973eea23cca941c211ac371c109dfce3","src/pixel_buffer.rs":"dd525165a667b2a28ceee3e488989221f02fdb4f3a8e79ebd72a4d30bf263f15","src/pixel_buffer_io_surface.rs":"c007270f9e6db4bab3ac963135a2ca9d761aa0aa40ab1411177d04e006d3c11d","src/pixel_buffer_pool.rs":"6b36547f222ab36ae01497b541fa6685f6a6b7a6d022923e41c57e524cb6648a","src/pixel_format_description.rs":"a2fbe12c6dfc813a0910ea082f334d9441f6a5fa8accfbcb6621ab61ac863970","src/return_.rs":"1702ae3e29a7439d7caa95b43a30747dbc3535e9479d91097850669d18a8bba8"},"package":"8dc065219542086f72d1e9f7aadbbab0989e980263695d129d502082d063a9d0"}

View File

@ -1,6 +0,0 @@
fn main() {
if std::env::var("TARGET").unwrap().contains("-apple") {
println!("cargo:rustc-link-lib=framework=CoreVideo");
}
}

View File

@ -0,0 +1 @@
{"files":{"Cargo.toml":"a494862db035d53a5263e7d2820a59e2d500ede90013ab868a3b0e514a5671c7","LICENSE":"439952354cd78da9e99d020667b01c011e89dfa57e8e091fe6e099bd7804d86b","src/base.rs":"cf9d1976f5d6cd1f92bb029994fc9e2d08f5d47ae7d67c07d7d5316dd06ae307","src/buffer.rs":"93bfc5193334aaa651aacee6f234b2687755b7209fc5cbb7612e2dc1b8b03b0b","src/display_link.rs":"87863c61a85dec42cb0a72f7ab33d4f37a7be6b2aee072b7982a72feb957291c","src/host_time.rs":"37187520def434271e1c69deb255e257b66292d2bc11ee741946334543712e57","src/image_buffer.rs":"aecc238c57cea8d67db2c9507d30ee425124a4bfc3adbf7770a9abb5d10a25c0","src/lib.rs":"c49ca1e3abb8571aa1d1bae8317f362e9fbddcc3f1af479e76d1383600f314c9","src/metal_texture.rs":"1e48454a983253093bb8c8f2a426043456a3ea5c7669d76998bb44ee5df8bbe9","src/metal_texture_cache.rs":"e451ca31cd68d37ff323984306196ae6c6de701e949b8261bd1967849abe90b9","src/open_gl_es_texture.rs":"57e5cddfa0de2fa6a24b166e481c0bf3a7491789f27f7e51b0614474a9dc7c5a","src/open_gl_es_texture_cache.rs":"8d9340cc63a4f0ac6b6ec4d988fdfc14e6ab0ca65f678fd86e004e92d2df712c","src/opengl_buffer.rs":"627383b446c3347d3540e932c7ff2fa396145a42761360806263c3ccad4205b0","src/opengl_buffer_pool.rs":"3cb6c8c2443a567af7dfdef3b3ddda64a64536d4c46617a49ccbd905f27216db","src/opengl_texture.rs":"8369a59288e3b3a0d79725379034e71bcbfb84c10e08290028067c261e767500","src/opengl_texture_cache.rs":"dab814ba2c9b9b1319d57a2260b8283a973eea23cca941c211ac371c109dfce3","src/pixel_buffer.rs":"0e39680c65e576d0df4ce60a86e28873330c248e8464517dda9fd8bf38a053f1","src/pixel_buffer_io_surface.rs":"c007270f9e6db4bab3ac963135a2ca9d761aa0aa40ab1411177d04e006d3c11d","src/pixel_buffer_pool.rs":"6b36547f222ab36ae01497b541fa6685f6a6b7a6d022923e41c57e524cb6648a","src/pixel_format_description.rs":"a2fbe12c6dfc813a0910ea082f334d9441f6a5fa8accfbcb6621ab61ac863970","src/return_.rs":"5bae8d265071d531b546e3cfb53265bac611d408a5be2d2ddc24e8e27c3e9a32"},"package":"34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"}

View File

@ -23,7 +23,6 @@ load(
)
# Unsupported target "build-script-build" with type "custom-build" omitted
rust_library(
name = "core_video_sys",
@ -33,15 +32,15 @@ rust_library(
srcs = glob(["**/*.rs"]),
deps = [
"//third_party/cargo/vendor/cfg-if-0.1.10:cfg_if",
"//third_party/cargo/vendor/core-foundation-sys-0.6.2:core_foundation_sys",
"//third_party/cargo/vendor/core-graphics-0.17.3:core_graphics",
"//third_party/cargo/vendor/libc-0.2.67:libc",
"//third_party/cargo/vendor/core-foundation-sys-0.7.0:core_foundation_sys",
"//third_party/cargo/vendor/core-graphics-0.19.0:core_graphics",
"//third_party/cargo/vendor/libc-0.2.71:libc",
"//third_party/cargo/vendor/objc-0.2.7:objc",
],
rustc_flags = [
"--cap-lints=allow",
],
version = "0.1.3",
version = "0.1.4",
crate_features = [
"core-graphics",
"display_link",

View File

@ -13,9 +13,8 @@
[package]
edition = "2018"
name = "core-video-sys"
version = "0.1.3"
version = "0.1.4"
authors = ["luozijun <luozijun.assistant@gmail.com>", "michael.laifx <cihv2@163.com>"]
build = "build.rs"
description = "Bindings to CoreVideo.framework for macOS and iOS"
homepage = "https://github.com/luozijun/rust-core-video-sys"
documentation = "https://docs.rs/core-video-sys/*/x86_64-apple-darwin/core-video-sys"
@ -25,22 +24,22 @@ repository = "https://github.com/luozijun/rust-core-video-sys"
version = "0.1"
[dependencies.core-foundation-sys]
version = "0.6.2"
version = "0.7"
[dependencies.core-graphics]
version = "0.17.3"
version = "0.19"
optional = true
[dependencies.libc]
version = "0.2.47"
version = "0.2"
[dependencies.metal]
version = "0.14.0"
version = "0.18"
features = ["private"]
optional = true
[dependencies.objc]
version = "0.2.5"
version = "0.2"
[features]
all = ["display_link", "direct3d", "io_suface", "opengl"]

View File

@ -1,12 +1,12 @@
use crate::libc::{ c_double, int16_t, int32_t, int64_t, uint32_t, uint64_t, };
use crate::libc::c_double;
// https://developer.apple.com/documentation/corevideo/cvoptionflags?language=objc
pub type CVOptionFlags = uint64_t;
pub type CVSMPTETimeType = uint32_t;
pub type CVSMPTETimeFlags = uint32_t;
pub type CVTimeFlags = int32_t;
pub type CVTimeStampFlags = uint64_t;
pub type CVOptionFlags = u64;
pub type CVSMPTETimeType = u32;
pub type CVSMPTETimeFlags = u32;
pub type CVTimeFlags = i32;
pub type CVTimeStampFlags = u64;
pub const kCVSMPTETimeType24: CVSMPTETimeType = 0;
@ -18,8 +18,8 @@ pub const kCVSMPTETimeType2997Drop: CVSMPTETimeType = 5;
pub const kCVSMPTETimeType60: CVSMPTETimeType = 6;
pub const kCVSMPTETimeType5994: CVSMPTETimeType = 7;
pub const kCVSMPTETimeValid: CVSMPTETimeFlags = (1 << 0);
pub const kCVSMPTETimeRunning: CVSMPTETimeFlags = (1 << 1);
pub const kCVSMPTETimeValid: CVSMPTETimeFlags = 1 << 0;
pub const kCVSMPTETimeRunning: CVSMPTETimeFlags = 1 << 1;
pub const kCVTimeIsIndefinite: CVTimeFlags = 1 << 0;
@ -27,54 +27,54 @@ pub const kCVTimeIsIndefinite: CVTimeFlags = 1 << 0;
#[repr(C)]
#[derive(Debug, Clone)]
pub struct CVSMPTETime {
pub subframes: int16_t,
pub subframeDivisor: int16_t,
pub counter: uint32_t,
pub type_: uint32_t,
pub flags: uint32_t,
pub hours: int16_t,
pub minutes: int16_t,
pub seconds: int16_t,
pub frames: int16_t,
pub subframes: i16,
pub subframeDivisor: i16,
pub counter: u32,
pub type_: u32,
pub flags: u32,
pub hours: i16,
pub minutes: i16,
pub seconds: i16,
pub frames: i16,
}
#[repr(C)]
#[derive(Debug, Clone)]
pub struct CVTime {
pub timeValue: int64_t,
pub timeScale: int32_t,
pub flags: int32_t
pub timeValue: i64,
pub timeScale: i32,
pub flags: i32
}
#[repr(C)]
#[derive(Debug, Clone)]
pub struct CVTimeStamp {
pub version: uint32_t,
pub videoTimeScale: int32_t,
pub videoTime: int64_t,
pub hostTime: uint64_t,
pub version: u32,
pub videoTimeScale: i32,
pub videoTime: i64,
pub hostTime: u64,
pub rateScalar: c_double,
pub videoRefreshPeriod: int64_t,
pub videoRefreshPeriod: i64,
pub smpteTime: CVSMPTETime,
pub flags: uint64_t,
pub reserved: uint64_t,
pub flags: u64,
pub reserved: u64,
}
pub const kCVTimeStampVideoTimeValid: CVTimeStampFlags = (1 << 0);
pub const kCVTimeStampHostTimeValid: CVTimeStampFlags = (1 << 1);
pub const kCVTimeStampSMPTETimeValid: CVTimeStampFlags = (1 << 2);
pub const kCVTimeStampVideoRefreshPeriodValid: CVTimeStampFlags = (1 << 3);
pub const kCVTimeStampRateScalarValid: CVTimeStampFlags = (1 << 4);
pub const kCVTimeStampVideoTimeValid: CVTimeStampFlags = 1 << 0;
pub const kCVTimeStampHostTimeValid: CVTimeStampFlags = 1 << 1;
pub const kCVTimeStampSMPTETimeValid: CVTimeStampFlags = 1 << 2;
pub const kCVTimeStampVideoRefreshPeriodValid: CVTimeStampFlags = 1 << 3;
pub const kCVTimeStampRateScalarValid: CVTimeStampFlags = 1 << 4;
// There are flags for each field to make it easier to detect interlaced vs progressive output
pub const kCVTimeStampTopField: CVTimeStampFlags = (1 << 16);
pub const kCVTimeStampBottomField: CVTimeStampFlags = (1 << 17);
pub const kCVTimeStampTopField: CVTimeStampFlags = 1 << 16;
pub const kCVTimeStampBottomField: CVTimeStampFlags = 1 << 17;
// Some commonly used combinations of timestamp flags
pub const kCVTimeStampVideoHostTimeValid: CVTimeStampFlags = (kCVTimeStampVideoTimeValid | kCVTimeStampHostTimeValid);
pub const kCVTimeStampIsInterlaced: CVTimeStampFlags = (kCVTimeStampTopField | kCVTimeStampBottomField);
pub const kCVTimeStampVideoHostTimeValid: CVTimeStampFlags = kCVTimeStampVideoTimeValid | kCVTimeStampHostTimeValid;
pub const kCVTimeStampIsInterlaced: CVTimeStampFlags = kCVTimeStampTopField | kCVTimeStampBottomField;
extern "C" {

View File

@ -1,4 +1,3 @@
use crate::libc::{ uint32_t, };
use crate::core_foundation_sys::{
base::{ CFTypeRef, },
string::CFStringRef,
@ -12,7 +11,7 @@ pub enum __CVBuffer { }
pub type CVBufferRef = *mut __CVBuffer;
pub type CVAttachmentMode = uint32_t;
pub type CVAttachmentMode = u32;
pub const kCVAttachmentMode_ShouldNotPropagate: CVAttachmentMode = 0;
pub const kCVAttachmentMode_ShouldPropagate: CVAttachmentMode = 1;

View File

@ -1,4 +1,4 @@
use crate::libc::{ c_double, uint32_t, uint64_t, };
use crate::libc::c_double;
extern "C" {
/// @function CVGetCurrentHostTime
@ -6,7 +6,7 @@ extern "C" {
/// @discussion On Mac OS X, the host time base for CoreVideo and CoreAudio are identical, and the values returned from either API
/// may be used interchangeably.
/// @result The current host time.
pub fn CVGetCurrentHostTime() -> uint64_t;
pub fn CVGetCurrentHostTime() -> u64;
/// @function CVGetHostClockFrequency
/// @abstract Retrieve the frequency of the host time base.
/// @discussion On Mac OS X, the host time base for CoreVideo and CoreAudio are identical, and the values returned from either API
@ -16,13 +16,13 @@ extern "C" {
/// @function CVGetHostClockMinimumTimeDelta
/// @abstract Retrieve the smallest possible increment in the host time base.
/// @result The smallest valid increment in the host time base.
pub fn CVGetHostClockMinimumTimeDelta() -> uint32_t;
pub fn CVGetHostClockMinimumTimeDelta() -> u32;
}
#[test]
fn test_get_curr_time() {
unsafe {
assert_eq!(CVGetCurrentHostTime() > 0, true);
assert!(CVGetCurrentHostTime() > 0);
}
}

Some files were not shown because too many files have changed in this diff Show More