-
Notifications
You must be signed in to change notification settings - Fork 104
/
zproject_gyp.gsl
238 lines (212 loc) · 6.61 KB
/
zproject_gyp.gsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Generate gyp build file for project
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/zeromq/gsl for details.
#
# Copyright (c) the Contributors as noted in the AUTHORS file.
# This file is part of zproject.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
register_target ("gyp", "GYP build system (project.gyp)")
.macro target_gyp
.my.targetdir = "builds/gyp"
.directory.create (my.targetdir)
.output "$(my.targetdir)/README.md"
# GYP Builds
## About GYP (Generate Your Projects)
GYP is a tool from Google, written in Python, that does multi-platform builds for C/C++ projects. It is rather cleaner and simpler than the old autotools, and CMake approaches. Like zproject, you define a model, not a script. GYP files are written in JSON.
To install GYP on Debian/Ubuntu:
sudo apt-get install gyp
To install GYP on Windows, you need git and Python 2.7. Then:
git clone https://chromium.googlesource.com/external/gyp
cd gyp
python setup.py install
## How to build this project
To build this project, first check out its dependencies, at the same level as this directory:
.for project.use where !optional & defined (use.repository)
git clone $(use.repository)
.endfor
On Linux, build just this project in $(my.targetdir) and it will automatically build its dependencies:
gyp --depth=.
make -j5
On Windows, you need Visual Studio 2015. Then:
gyp --depth=.
"\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
msbuild /m /v:m project.sln
.output "$(my.targetdir)/.gitignore"
project.Makefile
*.mk
out/
Makefile
tmp-deps/
.#TODO: Remove this for if tmp-deps/ works for this
.for project.use where !optional
$(use.project)/
.endfor
.output "$(my.targetdir)/platform.h"
/* =========================================================================
$(project.name) - $(project.description?'':)
. for project.license
$(string.trim (license.):block )
. endfor
=========================================================================
*/
#ifndef __PLATFORM_H_INCLUDED__
#define __PLATFORM_H_INCLUDED__
// This file provides the configuration for Linux, Windows, and OS/X
// as determined by $(PROJECT.PREFIX)_HAVE_XXX macros passed from project.gyp
// Check that we're being called from our gyp makefile
#ifndef $(PROJECT.PREFIX)_GYP_BUILD
# error "foreign platform.h detected, please re-configure"
#endif
#define $(PROJECT.PREFIX)_BUILD_DRAFT_API
#if defined $(PROJECT.PREFIX)_HAVE_WINDOWS
#elif defined $(PROJECT.PREFIX)_HAVE_OSX
# define $(PROJECT.PREFIX)_HAVE_IFADDRS
# define HAVE_GETIFADDRS
# define HAVE_NET_IF_H
# define HAVE_NET_IF_MEDIA_H
#elif defined $(PROJECT.PREFIX)_HAVE_LINUX
# define $(PROJECT.PREFIX)_HAVE_IFADDRS
# define HAVE_GETIFADDRS
# define HAVE_LINUX_WIRELESS_H
# define HAVE_NET_IF_H
# define HAVE_NET_IF_MEDIA_H
#else
# error "No platform defined, abandoning"
#endif
#endif
.output "$(my.targetdir)/project.gyp"
$(project.GENERATED_WARNING_HEADER:)
# GYP file for $(project.name:)
# gyp --depth=.
{
'target_defaults': {
'include_dirs': [
.for project.use where !optional
'../../../$(use.project)/include',
.endfor
'../../include',
'.'
],
'defines': [
'$(PROJECT.PREFIX)_GYP_BUILD'
],
'conditions': [
[ 'OS=="win"', {
'defines': [
'$(PROJECT.PREFIX)_HAVE_WINDOWS',
.for project.use where !optional
'$(USE.PREFIX)_STATIC',
.endfor
'$(PROJECT.PREFIX)_STATIC'
],
'libraries': [
'ws2_32',
'advapi32',
'iphlpapi',
'Rpcrt4'
]
}],
[ 'OS=="mac"', {
'defines': [
'$(PROJECT.PREFIX)_HAVE_OSX'
]
}],
[ 'OS=="linux"', {
'defines': [
'$(PROJECT.PREFIX)_HAVE_LINUX'
],
'xcode_settings': {
'OTHER_CFLAGS': [
'-fPIC'
],
},
'libraries': [
'-lpthread'
]
}]
]
},
'targets': [
.if count (class)
{
'target_name': '$(project.libname)',
'type': 'static_library',
'sources': [
'platform.h',
'../../include/$(project.header)',
. if file.exists ("include/$(project.prelude)")
'../../include/$(project.prelude)',
. endif
. for class by name
'../../src/$(name:$(project.filename_prettyprint)).$(project.source_ext)',
. if scope = "public"
'../../include/$(name:$(project.filename_prettyprint)).$(project.header_ext)',
. else
'../../src/$(name:$(project.filename_prettyprint)).$(project.header_ext)',
. endif
. endfor
. for header by name
'../../include/$(header.name).$(project.header_ext)',
. endfor
. for extra by name
'../../src/$(extra.name)',
. endfor
'../../include/$(project.prefix)_library.$(project.header_ext)',
'../../src/$(project.prefix)_selftest.$(project.source_ext)',
. if project.use_cxx
'../../src/$(project.prefix)_private_selftest.$(project.source_ext)',
. else
'../../src/$(project.prefix)_private_selftest.$(project.source_ext)',
. endif
'../../src/$(project.prefix)_classes.$(project.header_ext)'
],
'dependencies': [
. for project.use where !optional
. prjdir = "../$(use.project)"
. gypfile = "$(prjdir)/$(my.targetdir)/project.gyp"
. if ! file.exists (gypfile)
. prjdir_tmp = "../tmp-deps/$(use.project)"
. gypfile_tmp = "$(prjdir_tmp)/$(my.targetdir)/project.gyp"
. endif
. if (file.exists (gypfile) | file.exists (gypfile_tmp))
.# Note: Use the location expected in usual, non-CI workflows
'../../$(gypfile):$(use.libname)',
. else
.# Note: Simply missing file with a properly checked out code is ok, it just is not there
. if (!file.exists (prjdir) & !file.exists (prjdir_tmp))
. abort "E: please checkout $(use.project) into $(prjdir_tmp) or $(prjdir)"
. endif
. endif
. endfor
],
'copies': [
{
'destination': '../../src',
'files': [
'platform.h'
]
}
]
},
.endif
.for main
{
'target_name': '$(name)',
'type': 'executable',
'sources': [
'../../src/$(name).$(project.source_ext)'
],
. if count (project.class)
'dependencies': [
'$(project.libname)'
]
. endif
}$(last ()?? ""? ",")
.endfor
]
}
.endmacro