Revision: 75335
http://sourceforge.net/p/brlcad/code/75335
Author: starseeker
Date: 2020-04-10 15:48:40 +0000 (Fri, 10 Apr 2020)
Log Message:
-----------
checkpoint
Modified Paths:
--------------
brlcad/trunk/regress/CMakeLists.txt
Added Paths:
-----------
brlcad/trunk/regress/licenses/
brlcad/trunk/regress/licenses/CMakeLists.txt
brlcad/trunk/regress/licenses/licenses_check.cpp
brlcad/trunk/regress/licenses/regress-licenses.cmake
Removed Paths:
-------------
brlcad/trunk/regress/license_check.cpp
Modified: brlcad/trunk/regress/CMakeLists.txt
===================================================================
--- brlcad/trunk/regress/CMakeLists.txt 2020-04-10 14:45:45 UTC (rev 75334)
+++ brlcad/trunk/regress/CMakeLists.txt 2020-04-10 15:48:40 UTC (rev 75335)
@@ -52,6 +52,9 @@
# MGED command tests
add_subdirectory(mged)
+# License check
+#add_subdirectory(licenses)
+
if(SH_EXEC)
macro(Sh_Regression_Test testname depends_list)
CMAKE_PARSE_ARGUMENTS(${testname} "EXCLUDE_FROM_REGRESS" "" "" ${ARGN})
@@ -140,7 +143,6 @@
gqa.sh
iges.sh
library.sh
- license_check.cpp
lights.ref.pix
lights.cmake
lights.sh
Deleted: brlcad/trunk/regress/license_check.cpp
===================================================================
--- brlcad/trunk/regress/license_check.cpp 2020-04-10 14:45:45 UTC (rev
75334)
+++ brlcad/trunk/regress/license_check.cpp 2020-04-10 15:48:40 UTC (rev
75335)
@@ -1,154 +0,0 @@
-/* L I C E N S E _ C H E C K . C X X
- * BRL-CAD
- *
- * Copyright (c) 2018-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @file license_check.cxx
- *
- * Check file for certain copyright/license signatures, and for
- * those that are 3rd party check that the appropriate license
- * information is included.
- */
-
-#include <cstdio>
-#include <fstream>
-#include <iomanip>
-#include <iostream>
-#include <regex>
-#include <set>
-#include <map>
-#include <sstream>
-#include <string>
-
-int
-process_file(std::string f)
-{
- std::regex copyright_regex(".*[Cc]opyright.*[12][0-9[0-9[0-9].*");
- std::regex gov_regex(".*United[ ]States[ ]Government.*");
- std::regex pd_regex(".*[Pp]ublic[ ][Dd]omain.*");
- std::string sline;
- std::ifstream fs;
- fs.open(f);
- if (!fs.is_open()) {
- std::cerr << "Unable to open " << f << " for reading, skipping\n";
- return -1;
- }
- int lcnt = 0;
- bool gov_copyright = false;
- bool other_copyright = false;
- bool public_domain = false;
-
- // Check the first 50 lines of the file for copyright statements
- while (std::getline(fs, sline) && lcnt < 50) {
- if (std::regex_match(sline, copyright_regex)) {
- if (std::regex_match(sline, gov_regex)) {
- gov_copyright = true;
- } else {
- other_copyright = true;
- }
- } else {
- if (std::regex_match(sline, pd_regex)) {
- public_domain = true;
- }
- }
- lcnt++;
- }
- fs.close();
-
- if ((gov_copyright || other_copyright) && public_domain) {
- std::cout << f << " has copyright and public domain references\n";
- return 0;
- }
- if (gov_copyright && other_copyright) {
- std::cout << f << " has gov and non-gov copyright\n";
- return 0;
- }
- if (other_copyright) {
- std::cout << f << " has non-gov copyright\n";
- return 0;
- }
- if (public_domain) {
- std::cout << f << " references the public domain\n";
- return 0;
- }
- if (!gov_copyright && !other_copyright && !public_domain) {
- std::cout << f << " has no info\n";
- }
- return 0;
-}
-
-int
-main(int argc, const char *argv[])
-{
- std::regex o_regex(".*[\\/]other[\\/].*");
- std::regex t_regex(".*[\\/]misc/tools[\\/].*");
- std::regex r_regex(".*[\\/]misc/repoconv[\\/].*");
- std::regex srcfile_regex(".*[.](c|cpp|cxx|h|hpp|hxx|tcl)*$");
-
- if (argc < 2) {
- std::cerr << "Usage: license_check [-v] file_list\n";
- return -1;
- }
-
- std::string sfile;
- std::ifstream fs;
- fs.open(argv[1]);
- if (!fs.is_open()) {
- std::cerr << "Unable to open file list " << argv[1] << "\n";
- }
- while (std::getline(fs, sfile)) {
- if (std::regex_match(sfile, o_regex) || std::regex_match(sfile,
t_regex) || std::regex_match(sfile, r_regex)) {
- continue;
- }
- if (!std::regex_match(std::string(sfile), srcfile_regex)) {
- continue;
- }
- //std::cout << "Checking " << sfile << "\n";
- if (process_file(sfile)) {
- fs.close();
- return -1;
- }
- }
- fs.close();
-
- return 0;
-}
-
-// Local Variables:
-// tab-width: 8
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: t
-// c-file-style: "stroustrup"
-// End:
-// ex: shiftwidth=4 tabstop=8
-
Added: brlcad/trunk/regress/licenses/CMakeLists.txt
===================================================================
--- brlcad/trunk/regress/licenses/CMakeLists.txt
(rev 0)
+++ brlcad/trunk/regress/licenses/CMakeLists.txt 2020-04-10 15:48:40 UTC
(rev 75335)
@@ -0,0 +1,46 @@
+add_executable(lcheck licenses_check.cpp)
+
+set(LOG_FILE "${CMAKE_CURRENT_BINARY_DIR}/regress-licenses.log")
+set(STAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/regress-licenses.done")
+set(ALL_FILES_LIST "${BRLCAD_BINARY_DIR}/cmakefiles.cmake")
+
+add_custom_command(
+ OUTPUT "${STAMP_FILE}"
+ COMMAND "${CMAKE_COMMAND}"
+ -DLCHECK_EXEC="$<TARGET_FILE:lcheck>"
-DBRLCAD_SOURCE_DIR="${BRLCAD_SOURCE_DIR}"
+ -DL_FILE="${LOG_FILE}" -DS_FILE="${STAMP_FILE}"
-DF_LIST="${ALL_FILES_LIST}"
+ -DW_DIR="${CMAKE_CURRENT_BINARY_DIR}"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/regress-licenses.cmake"
+ )
+add_custom_target(regress-licenses DEPENDS ${STAMP_FILE})
+set_target_properties(regress-licenses PROPERTIES FOLDER "BRL-CAD Regression
Tests")
+add_dependencies(regress regress-licenses)
+add_dependencies(check regress-licenses)
+
+add_test(NAME regress-licenses
+ COMMAND "${CMAKE_COMMAND}"
+ -DLCHECK_EXEC="$<TARGET_FILE:lcheck>"
-DBRLCAD_SOURCE_DIR="${BRLCAD_SOURCE_DIR}"
+ -DL_FILE="${LOG_FILE}" -DS_FILE="${STAMP_FILE}"
-DF_LIST="${ALL_FILES_LIST}"
+ -DW_DIR="${CMAKE_CURRENT_BINARY_DIR}"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/regress-licenses.cmake"
+ )
+set_tests_properties(regress-licenses PROPERTIES LABELS "Regression")
+
+DISTCLEAN(
+ ${STAMP_FILE}
+ ${LOG_FILE}
+ )
+
+set_target_properties(regress-licenses PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
+
+CMAKEFILES(
+ CMakeLists.txt
+ licenses_check.cpp
+ regress-licenses.cmake
+ )
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
Property changes on: brlcad/trunk/regress/licenses/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/regress/licenses/licenses_check.cpp
===================================================================
--- brlcad/trunk/regress/licenses/licenses_check.cpp
(rev 0)
+++ brlcad/trunk/regress/licenses/licenses_check.cpp 2020-04-10 15:48:40 UTC
(rev 75335)
@@ -0,0 +1,154 @@
+/* L I C E N S E _ C H E C K . C X X
+ * BRL-CAD
+ *
+ * Copyright (c) 2018-2020 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** @file license_check.cxx
+ *
+ * Check file for certain copyright/license signatures, and for
+ * those that are 3rd party check that the appropriate license
+ * information is included.
+ */
+
+#include <cstdio>
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <regex>
+#include <set>
+#include <map>
+#include <sstream>
+#include <string>
+
+int
+process_file(std::string f)
+{
+ std::regex copyright_regex(".*[Cc]opyright.*[12][0-9[0-9[0-9].*");
+ std::regex gov_regex(".*United[ ]States[ ]Government.*");
+ std::regex pd_regex(".*[Pp]ublic[ ][Dd]omain.*");
+ std::string sline;
+ std::ifstream fs;
+ fs.open(f);
+ if (!fs.is_open()) {
+ std::cerr << "Unable to open " << f << " for reading, skipping\n";
+ return -1;
+ }
+ int lcnt = 0;
+ bool gov_copyright = false;
+ bool other_copyright = false;
+ bool public_domain = false;
+
+ // Check the first 50 lines of the file for copyright statements
+ while (std::getline(fs, sline) && lcnt < 50) {
+ if (std::regex_match(sline, copyright_regex)) {
+ if (std::regex_match(sline, gov_regex)) {
+ gov_copyright = true;
+ } else {
+ other_copyright = true;
+ }
+ } else {
+ if (std::regex_match(sline, pd_regex)) {
+ public_domain = true;
+ }
+ }
+ lcnt++;
+ }
+ fs.close();
+
+ if ((gov_copyright || other_copyright) && public_domain) {
+ std::cout << f << " has copyright and public domain references\n";
+ return 0;
+ }
+ if (gov_copyright && other_copyright) {
+ std::cout << f << " has gov and non-gov copyright\n";
+ return 0;
+ }
+ if (other_copyright) {
+ std::cout << f << " has non-gov copyright\n";
+ return 0;
+ }
+ if (public_domain) {
+ std::cout << f << " references the public domain\n";
+ return 0;
+ }
+ if (!gov_copyright && !other_copyright && !public_domain) {
+ std::cout << f << " has no info\n";
+ }
+ return 0;
+}
+
+int
+main(int argc, const char *argv[])
+{
+ std::regex o_regex(".*[\\/]other[\\/].*");
+ std::regex t_regex(".*[\\/]misc/tools[\\/].*");
+ std::regex r_regex(".*[\\/]misc/repoconv[\\/].*");
+ std::regex srcfile_regex(".*[.](c|cpp|cxx|h|hpp|hxx|tcl)*$");
+
+ if (argc < 3) {
+ std::cerr << "Usage: license_check [-v] licenses_list file_list\n";
+ return -1;
+ }
+
+ std::string sfile;
+ std::ifstream src_file_stream;
+ src_file_stream.open(argv[2]);
+ if (!src_file_stream.is_open()) {
+ std::cerr << "Unable to open source file list " << argv[2] << "\n";
+ }
+ while (std::getline(src_file_stream, sfile)) {
+ if (std::regex_match(sfile, o_regex) || std::regex_match(sfile,
t_regex) || std::regex_match(sfile, r_regex)) {
+ continue;
+ }
+ if (!std::regex_match(std::string(sfile), srcfile_regex)) {
+ continue;
+ }
+ //std::cout << "Checking " << sfile << "\n";
+ if (process_file(sfile)) {
+ src_file_stream.close();
+ return -1;
+ }
+ }
+ src_file_stream.close();
+
+ return 0;
+}
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8
+
Property changes on: brlcad/trunk/regress/licenses/licenses_check.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/regress/licenses/regress-licenses.cmake
===================================================================
--- brlcad/trunk/regress/licenses/regress-licenses.cmake
(rev 0)
+++ brlcad/trunk/regress/licenses/regress-licenses.cmake 2020-04-10
15:48:40 UTC (rev 75335)
@@ -0,0 +1,43 @@
+set(LICENSE_CHECK_EXEC "${LCHECK_EXEC}")
+set(LICENSES_DIR "${BRLCAD_SOURCE_DIR}/doc/legal/embedded")
+set(WORKING_DIR "${W_DIR}")
+set(FILES_LIST "${F_LIST}")
+set(LOG_FILE "${L_FILE}")
+set(STAMP_FILE "${S_FILE}")
+
+message("Identifying third party license files...")
+file(GLOB_RECURSE LICENSE_FILES "${LICENSES_DIR}/*")
+
+set(LICENSE_FILE_SET "${WORKING_DIR}/license_files.txt")
+file(WRITE "${LICENSE_FILE_SET}" "")
+foreach(LFILE ${LICENSE_FILES})
+ if (NOT "${LFILE}" MATCHES "CMakeLists.txt")
+ file(APPEND "${LICENSE_FILE_SET}" "${LFILE}\n")
+ endif (NOT "${LFILE}" MATCHES "CMakeLists.txt")
+endforeach(LFILE ${LICENSE_FILES})
+message("Identifying third party license files... done.")
+
+file(WRITE "${LOG_FILE}" "Running license check:\n${LICENSE_CHECK_EXEC}
${LICENSE_FILE_SET} ${FILES_LIST}\n")
+message("Processing...")
+execute_process(
+ COMMAND "${LICENSE_CHECK_EXEC}" "${LICENSE_FILE_SET}" "${FILES_LIST}"
RESULT_VARIABLE license_result
+ OUTPUT_VARIABLE license_log ERROR_VARIABLE license_log
+ WORKING_DIRECTORY ${WORKING_DIR}
+ )
+message("Processing... done.")
+
+file(APPEND "${LOG_FILE}" "\n${license_log}\n")
+
+if(license_result)
+ file(APPEND "${LOG_FILE}" "\n\nError: return code ${license_result}")
+ message(FATAL_ERROR "[license check] Failure, see ${LOG_FILE} for more
info.\n")
+else(license_result)
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${STAMP_FILE}")
+endif(license_result)
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
Property changes on: brlcad/trunk/regress/licenses/regress-licenses.cmake
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits