summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--auto/modules/go40
-rw-r--r--src/go/unit/darwin-cflags.go13
-rw-r--r--src/go/unit/linux-lrt.go13
-rw-r--r--src/go/unit/nxt_go_array.c4
-rw-r--r--src/go/unit/nxt_go_lib.c56
-rw-r--r--src/go/unit/nxt_go_port.c9
-rw-r--r--src/go/unit/nxt_go_port_memory.c9
-rw-r--r--src/go/unit/nxt_go_process.c6
-rw-r--r--src/go/unit/nxt_go_run_ctx.c9
9 files changed, 52 insertions, 107 deletions
diff --git a/auto/modules/go b/auto/modules/go
index c31dbe94..68eb7d4a 100644
--- a/auto/modules/go
+++ b/auto/modules/go
@@ -85,41 +85,37 @@ fi
cat << END >> $NXT_MAKEFILE
-.PHONY: ${NXT_GO} ${NXT_GO}-install ${NXT_GO}-uninstall
-
-all: ${NXT_GO}
-
-NXT_ROOT = `pwd`
+.PHONY: ${NXT_GO}
+.PHONY: ${NXT_GO}-install
+.PHONY: ${NXT_GO}-install-src
+.PHONY: ${NXT_GO}-install-build
+.PHONY: ${NXT_GO}-uninstall
GOPATH = $NXT_GO_PATH
GOOS = `${NXT_GO} env GOOS`
GOARCH = `${NXT_GO} env GOARCH`
-${NXT_GO}: $NXT_BUILD_DIR/nxt_go_gen.h
+NXT_GO_DST = ${NXT_GO_PATH%%:*}
-$NXT_BUILD_DIR/nxt_go_gen.h: src/go/unit/*.go
- GOPATH=`pwd` \\
- CGO_CPPFLAGS="-DNXT_CONFIGURE \\
- -I`pwd`/src" \\
- ${NXT_GO} build -o $NXT_BUILD_DIR/nxt_go_gen.a \\
- --buildmode=c-archive go/unit
+install: ${NXT_GO}-install
+${NXT_GO}:
-install: ${NXT_GO}-install
+${NXT_GO}-install: ${NXT_GO}-install-build
+
+${NXT_GO}-install-src:
+ install -d \$(DESTDIR)\$(NXT_GO_DST)/src/nginx/unit
+ install -p -m644 ./src/*.h ./build/*.h ./src/go/unit/* \
+ \$(DESTDIR)\$(NXT_GO_DST)/src/nginx/unit/
-${NXT_GO}-install: ${NXT_GO}
- install -d \$(DESTDIR)\$(GOPATH)/src/unit
- install -p -m644 ./src/go/unit/* \$(DESTDIR)\$(GOPATH)/src/unit/
- CGO_CFLAGS="-I\$(NXT_ROOT)/$NXT_BUILD_DIR -I\$(NXT_ROOT)/src" \\
- CGO_LDFLAGS="-L\$(NXT_ROOT)/$NXT_BUILD_DIR ${NXT_LIBRT}" \\
- GOPATH=\$(DESTDIR)\$(GOPATH) \\
- ${NXT_GO} install -v unit
+${NXT_GO}-install-build: ${NXT_GO}-install-src
+ GOPATH=\$(DESTDIR)\$(GOPATH) ${NXT_GO} build nginx/unit
uninstall: ${NXT_GO}-uninstall
${NXT_GO}-uninstall:
- rm -rf \$(DESTDIR)\$(GOPATH)/src/unit
- rm -f \$(DESTDIR)\$(GOPATH)/pkg/\$(GOOS)_\$(GOARCH)/unit.a
+ rm -rf \$(DESTDIR)\$(NXT_GO_DST)/src/nginx/unit
+ rm -rf \$(DESTDIR)\$(NXT_GO_DST)/pkg/\$(GOOS)_\$(GOARCH)/nginx/unit
END
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 <stdint.h>
#include <sys/types.h>
@@ -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 <stdio.h>
-#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 <nxt_main.h>
-#include <nxt_go_gen.h>
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 <nxt_main.h>
-#include <nxt_go_gen.h>
#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 <nxt_go_gen.h>
+#include "_cgo_export.h"
+
#include <nxt_main.h>
#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 <nxt_port_memory_int.h>
#include <nxt_main.h>
-#include <nxt_go_gen.h>
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 */