From 40eb1f8b9b2a76d76ef6a4a094bf8192a44cbe41 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Fri, 1 Dec 2017 16:57:30 +0300 Subject: Making Go package source distributable and renaming to 'nginx/unit'. All header files are copied to Go package sources. As the result, package can be (re-)build when required. This closes #23 issue on GitHub. --- src/go/unit/darwin-cflags.go | 13 ++++++++++ src/go/unit/linux-lrt.go | 13 ++++++++++ src/go/unit/nxt_go_array.c | 4 --- src/go/unit/nxt_go_lib.c | 56 ++-------------------------------------- src/go/unit/nxt_go_port.c | 9 ++----- src/go/unit/nxt_go_port_memory.c | 9 ++----- src/go/unit/nxt_go_process.c | 6 ----- src/go/unit/nxt_go_run_ctx.c | 9 ++----- 8 files changed, 34 insertions(+), 85 deletions(-) create mode 100644 src/go/unit/darwin-cflags.go create mode 100644 src/go/unit/linux-lrt.go (limited to 'src/go/unit') diff --git a/src/go/unit/darwin-cflags.go b/src/go/unit/darwin-cflags.go new file mode 100644 index 00000000..a5e37c39 --- /dev/null +++ b/src/go/unit/darwin-cflags.go @@ -0,0 +1,13 @@ +// +build darwin + +/* + * Copyright (C) Max Romanov + * Copyright (C) NGINX, Inc. + */ + +package unit + +/* +#cgo CFLAGS: -mmacosx-version-min=10.5 +*/ +import "C" diff --git a/src/go/unit/linux-lrt.go b/src/go/unit/linux-lrt.go new file mode 100644 index 00000000..37ea4880 --- /dev/null +++ b/src/go/unit/linux-lrt.go @@ -0,0 +1,13 @@ +// +build linux + +/* + * Copyright (C) Max Romanov + * Copyright (C) NGINX, Inc. + */ + +package unit + +/* +#cgo LDFLAGS: -lrt +*/ +import "C" diff --git a/src/go/unit/nxt_go_array.c b/src/go/unit/nxt_go_array.c index f409cb10..fea97faf 100644 --- a/src/go/unit/nxt_go_array.c +++ b/src/go/unit/nxt_go_array.c @@ -4,8 +4,6 @@ * Copyright (C) NGINX, Inc. */ -#ifndef NXT_CONFIGURE - #include #include @@ -62,5 +60,3 @@ nxt_go_array_add(nxt_array_t *array) return p; } - -#endif /* NXT_CONFIGURE */ diff --git a/src/go/unit/nxt_go_lib.c b/src/go/unit/nxt_go_lib.c index 71940461..691688ab 100644 --- a/src/go/unit/nxt_go_lib.c +++ b/src/go/unit/nxt_go_lib.c @@ -4,62 +4,13 @@ * Copyright (C) NGINX, Inc. */ -#ifdef NXT_CONFIGURE - -#include -#include "nxt_go_lib.h" - -// Stubs to compile during configure process. -int -nxt_go_response_write(nxt_go_request_t r, void *buf, size_t len) -{ - return -1; -} - -int -nxt_go_request_read(nxt_go_request_t r, void *dst, size_t dst_len) -{ - return -1; -} - -int -nxt_go_request_read_from(nxt_go_request_t r, void *dst, size_t dst_len, - void *src, size_t src_len) -{ - return -1; -} - -int -nxt_go_request_close(nxt_go_request_t r) -{ - return -1; -} - -int -nxt_go_request_done(nxt_go_request_t r) -{ - return -1; -} - -void -nxt_go_ready() -{ -} - -nxt_go_request_t -nxt_go_process_port_msg(void *buf, size_t buf_len, void *oob, size_t oob_len) -{ - return 0; -} - -#else - #include "nxt_go_run_ctx.h" #include "nxt_go_log.h" #include "nxt_go_port.h" +#include "_cgo_export.h" + #include -#include int nxt_go_response_write(nxt_go_request_t r, void *buf, size_t len) @@ -190,6 +141,3 @@ nxt_go_process_port_msg(void *buf, size_t buf_len, void *oob, size_t oob_len) { return nxt_go_port_on_read(buf, buf_len, oob, oob_len); } - - -#endif /* NXT_CONFIGURE */ diff --git a/src/go/unit/nxt_go_port.c b/src/go/unit/nxt_go_port.c index e866a242..8ea9a5ca 100644 --- a/src/go/unit/nxt_go_port.c +++ b/src/go/unit/nxt_go_port.c @@ -4,16 +4,14 @@ * Copyright (C) NGINX, Inc. */ -#ifndef NXT_CONFIGURE - - #include "nxt_go_port.h" #include "nxt_go_log.h" #include "nxt_go_process.h" #include "nxt_go_run_ctx.h" +#include "_cgo_export.h" + #include -#include #define nxt_go_str(p) ((nxt_go_str_t *)(p)) @@ -205,6 +203,3 @@ fail: return 0; } - - -#endif /* NXT_CONFIGURE */ diff --git a/src/go/unit/nxt_go_port_memory.c b/src/go/unit/nxt_go_port_memory.c index 2c183161..e1b732d2 100644 --- a/src/go/unit/nxt_go_port_memory.c +++ b/src/go/unit/nxt_go_port_memory.c @@ -4,15 +4,13 @@ * Copyright (C) NGINX, Inc. */ -#ifndef NXT_CONFIGURE - - #include "nxt_go_port_memory.h" #include "nxt_go_process.h" #include "nxt_go_array.h" #include "nxt_go_log.h" -#include +#include "_cgo_export.h" + #include #if (NXT_HAVE_MEMFD_CREATE) @@ -197,6 +195,3 @@ unlock_return: return hdr; } - - -#endif /* NXT_CONFIGURE */ diff --git a/src/go/unit/nxt_go_process.c b/src/go/unit/nxt_go_process.c index eb29cee1..bb2d279c 100644 --- a/src/go/unit/nxt_go_process.c +++ b/src/go/unit/nxt_go_process.c @@ -4,9 +4,6 @@ * Copyright (C) NGINX, Inc. */ -#ifndef NXT_CONFIGURE - - #include "nxt_go_process.h" #include "nxt_go_array.h" #include "nxt_go_mutex.h" @@ -149,6 +146,3 @@ fail: nxt_go_mutex_unlock(&process->incoming_mutex); } - - -#endif /* NXT_CONFIGURE */ diff --git a/src/go/unit/nxt_go_run_ctx.c b/src/go/unit/nxt_go_run_ctx.c index 68df8f49..902872ce 100644 --- a/src/go/unit/nxt_go_run_ctx.c +++ b/src/go/unit/nxt_go_run_ctx.c @@ -4,9 +4,6 @@ * Copyright (C) NGINX, Inc. */ -#ifndef NXT_CONFIGURE - - #include "nxt_go_run_ctx.h" #include "nxt_go_log.h" #include "nxt_go_process.h" @@ -14,9 +11,10 @@ #include "nxt_go_mutex.h" #include "nxt_go_port_memory.h" +#include "_cgo_export.h" + #include #include -#include static nxt_int_t @@ -530,6 +528,3 @@ nxt_go_ctx_read_raw(nxt_go_run_ctx_t *ctx, void *dst, size_t size) return res; } - - -#endif /* NXT_CONFIGURE */ -- cgit