Skip to content

Commit bfc11fa

Browse files
committed
Merge pull request #345 from stepcode/review/misc
appveyor isn't at 100%, but it's considerably better
2 parents 7568033 + 677261d commit bfc11fa

43 files changed

Lines changed: 478 additions & 570 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

appveyor.yml renamed to .appveyor.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ build_script:
4747
cmake -version
4848
grep --version
4949
cmake .. -DSC_ENABLE_TESTING=ON -G"$env:GENERATOR" -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209"
50-
dir *.sln
51-
dir *.vcxproj
5250
echo "filtering build output with grep"
5351
cmake --build . --config Debug | grep -ve "CMake does not need to re-run because" -e "ZERO_CHECK.ZERO_CHECK" -e "^ Creating directory"
5452
@@ -59,7 +57,7 @@ build_script:
5957
test_script:
6058
- cmd: echo Running CTest...
6159
- cmd: cd c:\projects\STEPcode\build
62-
- cmd: ctest -j2 . -C Debug --output-on-failure | grep -ve " Start ...:"
60+
- cmd: ctest -j2 . -C Debug --output-on-failure
6361

6462
# - cmd: grep -niB20 "Test Failed" Testing/Temporary/LastTest.log
6563

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ sudo: false
22
language: cpp
33
compiler:
44
- clang
5-
script: mkdir build && cd build && cmake .. -DSC_ENABLE_TESTING=ON && make -j3 && ctest -j2; if [ $? -ne 0 ]; then echo; echo; echo "-----------------------------"; grep -niB20 "Test Failed" Testing/Temporary/LastTest.log && false; fi
5+
script: mkdir build && cd build && cmake .. -DSC_ENABLE_TESTING=ON && make -j3 && ctest -j2 --output-on-failure
66
branches:
77
only:
88
- master

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ elseif(BORLAND)
114114
add_definitions(-D__BORLAND__ -D__WIN32__)
115115
else()
116116
add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long)
117+
if(HAVE_NULLPTR)
118+
list(APPEND CMAKE_CXX_FLAGS -std=c++11)
119+
endif(HAVE_NULLPTR)
117120
endif()
118121

119122
include_directories(
@@ -130,9 +133,7 @@ add_subdirectory(src/clstepcore)
130133
add_subdirectory(src/cleditor)
131134
add_subdirectory(src/cldai)
132135
add_subdirectory(src/clutils)
133-
if(NOT WIN32) # don't build cllazyfile on windows until export/import macros are in place
134-
add_subdirectory(src/cllazyfile)
135-
endif(NOT WIN32)
136+
add_subdirectory(src/cllazyfile)
136137
add_subdirectory(include)
137138
add_subdirectory(data)
138139
if(SC_ENABLE_TESTING)

CONTRIBUTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# How to contribute
2+
3+
We love contributions!
4+
5+
## Getting started
6+
7+
* Create a github account if you haven't already, and fork the project
8+
* Create a new branch, using a branch name that gives an idea of what the changes are about
9+
* One topic per commit; a number of small commits are better than one big one
10+
* Do not introduce whitespace changes! (**Windows users:** `git config --global core.autocrlf true`)
11+
* Encouraged but not enforced: each commit should stand alone, in the sense that the code should compile and run at that point.
12+
* One major topic per pull request. Commits that fix small things (typos, formatting) are perfectly acceptable in a PR fixing a bug or adding a feature.
13+
* Tests are good. Tests are required unless you're fixing something simple or that was obviously broken.
14+
* Make your changes and push them to your GitHub repo
15+
* Once your branch is pushed, submit a pull request.
16+
* We'll look at the PR and either merge or add feedback. If there isn't any activity within several days, send a message to the mailing list - `scl-dev` AT `groups.google.com`.
17+
18+
## Coding Standards
19+
20+
SC's source has been reformatted with astyle. When making changes, try
21+
to match the current formatting. The main points are:
22+
23+
- compact (java-style) brackets:
24+
```C
25+
if( a == 3 ) {
26+
c = 5;
27+
function( a, b );
28+
} else {
29+
somefunc();
30+
}
31+
```
32+
- indents are 4 spaces
33+
- no tab characters
34+
- line endings are LF (linux), not CRLF (windows)
35+
- brackets around single-line conditionals
36+
- spaces inside parentheses and around operators
37+
- return type on the same line as the function name, unless that's
38+
too long
39+
- doxygen-style comments
40+
(see http://www.stack.nl/~dimitri/doxygen/docblocks.html)
41+
42+
If in doubt about a large patch, run astyle with the config file
43+
misc/astyle.cfg.
44+
Download astyle from http://sourceforge.net/projects/astyle/files/astyle/
45+

cmake/SC_Config_Headers.cmake

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,44 @@ int main() {
5757
" )
5858
cmake_push_check_state()
5959
if( UNIX )
60-
set( CMAKE_REQUIRED_FLAGS "-pthread -std=c++0x" )
60+
set( CMAKE_REQUIRED_FLAGS "-pthread -std=c++11" )
6161
else( UNIX )
62-
# vars probably need set for MSVC11, embarcadero, etc
62+
# vars probably need set for embarcadero, etc
6363
endif( UNIX )
6464
CHECK_CXX_SOURCE_RUNS( "${TEST_STD_THREAD}" HAVE_STD_THREAD ) #quotes are *required*!
6565
cmake_pop_check_state()
6666

67+
set( TEST_STD_CHRONO "
68+
#include <iostream>
69+
#include <chrono>
70+
int main() {
71+
std::chrono::seconds sec(1);
72+
std::cout << \"1s is \"<< std::chrono::duration_cast<std::chrono::milliseconds>(sec).count() << \" ms\" << std::endl;
73+
}
74+
" )
75+
cmake_push_check_state()
76+
if( UNIX )
77+
set( CMAKE_REQUIRED_FLAGS "-std=c++11" )
78+
else( UNIX )
79+
# vars probably need set for embarcadero, etc
80+
endif( UNIX )
81+
CHECK_CXX_SOURCE_RUNS( "${TEST_STD_CHRONO}" HAVE_STD_CHRONO ) #quotes are *required*!
82+
cmake_pop_check_state()
83+
84+
set( TEST_NULLPTR "
85+
#include <cstddef>
86+
std::nullptr_t f() {return nullptr;}
87+
int main() {return !!f();}
88+
" )
89+
cmake_push_check_state()
90+
if( UNIX )
91+
set( CMAKE_REQUIRED_FLAGS "-std=c++11" )
92+
else( UNIX )
93+
# vars probably need set for embarcadero, etc
94+
endif( UNIX )
95+
CHECK_CXX_SOURCE_RUNS( "${TEST_NULLPTR}" HAVE_NULLPTR ) #quotes are *required*!
96+
cmake_pop_check_state()
97+
6798
# Now that all the tests are done, configure the sc_cf.h file:
6899
get_property(CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS)
69100
file(WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS}")

cmake/SC_Targets.cmake

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,21 @@ macro(DEFINE_DLL_EXPORTS libname)
1010
string(TOUPPER ${LOWERCORE} UPPER_CORE)
1111
set(export "SC_${UPPER_CORE}_DLL_EXPORTS")
1212
endif()
13-
get_target_property(defs ${libname} COMPILE_DEFINITIONS)
14-
if(defs) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
15-
set(defs "${defs};${export}")
16-
else(defs)
17-
set(defs "${export}")
18-
endif(defs)
19-
set_target_properties(${libname} PROPERTIES COMPILE_DEFINITIONS "${defs}")
13+
set_property(TARGET ${libname} APPEND PROPERTY COMPILE_DEFINITIONS "${export}")
2014
endif(MSVC OR BORLAND)
2115
endmacro(DEFINE_DLL_EXPORTS libname)
2216

2317
# set compile definitions for dll imports on windows
2418
macro(DEFINE_DLL_IMPORTS tgt libs)
2519
if(MSVC OR BORLAND)
26-
get_target_property(defs ${tgt} COMPILE_DEFINITIONS)
27-
if(NOT defs) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
28-
set(defs "")
29-
endif(NOT defs)
20+
set(imports "")
3021
foreach(lib ${libs})
3122
string(REGEX REPLACE "lib" "" shortname "${lib}")
3223
string(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
3324
string(TOUPPER ${LOWERCORE} UPPER_CORE)
34-
list(APPEND defs "SC_${UPPER_CORE}_DLL_IMPORTS")
25+
list(APPEND imports "SC_${UPPER_CORE}_DLL_IMPORTS")
3526
endforeach(lib ${libs})
36-
if(DEFINED defs)
37-
if(defs)
38-
set_target_properties(${tgt} PROPERTIES COMPILE_DEFINITIONS "${defs}")
39-
endif(defs)
40-
endif(DEFINED defs)
27+
set_property(TARGET ${tgt} APPEND PROPERTY COMPILE_DEFINITIONS "${imports}")
4128
endif(MSVC OR BORLAND)
4229
endmacro(DEFINE_DLL_IMPORTS tgt libs)
4330

cmake/schema_scanner/schemaScanner.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# this makes compilation faster, but sometimes runs into compiler limitations
1313
if(NOT DEFINED SC_UNITY_BUILD)
1414
if(BORLAND)
15-
message( STATUS "Will not do unity build for this compiler.")
15+
message( STATUS "Will not do unity build for this compiler. (SC_UNITY_BUILD=FALSE)")
1616
set(SC_UNITY_BUILD FALSE)
1717
else()
18-
message( STATUS "Assuming compiler is capable of unity build.")
18+
message( STATUS "Assuming compiler is capable of unity build. (SC_UNITY_BUILD=TRUE)")
1919
set(SC_UNITY_BUILD TRUE)
2020
endif(BORLAND)
21-
message( STATUS "Override by setting SC_UNITY_BUILD; TRUE will result in *huge* translation units, higher memory use in compilation, and faster build times.")
21+
message( STATUS "Override by setting SC_UNITY_BUILD; TRUE will result in faster build times but *huge* translation units and higher memory use in compilation.")
2222
else(NOT DEFINED SC_UNITY_BUILD)
2323
message( STATUS "Respecting user-defined SC_UNITY_BUILD value of ${SC_UNITY_BUILD}.")
2424
endif(NOT DEFINED SC_UNITY_BUILD)

include/sc_cf_cmake.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@
2424
#cmakedefine HAVE_SSIZE_T 1
2525

2626
#cmakedefine HAVE_STD_THREAD 1
27+
#cmakedefine HAVE_STD_CHRONO 1
28+
#cmakedefine HAVE_NULLPTR 1
2729

2830
#endif /* SCL_CF_H */

misc/summarize-appveyor-log.go

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"regexp"
1010
"strings"
11+
"sort"
1112
)
1213

1314
//uses stdin and stdout
@@ -18,24 +19,26 @@ func main() {
1819
printMessages("warning", warns)
1920
}
2021

21-
/* the regex will match lines like
22-
[ 00:03:42] c:\projects\stepcode\src\base\sc_benchmark.h(45): war*ning C4251: 'benchmark::descr' : class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'benchmark' [C:\projects\STEPcode\build\src\base\base.vcxproj]
22+
/* categorizes warnings and errors based upon the MSVC message number (i.e. C4244)
23+
* the regex will match lines like
24+
[ 00:03:42] c:\projects\stepcode\src\base\sc_benchmark.h(45): warning C4251: 'benchmark::descr' : class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'benchmark' [C:\projects\STEPcode\build\src\base\base.vcxproj]
2325
[00:03:48] C:\projects\STEPcode\src\base\sc_benchmark.cc(61): warning C4244: '=' : conversion from 'SIZE_T' to 'long', possible loss of data [C:\projects\STEPcode\build\src\base\base.vcxproj]*
2426
*/
25-
func countMessages(log string) (warns, errs map[string][]string) {
27+
func countMessages(log []string) (warns, errs map[string][]string) {
2628
warns = make(map[string][]string)
2729
errs = make(map[string][]string)
2830
tstamp := `\[\d\d:\d\d:\d\d\] `
29-
fname := " *(.*)"
30-
fline := `\((\d+)\): `
31-
msgNr := `([A-Z]\d+): `
32-
msgTxt := `([^\[]*) `
31+
fname := " *(.*)" // $1
32+
fline := `(?:\((\d+)\)| ): ` // $2 - either line number in parenthesis or a space, followed by a colon
33+
msgNr := `([A-Z]+\d+): ` // $3 - C4251, LNK2005, etc
34+
msgTxt := `([^\[]*) ` // $4
3335
tail := `\[[^\[\]]*\]`
3436
warnRe := regexp.MustCompile(tstamp + fname + fline + `warning ` + msgNr + msgTxt + tail)
3537
errRe := regexp.MustCompile(tstamp + fname + fline + `(?:fatal )?error ` + msgNr + msgTxt + tail)
36-
reScanner := bufio.NewScanner(strings.NewReader(log))
37-
for reScanner.Scan() {
38-
line := reScanner.Text()
38+
//reScanner := bufio.NewScanner(strings.NewReader(...log))
39+
//for reScanner.Scan() {
40+
//line := reScanner.Text()
41+
for _,line := range log {
3942
if warnRe.MatchString(line) {
4043
key := warnRe.ReplaceAllString(line, "$3")
4144
path := strings.ToLower(warnRe.ReplaceAllString(line, "$1:$2"))
@@ -82,8 +85,15 @@ func countMessages(log string) (warns, errs map[string][]string) {
8285
}
8386

8487
func printMessages(typ string, m map[string][]string) {
85-
for k, v := range m {
86-
for i, l := range v {
88+
//sort keys
89+
keys := make([]string, 0, len(m))
90+
for key := range m {
91+
keys = append(keys, key)
92+
}
93+
sort.Strings(keys)
94+
//fmt.Println(keys)
95+
for _, k := range keys {
96+
for i, l := range m[k] {
8797
//first string is an example, not a location
8898
if i == 0 {
8999
fmt.Printf("%s %s (i.e. \"%s\")\n", typ, k, l)
@@ -94,23 +104,29 @@ func printMessages(typ string, m map[string][]string) {
94104
}
95105
}
96106

97-
func unwrap() (log string) {
98-
//read stdin, write stdout
99-
newline := true
107+
//
108+
func unwrap() (log []string) {
109+
startNewLine := true
100110
unwrapScanner := bufio.NewScanner(os.Stdin)
111+
var lineOut string
101112
for unwrapScanner.Scan() {
102-
lastNewline := newline
103-
line := unwrapScanner.Text()
104-
newline = (len(line) < 240)
113+
lastNewline := startNewLine
114+
lineIn := unwrapScanner.Text()
115+
startNewLine = (len(lineIn) < 240) || strings.HasSuffix(lineIn,"vcxproj]")
105116
if !lastNewline {
106-
log += fmt.Sprintf("%s", line[11:])
117+
lineOut += lineIn[11:]
107118
} else {
108-
log += fmt.Sprintf("%s", line)
119+
lineOut = lineIn
109120
}
110-
if newline {
111-
log += fmt.Sprintf("\n")
121+
if startNewLine {
122+
log = append(log,lineOut)
123+
lineOut = ""
124+
//log += fmt.Sprintf("\n")
112125
}
113126
}
127+
if len(lineOut) > 0 {
128+
log = append(log,lineOut)
129+
}
114130
if err := unwrapScanner.Err(); err != nil {
115131
fmt.Fprintln(os.Stderr, "Error reading appveyor log:", err)
116132
}

src/base/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set(SC_BASE_SOURCES
55
sc_getopt.cc
66
sc_benchmark.cc
77
sc_mkdir.c
8+
path2str.c
9+
judy/src/judy.c
810
)
911

1012
set(SC_BASE_HDRS
@@ -13,8 +15,20 @@ set(SC_BASE_HDRS
1315
sc_getopt.h
1416
sc_trace_fprintf.h
1517
sc_mkdir.h
18+
sc_nullptr.h
19+
path2str.h
20+
judy/src/judy.h
21+
judy/src/judyLArray.h
22+
judy/src/judyL2Array.h
23+
judy/src/judySArray.h
24+
judy/src/judyS2Array.h
1625
)
1726

27+
include_directories(
28+
${CMAKE_CURRENT_SOURCE_DIR}
29+
${CMAKE_CURRENT_SOURCE_DIR}/judy/src
30+
)
31+
1832
if(MINGW OR MSVC OR BORLAND)
1933
add_definitions(-DSC_BASE_DLL_EXPORTS)
2034
endif()

0 commit comments

Comments
 (0)