Skip to content

Commit

Permalink
adding check for windows then using Scripts instead of bin
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwilliams authored and larsbergstrom committed Jan 23, 2016
1 parent 095658e commit 13d98f1
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 41 deletions.
17 changes: 16 additions & 1 deletion components/compositing/Cargo.toml
Expand Up @@ -63,7 +63,22 @@ git = "https://github.com/servo/ipc-channel"
[dependencies.offscreen_gl_context]
git = "https://github.com/ecoal95/rust-offscreen-rendering-context"

[dependencies.gaol]
[target.arm-linux-androideabi.dependencies.gaol]
git = "https://github.com/pcwalton/gaol"

[target.x86_64-apple-darwin.dependencies.gaol]
git = "https://github.com/pcwalton/gaol"

[target.x86_64-unknown-linux-gnu.dependencies.gaol]
git = "https://github.com/pcwalton/gaol"

[target.i686-unknown-linux-gnu.dependencies.gaol]
git = "https://github.com/pcwalton/gaol"

[target.arm-unknown-linux-gnueabihf.dependencies.gaol]
git = "https://github.com/pcwalton/gaol"

[target.aarch64-unknown-linux-gnueabihf.dependencies.gaol]
git = "https://github.com/pcwalton/gaol"

[dependencies]
Expand Down
52 changes: 31 additions & 21 deletions components/compositing/constellation.rs
Expand Up @@ -406,27 +406,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
//
// Yes, that's all there is to it!
if opts::multiprocess() {
let (server, token) =
IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap();

// If there is a sandbox, use the `gaol` API to create the child process.
let child_process = if opts::get().sandbox {
let mut command = sandbox::Command::me().unwrap();
command.arg("--content-process").arg(token);
let profile = sandboxing::content_process_sandbox_profile();
ChildProcess::Sandboxed(Sandbox::new(profile).start(&mut command).expect(
"Failed to start sandboxed child process!"))
} else {
let path_to_self = env::current_exe().unwrap();
let mut child_process = process::Command::new(path_to_self);
child_process.arg("--content-process");
child_process.arg(token);
ChildProcess::Unsandboxed(child_process.spawn().unwrap())
};
self.child_processes.push(child_process);

let (_receiver, sender) = server.accept().unwrap();
sender.send(unprivileged_pipeline_content).unwrap();
self.spawn_multiprocess(unprivileged_pipeline_content);
} else {
unprivileged_pipeline_content.start_all::<LTF, STF>(false);
}
Expand All @@ -436,6 +416,36 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
self.pipelines.insert(pipeline_id, pipeline);
}

#[cfg(not(target_os = "windows"))]
fn spawn_multiprocess(&mut self, unprivileged_pipeline_content: UnprivilegedPipelineContent) {
let (server, token) =
IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap();

// If there is a sandbox, use the `gaol` API to create the child process.
let child_process = if opts::get().sandbox {
let mut command = sandbox::Command::me().unwrap();
command.arg("--content-process").arg(token);
let profile = sandboxing::content_process_sandbox_profile();
ChildProcess::Sandboxed(Sandbox::new(profile).start(&mut command).expect(
"Failed to start sandboxed child process!"))
} else {
let path_to_self = env::current_exe().unwrap();
let mut child_process = process::Command::new(path_to_self);
child_process.arg("--content-process");
child_process.arg(token);
ChildProcess::Unsandboxed(child_process.spawn().unwrap())
};

self.child_processes.push(child_process);
let (_receiver, sender) = server.accept().unwrap();
sender.send(unprivileged_pipeline_content).unwrap();
}

#[cfg(target_os = "windows")]
fn spawn_multiprocess(&mut self, _: UnprivilegedPipelineContent) {
panic!("Multiprocess is not supported on Windows.");
}

// Push a new (loading) pipeline to the list of pending frame changes
fn push_pending_frame(&mut self, new_pipeline_id: PipelineId,
old_pipeline_id: Option<PipelineId>) {
Expand Down
4 changes: 3 additions & 1 deletion python/mach_bootstrap.py
Expand Up @@ -92,7 +92,9 @@ def _activate_virtualenv(topdir):
if python is None:
sys.exit("Python is not installed. Please install it prior to running mach.")

activate_path = os.path.join(virtualenv_path, "bin", "activate_this.py")
# Virtualenv calls its scripts folder "bin" on linux/OSX but "Scripts" on Windows, detect which one then use that
script_dir = "Scripts" if os.name == "nt" else "bin"
activate_path = os.path.join(virtualenv_path, script_dir, "activate_this.py")
if not (os.path.exists(virtualenv_path) and os.path.exists(activate_path)):
virtualenv = _get_exec(*VIRTUALENV_NAMES)
if virtualenv is None:
Expand Down
2 changes: 1 addition & 1 deletion python/servo/bootstrap_commands.py
Expand Up @@ -28,7 +28,7 @@
Command,
)

from servo.command_base import CommandBase, cd, host_triple, use_nightly_rust, check_call, BIN_SUFFIX
from servo.command_base import CommandBase, cd, host_triple, check_call, BIN_SUFFIX


def download(desc, src, writer):
Expand Down
26 changes: 9 additions & 17 deletions python/servo/command_base.py
Expand Up @@ -16,9 +16,7 @@

from mach.registrar import Registrar

BIN_SUFFIX = ""
if sys.platform == "win32":
BIN_SUFFIX = ".exe"
BIN_SUFFIX = ".exe" if sys.platform == "win32" else ""


@contextlib.contextmanager
Expand Down Expand Up @@ -59,34 +57,28 @@ def host_triple():


def use_nightly_rust():
envvar = os.environ.get("SERVO_USE_NIGHTLY_RUST")
if envvar:
return envvar != "0"
return False
envvar = os.environ.get("SERVO_USE_NIGHTLY_RUST", "0")
return envvar != "0"


def call(*args, **kwargs):
"""Wrap `subprocess.call`, printing the command if verbose=True."""
verbose = kwargs.pop('verbose', False)
if verbose:
print(' '.join(args[0]))
if sys.platform == "win32":
# we have to use shell=True in order to get PATH handling
# when looking for the binary on Windows
return subprocess.call(*args, shell=True, **kwargs)
return subprocess.call(*args, **kwargs)
# we have to use shell=True in order to get PATH handling
# when looking for the binary on Windows
return subprocess.call(*args, shell=sys.platform == 'win32', **kwargs)


def check_call(*args, **kwargs):
"""Wrap `subprocess.check_call`, printing the command if verbose=True."""
verbose = kwargs.pop('verbose', False)
if verbose:
print(' '.join(args[0]))
if sys.platform == "win32":
# we have to use shell=True in order to get PATH handling
# when looking for the binary on Windows
return subprocess.check_call(*args, shell=True, **kwargs)
return subprocess.check_call(*args, **kwargs)
# we have to use shell=True in order to get PATH handling
# when looking for the binary on Windows
return subprocess.check_call(*args, shell=sys.platform == 'win32', **kwargs)


class CommandBase(object):
Expand Down
1 change: 1 addition & 0 deletions python/servo/devenv_commands.py
Expand Up @@ -10,6 +10,7 @@
from __future__ import print_function, unicode_literals
from os import path, getcwd, listdir

import subprocess
import sys

from mach.decorators import (
Expand Down

0 comments on commit 13d98f1

Please sign in to comment.