Commit 67d918f8 authored by David Antler's avatar David Antler Committed by Dave Thaler

Undo revert "Generate iotivity_config.h at build time"

This reverts commit 8754a91b.

Change-Id: I180eea046754d3c67fc12e426b675c569df57331
Signed-off-by: default avatarDavid Antler <david.a.antler@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11453Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarDave Thaler <dthaler@microsoft.com>
parent d062e600
......@@ -37,6 +37,9 @@ resource/csdk/stack/samples/linux/SimpleClientServer/release/
resource/csdk/connectivity/build/out/
# Ignore autogenerated files
resource/c_common/iotivity_config.h
resource/oc_logger/bin/
resource/oc_logger/lib/
resource/oc_logger/samples/linux/release/
......
......@@ -52,6 +52,7 @@ LOCAL_SRC_FILES := JniCaInterface.c
LOCAL_STATIC_LIBRARIES := libandroid-ca
LOCAL_LDLIBS := -llog
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/api
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/c_common
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
......
......@@ -433,52 +433,6 @@ conf = Configure(env,
# POSIX_SUPPORTED, 1 if it is supported, 0 otherwise
conf.CheckPThreadsSupport()
######################################################################
# Generate macros for presence of headers
######################################################################
cxx_headers = ['arpa/inet.h',
'fcntl.h',
'grp.h',
'in6addr.h',
'linux/limits.h',
'memory.h',
'netdb.h',
'netinet/in.h',
'pthread.h',
'pwd.h',
'stdlib.h',
'string.h',
'strings.h',
'sys/socket.h',
'sys/stat.h',
'sys/time.h',
'sys/timeb.h',
'sys/types.h',
'sys/unistd.h',
'syslog.h',
'time.h',
'unistd.h',
'uuid/uuid.h',
'windows.h',
'winsock2.h',
'ws2tcpip.h']
if target_os == 'arduino':
# Detection of headers on the Arduino platform is currently broken.
cxx_headers = []
if target_os == 'msys_nt':
# WinPThread provides a pthread.h, but we want to use native threads.
cxx_headers.remove('pthread.h')
def get_define_from_header_file(header_file):
header_file_converted = header_file.replace("/","_").replace(".","_").upper()
return "HAVE_" + header_file_converted
for header_file_name in cxx_headers:
if conf.CheckCXXHeader(header_file_name):
conf.env.AppendUnique(CPPDEFINES = [get_define_from_header_file(header_file_name)])
env = conf.Finish()
######################################################################
......
......@@ -22,6 +22,7 @@
#define _BSD_SOURCE
#include "iotivity_config.h"
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
......@@ -40,7 +41,6 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "platform_features.h"
#include <stdio.h>
......
......@@ -21,6 +21,7 @@
#ifndef TIMER_H_
#define TIMER_H_
#include "iotivity_config.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
......
#include "iotivity_config.h"
#include "tinydtls.h"
/* This is needed for apple */
......@@ -28,7 +29,6 @@
#endif
#include <signal.h>
#include <getopt.h>
#include "platform_features.h"
#include "global.h"
#include "debug.h"
......
......@@ -2,6 +2,7 @@
/* This is needed for apple */
#define __APPLE_USE_RFC_3542
#include "iotivity_config.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
......
......@@ -13,6 +13,7 @@ URL: https://www.iotivity.org
Requires:
Libs: -L${libdir} -loc -loc_logger -loc_logger_core -loctbstack -lconnectivity_abstraction
Cflags: -I${includedir}/resource \
-I${includedir}/c_common \
-I${svcincludedir}/resource-encapsulation \
-I${svcincludedir}/resource-container \
-I${svcincludedir}/resource-hosting \
......
......@@ -21,15 +21,120 @@
Import('env')
import os
import datetime
target_os = env.get('TARGET_OS')
target_arch = env.get('TARGET_ARCH')
######################################################################
# Generate iotivity_config.h using presence of headers
######################################################################
config_h_env = env.Clone()
conf = Configure(config_h_env)
config_h_header = '''
/* ****************************************************************************
* iotivity_config.h - IoTivity platform-specific configuration header.
*
* Auto-generated code for the %s %s platform.
*
* Generated at %s
*
*************************************************************************** */
#ifndef IOTIVITY_CONFIG_H__
#define IOTIVITY_CONFIG_H__
#include "platform_features.h"
''' % (str(target_os), str(target_arch), str(datetime.datetime.utcnow()))
config_h_body = ''
config_h_footer = '''
#endif // IOTIVITY_CONFIG_H__
'''
cxx_headers = ['arpa/inet.h',
'fcntl.h',
'grp.h',
'in6addr.h',
'linux/limits.h',
'memory.h',
'netdb.h',
'netinet/in.h',
'pthread.h',
'pwd.h',
'stdlib.h',
'string.h',
'strings.h',
'sys/socket.h',
'sys/stat.h',
'sys/time.h',
'sys/timeb.h',
'sys/types.h',
'sys/unistd.h',
'syslog.h',
'time.h',
'unistd.h',
'uuid/uuid.h',
'windows.h',
'winsock2.h',
'ws2tcpip.h']
if target_os == 'arduino':
# Detection of headers on the Arduino platform is currently broken.
cxx_headers = []
if target_os == 'msys_nt':
# WinPThread provides a pthread.h, but we want to use native threads.
cxx_headers.remove('pthread.h')
def get_define_from_header_file(header_file):
header_file_converted = header_file.replace("/","_").replace(".","_").upper()
return "HAVE_" + header_file_converted
for header_file_name in cxx_headers:
if conf.CheckCXXHeader(header_file_name):
config_h_body += "#define %s 1\n\n" % get_define_from_header_file(header_file_name)
conf.Finish()
# Autoconf feature doesn't work with Jenkins' arduino toolchain, so hardcode it here.
if target_os == 'arduino':
config_h_body += "#define HAVE_ARDUINO_TIME_H\n\n"
# Generate the file
src_dir = env.get('SRC_DIR')
config_h_file_path = os.path.join(src_dir, 'resource', 'c_common', 'iotivity_config.h')
if os.path.exists(config_h_file_path):
os.remove(config_h_file_path)
config_h_file = open(config_h_file_path, "w")
config_h_file.write(config_h_header + config_h_body + config_h_footer)
config_h_file.close()
# Sanity check to ensure that the above block created the file.
if not os.path.exists(config_h_file_path):
print "Error: iotivity_config.h file not created!"
# iotivity_config.h should be copied to the build dir
env.UserInstallTargetHeader(config_h_file_path, 'c_common', 'iotivity_config.h')
# Use the generated file internally
env.AppendUnique(CPPPATH = [os.path.join(src_dir, 'resource', 'c_common')])
######################################################################
######################################################################
# Add platform-specific helper library
######################################################################
if target_os in ['windows', 'msys_nt']:
SConscript('windows/SConscript')
env.AppendUnique(CPPPATH = [
os.path.join(Dir('.').abspath),
os.path.join(Dir('.').abspath, 'oic_malloc', 'include'),
os.path.join(Dir('.').abspath, 'oic_string', 'include'),
os.path.join(Dir('.').abspath, 'oic_time', 'include'),
......@@ -45,7 +150,6 @@ if target_os in ['tizen', 'linux']:
env.ParseConfig("pkg-config --cflags --libs uuid")
common_env = env.Clone()
common_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource')])
######################################################################
# Build flags
......@@ -64,10 +168,9 @@ common_src = [
'oic_time/src/oic_time.c',
'ocrandom/src/ocrandom.c',
]
commonlib = common_env.StaticLibrary('c_common', common_src)
common_env.InstallTarget(commonlib, 'c_common')
common_env.UserInstallTargetLib(commonlib, 'c_common')
common_env.UserInstallTargetHeader('platform_features.h', 'resource', 'platform_features.h')
common_env.UserInstallTargetHeader('platform_features.h', 'c_common', 'platform_features.h')
env.PrependUnique(LIBS = ['c_common'])
......@@ -30,7 +30,8 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include "platform_features.h"
#include "iotivity_config.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
......
......@@ -30,6 +30,7 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include "iotivity_config.h"
#include "oic_time.h"
#include <stddef.h> // For NULL
......
......@@ -21,6 +21,9 @@ helper_src = [
static_libwinhelper = env.StaticLibrary('win_helper', helper_src)
env.InstallTarget(static_libwinhelper, 'win_helper')
env.UserInstallTargetLib(static_libwinhelper, 'win_helper')
env.UserInstallTargetHeader('include/win_sleep.h', 'c_common/windows/include', 'win_sleep.h')
env.UserInstallTargetHeader('include/pthread_create.h', 'c_common/windows/include', 'pthread_create.h')
env.UserInstallTargetHeader('include/vs12_snprintf.h', 'c_common/windows/include', 'vs12_snprintf.h')
env.AppendUnique(LIBS = ['win_helper'])
......@@ -26,6 +26,8 @@
#ifndef CA_COMMON_H_
#define CA_COMMON_H_
#include "iotivity_config.h"
#ifndef WITH_ARDUINO
#ifdef TCP_ADAPTER
#define HAVE_SYS_POLL_H
......
......@@ -36,6 +36,7 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include "iotivity_config.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif
......@@ -58,7 +59,6 @@
#include <errno.h>
#include <assert.h>
#include <oic_malloc.h>
#include "platform_features.h"
#include "camutex.h"
#include "logger.h"
......
......@@ -27,6 +27,7 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "iotivity_config.h"
#include <errno.h>
#if defined HAVE_PTHREAD_H
#include <pthread.h>
......
......@@ -20,7 +20,6 @@
#ifndef CA_ADAPTER_NET_DTLS_H_
#define CA_ADAPTER_NET_DTLS_H_
#include "platform_features.h"
#include "dtls.h"
#include "uarraylist.h"
#include "camutex.h"
......
......@@ -27,6 +27,8 @@
#ifndef CA_ADAPTER_UTILS_H_
#define CA_ADAPTER_UTILS_H_
#include "iotivity_config.h"
#include <stdbool.h>
#ifdef __ANDROID__
#include <jni.h>
......
......@@ -69,6 +69,11 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#if !defined(WITH_ARDUINO) && !defined(_WIN32)
#define HAVE_SYS_TYPES_H 1
#endif
/* Define to 1 if you have the <sys/unistd.h> header file. */
#if !defined(WITH_ARDUINO) && !defined(_WIN32)
#define HAVE_SYS_UNISTD_H 1
......
......@@ -17,7 +17,7 @@
* limitations under the License.
*
******************************************************************/
#include "platform_features.h"
#include "iotivity_config.h"
#include "caadapternetdtls.h"
#include "cacommon.h"
#include "caipinterface.h"
......
......@@ -18,6 +18,7 @@
*
******************************************************************/
#include "iotivity_config.h"
#include "caadapterutils.h"
#include <string.h>
......
......@@ -28,6 +28,7 @@
// Refer http://www.gnu.org/software/libc/manual/html_node/BSD-Random.html
#define _DEFAULT_SOURCE
#include "iotivity_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -18,6 +18,7 @@
*
******************************************************************/
#include "iotivity_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -41,6 +41,7 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include "iotivity_config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -55,7 +56,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_SYS_TIMEB_H
#ifdef HAVE_SYS_TIMEB_H
#include <sys/timeb.h>
#endif
#ifdef HAVE_TIME_H
......
......@@ -25,6 +25,7 @@
#define _GNU_SOURCE // for in6_pktinfo
#endif
#include "iotivity_config.h"
#include <sys/types.h>
#if !defined(_WIN32)
#include <sys/socket.h>
......@@ -65,7 +66,6 @@
#include "camutex.h"
#include "oic_malloc.h"
#include "oic_string.h"
#include "platform_features.h"
#define USE_IP_MREQN
#if defined(_WIN32)
......
......@@ -33,6 +33,7 @@
#define _POSIX_C_SOURCE 200809L
#endif // _POSIX_C_SOURCE
#include "iotivity_config.h"
#include "gtest/gtest.h"
#include <camutex.h>
......@@ -47,7 +48,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "platform_features.h"
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
......
......@@ -18,6 +18,7 @@
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "iotivity_config.h"
#include "gtest/gtest.h"
#ifdef HAVE_PTHREAD_H
......
......@@ -30,6 +30,8 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include "iotivity_config.h"
// Pull in _POSIX_TIMERS feature test macro to check for
// clock_gettime() support.
#ifdef HAVE_UNISTD_H
......@@ -52,7 +54,6 @@
#include "logger.h"
#include "string.h"
#include "logger_types.h"
#include "platform_features.h"
#ifndef __TIZEN__
static oc_log_ctx_t *logCtx = 0;
......
......@@ -41,14 +41,14 @@
#ifndef OC_SECURITY_RESOURCE_TYPES_H
#define OC_SECURITY_RESOURCE_TYPES_H
#include "iotivity_config.h"
#include <stdint.h> // for uint8_t typedef
#include <stdbool.h>
#if defined(__WITH_X509__) || defined(__WITH_TLS__)
#include "byte_array.h"
#endif /* __WITH_X509__ or __WITH_TLS__*/
#include "platform_features.h"
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -18,13 +18,14 @@
*
*****************************************************************/
#include "iotivity_config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "platform_features.h"
#include "utlist.h"
#include "logger.h"
#include "oic_malloc.h"
......
......@@ -20,6 +20,7 @@
///////////////////////////////////////////////////////////////////////
//NOTE : This sample server is generated based on ocserverbasicops.cpp
///////////////////////////////////////////////////////////////////////
#include "iotivity_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
......
......@@ -20,6 +20,7 @@
///////////////////////////////////////////////////////////////////////
//NOTE : This sample server is generated based on ocserverbasicops.cpp
///////////////////////////////////////////////////////////////////////
#include "iotivity_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
......
......@@ -30,6 +30,7 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include "iotivity_config.h"
#ifdef HAVE_TIME_H
#include <time.h>
#endif
......
......@@ -21,7 +21,8 @@
#define _POSIX_C_SOURCE 200112L
#endif
#if HAVE_UNISTD_H
#include "iotivity_config.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STRING_H
......
......@@ -17,6 +17,7 @@
* limitations under the License.
*
* *****************************************************************/
#include "iotivity_config.h"
#include <stdio.h>
#include <string.h>
#include <stdint.h>
......
......@@ -17,6 +17,7 @@
* limitations under the License.
*
* *****************************************************************/
#include "iotivity_config.h"
#include "gtest/gtest.h"
#include "provisioningdatabasemanager.h"
......
......@@ -18,9 +18,10 @@
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "iotivity_config.h"
#ifdef HAVE_STRING_H
#include <string.h>
#elif HAVE_STRINGS_H
#elif defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
#include <stdlib.h>
......
......@@ -20,6 +20,7 @@
#define __STDC_LIMIT_MACROS
#include "iotivity_config.h"
#include <stdlib.h>
#ifdef HAVE_STRING_H
#include <string.h>
......
......@@ -20,6 +20,7 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif
#include "iotivity_config.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......
......@@ -17,10 +17,11 @@
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "iotivity_config.h"
#include <stdlib.h>
#include <string.h>
#if HAVE_STRINGS_H
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
......
......@@ -18,6 +18,7 @@
*
* *****************************************************************/
#include "iotivity_config.h"
#include <stdlib.h>
#include <string.h>
#include "ocstack.h"
......
......@@ -22,6 +22,7 @@
#if !defined(WITH_ARDUINO)
#define _XOPEN_SOURCE //Needed by strptime
#include "iotivity_config.h"
#include <string.h>
#include "iotvticalendar.h"
#include "oic_string.h"
......