pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/cwrappers cwrappers-20170611:
details: https://anonhg.NetBSD.org/pkgsrc/rev/4f211fdd019f
branches: trunk
changeset: 363540:4f211fdd019f
user: joerg <joerg%pkgsrc.org@localhost>
date: Sun Jun 11 19:34:43 2017 +0000
description:
cwrappers-20170611:
Add new configuration options {ap,pre}pend_{shared,executable} for
adding options when the operation mode is identified as linking.
Based loosely on patch from khorben.
diffstat:
pkgtools/cwrappers/Makefile | 4 +-
pkgtools/cwrappers/files/bin/base-wrapper.c | 9 ++-
pkgtools/cwrappers/files/bin/common.c | 70 +++++++++++++++++++++++--
pkgtools/cwrappers/files/bin/common.h | 16 +++++-
pkgtools/cwrappers/files/bin/normalise-cc.c | 32 +++++++++++-
pkgtools/cwrappers/files/bin/normalise-ld.c | 21 +++++++-
pkgtools/cwrappers/files/doc/configuration.txt | 18 +++++-
pkgtools/cwrappers/files/doc/normalise-ld.txt | 5 +-
pkgtools/cwrappers/files/doc/normalise.txt | 10 +++-
9 files changed, 164 insertions(+), 21 deletions(-)
diffs (truncated from 358 to 300 lines):
diff -r ad7b351f14d2 -r 4f211fdd019f pkgtools/cwrappers/Makefile
--- a/pkgtools/cwrappers/Makefile Sun Jun 11 18:54:25 2017 +0000
+++ b/pkgtools/cwrappers/Makefile Sun Jun 11 19:34:43 2017 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.19 2017/01/12 14:56:35 joerg Exp $
+# $NetBSD: Makefile,v 1.20 2017/06/11 19:34:43 joerg Exp $
-PKGNAME= cwrappers-20170112
+PKGNAME= cwrappers-20170611
CATEGORIES= pkgtools sysutils
MAINTAINER= joerg%NetBSD.org@localhost
diff -r ad7b351f14d2 -r 4f211fdd019f pkgtools/cwrappers/files/bin/base-wrapper.c
--- a/pkgtools/cwrappers/files/bin/base-wrapper.c Sun Jun 11 18:54:25 2017 +0000
+++ b/pkgtools/cwrappers/files/bin/base-wrapper.c Sun Jun 11 19:34:43 2017 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: base-wrapper.c,v 1.4 2017/01/12 14:56:35 joerg Exp $ */
+/* $NetBSD: base-wrapper.c,v 1.5 2017/06/11 19:34:43 joerg Exp $ */
/*-
- * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2007, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
* All rights reserved.
*
* This code was developed as part of Google's Summer of Code 2007 program.
@@ -128,6 +128,11 @@
goto skip_transforms;
#endif
+#if defined(WRAPPER_LD)
+ operation_mode_ld(&args);
+#else
+ operation_mode_cc(&args);
+#endif
arglist_apply_config(&args);
#if defined(WRAPPER_LD)
normalise_ld(&args);
diff -r ad7b351f14d2 -r 4f211fdd019f pkgtools/cwrappers/files/bin/common.c
--- a/pkgtools/cwrappers/files/bin/common.c Sun Jun 11 18:54:25 2017 +0000
+++ b/pkgtools/cwrappers/files/bin/common.c Sun Jun 11 19:34:43 2017 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: common.c,v 1.6 2016/12/09 22:25:28 joerg Exp $ */
+/* $NetBSD: common.c,v 1.7 2017/06/11 19:34:43 joerg Exp $ */
/*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,9 +49,18 @@
char *exec_name;
char *wrksrc;
int debug;
+enum operation_mode current_operation_mode = mode_unknown;
static struct arglist prepend_args = TAILQ_HEAD_INITIALIZER(prepend_args);
static struct arglist append_args = TAILQ_HEAD_INITIALIZER(append_args);
+static struct arglist prepend_executable_args =
+ TAILQ_HEAD_INITIALIZER(prepend_executable_args);
+static struct arglist append_executable_args =
+ TAILQ_HEAD_INITIALIZER(append_executable_args);
+static struct arglist prepend_shared_args =
+ TAILQ_HEAD_INITIALIZER(prepend_shared_args);
+static struct arglist append_shared_args =
+ TAILQ_HEAD_INITIALIZER(append_shared_args);
struct argument *prepend_after;
const char library_name_chars[] =
@@ -135,29 +144,56 @@
}
}
-void
-arglist_apply_config(struct arglist *args)
+static void
+arglist_prepend_list(struct arglist *args, struct arglist *prepends)
{
struct argument *arg, *arg2;
if (prepend_after) {
- TAILQ_FOREACH(arg, &prepend_args, link) {
+ TAILQ_FOREACH(arg, prepends, link) {
arg2 = argument_copy(arg->val);
TAILQ_INSERT_AFTER(args, prepend_after, arg2, link);
}
} else {
- TAILQ_FOREACH_REVERSE(arg, &prepend_args, arglist, link) {
+ TAILQ_FOREACH_REVERSE(arg, prepends, arglist, link) {
arg2 = argument_copy(arg->val);
TAILQ_INSERT_HEAD(args, arg2, link);
}
}
- TAILQ_FOREACH(arg, &append_args, link) {
+}
+
+static void
+arglist_append_list(struct arglist *args, struct arglist *appends)
+{
+ struct argument *arg, *arg2;
+
+ TAILQ_FOREACH(arg, appends, link) {
arg2 = argument_copy(arg->val);
TAILQ_INSERT_TAIL(args, arg2, link);
}
}
void
+arglist_apply_config(struct arglist *args)
+{
+ arglist_prepend_list(args, &prepend_args);
+ arglist_append_list(args, &append_args);
+
+ switch (current_operation_mode) {
+ default:
+ break;
+ case mode_link_executable:
+ arglist_prepend_list(args, &prepend_executable_args);
+ arglist_append_list(args, &append_executable_args);
+ break;
+ case mode_link_shared:
+ arglist_prepend_list(args, &prepend_shared_args);
+ arglist_append_list(args, &prepend_shared_args);
+ break;
+ }
+}
+
+void
argument_unlink(struct arglist *args, struct argument **argp)
{
struct argument *arg;
@@ -233,6 +269,26 @@
arg = argument_copy(line + 7);
TAILQ_INSERT_TAIL(&append_args, arg, link);
}
+ if (strncmp(line, "prepend_executable=", 19) == 0) {
+ struct argument *arg;
+ arg = argument_copy(line + 19);
+ TAILQ_INSERT_TAIL(&prepend_executable_args, arg, link);
+ }
+ if (strncmp(line, "append_executable=", 18) == 0) {
+ struct argument *arg;
+ arg = argument_copy(line + 18);
+ TAILQ_INSERT_TAIL(&append_executable_args, arg, link);
+ }
+ if (strncmp(line, "prepend_shared=", 15) == 0) {
+ struct argument *arg;
+ arg = argument_copy(line + 15);
+ TAILQ_INSERT_TAIL(&prepend_shared_args, arg, link);
+ }
+ if (strncmp(line, "append_shared=", 14) == 0) {
+ struct argument *arg;
+ arg = argument_copy(line + 14);
+ TAILQ_INSERT_TAIL(&append_shared_args, arg, link);
+ }
if (strncmp(line, "wrksrc=", 7) == 0) {
free(wrksrc);
wrksrc = xstrdup(line + 7);
diff -r ad7b351f14d2 -r 4f211fdd019f pkgtools/cwrappers/files/bin/common.h
--- a/pkgtools/cwrappers/files/bin/common.h Sun Jun 11 18:54:25 2017 +0000
+++ b/pkgtools/cwrappers/files/bin/common.h Sun Jun 11 19:34:43 2017 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: common.h,v 1.5 2016/11/27 11:46:45 joerg Exp $ */
+/* $NetBSD: common.h,v 1.6 2017/06/11 19:34:43 joerg Exp $ */
/*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,16 @@
extern char *wrksrc;
extern int debug;
+enum operation_mode {
+ mode_unknown,
+ mode_preprocess,
+ mode_assemble,
+ mode_compile,
+ mode_link_executable,
+ mode_link_shared
+};
+extern enum operation_mode current_operation_mode;
+
TAILQ_HEAD(arglist, argument);
struct argument {
@@ -84,6 +94,7 @@
char *xstrdup(const char *);
char *xstrndup(const char *, size_t);
+void operation_mode_cc(struct arglist *);
void normalise_cc(struct arglist *);
void cleanup_cc(struct arglist *args);
void transform_cc(struct arglist *args);
@@ -95,6 +106,7 @@
void register_generic_transform(const char *);
void generic_transform_cc(struct arglist *);
+void operation_mode_ld(struct arglist *);
void normalise_ld(struct arglist *);
void generic_transform_ld(struct arglist *);
diff -r ad7b351f14d2 -r 4f211fdd019f pkgtools/cwrappers/files/bin/normalise-cc.c
--- a/pkgtools/cwrappers/files/bin/normalise-cc.c Sun Jun 11 18:54:25 2017 +0000
+++ b/pkgtools/cwrappers/files/bin/normalise-cc.c Sun Jun 11 19:34:43 2017 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: normalise-cc.c,v 1.4 2016/09/15 17:08:14 joerg Exp $ */
+/* $NetBSD: normalise-cc.c,v 1.5 2017/06/11 19:34:43 joerg Exp $ */
/*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,34 @@
}
void
+operation_mode_cc(struct arglist *args)
+{
+ struct argument *arg;
+
+ current_operation_mode = mode_link_executable;
+ TAILQ_FOREACH(arg, args, link) {
+ if (arg->val[0] != '-')
+ continue;
+ if (strcmp(arg->val, "-E") == 0) {
+ current_operation_mode = mode_preprocess;
+ continue;
+ }
+ if (strcmp(arg->val, "-S") == 0) {
+ current_operation_mode = mode_assemble;
+ continue;
+ }
+ if (strcmp(arg->val, "-c") == 0) {
+ current_operation_mode = mode_compile;
+ continue;
+ }
+ if (strcmp(arg->val, "-shared") == 0) {
+ current_operation_mode = mode_link_shared;
+ continue;
+ }
+ }
+}
+
+void
normalise_cc(struct arglist *args)
{
struct argument *arg, *arg2, *arg3;
diff -r ad7b351f14d2 -r 4f211fdd019f pkgtools/cwrappers/files/bin/normalise-ld.c
--- a/pkgtools/cwrappers/files/bin/normalise-ld.c Sun Jun 11 18:54:25 2017 +0000
+++ b/pkgtools/cwrappers/files/bin/normalise-ld.c Sun Jun 11 19:34:43 2017 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: normalise-ld.c,v 1.2 2015/04/19 14:30:07 jperkin Exp $ */
+/* $NetBSD: normalise-ld.c,v 1.3 2017/06/11 19:34:43 joerg Exp $ */
/*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,23 @@
#include "common.h"
void
+operation_mode_ld(struct arglist *args)
+{
+ struct argument *arg;
+
+ current_operation_mode = mode_link_executable;
+ TAILQ_FOREACH(arg, args, link) {
+ if (arg->val[0] != '-')
+ continue;
+ if (strcmp(arg->val, "-shared") == 0 ||
+ strcmp(arg->val, "-Bshareable") == 0) {
+ current_operation_mode = mode_link_shared;
+ continue;
+ }
+ }
+}
+
+void
normalise_ld(struct arglist *args)
{
struct argument *arg, *arg2, *arg3;
diff -r ad7b351f14d2 -r 4f211fdd019f pkgtools/cwrappers/files/doc/configuration.txt
--- a/pkgtools/cwrappers/files/doc/configuration.txt Sun Jun 11 18:54:25 2017 +0000
+++ b/pkgtools/cwrappers/files/doc/configuration.txt Sun Jun 11 19:34:43 2017 +0000
@@ -1,4 +1,4 @@
-$NetBSD: configuration.txt,v 1.2 2014/11/27 20:36:43 joerg Exp $
+$NetBSD: configuration.txt,v 1.3 2017/06/11 19:34:44 joerg Exp $
The configuration of the wrapper framework depends on two variables.
The environment variable CWRAPPERS_CONFIG_DIR points to a directory
@@ -22,7 +22,21 @@
the details.
Home |
Main Index |
Thread Index |
Old Index