blob: 8d1d61f7d4162aa515ab708c0e7fda13b60ab170 [file] [log] [blame]
Yingdi Yuce94f352015-04-11 19:17:01 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3"""
4Copyright (c) 2014-2015, Regents of the University of California
5
6This file is part of ndn-group-encrypt (Group-based Encryption Protocol for NDN).
7See AUTHORS.md for complete list of ndn-group-encrypt authors and contributors.
8
9ndn-group-encrypt is free software: you can redistribute it and/or modify it under the terms
10of the GNU General Public License as published by the Free Software Foundation,
11either version 3 of the License, or (at your option) any later version.
12
13ndn-group-encrypt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15PURPOSE. See the GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License along with
18ndn-group-encrypt, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19"""
20
21VERSION = "0.0.1"
22APPNAME = "libndn-group-encrypt"
Alexander Afanasyev9d7f8fe2016-08-05 11:28:06 -070023PACKAGE_BUGREPORT = "http://redmine.named-data.net/projects/gep"
24PACKAGE_URL = "http://named-data.net/doc/ndn-group-encrypt/"
25GIT_TAG_PREFIX = "ndn-group-encrypt"
Yingdi Yuce94f352015-04-11 19:17:01 -070026
27from waflib import Logs, Utils, Context
28import os
29
30def options(opt):
31 opt.load(['compiler_c', 'compiler_cxx', 'gnu_dirs'])
Alexander Afanasyev867228e2016-10-17 16:54:55 -070032 opt.load(['boost', 'default-compiler-flags', 'sanitizers', 'doxygen'],
Yingdi Yuce94f352015-04-11 19:17:01 -070033 tooldir=['.waf-tools'])
34
35 syncopt = opt.add_option_group ("NDN-GROUP-ENCRYPT Options")
36
37 syncopt.add_option('--debug', action='store_true', default=False, dest='debug',
38 help='''debugging mode''')
39 syncopt.add_option('--with-tests', action='store_true', default=False, dest='_tests',
40 help='''build unit tests''')
41
42def configure(conf):
Alexander Afanasyev867228e2016-10-17 16:54:55 -070043 conf.load(['compiler_c', 'compiler_cxx', 'gnu_dirs', 'boost', 'default-compiler-flags', 'sanitizers', 'doxygen'])
Yingdi Yuce94f352015-04-11 19:17:01 -070044
Yingdi Yuda495a92015-05-05 13:57:59 -070045 if 'PKG_CONFIG_PATH' not in os.environ:
46 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Yingdi Yuce94f352015-04-11 19:17:01 -070047 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
48 uselib_store='NDN_CXX', mandatory=True)
49
50 boost_libs = 'system iostreams'
51 if conf.options._tests:
52 conf.env['NDN_GEP_HAVE_TESTS'] = 1
53 conf.define('NDN_GEP_HAVE_TESTS', 1);
54 boost_libs += ' unit_test_framework'
55
56 conf.check_boost(lib=boost_libs)
57
58 conf.write_config_header('config.hpp')
59
60def build(bld):
61 libndn_group_encrypt = bld(
Yingdi Yuda495a92015-05-05 13:57:59 -070062 target="ndn-group-encrypt",
Yingdi Yuce94f352015-04-11 19:17:01 -070063 # vnum = "0.0.1",
64 features=['cxx', 'cxxshlib'],
65 source = bld.path.ant_glob(['src/**/*.cpp']),
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070066 use = 'BOOST NDN_CXX CRYPTOPP',
Yingdi Yuce94f352015-04-11 19:17:01 -070067 includes = ['src', '.'],
68 export_includes=['src', '.'],
69 )
70
71 # Unit tests
72 if bld.env["NDN_GEP_HAVE_TESTS"]:
73 bld.recurse('tests')
74
75 bld.install_files(
76 dest = "%s/ndn-group-encrypt" % bld.env['INCLUDEDIR'],
Yingdi Yu0a6663a2016-03-20 18:55:46 -070077 files = bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h', 'common.hpp']),
78 cwd = bld.path.find_dir("src"),
Yingdi Yub3c47762016-03-20 19:37:27 -070079 relative_trick = True,
Yingdi Yu0a6663a2016-03-20 18:55:46 -070080 )
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070081
Yingdi Yu0a6663a2016-03-20 18:55:46 -070082
83 bld.install_files(
84 dest = "%s/ndn-group-encrypt" % bld.env['INCLUDEDIR'],
Yingdi Yuce94f352015-04-11 19:17:01 -070085 files = bld.path.get_bld().ant_glob(['src/**/*.hpp', 'common.hpp', 'config.hpp']),
86 cwd = bld.path.get_bld().find_dir("src"),
87 relative_trick = False,
88 )
89
Yingdi Yuda495a92015-05-05 13:57:59 -070090 bld(features = "subst",
Yingdi Yuce94f352015-04-11 19:17:01 -070091 source='ndn-group-encrypt.pc.in',
92 target='ndn-group-encrypt.pc',
93 install_path = '${LIBDIR}/pkgconfig',
94 PREFIX = bld.env['PREFIX'],
95 INCLUDEDIR = "%s/ndn-group-encrypt" % bld.env['INCLUDEDIR'],
96 VERSION = VERSION,
97 )
Alexander Afanasyev9d7f8fe2016-08-05 11:28:06 -070098
99def docs(bld):
100 from waflib import Options
101 Options.commands = ['doxygen'] + Options.commands
102
103def doxygen(bld):
104 version(bld)
105
106 if not bld.env.DOXYGEN:
107 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
108 else:
109 bld(features="subst",
110 name="doxygen-conf",
111 source=["docs/doxygen.conf.in",
112 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
113 target=["docs/doxygen.conf",
114 "docs/named_data_theme/named_data_footer-with-analytics.html"],
115 VERSION=VERSION,
116 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
117 if os.getenv('GOOGLE_ANALYTICS', None) \
118 else "../docs/named_data_theme/named_data_footer.html",
119 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
120 )
121
122 bld(features="doxygen",
123 doxyfile='docs/doxygen.conf',
124 use="doxygen-conf")
125
126def version(ctx):
127 if getattr(Context.g_module, 'VERSION_BASE', None):
128 return
129
130 Context.g_module.VERSION_BASE = Context.g_module.VERSION
131 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
132
133 didGetVersion = False
134 try:
135 cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX]
136 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
137 stderr=None, stdin=None)
138 out = str(p.communicate()[0].strip())
139 didGetVersion = (p.returncode == 0 and out != "")
140 if didGetVersion:
141 if out.startswith(GIT_TAG_PREFIX):
142 Context.g_module.VERSION = out[len(GIT_TAG_PREFIX):]
143 else:
144 Context.g_module.VERSION = "%s-commit-%s" % (Context.g_module.VERSION_BASE, out)
145 except OSError:
146 pass
147
148 versionFile = ctx.path.find_node('VERSION')
149
150 if not didGetVersion and versionFile is not None:
151 try:
152 Context.g_module.VERSION = versionFile.read()
153 return
154 except (OSError, IOError):
155 pass
156
157 # version was obtained from git, update VERSION file if necessary
158 if versionFile is not None:
159 try:
160 version = versionFile.read()
161 if version == Context.g_module.VERSION:
162 return # no need to update
163 except (OSError, IOError):
164 Logs.warn("VERSION file exists, but not readable")
165 else:
166 versionFile = ctx.path.make_node('VERSION')
167
168 if versionFile is None:
169 return
170
171 try:
172 versionFile.write(Context.g_module.VERSION)
173 except (OSError, IOError):
174 Logs.warn("VERSION file is not writeable")
175
176def dist(ctx):
177 version(ctx)
178
179def distcheck(ctx):
180 version(ctx)