[brlcad-commits] SF.net SVN: brlcad:[69960] brlcad/trunk

2017-07-16 Thread starseeker--- via brlcad-commits
Revision: 69960
  http://sourceforge.net/p/brlcad/code/69960
Author:   starseeker
Date: 2017-07-17 02:32:54 + (Mon, 17 Jul 2017)
Log Message:
---
Consolidate and simplify the username reporting logic

Modified Paths:
--
brlcad/trunk/CMakeLists.txt

Removed Paths:
-
brlcad/trunk/misc/CMake/test_srcs/report_username.c.in

Modified: brlcad/trunk/CMakeLists.txt
===
--- brlcad/trunk/CMakeLists.txt 2017-07-16 22:08:08 UTC (rev 69959)
+++ brlcad/trunk/CMakeLists.txt 2017-07-17 02:32:54 UTC (rev 69960)
@@ -2677,16 +2677,38 @@
 DISTCLEAN("${BRLCAD_HOSTNAME_FILE}")
 
 # USER
-set(BRLCAD_USERNAME_FILE "${BRLCAD_BINARY_DIR}/CMakeTmp/BRLCAD_BUILD_USER")
-configure_file("${BRLCAD_CMAKE_DIR}/test_srcs/report_username.c.in" 
"${CMAKE_BINARY_DIR}/CMakeTmp/report_username.c")
-TRY_RUN(TIME_RESULT TIME_COMPILED
-  "${CMAKE_BINARY_DIR}/CMakeTmp"
+set(report_username_src "
+#include 
+#include 
+#ifdef HAVE_UNISTD_H
+   #include 
+#endif
+int main(void) {
+  char *name = getenv(\"USERNAME\");
+  if (!name) name = getenv(\"USER\");
+  if (!name) name = \"unknown\";
+  printf(\"%s\", name);
+  return 0;
+}")
+file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/report_username.c" 
"${report_username_src}")
+# Add definition HAVE_UNISTD_H to try_run
+if(HAVE_UNISTED_H)
+  set(UNISTED_DEF "-DHAVE_UNISTED_H")
+endif(HAVE_UNISTED_H)
+try_run(RU_RESULT RU_COMPILED "${CMAKE_BINARY_DIR}/CMakeTmp"
   "${CMAKE_BINARY_DIR}/CMakeTmp/report_username.c"
-  OUTPUT_VARIABLE COMPILEMESSAGES)
-# Let CMake give us the proper newline character(s) for the current platform
-file(READ "${BRLCAD_USERNAME_FILE}"  BRLCAD_COMPILE_USER)
+  COMPILE_DEFINITIONS "${UNISTED_DEF}"
+  COMPILE_OUTPUT_VARIABLE RU_COMPILE_MSGS
+  RUN_OUTPUT_VARIABLE BRLCAD_COMPILE_USER)
+if(NOT RU_COMPILED)
+  message(FATAL_ERROR "Could not build username reporting utility: 
${RU_COMPILE_MSGS}")
+endif(NOT RU_COMPILED)
+if(RU_RESULT)
+  message(FATAL_ERROR "Could not run username reporting utility: 
${BRLCAD_COMPILE_USER}")
+endif(RU_RESULT)
 string(STRIP ${BRLCAD_COMPILE_USER} BRLCAD_COMPILE_USER)
-DISTCLEAN("${BRLCAD_USERNAME_FILE}")
+message("BRLCAD_COMPILE_USER: ${BRLCAD_COMPILE_USER}")
+file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/report_username.c")
 
 #-
 # We now have everything we need - configure files

Deleted: brlcad/trunk/misc/CMake/test_srcs/report_username.c.in
===
--- brlcad/trunk/misc/CMake/test_srcs/report_username.c.in  2017-07-16 
22:08:08 UTC (rev 69959)
+++ brlcad/trunk/misc/CMake/test_srcs/report_username.c.in  2017-07-17 
02:32:54 UTC (rev 69960)
@@ -1,20 +0,0 @@
-#include 
-#include 
-#ifdef _WIN32
-   #define USERVAR "USERNAME"
-#else
-   #include 
-   #define USERVAR "USER"
-#endif
-#define chararraysize 2048
-int main(void) {
-  FILE *outfp = NULL;
-  char *name = getenv(USERVAR);
-  outfp = fopen("@BRLCAD_USERNAME_FILE@", "w");
-  if (!name)
-name = "unknown";
-  printf("user name: %s\n", name);
-  fprintf(outfp, "%s", name);
-  fclose(outfp);
-  return 0;
-}

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[69959] brlcad/trunk

2017-07-16 Thread starseeker--- via brlcad-commits
Revision: 69959
  http://sourceforge.net/p/brlcad/code/69959
Author:   starseeker
Date: 2017-07-16 22:08:08 + (Sun, 16 Jul 2017)
Log Message:
---
Further simplification of the timing logic.

Modified Paths:
--
brlcad/trunk/CMakeLists.txt
brlcad/trunk/misc/CMake/BRLCAD_Util.cmake

Modified: brlcad/trunk/CMakeLists.txt
===
--- brlcad/trunk/CMakeLists.txt 2017-07-16 21:23:19 UTC (rev 69958)
+++ brlcad/trunk/CMakeLists.txt 2017-07-16 22:08:08 UTC (rev 69959)
@@ -138,49 +138,12 @@
 # Set up the necessary support for timing of the configuration and
 # build processes
 set_config_time()
-#generate_timer_exes()
+generate_timer_exes()
 
 #-
-# Write out entries to populate a tm struct (will be used for time
-# delta calculations later)
-if(NOT BRLCAD_IS_SUBBUILD)
-  set(DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/DELTA_START")
-  set(timedelta_start_src "
-#include 
-#include 
-int main(void) {
-  FILE *outfp = NULL;
-  time_t t;
-  struct tm *currenttime;
-  t = time(NULL);
-  currenttime = localtime();
-  outfp = fopen(\"${DELTA_START}\", \"w\");
-  fprintf(outfp, \"%d/\", currenttime->tm_sec); /* seconds after the 
minute [0-60] */
-  fprintf(outfp, \"%d/\", currenttime->tm_min); /* minutes after the 
hour [0-59] */
-  fprintf(outfp, \"%d/\", currenttime->tm_hour);/* hours since 
midnight [0-23] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mday);/* day of the month 
[1-31] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mon); /* months since 
January [0-11] */
-  fprintf(outfp, \"%d/\", currenttime->tm_year);/* years since 1900 */
-  fprintf(outfp, \"%d/\", currenttime->tm_wday);/* days since Sunday 
[0-6] */
-  fprintf(outfp, \"%d/\", currenttime->tm_yday);/* days since January 
1 [0-365] */
-  fprintf(outfp, \"%d\", currenttime->tm_isdst);   /* Daylight Savings 
Time flag */
-  fclose(outfp);
-  return 0;
-}
-")
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c" 
"${timedelta_start_src}")
-  try_run(TIME_RESULT TIME_COMPILED
-"${CMAKE_BINARY_DIR}/CMakeTmp"
-"${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c"
-OUTPUT_VARIABLE COMPILEMESSAGES)
-  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c")
-endif(NOT BRLCAD_IS_SUBBUILD)
-
-
-#-
 # Mark the time at which the configuration process began.
-#set(DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/DELTA_START")
-#execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp" 
"${DELTA_START}")
+set(CONFIG_DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/CONFIG_DELTA_START")
+execute_process(COMMAND "${CMAKE_BINARY_DIR}/CMakeTmp/sstamp" 
"${CONFIG_DELTA_START}")
 
 #-
 # Allow the BRLCAD_ROOT environment variable to set CMAKE_INSTALL_PREFIX
@@ -2786,193 +2749,20 @@
 if(NOT BRLCAD_IS_SUBBUILD)
 
   # Set up rules to print a timestamp string during build
-
-  
#
-  # We need to stamp the start time in a format we can read back in later.
-  set(BUILD_DELTA_FILE "${CMAKE_BINARY_DIR}/CMakeTmp/BUILD_DELTA_FILE")
-  set(builddelta_start_src "
-#define _CRT_SECURE_NO_WARNINGS 1
-
-#include 
-#include 
-
-int main(void)
-{
-  FILE *outfp = NULL;
-  time_t t;
-  struct tm *currenttime;
-  t = time(NULL);
-  currenttime = localtime();
-  outfp = fopen(\"${BUILD_DELTA_FILE}\", \"w\");
-  fprintf(outfp, \"%d/\", currenttime->tm_sec); /* seconds after the 
minute [0-60] */
-  fprintf(outfp, \"%d/\", currenttime->tm_min); /* minutes after the 
hour [0-59] */
-  fprintf(outfp, \"%d/\", currenttime->tm_hour);/* hours since 
midnight [0-23] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mday);/* day of the month 
[1-31] */
-  fprintf(outfp, \"%d/\", currenttime->tm_mon); /* months since 
January [0-11] */
-  fprintf(outfp, \"%d/\", currenttime->tm_year);/* years since 1900 */
-  fprintf(outfp, \"%d/\", currenttime->tm_wday);/* days since Sunday 
[0-6] */
-  fprintf(outfp, \"%d/\", currenttime->tm_yday);/* days since January 
1 [0-365] */
-  fprintf(outfp, \"%d\", currenttime->tm_isdst);/* Daylight Savings 
Time flag */
-  fclose(outfp);
-  return 0;
-}
-")
-  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/builddelta_start.c" 
"${builddelta_start_src}")
-  try_compile(bds_build ${CMAKE_BINARY_DIR}/CMakeTmp
-"${CMAKE_BINARY_DIR}/CMakeTmp/builddelta_start.c"
-COPY_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/bds)
-  if(NOT bds_build)
-message(FATAL_ERROR "Could not build timestamp initialization utility")
-  endif(NOT bds_build)
-
-  
#
-  # The following code does most of 

[brlcad-commits] SF.net SVN: brlcad:[69958] brlcad/trunk

2017-07-16 Thread starseeker--- via brlcad-commits
Revision: 69958
  http://sourceforge.net/p/brlcad/code/69958
Author:   starseeker
Date: 2017-07-16 21:23:19 + (Sun, 16 Jul 2017)
Log Message:
---
Reorganize some logic

Modified Paths:
--
brlcad/trunk/CMakeLists.txt
brlcad/trunk/misc/CMake/BRLCAD_Util.cmake

Removed Paths:
-
brlcad/trunk/misc/CMake/BRLCAD_CMakeFiles.cmake

Modified: brlcad/trunk/CMakeLists.txt
===
--- brlcad/trunk/CMakeLists.txt 2017-07-16 20:25:59 UTC (rev 69957)
+++ brlcad/trunk/CMakeLists.txt 2017-07-16 21:23:19 UTC (rev 69958)
@@ -78,39 +78,6 @@
 # This file contains the top level CMakeLists.txt logic for the
 # BRL-CAD software package.
 
-
-# We want to support a "distclean" build target that will clear all
-# CMake-generated files from a source directory in the case of an
-# in-source-dir configuration.  Not recommended, but we'll try to
-# recover if it happens.
-define_property(GLOBAL PROPERTY CMAKE_DISTCLEAN_TARGET_LIST BRIEF_DOCS "All 
CMake generated files" FULL_DOCS "List of all files generated by CMake")
-function(distclean)
-  foreach(item ${ARGN})
-set_property(GLOBAL APPEND PROPERTY CMAKE_DISTCLEAN_TARGET_LIST "${item}")
-  endforeach(item ${ARGN})
-endfunction(distclean)
-
-# Used a variation on Fraser's approach for capturing command line args from
-# 
http://stackoverflow.com/questions/10205986/how-to-capture-cmake-command-line-arguments
-# to log what variables have been passed in from the user via -D arguments - 
haven't
-# found a variable that saves the original ARGV list except for those defined 
in
-# -P script mode, which doesn't help here.
-get_cmake_property(VARS VARIABLES)
-foreach(VAR ${VARS})
-  get_property(VAR_HELPSTRING CACHE ${VAR} PROPERTY HELPSTRING)
-  # Rather than look for "No help, variable specified on the command line."
-  # exactly, match a slightly more robust subset...
-  string(TOLOWER "${VAR_HELPSTRING}" VAR_HELPSTRING)
-  if("${VAR_HELPSTRING}" MATCHES "specified on the command line")
-get_property(VAR_TYPE CACHE ${VAR} PROPERTY TYPE)
-if(NOT VAR_TYPE STREQUAL "UNINITIALIZED")
-  set(VAR "${VAR}:${VAR_TYPE}")
-endif(NOT VAR_TYPE STREQUAL "UNINITIALIZED")
-set(CMAKE_ARGS "${CMAKE_ARGS} -D${VAR}=${${VAR}}")
-  endif("${VAR_HELPSTRING}" MATCHES "specified on the command line")
-endforeach(VAR ${VARS})
-file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeOutput.log" 
"${CMAKE_COMMAND} \"${CMAKE_SOURCE_DIR}\" ${CMAKE_ARGS}\n")
-
 # Minimum required version of CMake
 cmake_minimum_required(VERSION 2.8.8)
 if(COMMAND CMAKE_POLICY)
@@ -129,7 +96,20 @@
 # set CMake project name
 project(BRLCAD)
 
+#-
+# Define the current BRL-CAD version.
+# See HACKING for details on how to properly update the version
 
+file(READ "${BRLCAD_SOURCE_DIR}/include/conf/MAJOR" BRLCAD_VERSION_MAJOR)
+string(STRIP ${BRLCAD_VERSION_MAJOR} BRLCAD_VERSION_MAJOR)
+file(READ "${BRLCAD_SOURCE_DIR}/include/conf/MINOR" BRLCAD_VERSION_MINOR)
+string(STRIP ${BRLCAD_VERSION_MINOR} BRLCAD_VERSION_MINOR)
+file(READ "${BRLCAD_SOURCE_DIR}/include/conf/PATCH" BRLCAD_VERSION_PATCH)
+string(STRIP ${BRLCAD_VERSION_PATCH} BRLCAD_VERSION_PATCH)
+
+set(BRLCAD_VERSION 
"${BRLCAD_VERSION_MAJOR}.${BRLCAD_VERSION_MINOR}.${BRLCAD_VERSION_PATCH}")
+
+#-
 # Let CMake know where to look for our counting file for configuration
 # passes.  It will impact whether we print certain messages
 set(BRLCAD_CNT_FILE "${BRLCAD_BINARY_DIR}/CMakeTmp/BRLCAD_BUILD_COUNT")
@@ -139,34 +119,27 @@
   set(BRLCAD_PRINT_MSGS 0)
 endif(NOT EXISTS ${BRLCAD_CNT_FILE})
 
+# Make sure the BRL-CAD library list is initialized empty - this way
+# if pieces are disabled between one configure and the next, they
+# won't linger in the list
+set(BRLCAD_LIBS "" CACHE STRING "BRL-CAD libraries" FORCE)
 
-# Wrap the default message() function to also append ALL messages to a
-# CMakeOutput.log file in addition to usual console printing.
-# Note - only do this after calling project, since this override seems to do
-# unexpected things to the messages returned by that command
 
-function(message)
+#-
+# Load general utility routines for BRL-CAD CMake logic
+include("${CMAKE_SOURCE_DIR}/misc/CMake/BRLCAD_Util.cmake")
 
-  # bleh, don't know a clean+safe way to avoid string comparing the
-  # optional arg, so we extract it and test.
-  list(GET ARGV 0 MessageType)
+#-
+# Record the CMake command line arguments (more or less) in
+# CMakeFiles/CMakeOutput.log
+record_cmdline_args()
 
-  if (MessageType STREQUAL FATAL_ERROR OR MessageType STREQUAL SEND_ERROR OR 
MessageType STREQUAL WARNING OR MessageType STREQUAL AUTHOR_WARNING OR 
MessageType STREQUAL STATUS)
-

[brlcad-commits] SF.net SVN: brlcad:[69957] brlcad/trunk

2017-07-16 Thread starseeker--- via brlcad-commits
Revision: 69957
  http://sourceforge.net/p/brlcad/code/69957
Author:   starseeker
Date: 2017-07-16 20:25:59 + (Sun, 16 Jul 2017)
Log Message:
---
Simplify config timestamp writing

Modified Paths:
--
brlcad/trunk/CMakeLists.txt
brlcad/trunk/misc/CMake/BRLCAD_Util.cmake

Removed Paths:
-
brlcad/trunk/misc/CMake/test_srcs/time.c.in

Modified: brlcad/trunk/CMakeLists.txt
===
--- brlcad/trunk/CMakeLists.txt 2017-07-16 03:58:26 UTC (rev 69956)
+++ brlcad/trunk/CMakeLists.txt 2017-07-16 20:25:59 UTC (rev 69957)
@@ -2742,9 +2742,7 @@
 set(BRLCAD_COMPILE_COUNT ${buildCounter})
 
 # DATE - RFC2822 timestamp
-file(READ ${CONFIG_TIMESTAMP_FILE} DATESTAMP)
-string(STRIP ${DATESTAMP} DATESTAMP)
-set(BRLCAD_COMPILE_DATE \"${DATESTAMP}\")
+set(BRLCAD_COMPILE_DATE \"${CONFIG_DATESTAMP}\")
 
 # HOST
 set(BRLCAD_HOSTNAME_FILE "${BRLCAD_BINARY_DIR}/CMakeTmp/BRLCAD_BUILD_HOST")

Modified: brlcad/trunk/misc/CMake/BRLCAD_Util.cmake
===
--- brlcad/trunk/misc/CMake/BRLCAD_Util.cmake   2017-07-16 03:58:26 UTC (rev 
69956)
+++ brlcad/trunk/misc/CMake/BRLCAD_Util.cmake   2017-07-16 20:25:59 UTC (rev 
69957)
@@ -307,38 +307,76 @@
 
 #---
 # Set variables reporting time of configuration.  Sets CONFIG_DATE and
-# CONFIG_TIMESTAMP_FILE in parent scope. (TODO - is the latter necessary?)
+# CONFIG_DATESTAMP in parent scope.
 #
 # Unfortunately, CMake doesn't give you variables with current day,
 # month, etc.  There are several possible approaches to this, but most
 # (e.g. the date command) are not cross platform. We build a small C
-# file which writes out the needed values to files in the build
-# directory. Those files are then read and stripped by CMake.
+# program which supplies the needed info.
 function(set_config_time)
-  set(CONFIG_TIME_DAY_FILE "${BRLCAD_BINARY_DIR}/include/conf/CONFIG_TIME_DAY")
-  set(CONFIG_TIME_MONTH_FILE 
"${BRLCAD_BINARY_DIR}/include/conf/CONFIG_TIME_MONTH")
-  set(CONFIG_TIME_YEAR_FILE 
"${BRLCAD_BINARY_DIR}/include/conf/CONFIG_TIME_YEAR")
-  set(CONFIG_TIMESTAMP_FILE 
"${BRLCAD_BINARY_DIR}/include/conf/CONFIG_TIMESTAMP" PARENT_SCOPE)
-  DISTCLEAN(${CONFIG_TIME_DAY_FILE} ${CONFIG_TIME_MONTH_FILE}
-${CONFIG_TIME_YEAR_FILE} ${CONFIG_TIMESTAMP_FILE})
-  file(MAKE_DIRECTORY "${BRLCAD_BINARY_DIR}/include")
-  file(MAKE_DIRECTORY "${BRLCAD_BINARY_DIR}/include/conf")
-  configure_file("${BRLCAD_CMAKE_DIR}/test_srcs/time.c.in" 
"${CMAKE_BINARY_DIR}/CMakeTmp/time.c")
-  try_run(TIME_RESULT TIME_COMPILED
-"${CMAKE_BINARY_DIR}/CMakeTmp"
-"${CMAKE_BINARY_DIR}/CMakeTmp/time.c"
-OUTPUT_VARIABLE COMPILEMESSAGES)
-  if(TIME_RESULT MATCHES "^0$")
-file(READ ${CONFIG_TIME_DAY_FILE} CONFIG_DAY)
-string(STRIP ${CONFIG_DAY} CONFIG_DAY)
-file(READ ${CONFIG_TIME_MONTH_FILE} CONFIG_MONTH)
-string(STRIP ${CONFIG_MONTH} CONFIG_MONTH)
-file(READ ${CONFIG_TIME_YEAR_FILE} CONFIG_YEAR)
-string(STRIP ${CONFIG_YEAR} CONFIG_YEAR)
-set(CONFIG_DATE "${CONFIG_YEAR}${CONFIG_MONTH}${CONFIG_DAY}" PARENT_SCOPE)
-  else(TIME_RESULT MATCHES "^0$")
-message(FATAL_ERROR "Code to determine current date and time failed!\n")
-  endif(TIME_RESULT MATCHES "^0$")
+
+  # We don't want any parent C flags here - hopefully, the below code will
+  # "just work" in any environment we are about.  The gnu89 standard doesn't
+  # like the %z print specifier, but unless/until we hit a compiler that really
+  # can't deal with it don't worry about it.
+  set(CMAKE_C_FLAGS "")
+
+  set(rfc2822_src "
+/* RFC2822 timestamp and individual day, month and year files */
+
+#include 
+#include 
+#include 
+
+int main(int argc, const char **argv) {
+   time_t t = time(NULL);
+   struct tm *currenttime = localtime();
+   if (argc <= 1) {
+  char rfc2822[200];
+  strftime(rfc2822, sizeof(rfc2822), \"%a, %d %b %Y %H:%M:%S %z\", 
currenttime);
+  printf(\"%s\", rfc2822);
+  return 0;
+   }
+   if (strncmp(argv[1], \"day\", 4) == 0) {
+  printf(\"%02d\", currenttime->tm_mday);
+   }
+   if (strncmp(argv[1], \"month\", 5) == 0) {
+  printf(\"%02d\", currenttime->tm_mon + 1);
+   }
+   if (strncmp(argv[1], \"year\", 4) == 0) {
+  printf(\"%d\", currenttime->tm_year + 1900);
+   }
+   return 0;
+}")
+
+  # Build the code so we can run it
+  file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822.c" "${rfc2822_src}")
+  try_compile(rfc2822_build "${CMAKE_BINARY_DIR}/CMakeTmp"
+SOURCES "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822.c"
+OUTPUT_VARIABLE RFC2822_BUILD_INFO
+COPY_FILE "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822")
+  if(NOT rfc2822_build)
+message(FATAL_ERROR "Could not build rfc2822 timestamp pretty-printing 
utility: ${RFC2822_BUILD_INFO}")
+  endif(NOT rfc2822_build)
+  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/rfc2822.c")
+
+  # Build up and