build: Change HAVE_OSX_SECURITY to a more general HAVE_OSX_FRAMEWORKS
We are starting to use more macOS frameworks and define/build
environment constant name needs to be more general.
Change-Id: I893d436a34c3370a7f12ac681d1796ef5631cc0e
diff --git a/.waf-tools/osx-security.py b/.waf-tools/osx-frameworks.py
similarity index 67%
rename from .waf-tools/osx-security.py
rename to .waf-tools/osx-frameworks.py
index f7f273e..881d3e1 100644
--- a/.waf-tools/osx-security.py
+++ b/.waf-tools/osx-frameworks.py
@@ -4,7 +4,7 @@
from waflib import Logs, Utils
from waflib.Configure import conf
-OSX_SECURITY_CODE='''
+OSX_SECURITY_CODE = '''
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#include <Security/SecRandom.h>
@@ -14,7 +14,7 @@
'''
@conf
-def check_osx_security(conf, *k, **kw):
+def check_osx_frameworks(conf, *k, **kw):
if Utils.unversioned_sys_platform() == "darwin":
try:
conf.check_cxx(framework_name='CoreFoundation', uselib_store='OSX_COREFOUNDATION',
@@ -22,11 +22,12 @@
conf.check_cxx(framework_name='CoreServices', uselib_store='OSX_CORESERVICES',
mandatory=True)
conf.check_cxx(framework_name='Security', uselib_store='OSX_SECURITY',
- define_name='HAVE_SECURITY', use="OSX_COREFOUNDATION",
- fragment=OSX_SECURITY_CODE, mandatory=True)
+ use='OSX_COREFOUNDATION', fragment=OSX_SECURITY_CODE,
+ mandatory=True)
- conf.define('HAVE_OSX_SECURITY', 1)
- conf.env['HAVE_OSX_SECURITY'] = True
+ conf.define('HAVE_OSX_FRAMEWORKS', 1)
+ conf.env['HAVE_OSX_FRAMEWORKS'] = True
except:
- Logs.warn("Compiling on OSX, but CoreFoundation, CoreServices, or Security framework is not functional.")
- Logs.warn("The frameworks are known to work only with Apple-specific compilers: llvm-gcc-4.2 or clang")
+ Logs.warn("Compiling on OSX, but CoreFoundation, CoreServices, or Security " +
+ "framework is not functional.")
+ Logs.warn("The frameworks are known to work only with the Apple clang compiler")
diff --git a/src/security/tpm/back-end-osx.hpp b/src/security/tpm/back-end-osx.hpp
index 8310984..8759ef4 100644
--- a/src/security/tpm/back-end-osx.hpp
+++ b/src/security/tpm/back-end-osx.hpp
@@ -25,7 +25,7 @@
#include "back-end.hpp"
#include "helper-osx.hpp"
-#ifndef NDN_CXX_HAVE_OSX_SECURITY
+#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be compiled ..."
#endif
diff --git a/src/security/tpm/helper-osx.hpp b/src/security/tpm/helper-osx.hpp
index 2e7d827..96c25c4 100644
--- a/src/security/tpm/helper-osx.hpp
+++ b/src/security/tpm/helper-osx.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,7 +24,7 @@
#include "../../common.hpp"
-#ifndef NDN_CXX_HAVE_OSX_SECURITY
+#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be included ..."
#endif
diff --git a/src/security/tpm/key-handle-osx.hpp b/src/security/tpm/key-handle-osx.hpp
index 4337f0d..669d7bd 100644
--- a/src/security/tpm/key-handle-osx.hpp
+++ b/src/security/tpm/key-handle-osx.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -25,7 +25,7 @@
#include "key-handle.hpp"
#include "helper-osx.hpp"
-#ifndef NDN_CXX_HAVE_OSX_SECURITY
+#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be compiled ..."
#endif
diff --git a/src/security/v1/key-chain.cpp b/src/security/v1/key-chain.cpp
index 57b8649..1916532 100644
--- a/src/security/v1/key-chain.cpp
+++ b/src/security/v1/key-chain.cpp
@@ -29,9 +29,9 @@
#include "sec-public-info-sqlite3.hpp"
-#ifdef NDN_CXX_HAVE_OSX_SECURITY
+#ifdef NDN_CXX_HAVE_OSX_FRAMEWORKS
#include "sec-tpm-osx.hpp"
-#endif // NDN_CXX_HAVE_OSX_SECURITY
+#endif // NDN_CXX_HAVE_OSX_FRAMEWORKS
#include "sec-tpm-file.hpp"
@@ -50,11 +50,11 @@
const std::string DEFAULT_PIB_SCHEME = "pib-sqlite3";
-#if defined(NDN_CXX_HAVE_OSX_SECURITY) and defined(NDN_CXX_WITH_OSX_KEYCHAIN)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) and defined(NDN_CXX_WITH_OSX_KEYCHAIN)
const std::string DEFAULT_TPM_SCHEME = "tpm-osxkeychain";
#else
const std::string DEFAULT_TPM_SCHEME = "tpm-file";
-#endif // defined(NDN_CXX_HAVE_OSX_SECURITY) and defined(NDN_CXX_WITH_OSX_KEYCHAIN)
+#endif // defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) and defined(NDN_CXX_WITH_OSX_KEYCHAIN)
// When static library is used, not everything is compiled into the resulting binary.
// Therefore, the following standard PIB and TPMs need to be registered here.
@@ -63,9 +63,9 @@
// Also, cannot use Type::SCHEME, as its value may be uninitialized
NDN_CXX_V1_KEYCHAIN_REGISTER_PIB(SecPublicInfoSqlite3, "pib-sqlite3", "sqlite3");
-#ifdef NDN_CXX_HAVE_OSX_SECURITY
+#ifdef NDN_CXX_HAVE_OSX_FRAMEWORKS
NDN_CXX_V1_KEYCHAIN_REGISTER_TPM(SecTpmOsx, "tpm-osxkeychain", "osx-keychain");
-#endif // NDN_CXX_HAVE_OSX_SECURITY
+#endif // NDN_CXX_HAVE_OSX_FRAMEWORKS
NDN_CXX_V1_KEYCHAIN_REGISTER_TPM(SecTpmFile, "tpm-file", "file");
@@ -650,7 +650,7 @@
}
const KeyParams&
-KeyChain::getDefaultKeyParamsForIdentity(const Name &identityName) const
+KeyChain::getDefaultKeyParamsForIdentity(const Name& identityName) const
{
KeyType keyType = KeyType::NONE;
try {
diff --git a/src/security/v1/sec-tpm-osx.hpp b/src/security/v1/sec-tpm-osx.hpp
index 7641514..0c1b4d9 100644
--- a/src/security/v1/sec-tpm-osx.hpp
+++ b/src/security/v1/sec-tpm-osx.hpp
@@ -26,7 +26,7 @@
#include "../../common.hpp"
-#ifndef NDN_CXX_HAVE_OSX_SECURITY
+#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This files should not be compiled ..."
#endif
diff --git a/src/security/v2/key-chain.cpp b/src/security/v2/key-chain.cpp
index d107d8a..45d9277 100644
--- a/src/security/v2/key-chain.cpp
+++ b/src/security/v2/key-chain.cpp
@@ -27,9 +27,9 @@
#include "../pib/pib-sqlite3.hpp"
#include "../pib/pib-memory.hpp"
-#ifdef NDN_CXX_HAVE_OSX_SECURITY
+#ifdef NDN_CXX_HAVE_OSX_FRAMEWORKS
#include "../tpm/back-end-osx.hpp"
-#endif // NDN_CXX_HAVE_OSX_SECURITY
+#endif // NDN_CXX_HAVE_OSX_FRAMEWORKS
#include "../tpm/back-end-file.hpp"
#include "../tpm/back-end-mem.hpp"
@@ -62,9 +62,9 @@
// TPM //
/////////
namespace tpm {
-#if defined(NDN_CXX_HAVE_OSX_SECURITY) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
NDN_CXX_V2_KEYCHAIN_REGISTER_TPM_BACKEND(BackEndOsx);
-#endif // defined(NDN_CXX_HAVE_OSX_SECURITY) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
+#endif // defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
NDN_CXX_V2_KEYCHAIN_REGISTER_TPM_BACKEND(BackEndFile);
NDN_CXX_V2_KEYCHAIN_REGISTER_TPM_BACKEND(BackEndMem);
@@ -100,11 +100,11 @@
const std::string&
KeyChain::getDefaultTpmScheme()
{
-#if defined(NDN_CXX_HAVE_OSX_SECURITY) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
return tpm::BackEndOsx::getScheme();;
#else
return tpm::BackEndFile::getScheme();
-#endif // defined(NDN_CXX_HAVE_OSX_SECURITY) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
+#endif // defined(NDN_CXX_HAVE_OSX_FRAMEWORKS) && defined(NDN_CXX_WITH_OSX_KEYCHAIN)
}
const std::string&
diff --git a/src/util/detail/network-monitor-impl-osx.cpp b/src/util/detail/network-monitor-impl-osx.cpp
index 9f28f27..327a103 100644
--- a/src/util/detail/network-monitor-impl-osx.cpp
+++ b/src/util/detail/network-monitor-impl-osx.cpp
@@ -52,8 +52,6 @@
#include "ndn-cxx-config.hpp"
-#ifdef NDN_CXX_HAVE_COREFOUNDATION_COREFOUNDATION_H
-
#include "network-monitor-impl-osx.hpp"
#include "../network-interface.hpp"
@@ -134,5 +132,3 @@
} // namespace util
} // namespace ndn
-
-#endif // NDN_CXX_HAVE_COREFOUNDATION_COREFOUNDATION_H
diff --git a/src/util/detail/network-monitor-impl-osx.hpp b/src/util/detail/network-monitor-impl-osx.hpp
index 747aefd..bd0a3c6 100644
--- a/src/util/detail/network-monitor-impl-osx.hpp
+++ b/src/util/detail/network-monitor-impl-osx.hpp
@@ -25,7 +25,7 @@
#include "ndn-cxx-config.hpp"
#include "../network-monitor.hpp"
-#ifndef NDN_CXX_HAVE_COREFOUNDATION_COREFOUNDATION_H
+#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be compiled ..."
#endif
diff --git a/src/util/network-monitor.cpp b/src/util/network-monitor.cpp
index 62d63a1..0cbc8c4 100644
--- a/src/util/network-monitor.cpp
+++ b/src/util/network-monitor.cpp
@@ -25,7 +25,7 @@
#include "network-monitor.hpp"
#include "ndn-cxx-config.hpp"
-#if defined(NDN_CXX_HAVE_COREFOUNDATION_COREFOUNDATION_H)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
#include "detail/network-monitor-impl-osx.hpp"
#elif defined(NDN_CXX_HAVE_RTNETLINK)
#include "detail/network-monitor-impl-rtnl.hpp"
diff --git a/tests/unit-tests/security/tpm/back-end.t.cpp b/tests/unit-tests/security/tpm/back-end.t.cpp
index 8dc93a4..efd4bd1 100644
--- a/tests/unit-tests/security/tpm/back-end.t.cpp
+++ b/tests/unit-tests/security/tpm/back-end.t.cpp
@@ -31,9 +31,9 @@
#include "back-end-wrapper-file.hpp"
#include "back-end-wrapper-mem.hpp"
-#ifdef NDN_CXX_HAVE_OSX_SECURITY
+#ifdef NDN_CXX_HAVE_OSX_FRAMEWORKS
#include "back-end-wrapper-osx.hpp"
-#endif // NDN_CXX_HAVE_OSX_SECURITY
+#endif // NDN_CXX_HAVE_OSX_FRAMEWORKS
#include "boost-test.hpp"
#include <boost/mpl/list.hpp>
@@ -51,9 +51,9 @@
using tpm::Tpm;
typedef boost::mpl::list<
-#ifdef NDN_CXX_HAVE_OSX_SECURITY
+#ifdef NDN_CXX_HAVE_OSX_FRAMEWORKS
BackEndWrapperOsx,
-#endif // NDN_CXX_HAVE_OSX_SECURITY
+#endif // NDN_CXX_HAVE_OSX_FRAMEWORKS
BackEndWrapperMem,
BackEndWrapperFile
> TestBackEnds;
diff --git a/tests/unit-tests/security/v1/key-chain.t.cpp b/tests/unit-tests/security/v1/key-chain.t.cpp
index ef10ca4..0ae3cc3 100644
--- a/tests/unit-tests/security/v1/key-chain.t.cpp
+++ b/tests/unit-tests/security/v1/key-chain.t.cpp
@@ -81,7 +81,7 @@
{
createClientConf({"pib=pib-sqlite3:%PATH%"});
-#if defined(NDN_CXX_HAVE_OSX_SECURITY)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
std::string oldHOME;
if (std::getenv("OLD_HOME"))
oldHOME = std::getenv("OLD_HOME");
@@ -100,7 +100,7 @@
KeyChain keyChain;
BOOST_CHECK_EQUAL(keyChain.getPib().getPibLocator(), "pib-sqlite3:" + m_pibDir);
-#if defined(NDN_CXX_HAVE_OSX_SECURITY)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
BOOST_CHECK_EQUAL(keyChain.getPib().getTpmLocator(), "tpm-osxkeychain:");
BOOST_CHECK_EQUAL(keyChain.getTpm().getTpmLocator(), "tpm-osxkeychain:");
#else
@@ -108,7 +108,7 @@
BOOST_CHECK_EQUAL(keyChain.getTpm().getTpmLocator(), "tpm-file:");
#endif
-#if defined(NDN_CXX_HAVE_OSX_SECURITY)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
if (!HOME.empty())
setenv("HOME", HOME.c_str(), true);
else
diff --git a/tests/unit-tests/security/v2/key-chain.t.cpp b/tests/unit-tests/security/v2/key-chain.t.cpp
index d1a954c..a874464 100644
--- a/tests/unit-tests/security/v2/key-chain.t.cpp
+++ b/tests/unit-tests/security/v2/key-chain.t.cpp
@@ -81,7 +81,7 @@
{
createClientConf({"pib=pib-memory:"});
-#if defined(NDN_CXX_HAVE_OSX_SECURITY)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
std::string oldHOME;
if (std::getenv("OLD_HOME"))
oldHOME = std::getenv("OLD_HOME");
@@ -100,7 +100,7 @@
KeyChain keyChain;
BOOST_CHECK_EQUAL(keyChain.getPib().getPibLocator(), "pib-memory:");
-#if defined(NDN_CXX_HAVE_OSX_SECURITY)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
BOOST_CHECK_EQUAL(keyChain.getPib().getTpmLocator(), "tpm-osxkeychain:");
BOOST_CHECK_EQUAL(keyChain.getTpm().getTpmLocator(), "tpm-osxkeychain:");
#else
@@ -108,7 +108,7 @@
BOOST_CHECK_EQUAL(keyChain.getTpm().getTpmLocator(), "tpm-file:");
#endif
-#if defined(NDN_CXX_HAVE_OSX_SECURITY)
+#if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
if (!HOME.empty())
setenv("HOME", HOME.c_str(), 1);
else
diff --git a/tests/wscript b/tests/wscript
index 89a06cc..af4b422 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -33,7 +33,7 @@
defines='UNIT_TEST_CONFIG_PATH=\"%s/tmp-files/\"' %(bld.bldnode),
install_path=None)
- if bld.env['HAVE_OSX_SECURITY']:
+ if bld.env['HAVE_OSX_FRAMEWORKS']:
unit_tests.source += bld.path.ant_glob('unit-tests/**/*-osx.t.cpp')
# In case we want to make it optional later
diff --git a/wscript b/wscript
index 376a49a..50f148c 100644
--- a/wscript
+++ b/wscript
@@ -12,7 +12,7 @@
def options(opt):
opt.load(['compiler_cxx', 'gnu_dirs', 'c_osx'])
opt.load(['default-compiler-flags', 'compiler-features', 'type_traits',
- 'coverage', 'pch', 'sanitizers', 'osx-security',
+ 'coverage', 'pch', 'sanitizers', 'osx-frameworks',
'boost', 'cryptopp', 'openssl', 'sqlite3',
'doxygen', 'sphinx_build'],
tooldir=['.waf-tools'])
@@ -68,7 +68,7 @@
conf.load(['compiler_cxx', 'gnu_dirs', 'c_osx',
'default-compiler-flags', 'compiler-features', 'type_traits',
- 'pch', 'osx-security', 'boost', 'cryptopp', 'openssl', 'sqlite3',
+ 'pch', 'osx-frameworks', 'boost', 'cryptopp', 'openssl', 'sqlite3',
'doxygen', 'sphinx_build'])
conf.env['WITH_TESTS'] = conf.options.with_tests
@@ -91,7 +91,7 @@
int main() { return IFA_FLAGS; }
''')
- conf.check_osx_security(mandatory=False)
+ conf.check_osx_frameworks()
conf.check_sqlite3(mandatory=True)
conf.check_cryptopp(mandatory=True, use='PTHREAD')
@@ -118,7 +118,7 @@
if not conf.options.with_sqlite_locking:
conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
- if conf.env['HAVE_OSX_SECURITY']:
+ if conf.env['HAVE_OSX_FRAMEWORKS']:
conf.env['WITH_OSX_KEYCHAIN'] = conf.options.with_osx_keychain
if conf.options.with_osx_keychain:
conf.define('WITH_OSX_KEYCHAIN', 1)
@@ -164,7 +164,7 @@
target="ndn-cxx",
name="ndn-cxx",
source=bld.path.ant_glob('src/**/*.cpp',
- excl=['src/security/**/*-osx.cpp',
+ excl=['src/**/*-osx.cpp',
'src/**/*-rtnl.cpp',
'src/**/*-sqlite3.cpp']),
headers='src/common-pch.hpp',
@@ -173,14 +173,13 @@
export_includes="src",
install_path='${LIBDIR}')
+ if bld.env['HAVE_OSX_FRAMEWORKS']:
+ libndn_cxx['source'] += bld.path.ant_glob('src/**/*-osx.cpp')
+ libndn_cxx['use'] += " OSX_COREFOUNDATION OSX_CORESERVICES OSX_SECURITY"
+
if bld.env['HAVE_RTNETLINK']:
libndn_cxx['source'] += bld.path.ant_glob('src/**/*-rtnl.cpp')
- if bld.env['HAVE_OSX_SECURITY']:
- libndn_cxx['source'] += bld.path.ant_glob('src/security/**/*-osx.cpp')
- libndn_cxx['mac_app'] = True
- libndn_cxx['use'] += " OSX_COREFOUNDATION OSX_SECURITY"
-
# In case we want to make it optional later
libndn_cxx['source'] += bld.path.ant_glob('src/**/*-sqlite3.cpp')
@@ -213,8 +212,8 @@
pkgconfig_cxxflags += Utils.to_list(bld.env['CXXFLAGS_%s' % lib])
EXTRA_FRAMEWORKS = ""
- if bld.env['HAVE_OSX_SECURITY']:
- EXTRA_FRAMEWORKS = "-framework CoreFoundation -framework Security"
+ if bld.env['HAVE_OSX_FRAMEWORKS']:
+ EXTRA_FRAMEWORKS = "-framework CoreFoundation -framework CoreServices -framework Security"
def uniq(alist):
seen = set()
@@ -245,11 +244,18 @@
bld.recurse("examples")
headers = bld.path.ant_glob('src/**/*.hpp',
- excl=['src/security/**/*-osx.hpp',
- 'src/detail/**/*',
- 'src/util/detail/**/*'])
- if bld.env['HAVE_OSX_SECURITY']:
- headers += bld.path.ant_glob('src/security/**/*-osx.hpp')
+ excl=['src/**/*-osx.hpp',
+ 'src/**/*-rtnl.hpp',
+ 'src/**/*-sqlite3.hpp',
+ 'src/**/detail/**/*'])
+ if bld.env['HAVE_OSX_FRAMEWORKS']:
+ headers += bld.path.ant_glob('src/**/*-osx.hpp', excl='src/**/detail/**/*')
+
+ if bld.env['HAVE_RTNETLINK']:
+ headers += bld.path.ant_glob('src/**/*-rtnl.hpp', excl='src/**/detail/**/*')
+
+ # In case we want to make it optional later
+ headers += bld.path.ant_glob('src/**/*-sqlite3.hpp', excl='src/**/detail/**/*')
bld.install_files("%s/ndn-cxx" % bld.env['INCLUDEDIR'], headers,
relative_trick=True, cwd=bld.path.find_node('src'))