Skip to content

Commit

Permalink
Auto merge of #207 - servo:rls, r=jdm
Browse files Browse the repository at this point in the history
Make mozjs_sys cope with RLS (fixes #206)

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/mozjs/207)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Oct 9, 2019
2 parents dd175ee + 169bcc0 commit 9e390c4
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 47 deletions.
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ use std::process::{Command, Stdio};
use std::str;

fn main() {
// https://github.com/servo/mozjs/issues/113
env::set_var("MOZCONFIG", "");

build_jsapi();
build_jsglue();
build_jsapi_bindings();
Expand All @@ -36,6 +39,7 @@ fn ignore(path: &Path) -> bool {
}

fn find_make() -> OsString {
println!("cargo:rerun-if-env-changed=MAKE");
if let Some(make) = env::var_os("MAKE") {
make
} else {
Expand Down Expand Up @@ -95,6 +99,7 @@ fn build_jsapi() {
let target = env::var("TARGET").unwrap();
let mut make = find_make();
// Put MOZTOOLS_PATH at the beginning of PATH if specified
println!("cargo:rerun-if-env-changed=MOZTOOLS_PATH");
if let Some(moztools) = env::var_os("MOZTOOLS_PATH") {
let path = env::var_os("PATH").unwrap();
let mut paths = Vec::new();
Expand Down Expand Up @@ -219,12 +224,14 @@ fn build_jsapi_bindings() {
builder = builder.clang_arg("-fms-compatibility");
}

println!("cargo:rerun-if-env-changed=CXXFLAGS");
if let Ok(flags) = env::var("CXXFLAGS") {
for flag in flags.split_whitespace() {
builder = builder.clang_arg(flag);
}
}

println!("cargo:rerun-if-env-changed=CLANGFLAGS");
if let Ok(flags) = env::var("CLANGFLAGS") {
for flag in flags.split_whitespace() {
builder = builder.clang_arg(flag);
Expand Down
69 changes: 69 additions & 0 deletions etc/patches/remove-cargo-version-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff --git i/mozjs/build/moz.configure/rust.configure w/mozjs/build/moz.configure/rust.configure
index 6c129579e..f6a3af9e2 100644
--- i/mozjs/build/moz.configure/rust.configure
+++ w/mozjs/build/moz.configure/rust.configure
@@ -29,34 +29,10 @@ def rustc_info(rustc):

set_config('RUSTC_VERSION', depends(rustc_info)(lambda info: str(info.version)))

-@depends_if(cargo)
-@checking('cargo version', lambda info: info.version)
-@imports('re')
-def cargo_info(cargo):
- out = check_cmd_output(cargo, '--version', '--verbose').splitlines()
- info = dict((s.strip() for s in line.split(':', 1)) for line in out[1:])
- version = info.get('release')
- # Older versions of cargo didn't support --verbose, in which case, they
- # only output a not-really-pleasant-to-parse output. Fortunately, they
- # don't error out, so we can just try some regexp matching on the output
- # we already got.
- if version is None:
- VERSION_FORMAT = r'^cargo (\d\.\d+\.\d+).*'
-
- m = re.search(VERSION_FORMAT, out[0])
- # Fail fast if cargo changes its output on us.
- if not m:
- die('Could not determine cargo version from output: %s', out)
- version = m.group(1)
-
- return namespace(
- version=Version(version),
- )

-
-@depends(rustc_info, cargo_info, build_project)
+@depends(rustc_info, build_project)
@imports(_from='textwrap', _import='dedent')
-def rust_compiler(rustc_info, cargo_info, build_project):
+def rust_compiler(rustc_info, build_project):
if not rustc_info:
die(dedent('''\
Rust compiler not found.
@@ -89,27 +65,6 @@ def rust_compiler(rustc_info, cargo_info, build_project):
installer is available from https://rustup.rs/
'''.format(version, rustc_min_version)))

- if not cargo_info:
- die(dedent('''\
- Cargo package manager not found.
- To compile Rust language sources, you must have 'cargo' in your path.
- See https://www.rust-lang.org/ for more information.
-
- You can install cargo by running './mach bootstrap'
- or by directly running the installer from https://rustup.rs/
- '''))
-
- version = cargo_info.version
- if version < cargo_min_version:
- die(dedent('''\
- Cargo package manager {} is too old.
-
- To compile Rust language sources please install at least
- version {} of 'cargo' and make sure it is first in your path.
-
- You can verify this by typing 'cargo --version'.
- ''').format(version, cargo_min_version))
-
return True


49 changes: 2 additions & 47 deletions mozjs/build/moz.configure/rust.configure
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,10 @@ def rustc_info(rustc):

set_config('RUSTC_VERSION', depends(rustc_info)(lambda info: str(info.version)))

@depends_if(cargo)
@checking('cargo version', lambda info: info.version)
@imports('re')
def cargo_info(cargo):
out = check_cmd_output(cargo, '--version', '--verbose').splitlines()
info = dict((s.strip() for s in line.split(':', 1)) for line in out[1:])
version = info.get('release')
# Older versions of cargo didn't support --verbose, in which case, they
# only output a not-really-pleasant-to-parse output. Fortunately, they
# don't error out, so we can just try some regexp matching on the output
# we already got.
if version is None:
VERSION_FORMAT = r'^cargo (\d\.\d+\.\d+).*'

m = re.search(VERSION_FORMAT, out[0])
# Fail fast if cargo changes its output on us.
if not m:
die('Could not determine cargo version from output: %s', out)
version = m.group(1)

return namespace(
version=Version(version),
)


@depends(rustc_info, cargo_info, build_project)
@depends(rustc_info, build_project)
@imports(_from='textwrap', _import='dedent')
def rust_compiler(rustc_info, cargo_info, build_project):
def rust_compiler(rustc_info, build_project):
if not rustc_info:
die(dedent('''\
Rust compiler not found.
Expand Down Expand Up @@ -89,27 +65,6 @@ def rust_compiler(rustc_info, cargo_info, build_project):
installer is available from https://rustup.rs/
'''.format(version, rustc_min_version)))

if not cargo_info:
die(dedent('''\
Cargo package manager not found.
To compile Rust language sources, you must have 'cargo' in your path.
See https://www.rust-lang.org/ for more information.
You can install cargo by running './mach bootstrap'
or by directly running the installer from https://rustup.rs/
'''))

version = cargo_info.version
if version < cargo_min_version:
die(dedent('''\
Cargo package manager {} is too old.
To compile Rust language sources please install at least
version {} of 'cargo' and make sure it is first in your path.
You can verify this by typing 'cargo --version'.
''').format(version, cargo_min_version))

return True


Expand Down

0 comments on commit 9e390c4

Please sign in to comment.