support sandboxed rust rules
This commit adds support for compiling rust rules inside the sbox sandbox. To compile a rust module with sandboxing enabled, the entry point to the crate must be specified via the `crate_root` property, and all input sources and compile-time data must be specified via the `srcs` and `compile_data` properties. Bug: 286077158 Change-Id: I8c9dc5cf7578037a583b4be2e2f73cf20ffd4408
This commit is contained in:
@@ -135,7 +135,7 @@ func TestBinaryFlags(t *testing.T) {
|
||||
|
||||
fizzBuzz := ctx.ModuleForTests("fizz-buzz", "linux_glibc_x86_64").Rule("rustc")
|
||||
|
||||
flags := fizzBuzz.Args["rustcFlags"]
|
||||
flags := fizzBuzz.RuleParams.Command
|
||||
if strings.Contains(flags, "--test") {
|
||||
t.Errorf("extra --test flag, rustcFlags: %#v", flags)
|
||||
}
|
||||
@@ -150,11 +150,11 @@ func TestBootstrap(t *testing.T) {
|
||||
bootstrap: true,
|
||||
}`)
|
||||
|
||||
foo := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Rule("rustLink")
|
||||
foo := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Rule("rustc")
|
||||
|
||||
flag := "-Wl,-dynamic-linker,/system/bin/bootstrap/linker64"
|
||||
if !strings.Contains(foo.Args["linkFlags"], flag) {
|
||||
t.Errorf("missing link flag to use bootstrap linker, expecting %#v, linkFlags: %#v", flag, foo.Args["linkFlags"])
|
||||
if !strings.Contains(foo.RuleParams.Command, flag) {
|
||||
t.Errorf("missing link flag to use bootstrap linker, expecting %#v, command: %#v", flag, foo.RuleParams.Command)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,19 +167,17 @@ func TestStaticBinaryFlags(t *testing.T) {
|
||||
}`)
|
||||
|
||||
fizzOut := ctx.ModuleForTests("fizz", "android_arm64_armv8-a").Rule("rustc")
|
||||
fizzOutLink := ctx.ModuleForTests("fizz", "android_arm64_armv8-a").Rule("rustLink")
|
||||
fizzMod := ctx.ModuleForTests("fizz", "android_arm64_armv8-a").Module().(*Module)
|
||||
|
||||
flags := fizzOut.Args["rustcFlags"]
|
||||
linkFlags := fizzOutLink.Args["linkFlags"]
|
||||
flags := fizzOut.RuleParams.Command
|
||||
if !strings.Contains(flags, "-C relocation-model=static") {
|
||||
t.Errorf("static binary missing '-C relocation-model=static' in rustcFlags, found: %#v", flags)
|
||||
t.Errorf("static binary missing '-C relocation-model=static' in command, found: %#v", flags)
|
||||
}
|
||||
if !strings.Contains(flags, "-C panic=abort") {
|
||||
t.Errorf("static binary missing '-C panic=abort' in rustcFlags, found: %#v", flags)
|
||||
t.Errorf("static binary missing '-C panic=abort' in command, found: %#v", flags)
|
||||
}
|
||||
if !strings.Contains(linkFlags, "-static") {
|
||||
t.Errorf("static binary missing '-static' in linkFlags, found: %#v", flags)
|
||||
if !strings.Contains(flags, "-static") {
|
||||
t.Errorf("static binary missing '-static' in command, found: %#v", flags)
|
||||
}
|
||||
|
||||
if !android.InList("libc", fizzMod.Properties.AndroidMkStaticLibs) {
|
||||
@@ -201,10 +199,9 @@ func TestLinkObjects(t *testing.T) {
|
||||
name: "libfoo",
|
||||
}`)
|
||||
|
||||
fizzBuzz := ctx.ModuleForTests("fizz-buzz", "android_arm64_armv8-a").Rule("rustLink")
|
||||
linkFlags := fizzBuzz.Args["linkFlags"]
|
||||
if !strings.Contains(linkFlags, "/libfoo.so") {
|
||||
t.Errorf("missing shared dependency 'libfoo.so' in linkFlags: %#v", linkFlags)
|
||||
fizzBuzz := ctx.ModuleForTests("fizz-buzz", "android_arm64_armv8-a").Rule("rustc")
|
||||
if !strings.Contains(fizzBuzz.RuleParams.Command, "/libfoo.so") {
|
||||
t.Errorf("missing shared dependency 'libfoo.so' in command: %#v", fizzBuzz.RuleParams.Command)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user