Skip to content

Commit be35d4b

Browse files
committed
Problem: duplicate code generated for projects depending on czmq
Solution: define new project.has_czmq = 1 if czmq is in project.use. Do not generate the code for czmq and projects depending on it.
1 parent 31f3c2f commit be35d4b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

zproject_class.gsl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ $(project.GENERATED_WARNING_HEADER:)
8383
$(PROJECT.PREFIX)_MAKE_VERSION($(PROJECT.PREFIX)_VERSION_MAJOR, $(PROJECT.PREFIX)_VERSION_MINOR, $(PROJECT.PREFIX)_VERSION_PATCH)
8484

8585
// czmq_prelude.h bits
86-
.if project.prefix <> "czmq"
86+
.if project.prefix <> "czmq" & project.has_czmq <> 1
8787
#if !defined (__WINDOWS__)
8888
# if (defined WIN32 || defined _WIN32 || defined WINDOWS || defined _WINDOWS)
8989
# undef __WINDOWS__
@@ -519,8 +519,7 @@ typedef struct _$(class.c_name:)_t $(class.c_name:)_t;
519519
.endfor
520520

521521
// Internal API
522-
523-
.if project.prefix <> "czmq"
522+
.if project.prefix <> "czmq" & project.has_czmq <> 1
524523
// common definitions and idioms from czmq_prelude.h, which are used in generated code
525524
#if ! defined(__CZMQ_PRELUDE_H_INCLUDED__)
526525
#include <stdlib.h>

zproject_projects.gsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ function resolve_scope (item)
145145
endif
146146
endfunction
147147

148+
project.has_czmq = 0
148149
for use
149150
resolve_project_dependency (use)
151+
if use.prefix = "czmq"
152+
project.has_czmq = 1
153+
endif
150154
endfor
151155

152156
for main

0 commit comments

Comments
 (0)