diff --git a/ROADMAP.md b/ROADMAP.md index 29dc957c98..ff9dcd3e40 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -43,7 +43,9 @@ For a list of all features and fixes, check out the changelog. - [x] Lambdas: `a.sort(|a, b| a > b)` - [ ] Custom attributes - [ ] Contexts that are passed implicitly (e.g. for custom allocation/memory management) +- [x] Implicit Veb contexts passed to requests - [ ] Direct C/C++ interop without generating wrappers +- [ ] Make ORM work without installing developer libs (libpq-dev etc) ## [Version 0.6] diff --git a/vlib/db/pg/pg.c.v b/vlib/db/pg/pg.c.v index 2ffb727f18..d888d4349d 100644 --- a/vlib/db/pg/pg.c.v +++ b/vlib/db/pg/pg.c.v @@ -12,6 +12,7 @@ $if $pkgconfig('libpq') { #flag -lpq } #flag linux -I/usr/include/postgresql + //#flag linux -Ipostgresql // cross compiling to linux #flag darwin -I/opt/local/include/postgresql11 #flag darwin -L/opt/local/lib/postgresql11 @@ -32,12 +33,19 @@ $if $pkgconfig('libpq') { #flag freebsd -L/usr/local/lib } -// PostgreSQL Source Code -// https://doxygen.postgresql.org/libpq-fe_8h.html -#include +$if cross_compile ? && linux { + #include + #include -// for PG_VERSION_NUM, which is defined everywhere at least since PG 9.5 -#include + //#flag -lpq // libpq.a is located in LINUXROOT/lib/x86_64-linux-gnu/libpq.a +} $else { + // PostgreSQL Source Code + // https://doxygen.postgresql.org/libpq-fe_8h.html + #include + + // for PG_VERSION_NUM, which is defined everywhere at least since PG 9.5 + #include +} // for orm $if windows { diff --git a/vlib/net/openssl/openssl.c.v b/vlib/net/openssl/openssl.c.v index e407a6f82b..1b7d314ca8 100644 --- a/vlib/net/openssl/openssl.c.v +++ b/vlib/net/openssl/openssl.c.v @@ -1,5 +1,7 @@ module openssl +#define OPENSSL_API_COMPAT 0x30000000L + // On Linux, prefer a locally built openssl, because it is // much more likely for it to be newer, than the system // openssl from libssl-dev. If there is no local openssl, @@ -116,6 +118,8 @@ fn C.SSL_set_cipher_list(ctx &SSL, str &char) int fn C.SSL_get_peer_certificate(ssl &SSL) &C.X509 +// fn C.SSL_get1_peer_certificate(ssl &SSL) &C.X509 + fn C.X509_free(const_cert &C.X509) fn C.ERR_clear_error() diff --git a/vlib/v/cflag/cflags.v b/vlib/v/cflag/cflags.v index 772649d6b1..82ce4513c8 100644 --- a/vlib/v/cflag/cflags.v +++ b/vlib/v/cflag/cflags.v @@ -105,7 +105,9 @@ pub fn (cflags []CFlag) c_options_without_object_files() []string { pub fn (cflags []CFlag) c_options_only_object_files() []string { mut args := []string{} for flag in cflags { - if flag.value.ends_with('.o') || flag.value.ends_with('.obj') { + // TODO figure out a better way to copy cross compiling flags to the linker + if flag.value.ends_with('.o') || flag.value.ends_with('.obj') + || (flag.name == '-l' && flag.value == 'pq') { args << flag.format() } } diff --git a/vlib/v/pref/default.v b/vlib/v/pref/default.v index 24a7dc6c89..b3fb62323c 100644 --- a/vlib/v/pref/default.v +++ b/vlib/v/pref/default.v @@ -138,6 +138,11 @@ pub fn (mut p Preferences) fill_with_defaults() { } rpath_name := os.file_name(rpath) p.building_v = !p.is_repl && (rpath_name == 'v' || rpath_name == 'vfmt.v') + if p.os == .linux { + $if !linux { + p.parse_define('cross_compile') + } + } if p.output_cross_c { // avoid linking any GC related code, since the target may not have an usable GC system p.gc_mode = .no_gc