From c98ff5a8382ceab6cfbb567734d729d8553b45fe Mon Sep 17 00:00:00 2001 From: Pawel Winogrodzki Date: Thu, 2 Mar 2017 18:15:14 -0800 Subject: [PATCH] IOT-1583: Disabling rebuild of config headers with every scons run. I'm changing the scons behavior to only rebuild the config headers if they don't exist, so scons wouldn't rebuild everything, what depends on these headers. I'm also making small fixes to make sure the generated headers are removed when scons is run with "-c". Change-Id: I4b8cf9cafac26e8d619280dccb1c14dab7c437cc Signed-off-by: Pawel Winogrodzki Reviewed-on: https://gerrit.iotivity.org/gerrit/17415 Tested-by: jenkins-iotivity Reviewed-by: Phil Coval Reviewed-by: Dan Mihai --- extlibs/libcoap/SConscript | 134 ++++++++++++++--------------- resource/c_common/SConscript | 172 +++++++++++++++++++------------------- resource/csdk/security/SConscript | 6 -- run.bat | 12 +-- service/third_party_libs.scons | 2 +- 5 files changed, 158 insertions(+), 168 deletions(-) diff --git a/extlibs/libcoap/SConscript b/extlibs/libcoap/SConscript index a3f4c86..8b87d67 100644 --- a/extlibs/libcoap/SConscript +++ b/extlibs/libcoap/SConscript @@ -139,6 +139,7 @@ if env.get('LOGGING') == '1': # Source files and Target(s) ###################################################################### with_upstream_libcoap = libcoap_env.get('WITH_UPSTREAM_LIBCOAP') +config_h_file_path = os.path.join(src_dir, 'extlibs', 'libcoap', 'libcoap', 'include', 'coap', 'coap_config.h') if with_upstream_libcoap == '1': libcoap_env.PrependUnique(CPPPATH = ['libcoap/include/coap']) libcoap_env.AppendUnique(CPPDEFINES = ['WITH_UPSTREAM_LIBCOAP']) @@ -152,27 +153,25 @@ if with_upstream_libcoap == '1': target_arch = env.get('TARGET_ARCH') lib_prefix = '' + str(libcoap_env.get('PREFIX')) + if (not os.path.isfile(config_h_file_path)) and (not env.GetOption('clean')): + conf = Configure(libcoap_env) - conf = Configure(libcoap_env) - - config_h_header = ''' + config_h_header = ''' /* **************************************************************************** * coap_config.h - libcoap platform-specific configuration header. * * Auto-generated code for the %s %s platform. * - * Generated at %s - * *************************************************************************** */ #ifndef _COAP_CONFIG_H_ #define _COAP_CONFIG_H_ -''' % (str(target_os), str(target_arch), str(datetime.datetime.utcnow())) +''' % (str(target_os), str(target_arch)) - config_h_body = '' + config_h_body = '' - config_h_footer = ''' + config_h_footer = ''' /* Define to the full name of this package. */ #define PACKAGE_NAME "%s" @@ -194,68 +193,68 @@ if with_upstream_libcoap == '1': #endif // _COAP_CONFIG_H_ -''' % (str(lib_prefix + 'coap'), str(lib_prefix + 'coap ' + libcoap_version)) - - cxx_headers = ['arpa/inet.h', - 'assert.h', - 'limits.h', - 'netinet/in.h', - 'stdio.h', - 'strings.h', - 'sys/select.h', - 'sys/socket.h', - 'sys/time.h', - 'sys/types.h', - 'sys/uio.h', - 'sys/unistd.h', - 'syslog.h', - 'time.h', - 'unistd.h', - 'winsock2.h', - 'ws2tcpip.h'] - - cxx_functions = ['malloc', - 'snprintf', - 'strnlen', - 'vprintf'] - - if target_os == 'arduino': - # Detection of headers on the Arduino platform is currently broken. - cxx_headers = [] - - def get_define_from_string(string): - string_converted = string.replace("/","_").replace(".","_").upper() - return "HAVE_" + string_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_string(header_file_name) - - for function_name in cxx_functions: - if conf.CheckFunc(function_name): - config_h_body += "#define %s 1\n\n" % get_define_from_string(function_name) - - if conf.CheckCXXHeader('windows.h'): - config_h_body += "#define ssize_t SSIZE_T\n\n" - config_h_body += "#define in_port_t uint16_t\n\n" - - 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 - config_h_file_path = os.path.join(src_dir, 'extlibs', 'libcoap', 'libcoap', 'include', 'coap', 'coap_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() + ''' % (str(lib_prefix + 'coap'), str(lib_prefix + 'coap ' + libcoap_version)) + + cxx_headers = ['arpa/inet.h', + 'assert.h', + 'limits.h', + 'netinet/in.h', + 'stdio.h', + 'strings.h', + 'sys/select.h', + 'sys/socket.h', + 'sys/time.h', + 'sys/types.h', + 'sys/uio.h', + 'sys/unistd.h', + 'syslog.h', + 'time.h', + 'unistd.h', + 'winsock2.h', + 'ws2tcpip.h'] + + cxx_functions = ['malloc', + 'snprintf', + 'strnlen', + 'vprintf'] + + if target_os == 'arduino': + # Detection of headers on the Arduino platform is currently broken. + cxx_headers = [] + + def get_define_from_string(string): + string_converted = string.replace("/","_").replace(".","_").upper() + return "HAVE_" + string_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_string(header_file_name) + + for function_name in cxx_functions: + if conf.CheckFunc(function_name): + config_h_body += "#define %s 1\n\n" % get_define_from_string(function_name) + + if conf.CheckCXXHeader('windows.h'): + config_h_body += "#define ssize_t SSIZE_T\n\n" + config_h_body += "#define in_port_t uint16_t\n\n" + + 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 + 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): + if (not os.path.exists(config_h_file_path)) and (not env.GetOption('clean')): print "Error: coap_config.h file not created!" + Exit(1) pc_vars = { '\@LIBCOAP_PACKAGE_NAME\@' : lib_prefix + 'coap', @@ -275,5 +274,6 @@ else: libcoap = libcoap_env.StaticLibrary('coap', libcoap_src, OBJPREFIX='libcoap_') +Clean(libcoap, config_h_file_path) libcoap_env.InstallTarget([libcoap], 'coap') diff --git a/resource/c_common/SConscript b/resource/c_common/SConscript index f64c3c8..c0c414f 100644 --- a/resource/c_common/SConscript +++ b/resource/c_common/SConscript @@ -25,32 +25,31 @@ import datetime target_os = env.get('TARGET_OS') target_arch = env.get('TARGET_ARCH') +src_dir = env.get('SRC_DIR') ###################################################################### # Generate iotivity_config.h using presence of headers ###################################################################### +config_h_file_path = os.path.join(src_dir, 'resource', 'c_common', 'iotivity_config.h') +if (not os.path.isfile(config_h_file_path)) and (not env.GetOption('clean')): + conf = Configure(env.Clone()) -config_h_env = env.Clone() -conf = Configure(config_h_env) - -config_h_header = ''' + 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__ -''' % (str(target_os), str(target_arch), str(datetime.datetime.utcnow())) +''' % (str(target_os), str(target_arch)) -config_h_body = '' + config_h_body = '' -config_h_footer = ''' + config_h_footer = ''' #include "platform_features.h" @@ -58,70 +57,74 @@ config_h_footer = ''' ''' -cxx_headers = ['arpa/inet.h', - 'fcntl.h', - 'grp.h', - 'in6addr.h', - 'linux/limits.h', - 'memory.h', - 'net/if.h', - 'netdb.h', - 'netinet/in.h', - 'pthread.h', - 'pwd.h', - 'stdlib.h', - 'string.h', - 'strings.h', - 'sys/ioctl.h', - 'sys/poll.h', - 'sys/select.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() + cxx_headers = ['arpa/inet.h', + 'fcntl.h', + 'grp.h', + 'in6addr.h', + 'linux/limits.h', + 'memory.h', + 'net/if.h', + 'netdb.h', + 'netinet/in.h', + 'pthread.h', + 'pwd.h', + 'stdlib.h', + 'string.h', + 'strings.h', + 'sys/ioctl.h', + 'sys/poll.h', + 'sys/select.h', + 'sys/socket.h', + 'sys/stat.h', + 'sys/time.h', + 'sys/types.h', + 'sys/unistd.h', + 'syslog.h', + 'time.h', + 'unistd.h', + 'uuid/uuid.h', + 'windows.h', + 'winsock2.h', + 'ws2tcpip.h'] + + cxx_functions = ['strptime'] + + 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_string(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_string(header_file_name) + + for function_name in cxx_functions: + if conf.CheckFunc(function_name): + config_h_body += "#define %s 1\n\n" % get_define_from_string(function_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 + 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!" +if (not os.path.exists(config_h_file_path)) and (not env.GetOption('clean')): + print "Error: iotivity_config.h file not created!" + Exit(1) # iotivity_config.h should be copied to the build dir env.UserInstallTargetHeader(config_h_file_path, 'c_common', 'iotivity_config.h') @@ -141,12 +144,12 @@ env.AppendUnique(CPPPATH = [ ]) if target_os == 'tizen': - env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) + env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) else: - env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'c_common')]) + env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'c_common')]) if target_os in ['tizen', 'linux']: - env.ParseConfig("pkg-config --cflags --libs uuid") + env.ParseConfig("pkg-config --cflags --libs uuid") common_env = env.Clone() @@ -155,31 +158,31 @@ common_env = env.Clone() ###################################################################### if target_os in ['windows', 'msys_nt']: - common_env.AppendUnique(CCFLAGS=['/W4', '/WX']) + common_env.AppendUnique(CCFLAGS=['/W4', '/WX']) ###################################################################### # Add platform-specific helper library ###################################################################### if target_os in ['windows', 'msys_nt']: - SConscript('windows/SConscript', 'common_env') + SConscript('windows/SConscript', 'common_env') ###################################################################### # Source files and Targets ###################################################################### common_src = [ - 'oic_string/src/oic_string.c', - 'oic_malloc/src/oic_malloc.c', - 'oic_time/src/oic_time.c', - 'ocrandom/src/ocrandom.c' - ] + 'oic_string/src/oic_string.c', + 'oic_malloc/src/oic_malloc.c', + 'oic_time/src/oic_time.c', + 'ocrandom/src/ocrandom.c' + ] if env['POSIX_SUPPORTED']: - common_src.append('octhread/src/posix/octhread.c') + common_src.append('octhread/src/posix/octhread.c') elif target_os in ['windows']: - common_src.append('octhread/src/windows/octhread.c') + common_src.append('octhread/src/windows/octhread.c') else: - common_src.append('octhread/src/noop/octhread.c') + common_src.append('octhread/src/noop/octhread.c') if target_os in ['windows', 'msys_nt']: common_src.append('ocatomic/src/windows/ocatomic.c') @@ -196,4 +199,5 @@ common_env.UserInstallTargetLib(commonlib, 'c_common') common_env.UserInstallTargetHeader('iotivity_debug.h', 'c_common', 'iotivity_debug.h') common_env.UserInstallTargetHeader('platform_features.h', 'c_common', 'platform_features.h') +Clean(commonlib, config_h_file_path) env.PrependUnique(LIBS = ['c_common']) diff --git a/resource/csdk/security/SConscript b/resource/csdk/security/SConscript index 70cc82e..28c016f 100644 --- a/resource/csdk/security/SConscript +++ b/resource/csdk/security/SConscript @@ -133,7 +133,6 @@ if libocsrm_env.get('SECURED') == '1': if target_os in ['windows', 'msys_nt']: libocsrm_src = libocsrm_src + [OCSRM_SRC + 'strptime.c'] - libocsrm_src.extend(env['cbor_files']) # Insert a hack for Arduino, whose compiler may not support all defines expected @@ -141,11 +140,6 @@ libocsrm_src.extend(env['cbor_files']) if target_os in ['arduino']: libocsrm_env.AppendUnique(CPPDEFINES = ['INT64_MAX=0x7FFFFFFFFFFFFFFF']) -libocsrm_conf = Configure(libocsrm_env) -if libocsrm_conf.CheckFunc('strptime'): - libocsrm_conf.env.AppendUnique(CPPDEFINES = ['HAVE_STRPTIME']) -libocsrm_env = libocsrm_conf.Finish() - libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src) libocsrm_env.InstallTarget(libocsrm, 'ocsrm') diff --git a/run.bat b/run.bat index 5a933c3..ec9a9bd 100644 --- a/run.bat +++ b/run.bat @@ -176,16 +176,8 @@ if "!RUN_ARG!"=="server" ( echo.scons VERBOSE=1 %BUILD_OPTIONS% scons VERBOSE=1 %BUILD_OPTIONS% ) else if "!RUN_ARG!"=="clean" ( - scons VERBOSE=1 %BUILD_OPTIONS% -c clean - rd /s /q out - del .sconsign.dblite - del extlibs\gtest\googletest*.lib - del extlibs\gtest\googletest-release-1.7.0\src\gtest*.obj - erase /s *.obj - erase resource\c_common\iotivity_config.h - erase extlibs\libcoap\coap.lib - erase extlibs\libcoap\libcoap\include\coap\coap_config.h - erase extlibs\mbedtls\mbed*.lib + del /S *.ilk + scons VERBOSE=1 %BUILD_OPTIONS% -c ) else if "!RUN_ARG!"=="cleangtest" ( rd /s /q extlibs\gtest\googletest-release-1.7.0 del extlibs\gtest\release-1.7.0.zip diff --git a/service/third_party_libs.scons b/service/third_party_libs.scons index e156744..3055b2e 100644 --- a/service/third_party_libs.scons +++ b/service/third_party_libs.scons @@ -38,7 +38,7 @@ resource_path = src_dir + '/resource' # Check dependent packages (Linux only) ###################################################################### if target_os in ['linux']: - if not env.GetOption('help'): + if (not env.GetOption('help')) and (not env.GetOption('clean')): if not target_arch == platform.machine(): print ''' *********************************** Warning *********************************** -- 2.7.4