Skip to content

Commit

Permalink
Merge pull request chris-morgan#14 from larsbergstrom/update_origin_b…
Browse files Browse the repository at this point in the history
…ranch

Update the servo branch with changes from upstream and to build in Servo
  • Loading branch information
metajack committed Apr 16, 2014
2 parents fa82ccf + 80ef656 commit 27da508
Show file tree
Hide file tree
Showing 39 changed files with 402 additions and 221 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ build/
TAGS
doc/http/
doc/src/http/
doc/.lock
doc/*.js
doc/*.css
lib/
.rust/
Makefile
5 changes: 5 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
~$
\.dSYM/
\.swp$
^src/http/generated/
^bin/
^build/
^TAGS$
^doc/http/
^doc/src/http/
^doc/\.lock$
^doc/.*\.js$
^doc/.*\.css$
^lib/
^.rust/
^Makefile$
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ before_install:
- sudo apt-get update
install:
- sudo apt-get install rust-nightly
- git clone https://github.com/sfackler/rust-openssl.git
- cd rust-openssl
- ./configure
- make
- cd ..
- mv rust-openssl ../
script:
- make check
- make docs
- WITHOUT_SSL=1 ./configure
- make all check
- ./configure
- make all check docs
after_script:
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh
80 changes: 0 additions & 80 deletions Makefile

This file was deleted.

107 changes: 78 additions & 29 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,42 +1,91 @@
VPATH=%VPATH%

RUST ?= rust
SSL_LIB ?= %SSL_LIB%
SSL_CFG ?= %SSL_CFG%
ifdef SSL_LIB
SSL_CFG += -L "$(SSL_LIB)"
endif
RUSTC ?= rustc
RUSTFLAGS ?= -O
HOST_RUSTFLAGS ?= -O
RUSTDOC ?= rustdoc
RUSTPKG ?= rustpkg
RUSTFLAGS ?= -O $(SSL_CFG)
RUST_REPOSITORY ?= ../rust
RUST_CTAGS ?= $(RUST_REPOSITORY)/src/etc/ctags.rust
VERSION=0.1-pre

libhttp_files=$(shell find $(VPATH)/src/http/ -type f -name '*.rs') \
$(VPATH)/src/http/generated/read_method.rs \
$(VPATH)/src/http/generated/status.rs
codegen_files=\
src/codegen/branchify.rs \
src/codegen/main.rs \
src/codegen/read_method.rs \
src/codegen/status.rs \

libhttp_so=build/.libhttp.timestamp
http_files=\
$(wildcard src/http/*.rs) \
src/http/generated/read_method.rs \
src/http/generated/status.rs \
$(wildcard src/http/headers/*.rs) \
$(wildcard src/http/client/*.rs) \
$(wildcard src/http/server/*.rs)

http: $(libhttp_so)

Makefile: configure Makefile.in
@echo "configure or Makefile.in changed, regenerating Makefile"
@DOING_RECONFIGURE=1 SSL_LIB="$(SSL_LIB)" SSL_CFG="$(SSL_CFG)" ./configure
@echo
@echo ======================
@echo Please run make again!
@echo ======================
@echo
@exit 1

$(libhttp_so): Makefile $(http_files)
mkdir -p build/
$(RUSTC) $(RUSTFLAGS) src/http/lib.rs --out-dir=build
@touch build/.libhttp.timestamp

all: http examples docs

build/codegen: $(codegen_files)
mkdir -p build/
$(RUSTC) src/codegen/main.rs --out-dir=build

src/http/generated:
mkdir -p src/http/generated

src/http/generated/%.rs: build/codegen src/http/generated
build/codegen $(patsubst src/http/generated/%,%,$@) src/http/generated/

build/%:: src/%/main.rs $(libhttp_so)
mkdir -p "$(dir $@)"
$(RUSTC) $(RUSTFLAGS) $< -o $@ -L build/

all: libhttp.dummy
examples: $(patsubst src/examples/%/main.rs,build/examples/%,$(wildcard src/examples/*/main.rs)) \
$(patsubst src/examples/%/main.rs,build/examples/%,$(wildcard src/examples/*/*/main.rs))

codegen: $(wildcard $(VPATH)/src/codegen/*.rs)
$(RUSTC) $(HOST_RUSTFLAGS) $(VPATH)/src/codegen/main.rs -o codegen
docs: doc/http/index.html

$(VPATH)/src/http/generated:
mkdir -p $(VPATH)/src/http/generated
doc/http/index.html: $(http_files)
$(RUSTDOC) src/http/lib.rs

$(VPATH)/src/http/generated/%.rs: codegen $(VPATH)/src/http/generated
./codegen $(patsubst $(VPATH)/src/http/generated/%,%,$@) $(VPATH)/src/http/generated/
build/tests: $(http_files)
$(RUSTC) $(RUSTFLAGS) --test -o build/tests src/http/lib.rs

libhttp.dummy: $(libhttp_files)
$(RUSTC) $(RUSTFLAGS) $(VPATH)/src/http/lib.rs --out-dir .
touch $@
build/quicktests: $(http_files)
$(RUSTC) --test -o build/quicktests src/http/lib.rs

check: tests
./tests --test
# Can't wait for everything to build, optimised too? OK, you can save some time here.
quickcheck: build/quicktests
build/quicktests --test

tests: $(libhttp_files)
$(RUSTC) $(RUSTFLAGS) --test -o tests $(VPATH)/src/http/lib.rs
check: all build/tests
build/tests --test

clean-tests:
rm -f tests
clean:
rm -rf src/http/generated/ src/http/codegen/codegen
rm -rf build/
rm -rf bin/ .rust/

clean: clean-tests
rm -rf $(VPATH)src/http/generated/ codegen
rm -rf libhttp.dummy
rm -f *.so *.dylib *.rlib *.dll
TAGS:
ctags -f TAGS --options=$(RUST_CTAGS) -R src

.PHONY: all examples clean clean-tests
.PHONY: all http examples docs clean check quickcheck
49 changes: 49 additions & 0 deletions Makefile.servo.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
VPATH=%VPATH%

RUST ?= rust
RUSTC ?= rustc
RUSTFLAGS ?= -O
HOST_RUSTFLAGS ?= -O
VERSION=0.1-pre

libhttp_files=$(shell find $(VPATH)/src/http/ -type f -name '*.rs') \
$(VPATH)/src/http/generated/read_method.rs \
$(VPATH)/src/http/generated/status.rs

all: libhttp.dummy

codegen: $(wildcard $(VPATH)/src/codegen/*.rs)
$(RUSTC) $(HOST_RUSTFLAGS) $(VPATH)/src/codegen/main.rs -o codegen

$(VPATH)/src/http/generated:
mkdir -p $(VPATH)/src/http/generated

$(VPATH)/src/http/generated/%.rs: codegen $(VPATH)/src/http/generated/
./codegen $(patsubst $(VPATH)/src/http/generated/%,%,$@) $(VPATH)/src/http/generated/

libhttp.dummy: $(libhttp_files)
$(RUSTC) $(RUSTFLAGS) $(VPATH)/src/http/lib.rs --out-dir .
touch $@

build/%:: src/%.rs libhttp.dummy
mkdir -p '$(dir $@)'
$(RUSTC) $(RUSTFLAGS) $< -o $@ -L build/

examples: build/examples/apache_fake build/examples/hello_world build/examples/info build/examples/client/client

.PHONY: check
check: tests

tests: $(libhttp_files)
$(RUSTC) $(RUSTFLAGS) --test -o tests $(VPATH)/src/http/lib.rs
./tests --test

clean-tests:
rm -f tests

clean: clean-tests
rm -rf $(VPATH)src/http/generated/ codegen
rm -rf libhttp.dummy
rm -f *.so *.dylib *.dll

.PHONY: all examples clean tests clean-tests
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ At present, all of the example servers serve to http://127.0.0.1:8001/.
Don't expect everything to work well. The server claims HTTP/1.1, but is not
in any way compliant yet.

SSL support
-----------

rust-http can be compiled with or without SSL support.

To compile with SSL support, drop rust-openssl_ in a sibling directory of
rust-http (i.e. ``../rust-openssl`` from this file) and run its ``configure``
and ``make``. rust-http's ``configure`` will then automatically detect it and
you will get SSL support enabled.

To compile rust-http without SSL support, just don’t put rust-openssl_ where it
can find it. You'll then get an ``IoError { kind: InvalidInput, .. }`` if you
try to make an SSL request (e.g. HTTPS).

.. _rust-openssl: https://github.com/sfackler/rust-openssl

Roadmap
-------

Expand Down
3 changes: 3 additions & 0 deletions comparisons/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def compile_server(self):
'--opt-level=3', self.source,
#'--out-dir', self.build_dir,
'-L', '../build', # '../build/{}/http/'.format(RustServerRunner.HOST),
# Just in case it was built with openssl support. This should
# really be done better, based on the Makefile contents.
'-L', '../../rust-openssl/build',
# Sorry, this main.rs business needs me to do this, or use rustpkg:
'-o', os.path.join(self.build_dir, self.bin_name))).communicate()

Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

SRCDIR="$(cd $(dirname $0) && pwd)"
sed "s#%VPATH%#${SRCDIR}#" ${SRCDIR}/Makefile.in > Makefile
sed "s#%VPATH%#${SRCDIR}#" ${SRCDIR}/Makefile.servo.in > Makefile
2 changes: 1 addition & 1 deletion src/codegen/branchify.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[macro_escape];
#![macro_escape]

use std::str::Chars;
use std::io::IoResult;
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[crate_id = "codegen"];
#![crate_id = "codegen"]

#[feature(macro_rules)];
#![feature(macro_rules)]

extern crate collections;

Expand Down
16 changes: 9 additions & 7 deletions src/examples/client/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#[crate_id = "client"];
#![crate_id = "client"]

extern crate http;
use http::client::RequestWriter;
use http::method::Get;
use http::headers::HeaderEnum;
use std::os;
use std::str;
use std::io::{Reader, println};
use std::io::net::tcp::TcpStream;
use std::io::println;

fn main() {
format!("{}", Get);
Expand All @@ -23,8 +22,8 @@ fn main() {
}

fn make_and_print_request(url: ~str) {
let request = RequestWriter::<TcpStream>::new(Get, from_str(url).expect("Invalid URL :-("))
.unwrap();
let request: RequestWriter = RequestWriter::new(Get, from_str(url).expect("Invalid URL :-("))
.unwrap();

println!("Request");
println!("=======");
Expand All @@ -51,6 +50,9 @@ fn make_and_print_request(url: ~str) {
println!(" - {}: {}", header.header_name(), header.header_value());
}
println!("Body:");
let body = response.read_to_end().unwrap();
println(str::from_utf8(body).expect("Uh oh, response wasn't UTF-8"));
let body = match response.read_to_end() {
Ok(body) => body,
Err(err) => fail!("Reading response failed: {}", err),
};
println(str::from_utf8(body.as_slice()).expect("Uh oh, response wasn't UTF-8"));
}
Loading

0 comments on commit 27da508

Please sign in to comment.