Skip to content

Commit

Permalink
auto merge of #4140 : SimonSapin/servo/no-root-cargo-toml, r=Manishearth
Browse files Browse the repository at this point in the history
This fixes #3957, and allow #4115 not to regress #4099.
  • Loading branch information
bors-servo committed Dec 3, 2014
2 parents 600da2a + 4b5979b commit 991d238
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 96 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.cargo/config
/Cargo.lock
/target
/rust
/cargo
/components/servo/target
/ports/cef/target
/ports/android/bin
/ports/android/libs
Expand All @@ -16,7 +16,7 @@
/components/script/dom/bindings/codegen/UnionTypes.h
/components/script/dom/bindings/codegen/UnionConversions.h
/.servobuild
/_virtualenv
/tests/wpt/_virtualenv
*~
*#
*.o
Expand Down
67 changes: 4 additions & 63 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,69 +1,10 @@
[package]

name = "servo"
name = "not-the-toml-you-re-looking-for"
version = "0.0.1"
authors = ["The Servo Project Developers"]

[lib]
name = "servo"
crate-type = ["rlib"]

[[bin]]
name = "servo"
test = false
doc = false
bench = false

[[test]]
name = "reftest"
path = "tests/reftest.rs"
harness = false

[[test]]
name = "contenttest"
path = "tests/contenttest.rs"
harness = false

[features]
default = ["glfw_app"]
glutin = ["glutin_app"]

[dependencies.compositing]
path = "components/compositing"

[dependencies.net]
path = "components/net"

[dependencies.msg]
path = "components/msg"

[dependencies.util]
path = "components/util"
build = "support/not-the-toml-you-re-looking-for.rs"

[dependencies.script]
path = "components/script"

[dependencies.layout]
path = "components/layout"

[dependencies.gfx]
path = "components/gfx"

[dependencies.glfw_app]
path = "ports/glfw"
optional = true

[dependencies.glutin_app]
path = "ports/glutin"
optional = true

[dependencies.url]
git = "https://github.com/servo/rust-url"

[dependencies.green]
git = "https://github.com/servo/green-rs"
branch = "servo"

[dependencies.rustuv]
git = "https://github.com/servo/green-rs"
branch = "servo"
[lib]
name = "not-the-toml-you-re-looking-for"
File renamed without changes.
71 changes: 71 additions & 0 deletions components/servo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[package]

name = "servo"
version = "0.0.1"
authors = ["The Servo Project Developers"]

[lib]
name = "servo"
path = "lib.rs"
crate-type = ["rlib"]

[[bin]]
name = "servo"
path = "main.rs"
test = false
doc = false
bench = false

[[test]]
name = "reftest"
path = "../../tests/reftest.rs"
harness = false

[[test]]
name = "contenttest"
path = "../../tests/contenttest.rs"
harness = false

[features]
default = ["glfw_app"]
glutin = ["glutin_app"]

[dependencies.compositing]
path = "../compositing"

[dependencies.net]
path = "../net"

[dependencies.msg]
path = "../msg"

[dependencies.util]
path = "../util"

[dependencies.script]
path = "../script"

[dependencies.layout]
path = "../layout"

[dependencies.gfx]
path = "../gfx"

[dependencies.glfw_app]
path = "../../ports/glfw"
optional = true

[dependencies.glutin_app]
path = "../../ports/glutin"
optional = true

[dependencies.url]
git = "https://github.com/servo/rust-url"

[dependencies.green]
git = "https://github.com/servo/green-rs"
branch = "servo"

[dependencies.rustuv]
git = "https://github.com/servo/green-rs"
branch = "servo"
File renamed without changes.
File renamed without changes.
8 changes: 6 additions & 2 deletions components/util/resource_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ pub fn resources_dir_path() -> Path {

#[cfg(not(target_os = "android"))]
pub fn resources_dir_path() -> Path {
// FIXME: Find a way to not rely on the executable being under `<servo source>/target`.
// FIXME: Find a way to not rely on the executable being
// under `<servo source>/components/servo/target`
// or `<servo source>/components/servo/target/release`.
let mut path = os::self_exe_path().expect("can't get exe path");
path.pop();
path.pop();
path.pop();
path.push("resources");
if !path.is_dir() {
if !path.is_dir() { // self_exe_path() is probably in .../target/release
path.pop();
path.pop();
path.push("resources");
Expand Down
10 changes: 6 additions & 4 deletions etc/ci/upload_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@

set -e

mkdir -p target/doc
cd "$(dirname $0)/../.."

mkdir -p components/servo/target/doc
./mach bootstrap-rust
# Ordered so that:
# * etc/doc.servo.org/index.html overwrites $(mach rust-root)/doc/index.html
# * ./mach doc overwrites $(mach rust-root)/doc/search-index.js
cp -R $(./mach rust-root)/doc/* target/doc/
cp etc/doc.servo.org/* target/doc/
cp -R $(./mach rust-root)/doc/* components/servo/target/doc/
cp etc/doc.servo.org/* components/servo/target/doc/
./mach doc

ghp-import -n target/doc
ghp-import -n components/servo/target/doc
git push -qf https://${TOKEN}@github.com/servo/doc.servo.org.git gh-pages
2 changes: 1 addition & 1 deletion ports/android/glut_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ git = "https://github.com/servo/rust-layers"
path = "../../../components/msg"

[dependencies.servo]
path = "../../.."
path = "../../../components/servo"
default-features = false

[dependencies.util]
Expand Down
2 changes: 1 addition & 1 deletion ports/cef/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ path = "lib.rs"
crate-type = ["dylib"]

[dependencies.servo]
path = "../.."
path = "../../components/servo"

[dependencies.glfw_app]
path = "../glfw"
Expand Down
11 changes: 7 additions & 4 deletions python/servo/build_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def build(self, target=None, release=False, jobs=None, android=None,
else:
status = subprocess.call(
["cargo", "build"] + opts,
env=self.build_env())
env=self.build_env(), cwd=self.servo_crate())
elapsed = time() - build_start

print("Build completed in %0.2fs" % elapsed)
Expand Down Expand Up @@ -105,7 +105,8 @@ def build_cef(self, jobs=None, verbose=False, release=False):

build_start = time()
with cd(path.join("ports", "cef")):
ret = subprocess.call(["cargo", "build"], env=self.build_env())
ret = subprocess.call(["cargo", "build"],
env=self.build_env(), cwd=self.servo_crate())
elapsed = time() - build_start

print("CEF build completed in %0.2fs" % elapsed)
Expand All @@ -124,7 +125,8 @@ def build_tests(self, jobs=None):
if jobs is not None:
opts += ["-j", jobs]
return subprocess.call(
["cargo", "test", "--no-run"], env=self.build_env())
["cargo", "test", "--no-run"],
env=self.build_env(), cwd=self.servo_crate())

@Command('clean',
description='Clean the build directory.',
Expand All @@ -144,4 +146,5 @@ def clean(self, manifest_path, verbose=False):
if verbose:
opts += ["-v"]

return subprocess.call(["cargo", "clean"] + opts, env=self.build_env())
return subprocess.call(["cargo", "clean"] + opts,
env=self.build_env(), cwd=self.servo_crate())
3 changes: 3 additions & 0 deletions python/servo/command_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def build_env(self):

return env

def servo_crate(self):
return path.join(self.context.topdir, "components", "servo")

def ensure_bootstrapped(self):
if self.context.bootstrapped:
return
Expand Down
10 changes: 5 additions & 5 deletions python/servo/post_build_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run(self, params, debug=False, debugger=None):
env = self.build_env()
env["RUST_BACKTRACE"] = "1"

args = [path.join("target", "servo")]
args = [path.join("components", "servo", "target", "servo")]

# Borrowed and modified from:
# http://hg.mozilla.org/mozilla-central/file/c9cfa9b91dea/python/mozbuild/mozbuild/mach_commands.py#l883
Expand Down Expand Up @@ -71,7 +71,7 @@ def run(self, params, debug=False, debugger=None):
def doc(self, params):
self.ensure_bootstrapped()
return subprocess.call(["cargo", "doc"] + params,
env=self.build_env())
env=self.build_env(), cwd=self.servo_crate())

@Command('serve-docs',
description='Locally serve Servo and Rust documentation',
Expand All @@ -81,13 +81,13 @@ def doc(self, params):
help="Port to serve documentation at (default is 8888)")
def serve_docs(self, port):
self.doc([])
servedir = path.join("target", "serve-docs")
docdir = path.join("target", "doc")
servedir = path.join("components", "servo", "target", "serve-docs")
docdir = path.join("components", "servo", "target", "doc")

rmtree(servedir, True)
copytree(docdir, servedir, ignore=ignore_patterns('.*'))

rustdocs = path.join("rust", self.rust_snapshot_path(), "doc")
rustdocs = path.join(self.config["tools"]["rust-root"], "doc")
copytree(rustdocs, path.join(servedir, "rust"), ignore=ignore_patterns('.*'))

chdir(servedir)
Expand Down
9 changes: 6 additions & 3 deletions python/servo/testing_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ def ensure_built_tests(self):
self.context.built_tests = True

def find_test(self, prefix):
target_contents = os.listdir(path.join(self.context.topdir, "target"))
target_contents = os.listdir(path.join(
self.context.topdir, "components", "servo", "target"))
for filename in target_contents:
if filename.startswith(prefix + "-"):
filepath = path.join(self.context.topdir, "target", filename)
filepath = path.join(
self.context.topdir, "components", "servo", "target", filename)
if path.isfile(filepath) and os.access(filepath, os.X_OK):
return filepath

Expand Down Expand Up @@ -104,7 +106,8 @@ def test_unit(self, test_name=None):

def cargo_test(component):
return 0 != subprocess.call(
["cargo", "test", "-p", component], env=self.build_env())
["cargo", "test", "-p", component],
env=self.build_env(), cwd=self.servo_crate())

for component in os.listdir("components"):
ret = ret or cargo_test(component)
Expand Down
9 changes: 9 additions & 0 deletions support/not-the-toml-you-re-looking-for.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main() {
::std::os::set_exit_status(1);
let _ = ::std::io::stderr().write(br"
This is not the `Cargo.toml` file you're looking for.
Invoke Cargo through mach instead, e.g. `./mach build`.
");
}
2 changes: 1 addition & 1 deletion tests/contenttest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn run_test(file: String) {
let stderr = InheritFd(2);
let args = ["-z", "-f", infile.as_slice()];

let mut prc = match Command::new("target/servo")
let mut prc = match Command::new(os::self_exe_path().unwrap().join("servo"))
.args(args)
.stdin(Ignored)
.stdout(stdout)
Expand Down
2 changes: 1 addition & 1 deletion tests/reftest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ fn make_test(reftest: Reftest) -> TestDescAndFn {

fn capture(reftest: &Reftest, side: uint) -> (u32, u32, Vec<u8>) {
let png_filename = format!("/tmp/servo-reftest-{:06u}-{:u}.png", reftest.id, side);
let mut command = Command::new("target/servo");
let mut command = Command::new(os::self_exe_path().unwrap().join("servo"));
command
.args(reftest.servo_args.as_slice())
// Allows pixel perfect rendering of Ahem font for reftests.
Expand Down
16 changes: 8 additions & 8 deletions tests/wpt/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

set -e

servo_root=$(pwd)
wpt_root=$(dirname $0)

PYTHON=$(which python2 2> /dev/null || echo python)
VIRTUALENV=$(which virtualenv2 2> /dev/null || echo virtualenv)

test -d _virtualenv || $VIRTUALENV _virtualenv -p $PYTHON
test -d $servo_root/tests/wpt/metadata || mkdir -p $servo_root/tests/wpt/metadata
test -d $servo_root/tests/wpt/prefs || mkdir -p $servo_root/tests/wpt/prefs
source _virtualenv/bin/activate
test -d $wpt_root/_virtualenv || $VIRTUALENV $wpt_root/_virtualenv -p $PYTHON
test -d $wpt_root/metadata || mkdir -p $wpt_root/metadata
test -d $wpt_root/prefs || mkdir -p $wpt_root/prefs
source $wpt_root/_virtualenv/bin/activate
if [[ $* == *--update-manifest* ]]; then
(python -c "import html5lib" &>/dev/null) || pip install html5lib
fi
(python -c "import wptrunner" &>/dev/null) || pip install 'wptrunner==1.7'

python $servo_root/tests/wpt/run.py \
--config $servo_root/tests/wpt/config.ini \
--binary target/servo \
python $wpt_root/run.py \
--config $wpt_root/config.ini \
--binary $wpt_root/../../components/servo/target/servo \
--log-mach - \
"$@"

0 comments on commit 991d238

Please sign in to comment.