Bug 1302704 - part 1 - define CARGO_TARGET_DIR in the backend; r=chmanchester

CARGO_TARGET_DIR is currently hardcoded to the current directory, but
we'd like the ability to choose a value for Rust libraries.
This commit is contained in:
Nathan Froyd 2017-02-23 10:35:07 -05:00
parent 2e0b11e312
commit 1cbbd567b5
3 changed files with 8 additions and 1 deletions

View File

@ -936,7 +936,7 @@ rustflags_override = RUSTFLAGS='$(rustflags)'
endif
CARGO_BUILD = env $(rustflags_override) \
CARGO_TARGET_DIR=. \
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
RUSTC=$(RUSTC) \
MOZ_DIST=$(ABS_DIST) \
LIBCLANG_PATH=$(MOZ_LIBCLANG_PATH) \

View File

@ -1077,6 +1077,7 @@ class RecursiveMakeBackend(CommonBackend):
target_variable,
target_cargo_variable):
backend_file.write_once('CARGO_FILE := %s\n' % obj.cargo_file)
backend_file.write_once('CARGO_TARGET_DIR := .\n')
backend_file.write('%s += %s\n' % (target_variable, obj.location))
backend_file.write('%s += %s\n' % (target_cargo_variable, obj.name))
@ -1250,6 +1251,7 @@ class RecursiveMakeBackend(CommonBackend):
feature_var = 'HOST_RUST_LIBRARY_FEATURES'
backend_file.write_once('%s := %s\n' % (libdef.LIB_FILE_VAR, libdef.import_name))
backend_file.write('CARGO_FILE := $(srcdir)/Cargo.toml\n')
backend_file.write('CARGO_TARGET_DIR := .\n')
if libdef.features:
backend_file.write('%s := %s\n' % (libdef.FEATURES_VAR, ' '.join(libdef.features)))

View File

@ -764,6 +764,7 @@ class TestRecursiveMakeBackend(BackendTester):
expected = [
'RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libgkrust.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := .',
]
self.assertEqual(lines, expected)
@ -778,6 +779,7 @@ class TestRecursiveMakeBackend(BackendTester):
expected = [
'HOST_RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libhostrusttool.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := .',
]
self.assertEqual(lines, expected)
@ -792,6 +794,7 @@ class TestRecursiveMakeBackend(BackendTester):
expected = [
'HOST_RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libhostrusttool.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := .',
'HOST_RUST_LIBRARY_FEATURES := musthave cantlivewithout',
]
@ -807,6 +810,7 @@ class TestRecursiveMakeBackend(BackendTester):
expected = [
'RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libgkrust.a',
'CARGO_FILE := $(srcdir)/Cargo.toml',
'CARGO_TARGET_DIR := .',
'RUST_LIBRARY_FEATURES := musthave cantlivewithout',
]
@ -821,6 +825,7 @@ class TestRecursiveMakeBackend(BackendTester):
expected = [
'CARGO_FILE := %s/code/Cargo.toml' % env.topsrcdir,
'CARGO_TARGET_DIR := .',
'RUST_PROGRAMS += i686-pc-windows-msvc/release/target.exe',
'RUST_CARGO_PROGRAMS += target',
'HOST_RUST_PROGRAMS += i686-pc-windows-msvc/release/host.exe',