From ab3a36e76b2a6cfacd418a0715d0bb709bd5793e Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 9 Nov 2011 00:46:39 -0600 Subject: first version of 'cakebaby' regression testing display program diff --git a/tests/cakebaby.py b/tests/cakebaby.py new file mode 100755 index 0000000..a58b6bc --- /dev/null +++ b/tests/cakebaby.py @@ -0,0 +1,202 @@ +#!/usr/bin/python +import string,platform,sys,re,os + +wiki_basepath = 'OpenSCAD' +platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' +logfilename = 'LastTest.log.tmp' +builddir = 'build' +logpath = os.path.join(builddir,'Testing','Temporary',logfilename) +NO_END = False +if logfilename.endswith('.tmp'): NO_END = True + +def readlog(): + try: + print 'reading',logpath + f = open(logpath) + except: + print 'couldnt open ',logpath + return None + + data = f.read() + return data + +class Test: + def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): + self.fullname,self.time,self.passed,self.output = \ + fullname, time, passed, output + self.type = type + self.outputfile = outputfile + self.expectedfile = expectedfile + + def __str__(self): + x = 'fullname: ' + self.fullname + x+= '\noutputfile: ' + self.outputfile + x+= '\nexpectedfile: ' + self.expectedfile + x+= '\ntesttime: ' + self.time + x+= '\ntesttype: ' + self.type + x+= '\npassfail: ' + self.passfail + x+= '\noutput: \n' + self.output + x+= '\n' + return x + +def gettest_strings(data): + chunks = data.split('----------------------------------------------------------') + print 'read',len(chunks), 'chunks' + if NO_END: + enddate = 'n/a (cancelled)' + chunks.pop() + else: + enddate = chunks.pop().replace('End testing: ','').strip() + chunks.reverse() + startdate = chunks.pop().replace('Start testing: ','').strip() + chunks.reverse() + tests=[] + chunksize = 3 + for i in range(0,len(chunks),chunksize): + testchunks = chunks[i:i+chunksize] + test = string.join(testchunks,'-----') + tests += [test] + #print '----------<<<<<<<<<<<<<<<<' + #print test + #print '----------<<<<<<<<<<<<<<<<' + test = '' + return startdate, tests, enddate, platform + +def parsetest(teststring): + s = teststring + def regex(pat,str): + x=re.search(pat,str,re.DOTALL|re.MULTILINE) + if x: + if len(x.groups())>0: + return x.group(1).strip() + return '' + testfullname = regex("Test:(.*?)\n",s) + testtime = regex("Test time =(.*?)\n",s).replace(' sec','') + passfail = regex("Test time.*?Test (Passed)",s) + command = regex("Command:(.*?)\n",s) + tmp = command.split(' "') + testtype = '' + try: + testtype = tmp[3].strip('"') + except: + print 'failed to parse log', teststring + goodimg = regex("expected image:(.*?)\n",s) + actualimg = regex("actual image:(.*?)\n",s) + if passfail=='Passed': passed = True + else: passed = False + output = regex("Output:(.*?)",s).replace('-----','') + test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) + return test + +def parse(data): + startdate, test_strs, enddate, platform = gettest_strings(data) + print 'found', len(test_strs),'test results' + tests = [] + for i in range(len(test_strs)): + test = parsetest(test_strs[i]) + tests += [test] + return startdate, tests, enddate, platform + +def towiki(startdate, tests, enddate, platform): + def convert_path(fulltestname,platform,path): + # convert system path name (image file) to wiki path name + testprogram = fulltestname[0:fulltestname.find('_')] + testprogram = testprogram.replace('test','') + filename = os.path.basename(path) + filename = filename.replace('-actual','') + filename = filename.replace('-tests','') + filename = filename.replace('-expected','') + try: + platform = platform[0].upper() + platform[1:] + except: + platform = 'error' + newpath = testprogram + '_' + filename + # must use _ not / b/c of wikinet.org weird name mangling + newpath = wiki_basepath + '_' + platform + '_' + newpath + return newpath + + x=''' +

OpenSCAD test run

+ +platform: PLATFORM + +runtime: STARTDATE to ENDDATE + +Failed tests + +{|TABLESTYLE +! Testname !! expected output !! actual output +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +|} + +Passed tests + +{|TABLESTYLE +! Testname +|- +| PTESTNAME +|} + +''' + + repeat1=''' +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +''' + + repeat2=''' +|- +| PTESTNAME +''' + + x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') + x = x.replace('STARTDATE',startdate) + x = x.replace('ENDDATE',enddate) + x = x.replace('PLATFORM',platform) + + for t in tests: + if t.passed: + tmp = str(repeat2) + tmp = tmp.replace('PTESTNAME',t.fullname) + x = x.replace(repeat2,tmp + repeat2) + else: + tmp = str(repeat1) + tmp = tmp.replace('FTESTNAME',t.fullname) + wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) + tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) + wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) + tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) + x = x.replace(repeat1,tmp + repeat1) + + x = x.replace(repeat1,'') + x = x.replace(repeat2,'') + return x + +def testsort(tests): + passed = [] + failed = [] + for t in tests: + if t.passed: passed+=[t] + else: failed +=[t] + return failed+passed + +def save(data,filename): + try: + f=open(filename,'w') + except: + print 'couldnt open ',filename, 'for writing' + return None + print 'writing',len(data),'bytes to',filename + f.write(data) + f.close() + +def main(): + data = readlog() + startdate, tests, enddate, platform = parse(data) + tests = testsort(tests) + out = towiki(startdate, tests, enddate, platform) + save(out, platform+'.wiki') + +main() + diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 688026e..485a821 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -73,7 +73,9 @@ def compare_png(resultfilename): if not resultfilename: print >> sys.stderr, "Error: OpenSCAD did not generate an image" return False - print >> sys.stderr, 'Yee image compare: ', expectedfilename, ' ', resultfilename + print >> sys.stderr, 'Yee image compare: ' + print >> sys.stderr, ' expected image: ', expectedfilename + print >> sys.stderr, ' actual image: ', resultfilename if execute_and_redirect("./yee_compare", [expectedfilename, resultfilename, "-downsample", "2", "-threshold", "300"], sys.stderr) != 0: return False return True -- cgit v0.10.1 From 3eb466b5a9dcb7507045898efc7ad52226f54782 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 13 Nov 2011 10:39:34 -0600 Subject: add pretty_print step to ctest run. add '-info' option to opencsgtest. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6966436..69e43a9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -75,24 +75,20 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") endif() -if(BOOST_ROOT) - #set(Boost_DEBUG TRUE) - set(Boost_NO_SYSTEM_PATHS TRUE) - set(Boost_ADDITIONAL_VERSIONS "1.47.0") - find_package( Boost 1.35.0 COMPONENTS thread program_options ) - if(Boost_FOUND) - message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS}) - message(STATUS "Boost libraries found:") - foreach(boostlib ${Boost_LIBRARIES}) - message(STATUS " " ${boostlib}) - endforeach() - include_directories(${Boost_INCLUDE_DIRS}) - else() - message(STATUS "BOOST_ROOT:" ${BOOST_ROOT}) - message(FATAL_ERROR "BOOST_ROOT specified but no boost found") - endif() +#set(Boost_DEBUG TRUE) +set(Boost_NO_SYSTEM_PATHS TRUE) +set(Boost_ADDITIONAL_VERSIONS "1.47.0") +find_package( Boost 1.35.0 COMPONENTS thread program_options ) +if(Boost_FOUND) + message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS}) + message(STATUS "Boost libraries found:") + foreach(boostlib ${Boost_LIBRARIES}) + message(STATUS " " ${boostlib}) + endforeach() + include_directories(${Boost_INCLUDE_DIRS}) else() - message(STATUS "BOOST_ROOT unset. Assuming it will be found automatically.") + message(STATUS "BOOST_ROOT: ${BOOST_ROOT}") + message(FATAL_ERROR "Boost not found.") endif() # Mac OS X @@ -260,13 +256,13 @@ set(COMMON_SOURCES # if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") message(STATUS "Offscreen OpenGL Context - using Apple CGL") - set(OFFSCREEN_CTX_SOURCE "OffscreenContext.mm") + set(OFFSCREEN_CTX_SOURCE "OffscreenContext.mm" CACHE TYPE STRING) elseif(UNIX) message(STATUS "Offscreen OpenGL Context - using Unix GLX") - set(OFFSCREEN_CTX_SOURCE "OffscreenContext.cc") + set(OFFSCREEN_CTX_SOURCE "OffscreenContext.cc" CACHE TYPE STRING) elseif(WIN32) message(STATUS "Offscreen OpenGL Context - using Microsoft WGL") - set(OFFSCREEN_CTX_SOURCE "OffscreenContextWGL.cc") + set(OFFSCREEN_CTX_SOURCE "OffscreenContextWGL.cc" CACHE TYPE STRING) endif() set(OFFSCREEN_SOURCES @@ -362,6 +358,19 @@ endfunction() enable_testing() +# set up custom pretty printing of results + +set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") +set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ctest_pretty_print.py\"") +set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) +set(CTEST_CUSTOM_TXT "\n + ${INFOCMD}\n + set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n +") +file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ctest_pretty_print.py + ${CMAKE_CURRENT_BINARY_DIR}/ctest_pretty_print.py COPYONLY) + # Find all scad files file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad) file(GLOB FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/*.scad) diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc index 839eea9..e2b28e5 100644 --- a/tests/OffscreenContext.cc +++ b/tests/OffscreenContext.cc @@ -99,6 +99,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx) GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 1, None }; @@ -123,8 +124,8 @@ bool create_glx_dummy_window(OffscreenContext &ctx) Window root = DefaultRootWindow( dpy ); XSetWindowAttributes xwin_attr; - int width = 42; - int height = 42; + int width = ctx.width; + int height = ctx.height; xwin_attr.background_pixel = 0; xwin_attr.border_pixel = 0; xwin_attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); @@ -147,7 +148,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx) XSetErrorHandler( original_xlib_handler ); // Most programs would call XMapWindow here. But we don't, to keep the window hidden - // XMapWindow( dpy, xWin ); + XMapWindow( dpy, xWin ); GLXContext context = glXCreateNewContext( dpy, fbconfigs[0], GLX_RGBA_TYPE, NULL, True ); if ( context == NULL ) { @@ -229,11 +230,11 @@ OffscreenContext *create_offscreen_context(int w, int h) } glew_dump(); - ctx->fbo = fbo_new(); +/* ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { cerr << "GL Framebuffer Object init failed; dumping GLEW info" << endl; return NULL; - } + }*/ return ctx; } diff --git a/tests/cakebaby.py b/tests/cakebaby.py deleted file mode 100755 index a58b6bc..0000000 --- a/tests/cakebaby.py +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/python -import string,platform,sys,re,os - -wiki_basepath = 'OpenSCAD' -platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' -logfilename = 'LastTest.log.tmp' -builddir = 'build' -logpath = os.path.join(builddir,'Testing','Temporary',logfilename) -NO_END = False -if logfilename.endswith('.tmp'): NO_END = True - -def readlog(): - try: - print 'reading',logpath - f = open(logpath) - except: - print 'couldnt open ',logpath - return None - - data = f.read() - return data - -class Test: - def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): - self.fullname,self.time,self.passed,self.output = \ - fullname, time, passed, output - self.type = type - self.outputfile = outputfile - self.expectedfile = expectedfile - - def __str__(self): - x = 'fullname: ' + self.fullname - x+= '\noutputfile: ' + self.outputfile - x+= '\nexpectedfile: ' + self.expectedfile - x+= '\ntesttime: ' + self.time - x+= '\ntesttype: ' + self.type - x+= '\npassfail: ' + self.passfail - x+= '\noutput: \n' + self.output - x+= '\n' - return x - -def gettest_strings(data): - chunks = data.split('----------------------------------------------------------') - print 'read',len(chunks), 'chunks' - if NO_END: - enddate = 'n/a (cancelled)' - chunks.pop() - else: - enddate = chunks.pop().replace('End testing: ','').strip() - chunks.reverse() - startdate = chunks.pop().replace('Start testing: ','').strip() - chunks.reverse() - tests=[] - chunksize = 3 - for i in range(0,len(chunks),chunksize): - testchunks = chunks[i:i+chunksize] - test = string.join(testchunks,'-----') - tests += [test] - #print '----------<<<<<<<<<<<<<<<<' - #print test - #print '----------<<<<<<<<<<<<<<<<' - test = '' - return startdate, tests, enddate, platform - -def parsetest(teststring): - s = teststring - def regex(pat,str): - x=re.search(pat,str,re.DOTALL|re.MULTILINE) - if x: - if len(x.groups())>0: - return x.group(1).strip() - return '' - testfullname = regex("Test:(.*?)\n",s) - testtime = regex("Test time =(.*?)\n",s).replace(' sec','') - passfail = regex("Test time.*?Test (Passed)",s) - command = regex("Command:(.*?)\n",s) - tmp = command.split(' "') - testtype = '' - try: - testtype = tmp[3].strip('"') - except: - print 'failed to parse log', teststring - goodimg = regex("expected image:(.*?)\n",s) - actualimg = regex("actual image:(.*?)\n",s) - if passfail=='Passed': passed = True - else: passed = False - output = regex("Output:(.*?)",s).replace('-----','') - test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) - return test - -def parse(data): - startdate, test_strs, enddate, platform = gettest_strings(data) - print 'found', len(test_strs),'test results' - tests = [] - for i in range(len(test_strs)): - test = parsetest(test_strs[i]) - tests += [test] - return startdate, tests, enddate, platform - -def towiki(startdate, tests, enddate, platform): - def convert_path(fulltestname,platform,path): - # convert system path name (image file) to wiki path name - testprogram = fulltestname[0:fulltestname.find('_')] - testprogram = testprogram.replace('test','') - filename = os.path.basename(path) - filename = filename.replace('-actual','') - filename = filename.replace('-tests','') - filename = filename.replace('-expected','') - try: - platform = platform[0].upper() + platform[1:] - except: - platform = 'error' - newpath = testprogram + '_' + filename - # must use _ not / b/c of wikinet.org weird name mangling - newpath = wiki_basepath + '_' + platform + '_' + newpath - return newpath - - x=''' -

OpenSCAD test run

- -platform: PLATFORM - -runtime: STARTDATE to ENDDATE - -Failed tests - -{|TABLESTYLE -! Testname !! expected output !! actual output -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -|} - -Passed tests - -{|TABLESTYLE -! Testname -|- -| PTESTNAME -|} - -''' - - repeat1=''' -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -''' - - repeat2=''' -|- -| PTESTNAME -''' - - x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') - x = x.replace('STARTDATE',startdate) - x = x.replace('ENDDATE',enddate) - x = x.replace('PLATFORM',platform) - - for t in tests: - if t.passed: - tmp = str(repeat2) - tmp = tmp.replace('PTESTNAME',t.fullname) - x = x.replace(repeat2,tmp + repeat2) - else: - tmp = str(repeat1) - tmp = tmp.replace('FTESTNAME',t.fullname) - wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) - tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) - wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) - tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) - x = x.replace(repeat1,tmp + repeat1) - - x = x.replace(repeat1,'') - x = x.replace(repeat2,'') - return x - -def testsort(tests): - passed = [] - failed = [] - for t in tests: - if t.passed: passed+=[t] - else: failed +=[t] - return failed+passed - -def save(data,filename): - try: - f=open(filename,'w') - except: - print 'couldnt open ',filename, 'for writing' - return None - print 'writing',len(data),'bytes to',filename - f.write(data) - f.close() - -def main(): - data = readlog() - startdate, tests, enddate, platform = parse(data) - tests = testsort(tests) - out = towiki(startdate, tests, enddate, platform) - save(out, platform+'.wiki') - -main() - diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 034084c..a6e3747 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -25,8 +25,15 @@ #include #include #include + #include +#include + +#include +namespace po = boost::program_options; +using std::string; +using std::vector; using std::cerr; using std::cout; @@ -41,9 +48,9 @@ public: CsgInfo(); CSGTerm *root_norm_term; // Normalized CSG products class CSGChain *root_chain; - std::vector highlight_terms; + vector highlight_terms; CSGChain *highlights_chain; - std::vector background_terms; + vector background_terms; CSGChain *background_chain; OffscreenView *glview; }; @@ -51,9 +58,9 @@ public: CsgInfo::CsgInfo() { root_norm_term = NULL; root_chain = NULL; - highlight_terms = std::vector(); + highlight_terms = vector(); highlights_chain = NULL; - background_terms = std::vector(); + background_terms = vector(); background_chain = NULL; glview = NULL; } @@ -67,15 +74,52 @@ AbstractNode *find_root_tag(AbstractNode *n) return NULL; } +string info_dump(OffscreenView *glview) +{ + std::stringstream out; + out << "test"; + return out.str(); +} + +po::variables_map parse_options(int argc, char *argv[]) +{ + po::options_description desc("Allowed options"); + desc.add_options() + ("info,i", "information on GLEW, OpenGL, OpenSCAD, and OS"); + + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value< vector >(), "input file"); + ("output-file", po::value< vector >(), "ouput file"); + + po::positional_options_description p; + p.add("input-file", -1); + p.add("output-file", -1); + + po::options_description all_options; + all_options.add(desc).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm); + + return vm; +} + int csgtestcore(int argc, char *argv[], test_type_e test_type) { - if (argc != 3) { - fprintf(stderr, "Usage: %s \n", argv[0]); - exit(1); + bool sysinfo_dump = false; + const char *filename, *outfilename = NULL; + po::variables_map vm = parse_options(argc, argv); + if (vm.count("info")) sysinfo_dump = true; + if (vm.count("input-file") && vm.count("output-file")) { + filename = vm["input-file"].as< vector >().begin()->c_str(); + outfilename = vm["output-file"].as< vector >().begin()->c_str(); } - const char *filename = argv[1]; - const char *outfilename = argv[2]; + if (!filename || !outfilename || !sysinfo_dump) { + cerr << "Usage: " << argv[0] << " \n"; + exit(1); + } Builtins::instance()->initialize(); @@ -194,6 +238,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i. Exiting.\n", error); exit(1); } + if (sysinfo_dump) cout << info_dump(csgInfo.glview); BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); Vector3d center = (bbox.min() + bbox.max()) / 2; diff --git a/tests/ctest_pretty_print.py b/tests/ctest_pretty_print.py new file mode 100755 index 0000000..a58b6bc --- /dev/null +++ b/tests/ctest_pretty_print.py @@ -0,0 +1,202 @@ +#!/usr/bin/python +import string,platform,sys,re,os + +wiki_basepath = 'OpenSCAD' +platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' +logfilename = 'LastTest.log.tmp' +builddir = 'build' +logpath = os.path.join(builddir,'Testing','Temporary',logfilename) +NO_END = False +if logfilename.endswith('.tmp'): NO_END = True + +def readlog(): + try: + print 'reading',logpath + f = open(logpath) + except: + print 'couldnt open ',logpath + return None + + data = f.read() + return data + +class Test: + def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): + self.fullname,self.time,self.passed,self.output = \ + fullname, time, passed, output + self.type = type + self.outputfile = outputfile + self.expectedfile = expectedfile + + def __str__(self): + x = 'fullname: ' + self.fullname + x+= '\noutputfile: ' + self.outputfile + x+= '\nexpectedfile: ' + self.expectedfile + x+= '\ntesttime: ' + self.time + x+= '\ntesttype: ' + self.type + x+= '\npassfail: ' + self.passfail + x+= '\noutput: \n' + self.output + x+= '\n' + return x + +def gettest_strings(data): + chunks = data.split('----------------------------------------------------------') + print 'read',len(chunks), 'chunks' + if NO_END: + enddate = 'n/a (cancelled)' + chunks.pop() + else: + enddate = chunks.pop().replace('End testing: ','').strip() + chunks.reverse() + startdate = chunks.pop().replace('Start testing: ','').strip() + chunks.reverse() + tests=[] + chunksize = 3 + for i in range(0,len(chunks),chunksize): + testchunks = chunks[i:i+chunksize] + test = string.join(testchunks,'-----') + tests += [test] + #print '----------<<<<<<<<<<<<<<<<' + #print test + #print '----------<<<<<<<<<<<<<<<<' + test = '' + return startdate, tests, enddate, platform + +def parsetest(teststring): + s = teststring + def regex(pat,str): + x=re.search(pat,str,re.DOTALL|re.MULTILINE) + if x: + if len(x.groups())>0: + return x.group(1).strip() + return '' + testfullname = regex("Test:(.*?)\n",s) + testtime = regex("Test time =(.*?)\n",s).replace(' sec','') + passfail = regex("Test time.*?Test (Passed)",s) + command = regex("Command:(.*?)\n",s) + tmp = command.split(' "') + testtype = '' + try: + testtype = tmp[3].strip('"') + except: + print 'failed to parse log', teststring + goodimg = regex("expected image:(.*?)\n",s) + actualimg = regex("actual image:(.*?)\n",s) + if passfail=='Passed': passed = True + else: passed = False + output = regex("Output:(.*?)",s).replace('-----','') + test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) + return test + +def parse(data): + startdate, test_strs, enddate, platform = gettest_strings(data) + print 'found', len(test_strs),'test results' + tests = [] + for i in range(len(test_strs)): + test = parsetest(test_strs[i]) + tests += [test] + return startdate, tests, enddate, platform + +def towiki(startdate, tests, enddate, platform): + def convert_path(fulltestname,platform,path): + # convert system path name (image file) to wiki path name + testprogram = fulltestname[0:fulltestname.find('_')] + testprogram = testprogram.replace('test','') + filename = os.path.basename(path) + filename = filename.replace('-actual','') + filename = filename.replace('-tests','') + filename = filename.replace('-expected','') + try: + platform = platform[0].upper() + platform[1:] + except: + platform = 'error' + newpath = testprogram + '_' + filename + # must use _ not / b/c of wikinet.org weird name mangling + newpath = wiki_basepath + '_' + platform + '_' + newpath + return newpath + + x=''' +

OpenSCAD test run

+ +platform: PLATFORM + +runtime: STARTDATE to ENDDATE + +Failed tests + +{|TABLESTYLE +! Testname !! expected output !! actual output +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +|} + +Passed tests + +{|TABLESTYLE +! Testname +|- +| PTESTNAME +|} + +''' + + repeat1=''' +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +''' + + repeat2=''' +|- +| PTESTNAME +''' + + x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') + x = x.replace('STARTDATE',startdate) + x = x.replace('ENDDATE',enddate) + x = x.replace('PLATFORM',platform) + + for t in tests: + if t.passed: + tmp = str(repeat2) + tmp = tmp.replace('PTESTNAME',t.fullname) + x = x.replace(repeat2,tmp + repeat2) + else: + tmp = str(repeat1) + tmp = tmp.replace('FTESTNAME',t.fullname) + wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) + tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) + wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) + tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) + x = x.replace(repeat1,tmp + repeat1) + + x = x.replace(repeat1,'') + x = x.replace(repeat2,'') + return x + +def testsort(tests): + passed = [] + failed = [] + for t in tests: + if t.passed: passed+=[t] + else: failed +=[t] + return failed+passed + +def save(data,filename): + try: + f=open(filename,'w') + except: + print 'couldnt open ',filename, 'for writing' + return None + print 'writing',len(data),'bytes to',filename + f.write(data) + f.close() + +def main(): + data = readlog() + startdate, tests, enddate, platform = parse(data) + tests = testsort(tests) + out = towiki(startdate, tests, enddate, platform) + save(out, platform+'.wiki') + +main() + -- cgit v0.10.1 From c4231685f6cba5feec8bcec324a3fd884687d56e Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 13 Nov 2011 14:34:01 -0600 Subject: option '--info' to opencsgtest for windows. also output html + wiki code. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 393055b..5723344 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -364,6 +364,7 @@ set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --i set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ctest_pretty_print.py\"") set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) set(CTEST_CUSTOM_TXT "\n + message(\"running 'opencsgtest --info' to generate sysinfo.txt\")\n ${INFOCMD}\n set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n ") diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc index e2b28e5..994a74d 100644 --- a/tests/OffscreenContext.cc +++ b/tests/OffscreenContext.cc @@ -44,10 +44,15 @@ See Also #include #include +#include +#include + +#include // for uname + using namespace std; struct OffscreenContext -{ + { GLXContext openGLContext; Display *xdisplay; Window xwindow; @@ -66,6 +71,42 @@ void offscreen_context_init(OffscreenContext &ctx, int width, int height) ctx.fbo = NULL; } +string get_unix_info() +{ + struct utsname u; + stringstream out; + + if (uname(&u) < 0) + out << "OS info: unknown, uname() error\n"; + else { + out << "OS info: " + << u.sysname << " " + << u.release << " " + << u.version << "\n"; + out << "Machine: " << u.machine; + } + return out.str(); +} + +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + assert(ctx); + + if (!ctx->xdisplay) + return string("No GL Context initialized. No information to report\n"); + + int major, minor; + glXQueryVersion(ctx->xdisplay, &major, &minor); + + stringstream out; + out << "GLX version: " << major << "." << minor << "\n"; + out << glew_dump(false); + + out << get_unix_info(); + + return out.str(); +} + static XErrorHandler original_xlib_handler = (XErrorHandler) NULL; static bool XCreateWindow_failed = false; static int XCreateWindow_error(Display *dpy, XErrorEvent *event) @@ -228,7 +269,7 @@ OffscreenContext *create_offscreen_context(int w, int h) cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; return NULL; } - glew_dump(); + // cerr << glew_dump(0); /* ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { @@ -266,7 +307,7 @@ bool save_framebuffer(OffscreenContext *ctx, const char *filename) int rowBytes = samplesPerPixel * ctx->width; unsigned char *flippedBuffer = (unsigned char *)malloc(rowBytes * ctx->height); if (!flippedBuffer) { - std::cerr << "Unable to allocate flipped buffer for corrected image."; + cerr << "Unable to allocate flipped buffer for corrected image."; return 1; } flip_image(pixels, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); diff --git a/tests/OffscreenContext.h b/tests/OffscreenContext.h index a079c3f..6eebcba 100644 --- a/tests/OffscreenContext.h +++ b/tests/OffscreenContext.h @@ -2,10 +2,12 @@ #define OFFSCREENCONTEXT_H_ #include // for error output +#include struct OffscreenContext *create_offscreen_context(int w, int h); void bind_offscreen_context(OffscreenContext *ctx); bool teardown_offscreen_context(OffscreenContext *ctx); bool save_framebuffer(OffscreenContext *ctx, const char *filename); +std::string offscreen_context_getinfo(OffscreenContext *ctx); #endif diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index 140516f..baa39e0 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -16,6 +16,13 @@ struct OffscreenContext fbo_t *fbo; }; +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + sstream result; + result << "OS info: Mac OSX\n"; + result << "Machine: Apple(TM) Mac(TM)\n"; + return result.str(); +} OffscreenContext *create_offscreen_context(int w, int h) { @@ -94,6 +101,7 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { + if (!ctx || !filename) return false; // Read pixels from OpenGL int samplesPerPixel = 4; // R, G, B and A int rowBytes = samplesPerPixel * ctx->width; diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 3b966e2..1aa99dc 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -22,6 +22,9 @@ For more info: #include // must be included after glew.h +#include +#include + using namespace std; struct OffscreenContext @@ -44,6 +47,34 @@ void offscreen_context_init(OffscreenContext &ctx, int width, int height) ctx.fbo = NULL; } +string get_windows_info() +{ + OSVERSIONINFO osvi; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + + SYSTEM_INFO si; + GetSystemInfo(&si); + + stringstream out; + out << "OS info: " + << "Microsoft(TM) Windows(TM) " << osvi.dwMajorVersion << " " + << osvi.dwMinorVersion << " " << osvi.dwBuildNumber << " " + << osvi.szCSDVersion << "\n"; + + out << "Machine: " << si.dwOemID << " " << si.dwProcessorType; +} + +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + stringstream out; + out << glew_dump(false); + out << get_windows_info(); + return result; +} + LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { return DefWindowProc( hwnd, message, wparam, lparam ); @@ -142,7 +173,7 @@ OffscreenContext *create_offscreen_context(int w, int h) cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n"; return NULL; } - glew_dump(); + //cerr << glew_dump(0); ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { diff --git a/tests/OffscreenView.cc b/tests/OffscreenView.cc index 46951c1..2a4a27e 100644 --- a/tests/OffscreenView.cc +++ b/tests/OffscreenView.cc @@ -249,6 +249,11 @@ bool OffscreenView::save(const char *filename) return save_framebuffer(this->ctx, filename); } +std::string OffscreenView::getInfo() +{ + return offscreen_context_getinfo(this->ctx); +} + void OffscreenView::setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d ¢er) { this->camera_eye = pos; diff --git a/tests/OffscreenView.h b/tests/OffscreenView.h index e3c8579..2e35921 100644 --- a/tests/OffscreenView.h +++ b/tests/OffscreenView.h @@ -4,6 +4,7 @@ #include "OffscreenContext.h" #include #include +#include #ifndef _MSC_VER #include #endif @@ -22,6 +23,7 @@ public: void setupOrtho(bool offset=false); void paintGL(); bool save(const char *filename); + std::string getInfo(); GLint shaderinfo[11]; OffscreenContext *ctx; diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index a6e3747..5866346 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -76,8 +76,27 @@ AbstractNode *find_root_tag(AbstractNode *n) string info_dump(OffscreenView *glview) { +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) +#ifdef __GNUG__ +#define compiler_info "GCC " << __VERSION__ +#elif defined(_MSC_VER) +#define compiler_info "MSVC " << _MSC_FULL_VER +#else +#define compiler_info "unknown compiler" +#endif + assert(glview); std::stringstream out; - out << "test"; + out << "OpenSCAD info dump:" + << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." + << int(OPENSCAD_MONTH) << "." +#ifdef OPENSCAD_DAY + << int(OPENSCAD_DAY) +#endif + << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) + << "\nCompiled with: " << compiler_info + << "\nGL Context info: \n" << glview->getInfo() + << "\n"; return out.str(); } @@ -85,22 +104,23 @@ po::variables_map parse_options(int argc, char *argv[]) { po::options_description desc("Allowed options"); desc.add_options() - ("info,i", "information on GLEW, OpenGL, OpenSCAD, and OS"); + ("help,h", "help message")//; + ("info,i", "information on GLEW, OpenGL, OpenSCAD, and OS")//; - po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value< vector >(), "input file"); +// po::options_description hidden("Hidden options"); +// hidden.add_options() + ("input-file", po::value< vector >(), "input file") ("output-file", po::value< vector >(), "ouput file"); po::positional_options_description p; - p.add("input-file", -1); - p.add("output-file", -1); + p.add("input-file", 1).add("output-file", 1); po::options_description all_options; - all_options.add(desc).add(hidden); + all_options.add(desc); // .add(hidden); po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm); + po::notify(vm); return vm; } @@ -109,14 +129,19 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) { bool sysinfo_dump = false; const char *filename, *outfilename = NULL; - po::variables_map vm = parse_options(argc, argv); + po::variables_map vm; + try { + vm = parse_options(argc, argv); + } catch ( po::error e ) { + cerr << "error parsing options\n"; + } if (vm.count("info")) sysinfo_dump = true; - if (vm.count("input-file") && vm.count("output-file")) { + if (vm.count("input-file")) filename = vm["input-file"].as< vector >().begin()->c_str(); + if (vm.count("output-file")) outfilename = vm["output-file"].as< vector >().begin()->c_str(); - } - if (!filename || !outfilename || !sysinfo_dump) { + if ((!filename || !outfilename) && !sysinfo_dump) { cerr << "Usage: " << argv[0] << " \n"; exit(1); } @@ -154,7 +179,11 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) AbstractModule *root_module; ModuleInstantiation root_inst; - root_module = parsefile(filename); + if (sysinfo_dump) + root_module = parse("sphere();","",false); + else + root_module = parsefile(filename); + if (!root_module) { exit(1); } diff --git a/tests/ctest_pretty_print.py b/tests/ctest_pretty_print.py index a58b6bc..0b81f98 100755 --- a/tests/ctest_pretty_print.py +++ b/tests/ctest_pretty_print.py @@ -2,13 +2,31 @@ import string,platform,sys,re,os wiki_basepath = 'OpenSCAD' -platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' -logfilename = 'LastTest.log.tmp' -builddir = 'build' +logfilename = 'LastTest.log' +builddir = '.' logpath = os.path.join(builddir,'Testing','Temporary',logfilename) NO_END = False if logfilename.endswith('.tmp'): NO_END = True +def read_sysinfo(): + try: + f=open('sysinfo.txt') + except: + return '' + data=f.read() + machine_str, osplain_str, renderer_str = '','','' + machine = re.search('Machine:(.*?)\n',data) + osinfo = re.search('OS info:(.*?)\n',data) + renderer = re.search('GL Renderer:(.*?)\n',data) + if machine: machine_str = machine.group(1).strip() + if osinfo: osplain_str = osinfo.group(1).strip().split(' ')[0].strip() + if renderer: + tmp = renderer.group(1).strip().split(' ') + renderer_str = string.join(tmp[0:3],'-') + platform = osplain_str + '_' + machine_str + '_' + renderer_str + platform = platform.lower() + return data, platform + def readlog(): try: print 'reading',logpath @@ -60,7 +78,8 @@ def gettest_strings(data): #print test #print '----------<<<<<<<<<<<<<<<<' test = '' - return startdate, tests, enddate, platform + sysinfo, platform = read_sysinfo() + return startdate, tests, enddate, sysinfo, platform def parsetest(teststring): s = teststring @@ -89,15 +108,15 @@ def parsetest(teststring): return test def parse(data): - startdate, test_strs, enddate, platform = gettest_strings(data) + startdate, test_strs, enddate, sysinfo, platform = gettest_strings(data) print 'found', len(test_strs),'test results' tests = [] for i in range(len(test_strs)): test = parsetest(test_strs[i]) tests += [test] - return startdate, tests, enddate, platform + return startdate, tests, enddate, sysinfo, platform -def towiki(startdate, tests, enddate, platform): +def towiki(startdate, tests, enddate, sysinfo, platform): def convert_path(fulltestname,platform,path): # convert system path name (image file) to wiki path name testprogram = fulltestname[0:fulltestname.find('_')] @@ -120,6 +139,11 @@ def towiki(startdate, tests, enddate, platform): platform: PLATFORM +detailed system info: +
+SYSINFO
+
+ runtime: STARTDATE to ENDDATE Failed tests @@ -153,6 +177,7 @@ Passed tests x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') x = x.replace('STARTDATE',startdate) x = x.replace('ENDDATE',enddate) + x = x.replace('SYSINFO',sysinfo) x = x.replace('PLATFORM',platform) for t in tests: @@ -173,6 +198,19 @@ Passed tests x = x.replace(repeat2,'') return x +def wikitohtml(data): + # not pretty + data = data.replace('\n\n','\n

\n') + data = re.sub('\{\|.*?\n','\n',data) + data = re.sub('\n\! ','\n\n') + data = re.sub('\n\| ','\n
',data) + data = data.replace(' !! ','') + data = data.replace('|-','
',data) + data = data.replace(' || ','') + data = data.replace('|}','\n
') + data = re.sub('[[File:(.*?)|.*?]]','',data) + return data + def testsort(tests): passed = [] failed = [] @@ -193,10 +231,12 @@ def save(data,filename): def main(): data = readlog() - startdate, tests, enddate, platform = parse(data) + startdate, tests, enddate, sysinfo, platform = parse(data) tests = testsort(tests) - out = towiki(startdate, tests, enddate, platform) - save(out, platform+'.wiki') + wikidata = towiki(startdate, tests, enddate, sysinfo, platform) + htmldata = wikitohtml(wikidata) + save(wikidata, platform+'.wiki') + save(htmldata, platform+'.html') main() diff --git a/tests/system-gl.cc b/tests/system-gl.cc index f95a5ca..2e3f3bc 100644 --- a/tests/system-gl.cc +++ b/tests/system-gl.cc @@ -2,34 +2,40 @@ /* OpenGL helper functions */ #include +#include +#include #include "system-gl.h" #include using namespace std; using namespace boost; -void glew_dump() { - cerr << "GLEW version: " << glewGetString(GLEW_VERSION) << endl - << "Renderer: " << (const char *)glGetString(GL_RENDERER) << endl - << "Vendor: " << (const char *)glGetString(GL_VENDOR) << endl - << "OpenGL version: " << (const char *)glGetString(GL_VERSION) << endl; +string glew_dump(bool dumpall) +{ + stringstream out; + out << "GLEW version: " << glewGetString(GLEW_VERSION) << endl + << "GL Renderer: " << (const char *)glGetString(GL_RENDERER) << endl + << "GL Vendor: " << (const char *)glGetString(GL_VENDOR) << endl + << "OpenGL Version: " << (const char *)glGetString(GL_VERSION) << endl; - bool dumpall = false; + out << "GL Extensions: " << endl; if (dumpall) { string extensions((const char *)glGetString(GL_EXTENSIONS)); replace_all( extensions, " ", "\n " ); - cerr << "Extensions: " << endl << " " << extensions << endl; + out << " " << extensions << endl; } - cerr << " GL_ARB_framebuffer_object: " - << (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no") - << endl - << " GL_EXT_framebuffer_object: " - << (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no") - << endl - << " GL_EXT_packed_depth_stencil: " - << (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no") - << endl; + out << "GL_ARB_framebuffer_object: " + << (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no") + << endl + << "GL_EXT_framebuffer_object: " + << (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no") + << endl + << "GL_EXT_packed_depth_stencil: " + << (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no") + << endl; + + return out.str(); }; bool report_glerror(const char * function) diff --git a/tests/system-gl.h b/tests/system-gl.h index bb41be5..45d5130 100644 --- a/tests/system-gl.h +++ b/tests/system-gl.h @@ -2,8 +2,9 @@ #define SYSTEMGL_H_ #include +#include -void glew_dump(); +std::string glew_dump(bool dumpall); bool report_glerror(const char *task); #endif -- cgit v0.10.1 From bf564e80595030578e04c235ccdab94b85eca010 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 13 Nov 2011 23:13:59 -0600 Subject: windows fixes for pretty printing test results. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5723344..85c4f21 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -75,9 +75,15 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") endif() +if (WIN32) + set(Boost_USE_STATIC_LIBS TRUE) + set(BOOST_STATIC TRUE) + set(BOOST_THREAD_USE_LIB TRUE) +endif() + #set(Boost_DEBUG TRUE) set(Boost_NO_SYSTEM_PATHS TRUE) -set(Boost_ADDITIONAL_VERSIONS "1.47.0") +set(Boost_ADDITIONAL_VERSIONS "1.47.0" "1.46.0") find_package( Boost 1.35.0 COMPONENTS thread program_options ) if(Boost_FOUND) message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS}) diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 1aa99dc..3756a82 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -22,6 +22,7 @@ For more info: #include // must be included after glew.h +#include #include #include @@ -57,14 +58,24 @@ string get_windows_info() SYSTEM_INFO si; GetSystemInfo(&si); + map archs; + archs[PROCESSOR_ARCHITECTURE_AMD64] = "amd64"; + archs[PROCESSOR_ARCHITECTURE_IA64] = "itanium"; + archs[PROCESSOR_ARCHITECTURE_INTEL] = "x86"; + archs[PROCESSOR_ARCHITECTURE_UNKNOWN] = "unknown"; stringstream out; out << "OS info: " - << "Microsoft(TM) Windows(TM) " << osvi.dwMajorVersion << " " - << osvi.dwMinorVersion << " " << osvi.dwBuildNumber << " " - << osvi.szCSDVersion << "\n"; + << "Microsoft(TM) Windows(TM) " << osvi.dwMajorVersion << " " + << osvi.dwMinorVersion << " " << osvi.dwBuildNumber << " " + << osvi.szCSDVersion; + if (archs.find(si.wProcessorArchitecture) != archs.end()) + out << " " << archs[si.wProcessorArchitecture]; + out << "\n"; - out << "Machine: " << si.dwOemID << " " << si.dwProcessorType; + out << "Machine: " << si.dwProcessorType; + + return out.str(); } string offscreen_context_getinfo(OffscreenContext *ctx) @@ -72,7 +83,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) stringstream out; out << glew_dump(false); out << get_windows_info(); - return result; + return out.str(); } LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) diff --git a/tests/ctest_pretty_print.py b/tests/ctest_pretty_print.py index 0b81f98..430f106 100755 --- a/tests/ctest_pretty_print.py +++ b/tests/ctest_pretty_print.py @@ -3,7 +3,7 @@ import string,platform,sys,re,os wiki_basepath = 'OpenSCAD' logfilename = 'LastTest.log' -builddir = '.' +builddir = os.getcwd() logpath = os.path.join(builddir,'Testing','Temporary',logfilename) NO_END = False if logfilename.endswith('.tmp'): NO_END = True @@ -18,11 +18,15 @@ def read_sysinfo(): machine = re.search('Machine:(.*?)\n',data) osinfo = re.search('OS info:(.*?)\n',data) renderer = re.search('GL Renderer:(.*?)\n',data) - if machine: machine_str = machine.group(1).strip() - if osinfo: osplain_str = osinfo.group(1).strip().split(' ')[0].strip() + if machine: machine_str = machine.group(1).strip().replace(' ','-').replace('/','-') + if osinfo: + osplain_str = osinfo.group(1).strip().split(' ')[0].strip().replace('/','-') + if 'windows' in osinfo.group(1).lower(): osplain_str = 'win' if renderer: tmp = renderer.group(1).strip().split(' ') - renderer_str = string.join(tmp[0:3],'-') + tmp = string.join(tmp[0:3],'-') + if '/' in tmp: tmp = tmp.split('/')[0] + renderer_str = tmp platform = osplain_str + '_' + machine_str + '_' + renderer_str platform = platform.lower() return data, platform @@ -119,12 +123,11 @@ def parse(data): def towiki(startdate, tests, enddate, sysinfo, platform): def convert_path(fulltestname,platform,path): # convert system path name (image file) to wiki path name - testprogram = fulltestname[0:fulltestname.find('_')] + testprogram = fulltestname[0:fulltestname.rfind('_')] testprogram = testprogram.replace('test','') filename = os.path.basename(path) - filename = filename.replace('-actual','') - filename = filename.replace('-tests','') - filename = filename.replace('-expected','') + filename = filename.replace('-tests-actual.png','.png') + filename = filename.replace('-tests-expected.png','.png') try: platform = platform[0].upper() + platform[1:] except: @@ -144,7 +147,8 @@ detailed system info: SYSINFO -runtime: STARTDATE to ENDDATE +start time: STARTDATE +end time : ENDDATE Failed tests @@ -181,17 +185,25 @@ Passed tests x = x.replace('PLATFORM',platform) for t in tests: + print t.type, t.fullname, t.expectedfile, t.outputfile if t.passed: tmp = str(repeat2) tmp = tmp.replace('PTESTNAME',t.fullname) x = x.replace(repeat2,tmp + repeat2) - else: + elif not t.passed and t.type=='png': tmp = str(repeat1) tmp = tmp.replace('FTESTNAME',t.fullname) + wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) + if t.type!='png': wiki_imgpath1 = '' + if t.expectedfile=='': wiki_imgpath2 = '' tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) + wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) + if t.type!='png': wiki_imgpath2 = '' + if t.outputfile=='': wiki_imgpath2 = '' tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) + x = x.replace(repeat1,tmp + repeat1) x = x.replace(repeat1,'') diff --git a/tests/fbo.cc b/tests/fbo.cc index 2a3342d..2f933d7 100644 --- a/tests/fbo.cc +++ b/tests/fbo.cc @@ -93,6 +93,7 @@ bool fbo_ext_init(fbo_t *fbo, size_t width, size_t height) glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->depthbuf_id); if (report_glerror("specifying depth render buffer EXT")) return false; + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->depthbuf_id); if (report_glerror("specifying stencil render buffer EXT")) return false; @@ -142,7 +143,8 @@ bool fbo_arb_init(fbo_t *fbo, size_t width, size_t height) return false; } - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo->depthbuf_id); if (report_glerror("specifying depth stencil render buffer")) return false; @@ -181,21 +183,22 @@ bool fbo_resize(fbo_t *fbo, size_t width, size_t height) { if (use_ext()) { glBindRenderbufferEXT(GL_RENDERBUFFER, fbo->depthbuf_id); - if (glewIsSupported("GL_EXT_packed_depth_stencil")) { + if (0) { // glewIsSupported("GL_EXT_packed_depth_stencil")) { glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); - if (report_glerror("creating depth stencil render buffer")) return false; + if (report_glerror("creating EXT depth stencil render buffer")) return false; } else { glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height); - if (report_glerror("creating depth render buffer")) return false; + if (report_glerror("creating EXT depth render buffer")) return false; } glBindRenderbufferEXT(GL_RENDERBUFFER, fbo->renderbuf_id); glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA8, width, height); - if (report_glerror("creating color render buffer")) return false; + if (report_glerror("creating EXT color render buffer")) return false; } else { glBindRenderbuffer(GL_RENDERBUFFER, fbo->depthbuf_id); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + //glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height); if (report_glerror("creating depth stencil render buffer")) return false; glBindRenderbuffer(GL_RENDERBUFFER, fbo->renderbuf_id); -- cgit v0.10.1 From b6b3e52543696c5d6efd85b4d86fc13abb327518 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 16 Nov 2011 05:58:07 -0600 Subject: add more info to --info dumps. improve wiki output diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 85c4f21..5315c01 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -265,7 +265,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(OFFSCREEN_CTX_SOURCE "OffscreenContext.mm" CACHE TYPE STRING) elseif(UNIX) message(STATUS "Offscreen OpenGL Context - using Unix GLX") - set(OFFSCREEN_CTX_SOURCE "OffscreenContext.cc" CACHE TYPE STRING) + set(OFFSCREEN_CTX_SOURCE "OffscreenContextGLX.cc" CACHE TYPE STRING) elseif(WIN32) message(STATUS "Offscreen OpenGL Context - using Microsoft WGL") set(OFFSCREEN_CTX_SOURCE "OffscreenContextWGL.cc" CACHE TYPE STRING) @@ -367,16 +367,20 @@ enable_testing() # set up custom pretty printing of results set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") -set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ctest_pretty_print.py\"") +set(PRETTYCMD "\"${PYTHON_EXECUTABLE} test_pretty_print.py\"") set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) set(CTEST_CUSTOM_TXT "\n message(\"running 'opencsgtest --info' to generate sysinfo.txt\")\n ${INFOCMD}\n - set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n + # set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n # doesn't work. log is written + # after all tests run. ") file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ctest_pretty_print.py - ${CMAKE_CURRENT_BINARY_DIR}/ctest_pretty_print.py COPYONLY) + +foreach(FILE test_pretty_print.py) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE} + ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY) +endforeach() # Find all scad files file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad) diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc deleted file mode 100644 index 994a74d..0000000 --- a/tests/OffscreenContext.cc +++ /dev/null @@ -1,325 +0,0 @@ -/* - -Create an OpenGL context without creating an OpenGL Window. for Linux. - -See Also - - glxgears.c by Brian Paul from mesa-demos (mesa3d.org) - http://cgit.freedesktop.org/mesa/demos/tree/src/xdemos?id=mesa-demos-8.0.1 - http://www.opengl.org/sdk/docs/man/xhtml/glXIntro.xml - http://www.mesa3d.org/brianp/sig97/offscrn.htm - http://glprogramming.com/blue/ch07.html - OffscreenContext.mm (Mac OSX version) - -*/ - -/* - * Some portions of the code below are: - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "OffscreenContext.h" -#include "printutils.h" -#include "imageutils.h" -#include "system-gl.h" -#include "fbo.h" - -#include -#include - -#include -#include - -#include // for uname - -using namespace std; - -struct OffscreenContext - { - GLXContext openGLContext; - Display *xdisplay; - Window xwindow; - int width; - int height; - fbo_t *fbo; -}; - -void offscreen_context_init(OffscreenContext &ctx, int width, int height) -{ - ctx.width = width; - ctx.height = height; - ctx.openGLContext = NULL; - ctx.xdisplay = NULL; - ctx.xwindow = (Window)NULL; - ctx.fbo = NULL; -} - -string get_unix_info() -{ - struct utsname u; - stringstream out; - - if (uname(&u) < 0) - out << "OS info: unknown, uname() error\n"; - else { - out << "OS info: " - << u.sysname << " " - << u.release << " " - << u.version << "\n"; - out << "Machine: " << u.machine; - } - return out.str(); -} - -string offscreen_context_getinfo(OffscreenContext *ctx) -{ - assert(ctx); - - if (!ctx->xdisplay) - return string("No GL Context initialized. No information to report\n"); - - int major, minor; - glXQueryVersion(ctx->xdisplay, &major, &minor); - - stringstream out; - out << "GLX version: " << major << "." << minor << "\n"; - out << glew_dump(false); - - out << get_unix_info(); - - return out.str(); -} - -static XErrorHandler original_xlib_handler = (XErrorHandler) NULL; -static bool XCreateWindow_failed = false; -static int XCreateWindow_error(Display *dpy, XErrorEvent *event) -{ - cerr << "XCreateWindow failed: XID: " << event->resourceid - << " request: " << (int)event->request_code - << " minor: " << (int)event->minor_code << "\n"; - char description[1024]; - XGetErrorText( dpy, event->error_code, description, 1023 ); - cerr << " error message: " << description << "\n"; - XCreateWindow_failed = true; - return 0; -} - -bool create_glx_dummy_window(OffscreenContext &ctx) -{ - /* - create a dummy X window without showing it. (without 'mapping' it) - and save information to the ctx. - - This purposely does not use glxCreateWindow, to avoid crashes, - "failed to create drawable" errors, and Mesa "WARNING: Application calling - GLX 1.3 function when GLX 1.3 is not supported! This is an application bug!" - - This function will alter ctx.openGLContext and ctx.xwindow if successfull - */ - - int attributes[] = { - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_DEPTH_SIZE, 1, - None - }; - - Display *dpy = ctx.xdisplay; - - int num_returned = 0; - GLXFBConfig *fbconfigs = glXChooseFBConfig( dpy, DefaultScreen(dpy), attributes, &num_returned ); - if ( fbconfigs == NULL ) { - cerr << "glXChooseFBConfig failed\n"; - return false; - } - - XVisualInfo *visinfo = glXGetVisualFromFBConfig( dpy, fbconfigs[0] ); - if ( visinfo == NULL ) { - cerr << "glXGetVisualFromFBConfig failed\n"; - XFree( fbconfigs ); - return false; - } - - // can't depend on xWin==NULL at failure. use a custom Xlib error handler instead. - original_xlib_handler = XSetErrorHandler( XCreateWindow_error ); - - Window root = DefaultRootWindow( dpy ); - XSetWindowAttributes xwin_attr; - int width = ctx.width; - int height = ctx.height; - xwin_attr.background_pixel = 0; - xwin_attr.border_pixel = 0; - xwin_attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); - xwin_attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; - unsigned long int mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; - - Window xWin = XCreateWindow( dpy, root, 0, 0, width, height, - 0, visinfo->depth, InputOutput, - visinfo->visual, mask, &xwin_attr ); - - // Window xWin = XCreateSimpleWindow( dpy, DefaultRootWindow(dpy), 0,0,42,42, 0,0,0 ); - - - XSync( dpy, false ); - if ( XCreateWindow_failed ) { - XFree( visinfo ); - XFree( fbconfigs ); - return false; - } - XSetErrorHandler( original_xlib_handler ); - - // Most programs would call XMapWindow here. But we don't, to keep the window hidden - XMapWindow( dpy, xWin ); - - GLXContext context = glXCreateNewContext( dpy, fbconfigs[0], GLX_RGBA_TYPE, NULL, True ); - if ( context == NULL ) { - cerr << "glXCreateNewContext failed\n"; - XDestroyWindow( dpy, xWin ); - XFree( visinfo ); - XFree( fbconfigs ); - return false; - } - - //GLXWindow glxWin = glXCreateWindow( dpy, fbconfigs[0], xWin, NULL ); - - if (!glXMakeContextCurrent( dpy, xWin, xWin, context )) { - //if (!glXMakeContextCurrent( dpy, glxWin, glxWin, context )) { - cerr << "glXMakeContextCurrent failed\n"; - glXDestroyContext( dpy, context ); - XDestroyWindow( dpy, xWin ); - XFree( visinfo ); - XFree( fbconfigs ); - return false; - } - - ctx.openGLContext = context; - ctx.xwindow = xWin; - - XFree( visinfo ); - XFree( fbconfigs ); - - return true; -} - - -Bool create_glx_dummy_context(OffscreenContext &ctx) -{ - // This will alter ctx.openGLContext and ctx.xdisplay and ctx.xwindow if successfull - int major; - int minor; - Bool result = False; - - ctx.xdisplay = XOpenDisplay( NULL ); - if ( ctx.xdisplay == NULL ) { - cerr << "Unable to open a connection to the X server\n"; - return False; - } - - // glxQueryVersion is not always reliable. Use it, but then - // also check to see if GLX 1.3 functions exist - - glXQueryVersion(ctx.xdisplay, &major, &minor); - - if ( major==1 && minor<=2 && glXGetVisualFromFBConfig==NULL ) { - cerr << "Error: GLX version 1.3 functions missing. " - << "Your GLX version: " << major << "." << minor << endl; - } else { - result = create_glx_dummy_window(ctx); - } - - if (!result) XCloseDisplay( ctx.xdisplay ); - return result; -} - -OffscreenContext *create_offscreen_context(int w, int h) -{ - OffscreenContext *ctx = new OffscreenContext; - offscreen_context_init( *ctx, w, h ); - - // before an FBO can be setup, a GLX context must be created - // this call alters ctx->xDisplay and ctx->openGLContext - // and ctx->xwindow if successfull - if (!create_glx_dummy_context( *ctx )) { - return NULL; - } - - // glewInit must come after Context creation and before FBO calls. - GLenum err = glewInit(); - if (GLEW_OK != err) { - cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; - return NULL; - } - // cerr << glew_dump(0); - -/* ctx->fbo = fbo_new(); - if (!fbo_init(ctx->fbo, w, h)) { - cerr << "GL Framebuffer Object init failed; dumping GLEW info" << endl; - return NULL; - }*/ - - return ctx; -} - -bool teardown_offscreen_context(OffscreenContext *ctx) -{ - if (ctx) { - fbo_unbind(ctx->fbo); - fbo_delete(ctx->fbo); - XDestroyWindow( ctx->xdisplay, ctx->xwindow ); - glXDestroyContext( ctx->xdisplay, ctx->openGLContext ); - XCloseDisplay( ctx->xdisplay ); - return true; - } - return false; -} - -/*! - Capture framebuffer from OpenGL and write it to the given filename as PNG. -*/ -bool save_framebuffer(OffscreenContext *ctx, const char *filename) -{ - if (!ctx || !filename) return false; - int samplesPerPixel = 4; // R, G, B and A - GLubyte pixels[ctx->width * ctx->height * samplesPerPixel]; - glReadPixels(0, 0, ctx->width, ctx->height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - // Flip it vertically - images read from OpenGL buffers are upside-down - int rowBytes = samplesPerPixel * ctx->width; - unsigned char *flippedBuffer = (unsigned char *)malloc(rowBytes * ctx->height); - if (!flippedBuffer) { - cerr << "Unable to allocate flipped buffer for corrected image."; - return 1; - } - flip_image(pixels, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); - - bool writeok = write_png(filename, flippedBuffer, ctx->width, ctx->height); - - free(flippedBuffer); - - return writeok; -} - -void bind_offscreen_context(OffscreenContext *ctx) -{ - if (ctx) fbo_bind(ctx->fbo); -} diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index baa39e0..7d95481 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -18,10 +18,11 @@ struct OffscreenContext string offscreen_context_getinfo(OffscreenContext *ctx) { - sstream result; - result << "OS info: Mac OSX\n"; - result << "Machine: Apple(TM) Mac(TM)\n"; - return result.str(); + stringstream out; + out << "GL context creator: Cocoa / CGL\n" + << "OS info: Mac OSX\n" + << "Machine: Apple(TM) Mac(TM)\n"; + return out.str(); } OffscreenContext *create_offscreen_context(int w, int h) diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc new file mode 100644 index 0000000..ed9ef46 --- /dev/null +++ b/tests/OffscreenContextGLX.cc @@ -0,0 +1,324 @@ +/* + +Create an OpenGL context without creating an OpenGL Window. for Linux. + +See Also + + glxgears.c by Brian Paul from mesa-demos (mesa3d.org) + http://cgit.freedesktop.org/mesa/demos/tree/src/xdemos?id=mesa-demos-8.0.1 + http://www.opengl.org/sdk/docs/man/xhtml/glXIntro.xml + http://www.mesa3d.org/brianp/sig97/offscrn.htm + http://glprogramming.com/blue/ch07.html + OffscreenContext.mm (Mac OSX version) + +*/ + +/* + * Some portions of the code below are: + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "OffscreenContext.h" +#include "printutils.h" +#include "imageutils.h" +#include "system-gl.h" +#include "fbo.h" + +#include +#include + +#include +#include + +#include // for uname + +using namespace std; + +struct OffscreenContext +{ + GLXContext openGLContext; + Display *xdisplay; + Window xwindow; + int width; + int height; + fbo_t *fbo; +}; + +void offscreen_context_init(OffscreenContext &ctx, int width, int height) +{ + ctx.width = width; + ctx.height = height; + ctx.openGLContext = NULL; + ctx.xdisplay = NULL; + ctx.xwindow = (Window)NULL; + ctx.fbo = NULL; +} + +string get_os_info() +{ + struct utsname u; + stringstream out; + + if (uname(&u) < 0) + out << "OS info: unknown, uname() error\n"; + else { + out << "OS info: " + << u.sysname << " " + << u.release << " " + << u.version << "\n"; + out << "Machine: " << u.machine; + } + return out.str(); +} + +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + assert(ctx); + + if (!ctx->xdisplay) + return string("No GL Context initialized. No information to report\n"); + + int major, minor; + glXQueryVersion(ctx->xdisplay, &major, &minor); + + stringstream out; + out << "GL context creator: GLX\n" + << "GLX version: " << major << "." << minor << "\n" + << get_os_info(); + + return out.str(); +} + +static XErrorHandler original_xlib_handler = (XErrorHandler) NULL; +static bool XCreateWindow_failed = false; +static int XCreateWindow_error(Display *dpy, XErrorEvent *event) +{ + cerr << "XCreateWindow failed: XID: " << event->resourceid + << " request: " << (int)event->request_code + << " minor: " << (int)event->minor_code << "\n"; + char description[1024]; + XGetErrorText( dpy, event->error_code, description, 1023 ); + cerr << " error message: " << description << "\n"; + XCreateWindow_failed = true; + return 0; +} + +bool create_glx_dummy_window(OffscreenContext &ctx) +{ + /* + create a dummy X window without showing it. (without 'mapping' it) + and save information to the ctx. + + This purposely does not use glxCreateWindow, to avoid crashes, + "failed to create drawable" errors, and Mesa "WARNING: Application calling + GLX 1.3 function when GLX 1.3 is not supported! This is an application bug!" + + This function will alter ctx.openGLContext and ctx.xwindow if successfull + */ + + int attributes[] = { + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 1, + None + }; + + Display *dpy = ctx.xdisplay; + + int num_returned = 0; + GLXFBConfig *fbconfigs = glXChooseFBConfig( dpy, DefaultScreen(dpy), attributes, &num_returned ); + if ( fbconfigs == NULL ) { + cerr << "glXChooseFBConfig failed\n"; + return false; + } + + XVisualInfo *visinfo = glXGetVisualFromFBConfig( dpy, fbconfigs[0] ); + if ( visinfo == NULL ) { + cerr << "glXGetVisualFromFBConfig failed\n"; + XFree( fbconfigs ); + return false; + } + + // can't depend on xWin==NULL at failure. use a custom Xlib error handler instead. + original_xlib_handler = XSetErrorHandler( XCreateWindow_error ); + + Window root = DefaultRootWindow( dpy ); + XSetWindowAttributes xwin_attr; + int width = ctx.width; + int height = ctx.height; + xwin_attr.background_pixel = 0; + xwin_attr.border_pixel = 0; + xwin_attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); + xwin_attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + unsigned long int mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + Window xWin = XCreateWindow( dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &xwin_attr ); + + // Window xWin = XCreateSimpleWindow( dpy, DefaultRootWindow(dpy), 0,0,42,42, 0,0,0 ); + + + XSync( dpy, false ); + if ( XCreateWindow_failed ) { + XFree( visinfo ); + XFree( fbconfigs ); + return false; + } + XSetErrorHandler( original_xlib_handler ); + + // Most programs would call XMapWindow here. But we don't, to keep the window hidden + XMapWindow( dpy, xWin ); + + GLXContext context = glXCreateNewContext( dpy, fbconfigs[0], GLX_RGBA_TYPE, NULL, True ); + if ( context == NULL ) { + cerr << "glXCreateNewContext failed\n"; + XDestroyWindow( dpy, xWin ); + XFree( visinfo ); + XFree( fbconfigs ); + return false; + } + + //GLXWindow glxWin = glXCreateWindow( dpy, fbconfigs[0], xWin, NULL ); + + if (!glXMakeContextCurrent( dpy, xWin, xWin, context )) { + //if (!glXMakeContextCurrent( dpy, glxWin, glxWin, context )) { + cerr << "glXMakeContextCurrent failed\n"; + glXDestroyContext( dpy, context ); + XDestroyWindow( dpy, xWin ); + XFree( visinfo ); + XFree( fbconfigs ); + return false; + } + + ctx.openGLContext = context; + ctx.xwindow = xWin; + + XFree( visinfo ); + XFree( fbconfigs ); + + return true; +} + + +Bool create_glx_dummy_context(OffscreenContext &ctx) +{ + // This will alter ctx.openGLContext and ctx.xdisplay and ctx.xwindow if successfull + int major; + int minor; + Bool result = False; + + ctx.xdisplay = XOpenDisplay( NULL ); + if ( ctx.xdisplay == NULL ) { + cerr << "Unable to open a connection to the X server\n"; + return False; + } + + // glxQueryVersion is not always reliable. Use it, but then + // also check to see if GLX 1.3 functions exist + + glXQueryVersion(ctx.xdisplay, &major, &minor); + + if ( major==1 && minor<=2 && glXGetVisualFromFBConfig==NULL ) { + cerr << "Error: GLX version 1.3 functions missing. " + << "Your GLX version: " << major << "." << minor << endl; + } else { + result = create_glx_dummy_window(ctx); + } + + if (!result) XCloseDisplay( ctx.xdisplay ); + return result; +} + +OffscreenContext *create_offscreen_context(int w, int h) +{ + OffscreenContext *ctx = new OffscreenContext; + offscreen_context_init( *ctx, w, h ); + + // before an FBO can be setup, a GLX context must be created + // this call alters ctx->xDisplay and ctx->openGLContext + // and ctx->xwindow if successfull + if (!create_glx_dummy_context( *ctx )) { + return NULL; + } + + // glewInit must come after Context creation and before FBO calls. + GLenum err = glewInit(); + if (GLEW_OK != err) { + cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; + return NULL; + } + // cerr << glew_dump(0); + +/* ctx->fbo = fbo_new(); + if (!fbo_init(ctx->fbo, w, h)) { + cerr << "GL Framebuffer Object init failed; dumping GLEW info" << endl; + return NULL; + }*/ + + return ctx; +} + +bool teardown_offscreen_context(OffscreenContext *ctx) +{ + if (ctx) { + fbo_unbind(ctx->fbo); + fbo_delete(ctx->fbo); + XDestroyWindow( ctx->xdisplay, ctx->xwindow ); + glXDestroyContext( ctx->xdisplay, ctx->openGLContext ); + XCloseDisplay( ctx->xdisplay ); + return true; + } + return false; +} + +/*! + Capture framebuffer from OpenGL and write it to the given filename as PNG. +*/ +bool save_framebuffer(OffscreenContext *ctx, const char *filename) +{ + if (!ctx || !filename) return false; + int samplesPerPixel = 4; // R, G, B and A + GLubyte pixels[ctx->width * ctx->height * samplesPerPixel]; + glReadPixels(0, 0, ctx->width, ctx->height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + + // Flip it vertically - images read from OpenGL buffers are upside-down + int rowBytes = samplesPerPixel * ctx->width; + unsigned char *flippedBuffer = (unsigned char *)malloc(rowBytes * ctx->height); + if (!flippedBuffer) { + cerr << "Unable to allocate flipped buffer for corrected image."; + return 1; + } + flip_image(pixels, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); + + bool writeok = write_png(filename, flippedBuffer, ctx->width, ctx->height); + + free(flippedBuffer); + + return writeok; +} + +void bind_offscreen_context(OffscreenContext *ctx) +{ + if (ctx) fbo_bind(ctx->fbo); +} diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 3756a82..4deaf2a 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -48,7 +48,7 @@ void offscreen_context_init(OffscreenContext &ctx, int width, int height) ctx.fbo = NULL; } -string get_windows_info() +string get_os_info() { OSVERSIONINFO osvi; @@ -81,8 +81,8 @@ string get_windows_info() string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; - out << glew_dump(false); - out << get_windows_info(); + out << "GL context creator: WGL\n" + << get_windows_info(); return out.str(); } diff --git a/tests/OffscreenView.cc b/tests/OffscreenView.cc index 2a4a27e..9c8964c 100644 --- a/tests/OffscreenView.cc +++ b/tests/OffscreenView.cc @@ -1,11 +1,13 @@ #include #include "OffscreenView.h" +#include "system-gl.h" #include #include "renderer.h" #include #include #include #include +#include #define FAR_FAR_AWAY 100000.0 @@ -17,19 +19,6 @@ OffscreenView::OffscreenView(size_t width, size_t height) this->ctx = create_offscreen_context(width, height); if ( this->ctx == NULL ) throw -1; -#ifdef DEBUG - GLint rbits, gbits, bbits, abits, dbits, sbits; - glGetIntegerv(GL_RED_BITS, &rbits); - glGetIntegerv(GL_GREEN_BITS, &gbits); - glGetIntegerv(GL_BLUE_BITS, &bbits); - glGetIntegerv(GL_ALPHA_BITS, &abits); - glGetIntegerv(GL_DEPTH_BITS, &dbits); - glGetIntegerv(GL_STENCIL_BITS, &sbits); - - fprintf(stderr, "FBO: RGBA(%d%d%d%d), depth(%d), stencil(%d)\n", - rbits, gbits, bbits, abits, dbits, sbits); -#endif - initializeGL(); resizeGL(width, height); } @@ -251,7 +240,22 @@ bool OffscreenView::save(const char *filename) std::string OffscreenView::getInfo() { - return offscreen_context_getinfo(this->ctx); + std::stringstream out; + GLint rbits, gbits, bbits, abits, dbits, sbits; + glGetIntegerv(GL_RED_BITS, &rbits); + glGetIntegerv(GL_GREEN_BITS, &gbits); + glGetIntegerv(GL_BLUE_BITS, &bbits); + glGetIntegerv(GL_ALPHA_BITS, &abits); + glGetIntegerv(GL_DEPTH_BITS, &dbits); + glGetIntegerv(GL_STENCIL_BITS, &sbits); + + out << glew_dump(false) + << "FBO: RGBA(" << rbits << gbits << bbits << abits + << "), depth(" << dbits + << "), stencil(" << sbits << ")\n" + << offscreen_context_getinfo(this->ctx); + + return out.str(); } void OffscreenView::setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d ¢er) diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 5866346..9511688 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -76,8 +76,8 @@ AbstractNode *find_root_tag(AbstractNode *n) string info_dump(OffscreenView *glview) { -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) + assert(glview); + #ifdef __GNUG__ #define compiler_info "GCC " << __VERSION__ #elif defined(_MSC_VER) @@ -85,18 +85,26 @@ string info_dump(OffscreenView *glview) #else #define compiler_info "unknown compiler" #endif - assert(glview); + std::stringstream out; out << "OpenSCAD info dump:" - << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." - << int(OPENSCAD_MONTH) << "." + << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." + << int(OPENSCAD_MONTH) << "." #ifdef OPENSCAD_DAY - << int(OPENSCAD_DAY) + << int(OPENSCAD_DAY); #endif - << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) - << "\nCompiled with: " << compiler_info - << "\nGL Context info: \n" << glview->getInfo() - << "\n"; +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) + << "\nCompiled by: " << compiler_info + << "\nBoost version: " << BOOST_LIB_VERSION + << "\nEigen version: " << EIGEN_WORLD_VERSION << "." + << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION + // << "\nCGAL version: " << CGAL_VERSION ??? + // << "\nOpenCSG" << ??? + << "\n" << glview->getInfo() + << "\n"; + return out.str(); } diff --git a/tests/ctest_pretty_print.py b/tests/ctest_pretty_print.py deleted file mode 100755 index 430f106..0000000 --- a/tests/ctest_pretty_print.py +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/python -import string,platform,sys,re,os - -wiki_basepath = 'OpenSCAD' -logfilename = 'LastTest.log' -builddir = os.getcwd() -logpath = os.path.join(builddir,'Testing','Temporary',logfilename) -NO_END = False -if logfilename.endswith('.tmp'): NO_END = True - -def read_sysinfo(): - try: - f=open('sysinfo.txt') - except: - return '' - data=f.read() - machine_str, osplain_str, renderer_str = '','','' - machine = re.search('Machine:(.*?)\n',data) - osinfo = re.search('OS info:(.*?)\n',data) - renderer = re.search('GL Renderer:(.*?)\n',data) - if machine: machine_str = machine.group(1).strip().replace(' ','-').replace('/','-') - if osinfo: - osplain_str = osinfo.group(1).strip().split(' ')[0].strip().replace('/','-') - if 'windows' in osinfo.group(1).lower(): osplain_str = 'win' - if renderer: - tmp = renderer.group(1).strip().split(' ') - tmp = string.join(tmp[0:3],'-') - if '/' in tmp: tmp = tmp.split('/')[0] - renderer_str = tmp - platform = osplain_str + '_' + machine_str + '_' + renderer_str - platform = platform.lower() - return data, platform - -def readlog(): - try: - print 'reading',logpath - f = open(logpath) - except: - print 'couldnt open ',logpath - return None - - data = f.read() - return data - -class Test: - def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): - self.fullname,self.time,self.passed,self.output = \ - fullname, time, passed, output - self.type = type - self.outputfile = outputfile - self.expectedfile = expectedfile - - def __str__(self): - x = 'fullname: ' + self.fullname - x+= '\noutputfile: ' + self.outputfile - x+= '\nexpectedfile: ' + self.expectedfile - x+= '\ntesttime: ' + self.time - x+= '\ntesttype: ' + self.type - x+= '\npassfail: ' + self.passfail - x+= '\noutput: \n' + self.output - x+= '\n' - return x - -def gettest_strings(data): - chunks = data.split('----------------------------------------------------------') - print 'read',len(chunks), 'chunks' - if NO_END: - enddate = 'n/a (cancelled)' - chunks.pop() - else: - enddate = chunks.pop().replace('End testing: ','').strip() - chunks.reverse() - startdate = chunks.pop().replace('Start testing: ','').strip() - chunks.reverse() - tests=[] - chunksize = 3 - for i in range(0,len(chunks),chunksize): - testchunks = chunks[i:i+chunksize] - test = string.join(testchunks,'-----') - tests += [test] - #print '----------<<<<<<<<<<<<<<<<' - #print test - #print '----------<<<<<<<<<<<<<<<<' - test = '' - sysinfo, platform = read_sysinfo() - return startdate, tests, enddate, sysinfo, platform - -def parsetest(teststring): - s = teststring - def regex(pat,str): - x=re.search(pat,str,re.DOTALL|re.MULTILINE) - if x: - if len(x.groups())>0: - return x.group(1).strip() - return '' - testfullname = regex("Test:(.*?)\n",s) - testtime = regex("Test time =(.*?)\n",s).replace(' sec','') - passfail = regex("Test time.*?Test (Passed)",s) - command = regex("Command:(.*?)\n",s) - tmp = command.split(' "') - testtype = '' - try: - testtype = tmp[3].strip('"') - except: - print 'failed to parse log', teststring - goodimg = regex("expected image:(.*?)\n",s) - actualimg = regex("actual image:(.*?)\n",s) - if passfail=='Passed': passed = True - else: passed = False - output = regex("Output:(.*?)",s).replace('-----','') - test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) - return test - -def parse(data): - startdate, test_strs, enddate, sysinfo, platform = gettest_strings(data) - print 'found', len(test_strs),'test results' - tests = [] - for i in range(len(test_strs)): - test = parsetest(test_strs[i]) - tests += [test] - return startdate, tests, enddate, sysinfo, platform - -def towiki(startdate, tests, enddate, sysinfo, platform): - def convert_path(fulltestname,platform,path): - # convert system path name (image file) to wiki path name - testprogram = fulltestname[0:fulltestname.rfind('_')] - testprogram = testprogram.replace('test','') - filename = os.path.basename(path) - filename = filename.replace('-tests-actual.png','.png') - filename = filename.replace('-tests-expected.png','.png') - try: - platform = platform[0].upper() + platform[1:] - except: - platform = 'error' - newpath = testprogram + '_' + filename - # must use _ not / b/c of wikinet.org weird name mangling - newpath = wiki_basepath + '_' + platform + '_' + newpath - return newpath - - x=''' -

OpenSCAD test run

- -platform: PLATFORM - -detailed system info: -
-SYSINFO
-
- -start time: STARTDATE -end time : ENDDATE - -Failed tests - -{|TABLESTYLE -! Testname !! expected output !! actual output -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -|} - -Passed tests - -{|TABLESTYLE -! Testname -|- -| PTESTNAME -|} - -''' - - repeat1=''' -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -''' - - repeat2=''' -|- -| PTESTNAME -''' - - x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') - x = x.replace('STARTDATE',startdate) - x = x.replace('ENDDATE',enddate) - x = x.replace('SYSINFO',sysinfo) - x = x.replace('PLATFORM',platform) - - for t in tests: - print t.type, t.fullname, t.expectedfile, t.outputfile - if t.passed: - tmp = str(repeat2) - tmp = tmp.replace('PTESTNAME',t.fullname) - x = x.replace(repeat2,tmp + repeat2) - elif not t.passed and t.type=='png': - tmp = str(repeat1) - tmp = tmp.replace('FTESTNAME',t.fullname) - - wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) - if t.type!='png': wiki_imgpath1 = '' - if t.expectedfile=='': wiki_imgpath2 = '' - tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) - - wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) - if t.type!='png': wiki_imgpath2 = '' - if t.outputfile=='': wiki_imgpath2 = '' - tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) - - x = x.replace(repeat1,tmp + repeat1) - - x = x.replace(repeat1,'') - x = x.replace(repeat2,'') - return x - -def wikitohtml(data): - # not pretty - data = data.replace('\n\n','\n

\n') - data = re.sub('\{\|.*?\n','\n',data) - data = re.sub('\n\! ','\n\n') - data = re.sub('\n\| ','\n
',data) - data = data.replace(' !! ','') - data = data.replace('|-','
',data) - data = data.replace(' || ','') - data = data.replace('|}','\n
') - data = re.sub('[[File:(.*?)|.*?]]','',data) - return data - -def testsort(tests): - passed = [] - failed = [] - for t in tests: - if t.passed: passed+=[t] - else: failed +=[t] - return failed+passed - -def save(data,filename): - try: - f=open(filename,'w') - except: - print 'couldnt open ',filename, 'for writing' - return None - print 'writing',len(data),'bytes to',filename - f.write(data) - f.close() - -def main(): - data = readlog() - startdate, tests, enddate, sysinfo, platform = parse(data) - tests = testsort(tests) - wikidata = towiki(startdate, tests, enddate, sysinfo, platform) - htmldata = wikitohtml(wikidata) - save(wikidata, platform+'.wiki') - save(htmldata, platform+'.html') - -main() - diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 485a821..3e9f45a 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -64,17 +64,20 @@ def compare_text(expected, actual): return get_normalized_text(expected) == get_normalized_text(actual) def compare_default(resultfilename): + print >> sys.stderr, 'diff text compare: ' + print >> sys.stderr, ' expected textfile: ', expectedfilename + print >> sys.stderr, ' actual textfile: ', resultfilename if not compare_text(expectedfilename, resultfilename): execute_and_redirect("diff", [expectedfilename, resultfilename], sys.stderr) return False return True def compare_png(resultfilename): + print >> sys.stderr, 'Yee image compare:' + print >> sys.stderr, ' expected image: ', expectedfilename if not resultfilename: - print >> sys.stderr, "Error: OpenSCAD did not generate an image" + print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" return False - print >> sys.stderr, 'Yee image compare: ' - print >> sys.stderr, ' expected image: ', expectedfilename print >> sys.stderr, ' actual image: ', resultfilename if execute_and_redirect("./yee_compare", [expectedfilename, resultfilename, "-downsample", "2", "-threshold", "300"], sys.stderr) != 0: return False diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py new file mode 100755 index 0000000..6bc3f54 --- /dev/null +++ b/tests/test_pretty_print.py @@ -0,0 +1,266 @@ +#!/usr/bin/python +# +# this program reads the ctest logfiles from builddir/Testing/Temporary +# and generates two 'pretty printed' outputs in that directory: +# +# 1. mediawiki format, for uploading to a wiki. +# automated uploading is available by following these steps: +# +# download mwclient +# python ctest_pretty_print.py --upload +# +# 2. html format, for easy local viewing +# +# sysinfo.txt: +# sysinfo.txt should have been created by ctest by the main test run. +# it is the output of opencsgtest --info + + +# todo +# 1. add sysinfo about ... git branch +# 2. consolidate image flip +# 3. uploading, can it be done in one file +# 4. consolidate pretty print + +import string,sys,re,os,hashlib,subprocess + +def tryread(filename): + data = None + try: + print 'reading', filename + f = open(filename) + data = f.read() + f.close() + except: + print 'couldn\'t open ',filename + return data + +def trysave(data,filename): + try: + f=open(filename,'w') + print 'writing',len(data),'bytes to',filename + f.write(data) + f.close() + except: + print 'problem writing to',filename + return None + return True + +def ezsearch(pattern,str): + x = re.search(pattern,str,re.DOTALL|re.MULTILINE) + if x and len(x.groups())>0: return x.group(1).strip() + return '' + +def read_gitinfo(): + # won't work if run from outside of branch. + data = subprocess.Popen(['git','remote','-v'],stdout=subprocess.PIPE).stdout.read() + origin = ezsearch('^origin *?(.*?)\(fetch.*?$',data) + upstream = ezsearch('^upstream *?(.*?)\(fetch.*?$',data) + data = subprocess.Popen(['git','branch'],stdout=subprocess.PIPE).stdout.read() + branch = ezsearch('^\*(.*?)$',data) + out = 'Git branch: ' + branch + ' from origin ' + origin + '\n' + out += 'Git upstream: ' + upstream + '\n' + return out + +def read_sysinfo(filename): + data = tryread(filename) + if not data: return 'sysinfo: unknown' + + machine = ezsearch('Machine:(.*?)\n',data) + machine = machine.replace(' ','-').replace('/','-') + + osinfo = ezsearch('OS info:(.*?)\n',data) + osplain = osinfo.split(' ')[0].strip().replace('/','-') + if 'windows' in osinfo.lower(): osplain = 'win' + + renderer = ezsearch('GL Renderer:(.*?)\n',data) + tmp = renderer.split(' ') + tmp = string.join(tmp[0:3],'-') + tmp = tmp.split('/')[0] + renderer = tmp + + hasher = hashlib.md5() + hasher.update(data) + hexhash = hasher.hexdigest()[-4:].upper() + # make all letters for aesthetic reasons + hash = '' + for c in hexhash: hash += chr(ord(c)+97-48) + + sysid = osplain + '_' + machine + '_' + renderer + '_' + hash + sysid = sysid.lower() + + data += read_gitinfo() + + return data, sysid + +class Test: + def __init__(self,fullname,time,passed,output,type,actualfile,expectedfile,scadfile): + self.fullname,self.time,self.passed,self.output = \ + fullname, time, passed, output + self.type, self.actualfile, self.expectedfile, self.scadfile = \ + type, actualfile, expectedfile, scadfile + + def __str__(self): + x = 'fullname: ' + self.fullname + x+= '\nactualfile: ' + self.actualfile + x+= '\nexpectedfile: ' + self.expectedfile + x+= '\ntesttime: ' + self.time + x+= '\ntesttype: ' + self.type + x+= '\npassed: ' + str(self.passed) + x+= '\nscadfile: ' + self.scadfile + x+= '\noutput bytes: ' + str(len(self.output)) + x+= '\n' + return x + +def parsetest(teststring): + patterns = ["Test:(.*?)\n", # fullname + "Test time =(.*?) sec\n", + "Test time.*?Test (Passed)", + "Output:(.*?)", + 'Command:.*?-s" "(.*?)"', # type + "actual .*?:(.*?)\n", + "expected .*?:(.*?)\n", + 'Command:.*?(testdata.*?)"' # scadfile + ] + hits = map( lambda pattern: ezsearch(pattern,teststring), patterns ) + test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7]) + return test + +def parselog(data): + startdate = ezsearch('Start testing: (.*?)\n',data) + enddate = ezsearch('End testing: (.*?)\n',data) + pattern = '([0-9]*/[0-9]* Testing:.*?time elapsed.*?\n)' + test_chunks = re.findall(pattern,data,re.S) + tests = map( parsetest, test_chunks ) + print 'found', len(tests),'test results' + return startdate, tests, enddate + +def wikify_filename(testname,filename,sysid): + # translate from local system to wiki style filename. + result = wiki_rootpath+'_'+testname+'_' + expected = ezsearch('(expected....$)',filename) + if expected!='': result += expected + actual = ezsearch(os.sep+'.*?-output.*?(actual.*)',filename) + if actual!='': + result += sysid+'_'+actual + return result.replace('/','_') + + +def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog): + wiki_template = ''' +

OpenSCAD test run

+ +sysid: SYSID + +detailed system info: +
+SYSINFO
+
+ +start time: STARTDATE +end time : ENDDATE + +Failed image tests + +{|border=1 cellspacing=0 cellpadding=1 align="center" +! Testname !! expected output !! actual output + +|- +| FTESTNAME || [[File:EXPECTEDFILE|thumb|250px]] || ACTUALFILE_WIKI + +|} + +Failed text tests (see test log, below, for diff output) + +{|border=1 cellspacing=0 cellpadding=1 align="center" + +|- +| FTESTNAME + +|} + +Passed tests + +{|border=1 cellspacing=0 cellpadding=1 align="center" +! Testname + +|- +| PTESTNAME + +|} + +LastTest.log + +
+LASTTESTLOG
+
+ +''' + manifest = {} + s = wiki_template + repeat1 = ezsearch('(.*?)',s) + repeat2 = ezsearch('(.*?)',s) + repeat3 = ezsearch('(.*?)',s) + dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, + 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog } + for key in dic.keys(): + s = re.sub(key,dic[key],s) + for t in tests: + print t.passed, t.type, t.fullname, t.expectedfile, t.actualfile + manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) + manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) + if t.passed: + newchunk = re.sub('PTESTNAME',t.fullname,repeat3) + s = s.replace(repeat3, newchunk+repeat3) + elif not t.passed and t.type=='txt': + newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) + newchunk = re.sub('FTESTNAME',t.fullname,repeat2) + s = s.replace(repeat2, newchunk+repeat2) + elif not t.passed and t.type=='png': + if t.actualfile: + actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|thumb|250px]]' + else: + actualfile_wiki = 'No file generated. See test output for more info' + newchunk = re.sub('FTESTNAME',t.fullname,repeat1) + newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) + newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) + s = s.replace(repeat1, newchunk+repeat1) + s = s.replace(repeat1,'') + s = s.replace(repeat2,'') + s = s.replace(repeat3,'') + s = re.sub('\n','',s) + s = re.sub('','',s) + return manifest, s + +def wikitohtml(data): + # not pretty + data = data.replace('\n\n','\n

\n') + data = re.sub('\{\|.*?\n','\n',data) + data = re.sub('\n\! ','\n\n') + data = re.sub('\n\| ','\n
',data) + data = data.replace(' !! ','') + data = data.replace('|-','
',data) + data = data.replace(' || ','') + data = data.replace('|}','\n
') + data = re.sub('[[File:(.*?)|.*?]]','',data) + return data + +wiki_rootpath = 'OpenSCAD' +builddir = os.getcwd() +logpath = os.path.join(builddir,'Testing','Temporary') +logfilename = os.path.join(logpath,'LastTest.log') + +def main(): + testlog = tryread(logfilename) + startdate, tests, enddate = parselog(testlog) + tests = sorted(tests, key = lambda t:t.passed) + sysinfo, sysid = read_sysinfo('sysinfo.txt') + manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) + htmldata = wikitohtml(wikidata) + #save(wikidata, os.path.join(logpath,sysid+'.wiki')) + #save(htmldata, os.path.join(logpath,sysid+'.html')) + trysave(wikidata, sysid+'.wiki') + trysave(htmldata, sysid+'.html') + +main() + -- cgit v0.10.1 From 1aa73df3b86a853469e8938fdc51388011bab961 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 16 Nov 2011 21:36:58 -0600 Subject: improve info report. add auto-uploading ability for wiki data/images diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index 7d95481..5a6a8ec 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -20,6 +20,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; out << "GL context creator: Cocoa / CGL\n" + << "PNG generator: Core Foundation\n" << "OS info: Mac OSX\n" << "Machine: Apple(TM) Mac(TM)\n"; return out.str(); diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index ed9ef46..0817ce2 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -100,6 +100,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) stringstream out; out << "GL context creator: GLX\n" + << "PNG generator: lodepng\n" << "GLX version: " << major << "." << minor << "\n" << get_os_info(); @@ -139,7 +140,8 @@ bool create_glx_dummy_window(OffscreenContext &ctx) GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, - GLX_DEPTH_SIZE, 1, + GLX_ALPHA_SIZE, 1, // extra stuff for fbo-disbaled on-screen testing. + GLX_DEPTH_SIZE, 24, None }; @@ -178,7 +180,6 @@ bool create_glx_dummy_window(OffscreenContext &ctx) // Window xWin = XCreateSimpleWindow( dpy, DefaultRootWindow(dpy), 0,0,42,42, 0,0,0 ); - XSync( dpy, false ); if ( XCreateWindow_failed ) { XFree( visinfo ); diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 4deaf2a..ba12a4f 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -82,6 +82,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; out << "GL context creator: WGL\n" + out << "PNG generator: lodepng\n" << get_windows_info(); return out.str(); } diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 9511688..a3d5097 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -87,16 +87,11 @@ string info_dump(OffscreenView *glview) #endif std::stringstream out; - out << "OpenSCAD info dump:" - << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." - << int(OPENSCAD_MONTH) << "." -#ifdef OPENSCAD_DAY - << int(OPENSCAD_DAY); -#endif #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) - << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) + out << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) << "\nCompiled by: " << compiler_info + << "\nCompile date: " << __DATE__ << "\nBoost version: " << BOOST_LIB_VERSION << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6bc3f54..c4b5c6c 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -1,26 +1,14 @@ #!/usr/bin/python # -# this program reads the ctest logfiles from builddir/Testing/Temporary -# and generates two 'pretty printed' outputs in that directory: -# -# 1. mediawiki format, for uploading to a wiki. -# automated uploading is available by following these steps: +# This program 'pretty prints' the ctest output, namely +# files from builddir/Testing/Temporary. +# html & wiki output are produced +# wiki uploading is available by running # -# download mwclient -# python ctest_pretty_print.py --upload -# -# 2. html format, for easy local viewing -# -# sysinfo.txt: -# sysinfo.txt should have been created by ctest by the main test run. -# it is the output of opencsgtest --info - +# python test_pretty_print.py --upload # todo -# 1. add sysinfo about ... git branch -# 2. consolidate image flip -# 3. uploading, can it be done in one file -# 4. consolidate pretty print +# ban opencsg<2.0 from opencsgtest import string,sys,re,os,hashlib,subprocess @@ -79,10 +67,9 @@ def read_sysinfo(filename): tmp = tmp.split('/')[0] renderer = tmp - hasher = hashlib.md5() - hasher.update(data) - hexhash = hasher.hexdigest()[-4:].upper() - # make all letters for aesthetic reasons + hexhash = hashlib.md5() + hexhash.update(data) + hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) @@ -91,14 +78,16 @@ def read_sysinfo(filename): data += read_gitinfo() + data += 'Image comparison: PerceptualDiff' return data, sysid class Test: - def __init__(self,fullname,time,passed,output,type,actualfile,expectedfile,scadfile): + def __init__(self,fullname,time,passed,output,type,actualfile,expectedfile,scadfile,log): self.fullname,self.time,self.passed,self.output = \ fullname, time, passed, output self.type, self.actualfile, self.expectedfile, self.scadfile = \ type, actualfile, expectedfile, scadfile + self.fulltestlog = log def __str__(self): x = 'fullname: ' + self.fullname @@ -109,6 +98,7 @@ class Test: x+= '\npassed: ' + str(self.passed) x+= '\nscadfile: ' + self.scadfile x+= '\noutput bytes: ' + str(len(self.output)) + x+= '\ntestlog bytes: ' + str(len(self.fulltestlog)) x+= '\n' return x @@ -123,7 +113,7 @@ def parsetest(teststring): 'Command:.*?(testdata.*?)"' # scadfile ] hits = map( lambda pattern: ezsearch(pattern,teststring), patterns ) - test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7]) + test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7],teststring) return test def parselog(data): @@ -147,22 +137,24 @@ def wikify_filename(testname,filename,sysid): def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog): - wiki_template = ''' -

OpenSCAD test run

+ wiki_template = """ +

[[WIKI_ROOTPATH]] test run report

-sysid: SYSID +'''Sysid''': SYSID -detailed system info: +'''Result summary''': NUMPASSED / NUMTESTS tests passed ( PERCENTPASSED % )
+ +'''System info''':
 SYSINFO
 
-start time: STARTDATE -end time : ENDDATE +start time: STARTDATE
+end time : ENDDATE
-Failed image tests +'''Failed image tests''' -{|border=1 cellspacing=0 cellpadding=1 align="center" +{| border=1 cellspacing=0 cellpadding=1 ! Testname !! expected output !! actual output |- @@ -170,81 +162,134 @@ Failed image tests |} -Failed text tests (see test log, below, for diff output) +'''Failed text tests''' -{|border=1 cellspacing=0 cellpadding=1 align="center" +{|border=1 cellspacing=0 cellpadding=1 +! Testname |- | FTESTNAME |} -Passed tests +'''Test logs''' -{|border=1 cellspacing=0 cellpadding=1 align="center" -! Testname - -|- -| PTESTNAME - -|} - -LastTest.log +(excerpted from Testing/Temporary/LastTest.Log)
-LASTTESTLOG
+FAILED_TESTLOGS
 
-''' +""" + numpassed = len(filter(lambda x: x.passed, tests)) + percent = str(int(100.0*numpassed / len(tests))) manifest = {} s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) - repeat3 = ezsearch('(.*?)',s) - dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, - 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog } + dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, + 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog, + 'NUMTESTS':len(tests), 'NUMPASSED':numpassed, 'PERCENTPASSED':percent } for key in dic.keys(): - s = re.sub(key,dic[key],s) + s = re.sub(key,str(dic[key]),s) + testlogs = '' for t in tests: - print t.passed, t.type, t.fullname, t.expectedfile, t.actualfile - manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) - manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) - if t.passed: - newchunk = re.sub('PTESTNAME',t.fullname,repeat3) - s = s.replace(repeat3, newchunk+repeat3) - elif not t.passed and t.type=='txt': - newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) - newchunk = re.sub('FTESTNAME',t.fullname,repeat2) - s = s.replace(repeat2, newchunk+repeat2) - elif not t.passed and t.type=='png': - if t.actualfile: - actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|thumb|250px]]' - else: - actualfile_wiki = 'No file generated. See test output for more info' - newchunk = re.sub('FTESTNAME',t.fullname,repeat1) - newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) - newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) - s = s.replace(repeat1, newchunk+repeat1) + # if t.passed: noop + if not t.passed: + testlogs += '\n\n'+t.fulltestlog + if t.type=='txt': + newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) + newchunk = re.sub('FTESTNAME',t.fullname,repeat2) + s = s.replace(repeat2, newchunk+repeat2) + elif t.type=='png': + manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) + manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) + if t.actualfile: + actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|thumb|250px]]' + else: + actualfile_wiki = 'No file generated.
See log for details' + newchunk = re.sub('FTESTNAME',t.fullname,repeat1) + newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) + newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) + s = s.replace(repeat1, newchunk+repeat1) + s = s.replace('FAILED_TESTLOGS',testlogs) s = s.replace(repeat1,'') s = s.replace(repeat2,'') - s = s.replace(repeat3,'') s = re.sub('\n','',s) s = re.sub('','',s) return manifest, s -def wikitohtml(data): - # not pretty - data = data.replace('\n\n','\n

\n') - data = re.sub('\{\|.*?\n','\n',data) - data = re.sub('\n\! ','\n\n') - data = re.sub('\n\| ','\n
',data) - data = data.replace(' !! ','') - data = data.replace('|-','
',data) - data = data.replace(' || ','') - data = data.replace('|}','\n
') - data = re.sub('[[File:(.*?)|.*?]]','',data) - return data +def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): + head = ''+wiki_rootpath+' test run for '+sysid +'' + revmanifest = dict((val,key) for key, val in manifest.iteritems()) + x=re.sub('\{\|(.*?)\n','\n',wikidata) + x=re.sub("'''(.*?)'''","\\1",x) + filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) + for f in filestrs: + newfile_html='' + x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) + dic = { '|}':'
', '|-':'', '||':'', '|':'', + '!!':'', '!':'', '\n\n':'\n

\n'} #order matters + for key in dic: x=x.replace(key,dic[key]) + x=re.sub("\[\[(.*?)\]\]","\\1",x) + return head + x + '' + +def upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass): + print 'dry run. no files to be uploaded' + print 'log in', wikiurl, api_php_path, botname, botpass + print 'save ' + '*[['+wiki_rootpath+sysid+']]' + ' to page ' + wiki_rootpath + print 'save ', len(wikidata), ' bytes to page ',wiki_rootpath+sysid + for localfile in manifest.keys(): + if localfile: + localf=open(localfile) + wikifile = manifest[localfile] + print 'upload',localfile,wikifile + +def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True): + if dryrun: + upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass) + return None + try: + import mwclient + except: + print 'please download mwclient and unpack here:', os.cwd() + print 'open site',wikiurl + if not api_php_path == '': + site = mwclient.Site(wikiurl,api_php_path) + else: + site = mwclient.Site(wikiurl) + + print 'bot login' + site.login(botname,botpass) + + print 'edit ',wiki_rootpath + page = site.Pages[wiki_rootpath] + text = page.edit() + rootpage = wiki_rootpath + sysid + if not '[['+rootpage+']]' in text: + page.save(text +'\n*[['+rootpage+']]\n') + + print 'upload wiki data to',rootpage + page = site.Pages[rootpage] + text = page.edit() + page.save(wikidata) + + print 'upload images' + for localfile in sorted(manifest.keys()): + if localfile: + localf=open(localfile) + wikifile = manifest[localfile] + skip=False + if 'expected.png' in wikifile.lower(): + image = site.Images[wikifile] + if image.exists: + print 'skipping ',wikifile, '(expected image, already on wiki)' + skip=True + if not skip: + print wikifile,'...' + site.upload(localf,wikifile,wiki_rootpath + ' test') +wikisite = 'cakebaby.referata.com' wiki_rootpath = 'OpenSCAD' builddir = os.getcwd() logpath = os.path.join(builddir,'Testing','Temporary') @@ -256,11 +301,10 @@ def main(): tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) - htmldata = wikitohtml(wikidata) - #save(wikidata, os.path.join(logpath,sysid+'.wiki')) - #save(htmldata, os.path.join(logpath,sysid+'.html')) - trysave(wikidata, sysid+'.wiki') - trysave(htmldata, sysid+'.html') - + trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) + htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) + trysave(htmldata, os.path.join(logpath,sysid+'.html')) + if '--upload' in sys.argv: + upload(wikisite,'',wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False) main() -- cgit v0.10.1 From e31bb0f60312e692f5ef57fd3823e413cc8a669c Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 16 Nov 2011 21:42:08 -0600 Subject: make use FBO without stencil buffer diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index 0817ce2..3523021 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -189,7 +189,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx) XSetErrorHandler( original_xlib_handler ); // Most programs would call XMapWindow here. But we don't, to keep the window hidden - XMapWindow( dpy, xWin ); + // XMapWindow( dpy, xWin ); GLXContext context = glXCreateNewContext( dpy, fbconfigs[0], GLX_RGBA_TYPE, NULL, True ); if ( context == NULL ) { -- cgit v0.10.1 From 03442e31241a859701c9efaf7525c9752444fa9f Mon Sep 17 00:00:00 2001 From: Don Bright Date: Mon, 21 Nov 2011 20:28:35 -0600 Subject: fixing GLX setup diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index 3523021..41f01f7 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -137,11 +137,12 @@ bool create_glx_dummy_window(OffscreenContext &ctx) int attributes[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, // extra stuff for fbo-disbaled on-screen testing. + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_ALPHA_SIZE, 8, // extra stuff for fbo-disbaled on-screen testing. GLX_DEPTH_SIZE, 24, + GLX_STENCIL_SIZE, 8, None }; @@ -271,11 +272,11 @@ OffscreenContext *create_offscreen_context(int w, int h) } // cerr << glew_dump(0); -/* ctx->fbo = fbo_new(); + ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { cerr << "GL Framebuffer Object init failed; dumping GLEW info" << endl; return NULL; - }*/ + } return ctx; } diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc index bfa92da..cc747fb 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -190,16 +190,19 @@ int main(int argc, char **argv) BoundingBox bbox; if (cgalRenderer.polyhedron) { + std::cout << "polyhedron\n" ; CGAL::Bbox_3 cgalbbox = cgalRenderer.polyhedron->bbox(); bbox = BoundingBox(Vector3d(cgalbbox.xmin(), cgalbbox.ymin(), cgalbbox.zmin()), Vector3d(cgalbbox.xmax(), cgalbbox.ymax(), cgalbbox.zmax())); } else if (cgalRenderer.polyset) { + std::cout << "polyset\n" ; bbox = cgalRenderer.polyset->getBoundingBox(); } Vector3d center = getBoundingCenter(bbox); double radius = getBoundingRadius(bbox); + std::cout << "radius: " << radius << "\n"; Vector3d cameradir(1, 1, -0.5); Vector3d camerapos = center - radius*2*cameradir; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index c4b5c6c..fce17f5 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -9,6 +9,11 @@ # todo # ban opencsg<2.0 from opencsgtest +# copy all images, sysinfo.txt to bundle for html/upload (images +# can be altered by subsequent runs) +# figure out hwo to make the thing run after the test +# figure out how CTEST treats the logfiles. +# why is hash differing import string,sys,re,os,hashlib,subprocess -- cgit v0.10.1 From cea502f9a3531888dbbb55099421fb1ab565f2c1 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 22 Nov 2011 20:31:57 -0600 Subject: tweak and fix Stencilbuffer setup. diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index 41f01f7..e607593 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -135,14 +135,15 @@ bool create_glx_dummy_window(OffscreenContext &ctx) */ int attributes[] = { - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT, //support all 3, for OpenCSG GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, - GLX_ALPHA_SIZE, 8, // extra stuff for fbo-disbaled on-screen testing. - GLX_DEPTH_SIZE, 24, + GLX_ALPHA_SIZE, 8, + GLX_DEPTH_SIZE, 24, // depth-stencil for OpenCSG GLX_STENCIL_SIZE, 8, + GLX_DOUBLEBUFFER, True, None }; @@ -169,6 +170,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx) XSetWindowAttributes xwin_attr; int width = ctx.width; int height = ctx.height; + xwin_attr.background_pixmap = None; xwin_attr.background_pixel = 0; xwin_attr.border_pixel = 0; xwin_attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); @@ -270,7 +272,6 @@ OffscreenContext *create_offscreen_context(int w, int h) cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; return NULL; } - // cerr << glew_dump(0); ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { @@ -299,6 +300,7 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { + glXSwapBuffers(ctx->xdisplay, ctx->xwindow); if (!ctx || !filename) return false; int samplesPerPixel = 4; // R, G, B and A GLubyte pixels[ctx->width * ctx->height * samplesPerPixel]; diff --git a/tests/fbo.cc b/tests/fbo.cc index 2f933d7..a6677c1 100644 --- a/tests/fbo.cc +++ b/tests/fbo.cc @@ -144,7 +144,11 @@ bool fbo_arb_init(fbo_t *fbo, size_t width, size_t height) } //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + // to prevent Mesa's software renderer from crashing, do this in two stages. + // ie. instead of using GL_DEPTH_STENCIL_ATTACHMENT, do DEPTH then STENCIL. + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_RENDERBUFFER, fbo->depthbuf_id); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo->depthbuf_id); if (report_glerror("specifying depth stencil render buffer")) return false; @@ -183,7 +187,7 @@ bool fbo_resize(fbo_t *fbo, size_t width, size_t height) { if (use_ext()) { glBindRenderbufferEXT(GL_RENDERBUFFER, fbo->depthbuf_id); - if (0) { // glewIsSupported("GL_EXT_packed_depth_stencil")) { + if (glewIsSupported("GL_EXT_packed_depth_stencil")) { glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); if (report_glerror("creating EXT depth stencil render buffer")) return false; } @@ -196,14 +200,14 @@ bool fbo_resize(fbo_t *fbo, size_t width, size_t height) glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA8, width, height); if (report_glerror("creating EXT color render buffer")) return false; } else { - glBindRenderbuffer(GL_RENDERBUFFER, fbo->depthbuf_id); - //glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height); - if (report_glerror("creating depth stencil render buffer")) return false; - glBindRenderbuffer(GL_RENDERBUFFER, fbo->renderbuf_id); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, width, height); if (report_glerror("creating color render buffer")) return false; + + glBindRenderbuffer(GL_RENDERBUFFER, fbo->depthbuf_id); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + if (report_glerror("creating depth stencil render buffer")) return false; + } return true; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index fce17f5..897f7b8 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -14,6 +14,10 @@ # figure out hwo to make the thing run after the test # figure out how CTEST treats the logfiles. # why is hash differing +# instead of having special '-info' prerun, put it as yet-another-test +# and parse the log +# provide option to replace 'expected' images on wiki +# (yes sometimes you do need to change/update them) import string,sys,re,os,hashlib,subprocess @@ -83,7 +87,7 @@ def read_sysinfo(filename): data += read_gitinfo() - data += 'Image comparison: PerceptualDiff' + data += 'Image comparison: PerceptualDiff by H. Yee' return data, sysid class Test: @@ -293,7 +297,8 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo skip=True if not skip: print wikifile,'...' - site.upload(localf,wikifile,wiki_rootpath + ' test') + site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) + wikisite = 'cakebaby.referata.com' wiki_rootpath = 'OpenSCAD' builddir = os.getcwd() @@ -305,6 +310,7 @@ def main(): startdate, tests, enddate = parselog(testlog) tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') + if '--hack' in sys.argv: sysid+='_hack' manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) -- cgit v0.10.1 From aa8d53614a1a8aa16d076a3346d781cb3dc797e2 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 22 Nov 2011 22:45:37 -0600 Subject: fix stencil code for windows. tweak pretty printer for windows diff --git a/doc/testing.txt b/doc/testing.txt index b2974fc..f90aca8 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -25,12 +25,11 @@ cmake .. nmake -f Makefile nmake -f Makefile test -Running on headless (no X) servers: +Running on headless (no X) unix servers: Xvnc :5 -screen 0 800x600x24 & DISPLAY=:5 make test - Adding a new regression test: ------------------------------ diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index ba12a4f..f36671c 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -82,8 +82,8 @@ string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; out << "GL context creator: WGL\n" - out << "PNG generator: lodepng\n" - << get_windows_info(); + << "PNG generator: lodepng\n" + << get_os_info(); return out.str(); } @@ -130,11 +130,15 @@ bool create_wgl_dummy_context(OffscreenContext &ctx) ZeroMemory( &pixformat, sizeof( pixformat ) ); pixformat.nSize = sizeof( pixformat ); pixformat.nVersion = 1; - pixformat.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + pixformat.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pixformat.iPixelType = PFD_TYPE_RGBA; - pixformat.cColorBits = 24; - pixformat.cDepthBits = 16; - pixformat.iLayerType = PFD_MAIN_PLANE; + pixformat.cGreenBits = 8; + pixformat.cRedBits = 8; + pixformat.cBlueBits = 8; + pixformat.cAlphaBits = 8; + pixformat.cDepthBits = 24; + pixformat.cStencilBits = 8; + chosenformat = ChoosePixelFormat( dev_context, &pixformat ); if (chosenformat==0) { cerr << "MS GDI - ChoosePixelFormat failed\n"; @@ -215,6 +219,7 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { + wglSwapLayerBuffers( ctx->dev_context, WGL_SWAP_MAIN_PLANE ); if (!ctx || !filename) return false; int samplesPerPixel = 4; // R, G, B and A vector pixels(ctx->width * ctx->height * samplesPerPixel); diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 3e9f45a..40aa4d6 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -35,6 +35,7 @@ def init_expected_filename(testname, cmd): global expecteddir, expectedfilename expecteddir = os.path.join(options.regressiondir, os.path.split(cmd)[1]) expectedfilename = os.path.join(expecteddir, testname + "-expected." + options.suffix) + expectedfilename = os.path.normpath( expectedfilename ) def verify_test(testname, cmd): global expectedfilename diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 897f7b8..8ba0512 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -196,11 +196,11 @@ FAILED_TESTLOGS s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) - dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, - 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog, - 'NUMTESTS':len(tests), 'NUMPASSED':numpassed, 'PERCENTPASSED':percent } + dic = { 'STARTDATE': str(startdate), 'ENDDATE': str(enddate), 'WIKI_ROOTPATH': str(wiki_rootpath), + 'SYSINFO': str(sysinfo), 'SYSID':str(sysid), 'LASTTESTLOG':str(testlog), + 'NUMTESTS':str(len(tests)), 'NUMPASSED':str(numpassed), 'PERCENTPASSED':str(percent) } for key in dic.keys(): - s = re.sub(key,str(dic[key]),s) + s = s.replace(key,dic[key]) testlogs = '' for t in tests: # if t.passed: noop @@ -236,7 +236,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: - newfile_html='' + newfile_html='' x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) dic = { '|}':'', '|-':'', '||':'', '|':'', '!!':'', '!':'', '\n\n':'\n

\n'} #order matters @@ -262,7 +262,7 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo try: import mwclient except: - print 'please download mwclient and unpack here:', os.cwd() + print 'please download mwclient and unpack here:', os.getcwd() print 'open site',wikiurl if not api_php_path == '': site = mwclient.Site(wikiurl,api_php_path) @@ -287,7 +287,7 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo print 'upload images' for localfile in sorted(manifest.keys()): if localfile: - localf=open(localfile) + localf = open(localfile,'rb') wikifile = manifest[localfile] skip=False if 'expected.png' in wikifile.lower(): -- cgit v0.10.1 From 29783dc4aa6e44221c9a584c2651624a93dfcf9a Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 21:47:33 -0600 Subject: patch for opencsg1.3.1 and add --forceupload option to pretty printer diff --git a/patches/OpenCSG-1.3.1-FBO.patch b/patches/OpenCSG-1.3.1-FBO.patch new file mode 100644 index 0000000..234992d --- /dev/null +++ b/patches/OpenCSG-1.3.1-FBO.patch @@ -0,0 +1,117 @@ +Only in OpenCSG-1.3.1-fbo-patch/: lib +diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp +--- OpenCSG-1.3.1/src/frameBufferObject.cpp 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp 2011-11-23 21:42:42.709641637 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -59,6 +59,7 @@ + glGenRenderbuffers(1, &depthID); + glGenTextures(1, &textureID); + ++ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFramebufferID); + glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); + glBindTexture(GL_TEXTURE_2D, textureID); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); +@@ -78,7 +79,7 @@ + return false; + } + +- glBindFramebuffer(GL_FRAMEBUFFER, 0); ++ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); + glBindTexture(GL_TEXTURE_2D, 0); + + textureTarget = GL_TEXTURE_2D; +Only in OpenCSG-1.3.1-fbo-patch/src: frameBufferObject.cpp~ +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp +--- OpenCSG-1.3.1/src/frameBufferObjectExt.cpp 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp 2011-11-23 21:07:00.073641732 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -60,6 +60,7 @@ + glGenRenderbuffersEXT(1, &depthID); + glGenTextures(1, &textureID); + ++ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &oldFramebufferID); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID); + glBindTexture(GL_TEXTURE_2D, textureID); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); +@@ -79,7 +80,7 @@ + return false; + } + +- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); ++ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); + glBindTexture(GL_TEXTURE_2D, 0); + + textureTarget = GL_TEXTURE_2D; +@@ -136,7 +137,7 @@ + // Unbinds frame buffer texture. + bool FrameBufferObjectExt::EndCapture() + { +- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); ++ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); + return true; + } + +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h +--- OpenCSG-1.3.1/src/frameBufferObjectExt.h 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h 2011-11-23 21:07:15.529642039 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -85,6 +85,7 @@ + unsigned int depthID; + + unsigned int framebufferID; ++ int oldFramebufferID; + + bool initialized; + }; +diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h +--- OpenCSG-1.3.1/src/frameBufferObject.h 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h 2011-11-23 21:37:07.565641308 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -85,6 +85,7 @@ + unsigned int depthID; + + unsigned int framebufferID; ++ int oldFramebufferID; + + bool initialized; + }; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 8ba0512..ffc74eb 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -10,14 +10,12 @@ # todo # ban opencsg<2.0 from opencsgtest # copy all images, sysinfo.txt to bundle for html/upload (images -# can be altered by subsequent runs) +# can be altered by subsequent runs) # figure out hwo to make the thing run after the test # figure out how CTEST treats the logfiles. # why is hash differing # instead of having special '-info' prerun, put it as yet-another-test # and parse the log -# provide option to replace 'expected' images on wiki -# (yes sometimes you do need to change/update them) import string,sys,re,os,hashlib,subprocess @@ -196,11 +194,11 @@ FAILED_TESTLOGS s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) - dic = { 'STARTDATE': str(startdate), 'ENDDATE': str(enddate), 'WIKI_ROOTPATH': str(wiki_rootpath), - 'SYSINFO': str(sysinfo), 'SYSID':str(sysid), 'LASTTESTLOG':str(testlog), - 'NUMTESTS':str(len(tests)), 'NUMPASSED':str(numpassed), 'PERCENTPASSED':str(percent) } + dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, + 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog, + 'NUMTESTS':len(tests), 'NUMPASSED':numpassed, 'PERCENTPASSED':percent } for key in dic.keys(): - s = s.replace(key,dic[key]) + s = re.sub(key,str(dic[key]),s) testlogs = '' for t in tests: # if t.passed: noop @@ -236,7 +234,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: - newfile_html='' + newfile_html='' x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) dic = { '|}':'', '|-':'', '||':'', '|':'', '!!':'', '!':'', '\n\n':'\n

\n'} #order matters @@ -255,14 +253,14 @@ def upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,bot wikifile = manifest[localfile] print 'upload',localfile,wikifile -def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True): +def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True,forceupload=False): if dryrun: upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass) return None try: import mwclient except: - print 'please download mwclient and unpack here:', os.getcwd() + print 'please download mwclient and unpack here:', os.cwd() print 'open site',wikiurl if not api_php_path == '': site = mwclient.Site(wikiurl,api_php_path) @@ -287,16 +285,16 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo print 'upload images' for localfile in sorted(manifest.keys()): if localfile: - localf = open(localfile,'rb') + localf = open(localfile) wikifile = manifest[localfile] skip=False if 'expected.png' in wikifile.lower(): image = site.Images[wikifile] - if image.exists: - print 'skipping ',wikifile, '(expected image, already on wiki)' + if image.exists and forceupload==False: + print 'skipping ',wikifile, '(image with same name and size ',localsize,'already on wiki)' skip=True if not skip: - print wikifile,'...' + print 'uploading',wikifile,'...' site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) wikisite = 'cakebaby.referata.com' @@ -310,8 +308,9 @@ def main(): startdate, tests, enddate = parselog(testlog) tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') - if '--hack' in sys.argv: sysid+='_hack' - manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) + if '--forceupload' in sys.argv: forceupload=True + else: forceupload=False + manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog, forceupload) trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) trysave(htmldata, os.path.join(logpath,sysid+'.html')) -- cgit v0.10.1 From 6c4b5bd3668467a9a65b6476440ba27d871d3037 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 22:22:33 -0600 Subject: tweak patch, tweak pretty print diff --git a/patches/OpenCSG-1.3.1-FBO.patch b/patches/OpenCSG-1.3.1-FBO.patch index 234992d..f4b3fcc 100644 --- a/patches/OpenCSG-1.3.1-FBO.patch +++ b/patches/OpenCSG-1.3.1-FBO.patch @@ -1,7 +1,20 @@ -Only in OpenCSG-1.3.1-fbo-patch/: lib -diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp +Only in OpenCSG-1.3.1-fbopatch/: lib +diff -ur OpenCSG-1.3.1/Makefile OpenCSG-1.3.1-fbopatch/Makefile +--- OpenCSG-1.3.1/Makefile 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbopatch/Makefile 2011-11-23 21:44:21.285641445 -0600 +@@ -1,4 +1,4 @@ +-SUBDIRS = glew src example ++SUBDIRS = src + + all: + for X in $(SUBDIRS); do make -C $$X ; done +Only in OpenCSG-1.3.1-fbopatch/src: area.o +Only in OpenCSG-1.3.1-fbopatch/src: batch.o +Only in OpenCSG-1.3.1-fbopatch/src: channelManager.o +Only in OpenCSG-1.3.1-fbopatch/src: context.o +diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp --- OpenCSG-1.3.1/src/frameBufferObject.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp 2011-11-23 21:42:42.709641637 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp 2011-11-23 22:19:33.545641258 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -30,10 +43,18 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbo-patch/src/fra glBindTexture(GL_TEXTURE_2D, 0); textureTarget = GL_TEXTURE_2D; -Only in OpenCSG-1.3.1-fbo-patch/src: frameBufferObject.cpp~ -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp +@@ -135,7 +136,7 @@ + // Unbinds frame buffer texture. + bool FrameBufferObject::EndCapture() + { +- glBindFramebuffer(GL_FRAMEBUFFER, 0); ++ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); + return true; + } + +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp --- OpenCSG-1.3.1/src/frameBufferObjectExt.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp 2011-11-23 21:07:00.073641732 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp 2011-11-23 21:43:17.701638949 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -71,9 +92,9 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbo-patch/src/ return true; } -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h --- OpenCSG-1.3.1/src/frameBufferObjectExt.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h 2011-11-23 21:07:15.529642039 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h 2011-11-23 21:43:17.701638949 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -93,9 +114,10 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbo-patch/src/fr bool initialized; }; -diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h +Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObjectExt.o +diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h --- OpenCSG-1.3.1/src/frameBufferObject.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h 2011-11-23 21:37:07.565641308 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h 2011-11-23 21:43:17.701638949 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -115,3 +137,17 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbo-patch/src/frame bool initialized; }; +Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObject.o +Only in OpenCSG-1.3.1-fbopatch/src: occlusionQuery.o +Only in OpenCSG-1.3.1-fbopatch/src: offscreenBuffer.o +Only in OpenCSG-1.3.1-fbopatch/src: opencsgRender.o +Only in OpenCSG-1.3.1-fbopatch/src: openglHelper.o +Only in OpenCSG-1.3.1-fbopatch/src: pBufferTexture.o +Only in OpenCSG-1.3.1-fbopatch/src: primitiveHelper.o +Only in OpenCSG-1.3.1-fbopatch/src: primitive.o +Only in OpenCSG-1.3.1-fbopatch/src: renderGoldfeather.o +Only in OpenCSG-1.3.1-fbopatch/src: renderSCS.o +Only in OpenCSG-1.3.1-fbopatch/src: RenderTexture.o +Only in OpenCSG-1.3.1-fbopatch/src: scissorMemo.o +Only in OpenCSG-1.3.1-fbopatch/src: settings.o +Only in OpenCSG-1.3.1-fbopatch/src: stencilManager.o diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index ffc74eb..6377929 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -74,18 +74,20 @@ def read_sysinfo(filename): tmp = tmp.split('/')[0] renderer = tmp + data += read_gitinfo() + + data += 'Image comparison: PerceptualDiff by H. Yee' + + data = data.strip() + hexhash = hashlib.md5() hexhash.update(data) hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) - sysid = osplain + '_' + machine + '_' + renderer + '_' + hash sysid = sysid.lower() - - data += read_gitinfo() - data += 'Image comparison: PerceptualDiff by H. Yee' return data, sysid class Test: @@ -234,7 +236,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: - newfile_html='' + newfile_html='' x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) dic = { '|}':'', '|-':'', '||':'', '|':'', '!!':'', '!':'', '\n\n':'\n

\n'} #order matters -- cgit v0.10.1 From 062244a3b15356defac5d3eee969e330a9447781 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 22:27:11 -0600 Subject: fix pretty print sysid hash diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6377929..97e99d5 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -80,8 +80,10 @@ def read_sysinfo(filename): data = data.strip() + # create 4 letter hash and stick on end of sysid + nondate_data = re.sub("\n.*?ompile date.*?\n","",data) hexhash = hashlib.md5() - hexhash.update(data) + hexhash.update(nondate_data) hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) -- cgit v0.10.1 From c2fb5d3650ffaa42c68e02891168c711d3b5f079 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 22:40:06 -0600 Subject: fix pretty printer diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 97e99d5..fb88c2f 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -295,7 +295,7 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo if 'expected.png' in wikifile.lower(): image = site.Images[wikifile] if image.exists and forceupload==False: - print 'skipping ',wikifile, '(image with same name and size ',localsize,'already on wiki)' + print 'skipping',wikifile, '(already on wiki)' skip=True if not skip: print 'uploading',wikifile,'...' @@ -312,13 +312,13 @@ def main(): startdate, tests, enddate = parselog(testlog) tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') - if '--forceupload' in sys.argv: forceupload=True - else: forceupload=False - manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog, forceupload) + if '--forceupload' in sys.argv: forceupl=True + else: forceupl=False + manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) trysave(htmldata, os.path.join(logpath,sysid+'.html')) if '--upload' in sys.argv: - upload(wikisite,'',wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False) + upload(wikisite,'',wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False,forceupload=forceupl) main() -- cgit v0.10.1 From 2bd48629ef8482a957f7db0921a3b3c7fdc458e1 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sat, 26 Nov 2011 11:24:38 -0600 Subject: add CGAL version to info diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5e93680..f57e40e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -192,6 +192,7 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(CMAKE_MODULE_PATH "${CGAL_DIR}") endif() find_package(CGAL REQUIRED) +message(STATUS "CGAL found in ${CGAL_USE_FILE} ${CGAL_INCLUDE_DIRS} ${CGAL_LIBRARIES_DIR}") include_directories(${CGAL_INCLUDE_DIRS}) # Internal includes diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index a3d5097..c962023 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -95,7 +95,7 @@ string info_dump(OffscreenView *glview) << "\nBoost version: " << BOOST_LIB_VERSION << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION - // << "\nCGAL version: " << CGAL_VERSION ??? + << "\nCGAL version: " << TOSTRING(CGAL_VERSION) // << "\nOpenCSG" << ??? << "\n" << glview->getInfo() << "\n"; -- cgit v0.10.1 From 2454c85348b5d1c645d8fbe777cfe611dbb49131 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sat, 26 Nov 2011 13:43:40 -0600 Subject: improve html output, logging diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 4dd614b..2f533ab 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -240,6 +240,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): head = ''+wiki_rootpath+' test run for '+sysid +'' revmanifest = dict((val,key) for key, val in manifest.iteritems()) x=re.sub('\{\|(.*?)\n','\n',wikidata) + x=re.sub('\|(.*?colspan.*?)\|','', '||':'
',x) x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: @@ -270,28 +271,28 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo import mwclient except: print 'please download mwclient and unpack here:', os.cwd() - print 'open site',wikiurl + print 'opening site:',wikiurl if not api_php_path == '': site = mwclient.Site(wikiurl,api_php_path) else: site = mwclient.Site(wikiurl) - print 'bot login' + print 'bot login:', botname site.login(botname,botpass) - print 'edit ',wiki_rootpath + print 'edit page:',wiki_rootpath page = site.Pages[wiki_rootpath] text = page.edit() rootpage = wiki_rootpath + sysid if not '[['+rootpage+']]' in text: page.save(text +'\n*[['+rootpage+']]\n') - print 'upload wiki data to',rootpage + print 'upload wiki page:',rootpage page = site.Pages[rootpage] text = page.edit() page.save(wikidata) - print 'upload images' + print 'upload images:' for localfile in sorted(manifest.keys()): if localfile: localf = open(localfile,'rb') -- cgit v0.10.1 From 2376814f2c4dd6e34a765ca37275b136785b26fd Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sat, 26 Nov 2011 21:35:53 -0600 Subject: make opencsg use framebuffer not pbuffer diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f604f73..5605f6a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -303,6 +303,7 @@ target_link_libraries(tests-cgal tests-common) add_library(tests-nocgal STATIC ${NOCGAL_SOURCES}) target_link_libraries(tests-nocgal tests-common) add_library(tests-offscreen STATIC ${OFFSCREEN_SOURCES}) +# set_target_properties(tests-offscreen PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") # # echotest diff --git a/tests/OffscreenView.cc b/tests/OffscreenView.cc index 9c8964c..61d5818 100644 --- a/tests/OffscreenView.cc +++ b/tests/OffscreenView.cc @@ -1,7 +1,6 @@ #include #include "OffscreenView.h" #include "system-gl.h" -#include #include "renderer.h" #include #include @@ -57,105 +56,13 @@ void OffscreenView::initializeGL() glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); -#ifdef ENABLE_OPENCSG - const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20"); - if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) - openscad_disable_gl20_env = NULL; - if (glewIsSupported("GL_VERSION_2_0") && openscad_disable_gl20_env == NULL) - { - const char *vs_source = - "uniform float xscale, yscale;\n" - "attribute vec3 pos_b, pos_c;\n" - "attribute vec3 trig, mask;\n" - "varying vec3 tp, tr;\n" - "varying float shading;\n" - "void main() {\n" - " vec4 p0 = gl_ModelViewProjectionMatrix * gl_Vertex;\n" - " vec4 p1 = gl_ModelViewProjectionMatrix * vec4(pos_b, 1.0);\n" - " vec4 p2 = gl_ModelViewProjectionMatrix * vec4(pos_c, 1.0);\n" - " float a = distance(vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" - " float b = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w));\n" - " float c = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" - " float s = (a + b + c) / 2.0;\n" - " float A = sqrt(s*(s-a)*(s-b)*(s-c));\n" - " float ha = 2.0*A/a;\n" - " gl_Position = p0;\n" - " tp = mask * ha;\n" - " tr = trig;\n" - " vec3 normal, lightDir;\n" - " normal = normalize(gl_NormalMatrix * gl_Normal);\n" - " lightDir = normalize(vec3(gl_LightSource[0].position));\n" - " shading = abs(dot(normal, lightDir));\n" - "}\n"; - - const char *fs_source = - "uniform vec4 color1, color2;\n" - "varying vec3 tp, tr, tmp;\n" - "varying float shading;\n" - "void main() {\n" - " gl_FragColor = vec4(color1.r * shading, color1.g * shading, color1.b * shading, color1.a);\n" - " if (tp.x < tr.x || tp.y < tr.y || tp.z < tr.z)\n" - " gl_FragColor = color2;\n" - "}\n"; - - GLuint vs = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vs, 1, (const GLchar**)&vs_source, NULL); - glCompileShader(vs); - - GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fs, 1, (const GLchar**)&fs_source, NULL); - glCompileShader(fs); - - GLuint edgeshader_prog = glCreateProgram(); - glAttachShader(edgeshader_prog, vs); - glAttachShader(edgeshader_prog, fs); - glLinkProgram(edgeshader_prog); - - shaderinfo[0] = edgeshader_prog; - shaderinfo[1] = glGetUniformLocation(edgeshader_prog, "color1"); - shaderinfo[2] = glGetUniformLocation(edgeshader_prog, "color2"); - shaderinfo[3] = glGetAttribLocation(edgeshader_prog, "trig"); - shaderinfo[4] = glGetAttribLocation(edgeshader_prog, "pos_b"); - shaderinfo[5] = glGetAttribLocation(edgeshader_prog, "pos_c"); - shaderinfo[6] = glGetAttribLocation(edgeshader_prog, "mask"); - shaderinfo[7] = glGetUniformLocation(edgeshader_prog, "xscale"); - shaderinfo[8] = glGetUniformLocation(edgeshader_prog, "yscale"); - - GLenum err = glGetError(); - if (err != GL_NO_ERROR) { - fprintf(stderr, "OpenGL Error: %s\n", gluErrorString(err)); - } - - GLint status; - glGetProgramiv(edgeshader_prog, GL_LINK_STATUS, &status); - if (status == GL_FALSE) { - int loglen; - char logbuffer[1000]; - glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); - fprintf(stderr, "OpenGL Program Linker Error:\n%.*s", loglen, logbuffer); - } else { - int loglen; - char logbuffer[1000]; - glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); - if (loglen > 0) { - fprintf(stderr, "OpenGL Program Link OK:\n%.*s", loglen, logbuffer); - } - glValidateProgram(edgeshader_prog); - glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); - if (loglen > 0) { - fprintf(stderr, "OpenGL Program Validation results:\n%.*s", loglen, logbuffer); - } - } - } -#endif /* ENABLE_OPENCSG */ + } void OffscreenView::resizeGL(int w, int h) { -#ifdef ENABLE_OPENCSG - shaderinfo[9] = w; - shaderinfo[10] = h; -#endif + this->width = w; + this->height = h; glViewport(0, 0, w, h); w_h_ratio = sqrt((double)w / (double)h); } @@ -226,9 +133,6 @@ void OffscreenView::paintGL() glColor3d(1.0, 0.0, 0.0); if (this->renderer) { -#ifdef ENABLE_OPENCSG - OpenCSG::setContext(0); -#endif this->renderer->draw(showfaces, showedges); } } diff --git a/tests/OffscreenView.h b/tests/OffscreenView.h index 2e35921..8b98b29 100644 --- a/tests/OffscreenView.h +++ b/tests/OffscreenView.h @@ -27,6 +27,8 @@ public: GLint shaderinfo[11]; OffscreenContext *ctx; + size_t width; + size_t height; private: Renderer *renderer; double w_h_ratio; diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index c962023..418738d 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -14,6 +14,7 @@ #include "CGALEvaluator.h" #include "PolySetCGALEvaluator.h" +#include #include "OpenCSGRenderer.h" #include "ThrownTogetherRenderer.h" @@ -128,6 +129,102 @@ po::variables_map parse_options(int argc, char *argv[]) return vm; } +void enable_opencsg_shaders( OffscreenView *glview ) +{ + bool ignore_gl_version = true; + const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20"); + if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) + openscad_disable_gl20_env = NULL; + if (glewIsSupported("GL_VERSION_2_0") && openscad_disable_gl20_env == NULL ) + { + const char *vs_source = + "uniform float xscale, yscale;\n" + "attribute vec3 pos_b, pos_c;\n" + "attribute vec3 trig, mask;\n" + "varying vec3 tp, tr;\n" + "varying float shading;\n" + "void main() {\n" + " vec4 p0 = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " vec4 p1 = gl_ModelViewProjectionMatrix * vec4(pos_b, 1.0);\n" + " vec4 p2 = gl_ModelViewProjectionMatrix * vec4(pos_c, 1.0);\n" + " float a = distance(vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" + " float b = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w));\n" + " float c = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" + " float s = (a + b + c) / 2.0;\n" + " float A = sqrt(s*(s-a)*(s-b)*(s-c));\n" + " float ha = 2.0*A/a;\n" + " gl_Position = p0;\n" + " tp = mask * ha;\n" + " tr = trig;\n" + " vec3 normal, lightDir;\n" + " normal = normalize(gl_NormalMatrix * gl_Normal);\n" + " lightDir = normalize(vec3(gl_LightSource[0].position));\n" + " shading = abs(dot(normal, lightDir));\n" + "}\n"; + + const char *fs_source = + "uniform vec4 color1, color2;\n" + "varying vec3 tp, tr, tmp;\n" + "varying float shading;\n" + "void main() {\n" + " gl_FragColor = vec4(color1.r * shading, color1.g * shading, color1.b * shading, color1.a);\n" + " if (tp.x < tr.x || tp.y < tr.y || tp.z < tr.z)\n" + " gl_FragColor = color2;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, (const GLchar**)&vs_source, NULL); + glCompileShader(vs); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, (const GLchar**)&fs_source, NULL); + glCompileShader(fs); + + GLuint edgeshader_prog = glCreateProgram(); + glAttachShader(edgeshader_prog, vs); + glAttachShader(edgeshader_prog, fs); + glLinkProgram(edgeshader_prog); + + glview->shaderinfo[0] = edgeshader_prog; + glview->shaderinfo[1] = glGetUniformLocation(edgeshader_prog, "color1"); + glview->shaderinfo[2] = glGetUniformLocation(edgeshader_prog, "color2"); + glview->shaderinfo[3] = glGetAttribLocation(edgeshader_prog, "trig"); + glview->shaderinfo[4] = glGetAttribLocation(edgeshader_prog, "pos_b"); + glview->shaderinfo[5] = glGetAttribLocation(edgeshader_prog, "pos_c"); + glview->shaderinfo[6] = glGetAttribLocation(edgeshader_prog, "mask"); + glview->shaderinfo[7] = glGetUniformLocation(edgeshader_prog, "xscale"); + glview->shaderinfo[8] = glGetUniformLocation(edgeshader_prog, "yscale"); + + GLenum err = glGetError(); + if (err != GL_NO_ERROR) { + fprintf(stderr, "OpenGL Error: %s\n", gluErrorString(err)); + } + + GLint status; + glGetProgramiv(edgeshader_prog, GL_LINK_STATUS, &status); + if (status == GL_FALSE) { + int loglen; + char logbuffer[1000]; + glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); + fprintf(stderr, "OpenGL Program Linker Error:\n%.*s", loglen, logbuffer); + } else { + int loglen; + char logbuffer[1000]; + glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); + if (loglen > 0) { + fprintf(stderr, "OpenGL Program Link OK:\n%.*s", loglen, logbuffer); + } + glValidateProgram(edgeshader_prog); + glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); + if (loglen > 0) { + fprintf(stderr, "OpenGL Program Validation results:\n%.*s", loglen, logbuffer); + } + } + } + glview->shaderinfo[9] = glview->width; + glview->shaderinfo[10] = glview->height; +} + int csgtestcore(int argc, char *argv[], test_type_e test_type) { bool sysinfo_dump = false; @@ -270,6 +367,8 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i. Exiting.\n", error); exit(1); } + enable_opencsg_shaders(csgInfo.glview); + if (sysinfo_dump) cout << info_dump(csgInfo.glview); BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); @@ -289,8 +388,11 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) else csgInfo.glview->setRenderer(&opencsgRenderer); - csgInfo.glview->paintGL(); + OpenCSG::setContext(0); + OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject); + csgInfo.glview->paintGL(); + csgInfo.glview->save(outfilename); Builtins::instance(true); -- cgit v0.10.1 From e077b31865bb15866e07928d505e563186116b0a Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 29 Nov 2011 22:15:07 -0600 Subject: enable uploading of build.make and flags.make files to wiki diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 2f533ab..82ece3d 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -8,7 +8,7 @@ # python test_pretty_print.py --upload # todo -# ban opencsg<2.0 from opencsgtest +# do something if tests for opencsg extensions fail (fail, no image production) # copy all images, sysinfo.txt to bundle for html/upload (images # can be altered by subsequent runs) # figure out hwo to make the thing run after the test @@ -17,7 +17,7 @@ # instead of having special '-info' prerun, put it as yet-another-test # and parse the log -import string,sys,re,os,hashlib,subprocess +import string,sys,re,os,hashlib,subprocess,textwrap def tryread(filename): data = None @@ -81,7 +81,7 @@ def read_sysinfo(filename): data = data.strip() # create 4 letter hash and stick on end of sysid - nondate_data = re.sub("\n.*?ompile date.*?\n","",data) + nondate_data = re.sub("\n.*?ompile date.*?\n","\n",data).strip() hexhash = hashlib.md5() hexhash.update(nondate_data) hexhash = hexhash.hexdigest()[-4:].upper() @@ -144,8 +144,22 @@ def wikify_filename(testname,filename,sysid): actual = ezsearch(os.sep+'.*?-output.*?(actual.*)',filename) if actual!='': result += sysid+'_'+actual - return result.replace('/','_') - + return result.replace('/','_').replace('\\','_') + +def parsemakes_towiki(wiki_rootpath, sysid): + filelist = [] + for root, dirs, files in os.walk('.'): + for fname in files: filelist += [ os.path.join(root, fname) ] + files = filter(lambda x: 'build.make' in os.path.basename(x), filelist) + files += filter(lambda x: 'flags.make' in os.path.basename(x), filelist) + manifest = {} + for fname in files: + wikifname = fname.replace('/','_').replace('\\','_').strip('.') + wikifname = wikifname.replace('CMakeFiles','').replace('.dir','') + manifest[fname] = wiki_rootpath + '_' + sysid + '_' + wikifname + wikicode = "\n'''build.make and flags.make'''\n\n\n" + for key in sorted(manifest.keys()): wikicode += '*[[' + manifest[key] + ']]\n' + return manifest, wikicode def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid): @@ -252,60 +266,67 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("\[\[(.*?)\]\]","\\1",x) return head + x + '' -def upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass): - print 'dry run. no files to be uploaded' - print 'log in', wikiurl, api_php_path, botname, botpass - print 'save ' + '*[['+wiki_rootpath+sysid+']]' + ' to page ' + wiki_rootpath - print 'save ', len(wikidata), ' bytes to page ',wiki_rootpath+sysid - for localfile in manifest.keys(): - if localfile: - localf=open(localfile,'rb') - wikifile = manifest[localfile] - print 'upload',localfile,wikifile - def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True,forceupload=False): - if dryrun: - upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass) - return None + if dryrun: print 'dry run' try: import mwclient except: print 'please download mwclient and unpack here:', os.cwd() print 'opening site:',wikiurl - if not api_php_path == '': - site = mwclient.Site(wikiurl,api_php_path) - else: - site = mwclient.Site(wikiurl) + if not dryrun: + if not api_php_path == '': + site = mwclient.Site(wikiurl,api_php_path) + else: + site = mwclient.Site(wikiurl) print 'bot login:', botname - site.login(botname,botpass) + if not dryrun: site.login(botname,botpass) print 'edit page:',wiki_rootpath - page = site.Pages[wiki_rootpath] - text = page.edit() rootpage = wiki_rootpath + sysid - if not '[['+rootpage+']]' in text: - page.save(text +'\n*[['+rootpage+']]\n') + if not dryrun: + page = site.Pages[wiki_rootpath] + text = page.edit() + if not '[['+rootpage+']]' in text: + page.save(text +'\n*[['+rootpage+']]\n') print 'upload wiki page:',rootpage - page = site.Pages[rootpage] - text = page.edit() - page.save(wikidata) + if not dryrun: + page = site.Pages[rootpage] + text = page.edit() + page.save(wikidata) print 'upload images:' - for localfile in sorted(manifest.keys()): + imagekeys = filter(lambda x: x.endswith('.png'), manifest.keys()) + for localfile in sorted(imagekeys): if localfile: localf = open(localfile,'rb') wikifile = manifest[localfile] skip=False if 'expected.png' in wikifile.lower(): - image = site.Images[wikifile] - if image.exists and forceupload==False: - print 'skipping',wikifile, '(already on wiki)' - skip=True + if not dryrun: + image = site.Images[wikifile] + if image.exists and forceupload==False: + print 'skipping',wikifile, '(already on wiki)' + skip=True if not skip: print 'uploading',wikifile,'...' - site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) + if not dryrun: + site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) + + print 'upload makefiles:' + makekeys = filter(lambda x: x.endswith('.make'), manifest.keys()) + for localfile in sorted(makekeys): + if localfile: + localf = open(localfile,'rb') + wikifile = manifest[localfile] + print 'uploading',wikifile,'...' + if not dryrun: + page = site.Pages[wikifile] + text = page.edit() + page.save('
\n'+localf.read()+'\n
') + + #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' @@ -323,11 +344,19 @@ def main(): sysinfo, sysid = read_sysinfo('sysinfo.txt') if '--forceupload' in sys.argv: forceupl=True else: forceupl=False + if '--dryrun' in sys.argv: dry=True + else: dry=False + + manifest_makes, wiki_makes = parsemakes_towiki(wiki_rootpath, sysid) manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid) + manifest.update(manifest_makes) + wikidata += wiki_makes trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) trysave(htmldata, os.path.join(logpath,sysid+'.html')) if '--upload' in sys.argv: - upload(wikisite,wiki_api_path,wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False,forceupload=forceupl) + upload(wikisite,wiki_api_path,wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=dry,forceupload=forceupl) + + main() -- cgit v0.10.1 From 988a88a64f0ee44426605c2b522588921f2a1890 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 29 Nov 2011 20:41:28 -0600 Subject: simplify test_pretty_print to work better with multiple page uploads diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 82ece3d..3f5041d 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -22,18 +22,19 @@ import string,sys,re,os,hashlib,subprocess,textwrap def tryread(filename): data = None try: - print 'reading', filename - f = open(filename) + f = open(filename,'rb') data = f.read() f.close() except: print 'couldn\'t open ',filename return data -def trysave(data,filename): +def trysave(filename,data): try: - f=open(filename,'w') - print 'writing',len(data),'bytes to',filename + if not os.path.isdir(os.path.dirname(filename)): + print 'creating',os.path.dirname(filename) + os.mkdir(os.path.dirname(filename)) + f=open(filename,'wb') f.write(data) f.close() except: @@ -125,6 +126,8 @@ def parsetest(teststring): ] hits = map( lambda pattern: ezsearch(pattern,teststring), patterns ) test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7],teststring) + test.actualfile_data = tryread(test.actualfile) + test.expectedfile_data = tryread(test.expectedfile) return test def parselog(data): @@ -133,35 +136,26 @@ def parselog(data): pattern = '([0-9]*/[0-9]* Testing:.*?time elapsed.*?\n)' test_chunks = re.findall(pattern,data,re.S) tests = map( parsetest, test_chunks ) - print 'found', len(tests),'test results' + tests = sorted(tests, key = lambda t:t.passed) return startdate, tests, enddate -def wikify_filename(testname,filename,sysid): - # translate from local system to wiki style filename. - result = wiki_rootpath+'_'+testname+'_' - expected = ezsearch('(expected....$)',filename) - if expected!='': result += expected - actual = ezsearch(os.sep+'.*?-output.*?(actual.*)',filename) - if actual!='': - result += sysid+'_'+actual - return result.replace('/','_').replace('\\','_') - -def parsemakes_towiki(wiki_rootpath, sysid): +def load_makefiles(builddir): filelist = [] - for root, dirs, files in os.walk('.'): + for root, dirs, files in os.walk(builddir): for fname in files: filelist += [ os.path.join(root, fname) ] files = filter(lambda x: 'build.make' in os.path.basename(x), filelist) files += filter(lambda x: 'flags.make' in os.path.basename(x), filelist) - manifest = {} + files = filter(lambda x: 'esting' not in x and 'emporary' not in x, files) + result = {} for fname in files: - wikifname = fname.replace('/','_').replace('\\','_').strip('.') - wikifname = wikifname.replace('CMakeFiles','').replace('.dir','') - manifest[fname] = wiki_rootpath + '_' + sysid + '_' + wikifname - wikicode = "\n'''build.make and flags.make'''\n\n\n" - for key in sorted(manifest.keys()): wikicode += '*[[' + manifest[key] + ']]\n' - return manifest, wikicode + result[fname.replace(builddir,'')] = open(fname,'rb').read() + return result + +def wikify_filename(fname, wiki_rootpath, sysid): + wikifname = fname.replace('/','_').replace('\\','_').strip('.') + return wiki_rootpath + '_' + sysid + '_' + wikifname -def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid): +def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles): wiki_template = """

[[WIKI_ROOTPATH]] test run report

@@ -209,8 +203,13 @@ TESTLOG |} - +'''build.make and flags.make''' + +*[[MAKEFILE_NAME]] + """ + txtpages = {} + imgs = {} passed_tests = filter(lambda x: x.passed, tests) failed_tests = filter(lambda x: not x.passed, tests) percent = str(int(100.0*len(passed_tests) / len(tests))) @@ -218,6 +217,7 @@ TESTLOG s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) + repeat3 = ezsearch('(.*?)',s) dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, 'SYSINFO': sysinfo, 'SYSID':sysid, 'NUMTESTS':len(tests), 'NUMPASSED':len(passed_tests), 'PERCENTPASSED':percent } @@ -231,24 +231,43 @@ TESTLOG newchunk = re.sub('FTESTNAME',t.fullname,repeat2) s = s.replace(repeat2, newchunk+repeat2) elif t.type=='png': - manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) - manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) + tmp = t.actualfile.replace(builddir,'') + wikiname_a = wikify_filename(tmp,wiki_rootpath,sysid) + # erase /home/whatever/openscad/tests/regression + tmp = t.expectedfile.replace(os.path.dirname(builddir),'') + wikiname_e = wikify_filename(tmp,wiki_rootpath,sysid) + imgs[wikiname_e] = t.expectedfile_data if t.actualfile: - actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|250px]]' + actualfile_wiki = '[[File:'+wikiname_a+'|250px]]' + imgs[wikiname_a] = t.actualfile_data else: actualfile_wiki = 'No image generated.' newchunk = re.sub('FTESTNAME',t.fullname,repeat1) newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) - newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) + newchunk = newchunk.replace('EXPECTEDFILE',wikiname_e) newchunk = newchunk.replace('TESTLOG',t.fulltestlog) s = s.replace(repeat1, newchunk+repeat1) + makefiles_wikinames = {} + for mf in sorted(makefiles.keys()): + tmp = mf.replace('CMakeFiles','').replace('.dir','') + wikiname = wikify_filename(tmp,wiki_rootpath,sysid) + newchunk = re.sub('MAKEFILE_NAME',wikiname,repeat3) + s = s.replace(repeat3, newchunk+repeat3) + makefiles_wikinames[mf] = wikiname + s = s.replace(repeat1,'') s = s.replace(repeat2,'') + s = s.replace(repeat3,'') s = re.sub('\n','',s) s = re.sub('','',s) - return manifest, s + mainpage_wikiname = wiki_rootpath + '_' + sysid + '_test_report' + txtpages[ mainpage_wikiname ] = s + for mf in sorted(makefiles.keys()): + txtpages[ makefiles_wikinames[ mf ] ] = '
\n'+makefiles[mf]+'\n
' + + return imgs, txtpages def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): head = ''+wiki_rootpath+' test run for '+sysid +'' @@ -266,97 +285,89 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("\[\[(.*?)\]\]","\\1",x) return head + x + '' -def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True,forceupload=False): +def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname='cakebaby',botpass='anniew',wikidir='.',dryrun=True): + wetrun = not dryrun if dryrun: print 'dry run' try: import mwclient except: - print 'please download mwclient and unpack here:', os.cwd() + print 'please download mwclient and unpack here:', os.getcwd() + sys.exit() print 'opening site:',wikiurl - if not dryrun: - if not api_php_path == '': - site = mwclient.Site(wikiurl,api_php_path) - else: - site = mwclient.Site(wikiurl) + if wetrun: + site = mwclient.Site(wikiurl,api_php_path) print 'bot login:', botname - if not dryrun: site.login(botname,botpass) - - print 'edit page:',wiki_rootpath - rootpage = wiki_rootpath + sysid - if not dryrun: + if wetrun: site.login(botname,botpass) + + wikifiles = os.listdir(wikidir) + testreport_page = filter( lambda x: 'test_report' in x, wikifiles ) + if (len(testreport_page)>1): + print 'multiple test reports found, please clean dir',wikidir + sys.exit() + rootpage = testreport_page[0] + print 'add',rootpage,' to main report page ',wiki_rootpath + if wetrun: page = site.Pages[wiki_rootpath] text = page.edit() if not '[['+rootpage+']]' in text: page.save(text +'\n*[['+rootpage+']]\n') - print 'upload wiki page:',rootpage - if not dryrun: - page = site.Pages[rootpage] - text = page.edit() - page.save(wikidata) - - print 'upload images:' - imagekeys = filter(lambda x: x.endswith('.png'), manifest.keys()) - for localfile in sorted(imagekeys): - if localfile: - localf = open(localfile,'rb') - wikifile = manifest[localfile] - skip=False - if 'expected.png' in wikifile.lower(): - if not dryrun: - image = site.Images[wikifile] - if image.exists and forceupload==False: - print 'skipping',wikifile, '(already on wiki)' - skip=True - if not skip: - print 'uploading',wikifile,'...' - if not dryrun: - site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) - - print 'upload makefiles:' - makekeys = filter(lambda x: x.endswith('.make'), manifest.keys()) - for localfile in sorted(makekeys): - if localfile: - localf = open(localfile,'rb') - wikifile = manifest[localfile] - print 'uploading',wikifile,'...' - if not dryrun: - page = site.Pages[wikifile] + wikifiles = os.listdir(wikidir) + print 'upload wiki pages:' + for wikiname in wikifiles: + filename = os.path.join(wikidir,wikiname) + filedata = tryread(filename) + print 'upload',len(filedata),'bytes from',wikiname,'...', + sys.stdout.flush() + if wikiname.endswith('.png'): + localf = open(filename,'rb') # mwclient needs file handle + descrip = wiki_rootpath + ' test' + if wetrun: + site.upload(localf,wikiname,descrip,ignore=True) + print 'image uploaded' + else: # textpage + if wetrun: + page = site.Pages[wikiname] text = page.edit() - page.save('
\n'+localf.read()+'\n
') + page.save(filedata) + print 'text page uploaded' + +def findlogfile(builddir): + logpath = os.path.join(builddir,'Testing','Temporary') + logfilename = os.path.join(logpath,'LastTest.log') + return logpath, logfilename + +def main(): + dry = False + if '--dryrun' in sys.argv: dry=True + print 'build dir set to', builddir + + sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) + makefiles = load_makefiles(builddir) + logpath, logfilename = findlogfile(builddir) + testlog = tryread(logfilename) + startdate, tests, enddate = parselog(testlog) + print 'found sysinfo.txt' + print 'found', len(makefiles),'makefiles' + print 'found', len(tests),'test results' + imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) + wikidir = os.path.join(logpath,'wiki') + print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', wikidir + for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) + for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) + if '--upload' in sys.argv: + upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', + 'tobdacsnepo',wikidir,dryrun=dry) + #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' wikisite = 'cakebaby.wikia.com' wiki_api_path = '/' wiki_rootpath = 'OpenSCAD' -builddir = os.getcwd() -logpath = os.path.join(builddir,'Testing','Temporary') -logfilename = os.path.join(logpath,'LastTest.log') - -def main(): - testlog = tryread(logfilename) - startdate, tests, enddate = parselog(testlog) - tests = sorted(tests, key = lambda t:t.passed) - sysinfo, sysid = read_sysinfo('sysinfo.txt') - if '--forceupload' in sys.argv: forceupl=True - else: forceupl=False - if '--dryrun' in sys.argv: dry=True - else: dry=False - - manifest_makes, wiki_makes = parsemakes_towiki(wiki_rootpath, sysid) - manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid) - manifest.update(manifest_makes) - wikidata += wiki_makes - trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) - htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) - trysave(htmldata, os.path.join(logpath,sysid+'.html')) - if '--upload' in sys.argv: - upload(wikisite,wiki_api_path,wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=dry,forceupload=forceupl) - +builddir = os.getcwd() # os.getcwd()+'/build' main() - -- cgit v0.10.1 From bcc6120f9b7ce4187c56e0f83dd021674ccdec80 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 29 Nov 2011 20:57:44 -0600 Subject: tweak pretty print diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 3f5041d..6931c35 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -2,7 +2,7 @@ # # This program 'pretty prints' the ctest output, namely # files from builddir/Testing/Temporary. -# html & wiki output are produced +# html & wiki output are produced in Testing/Temporary/wiki # wiki uploading is available by running # # python test_pretty_print.py --upload @@ -17,6 +17,7 @@ # instead of having special '-info' prerun, put it as yet-another-test # and parse the log + import string,sys,re,os,hashlib,subprocess,textwrap def tryread(filename): @@ -88,6 +89,7 @@ def read_sysinfo(filename): hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) + sysid = osplain + '_' + machine + '_' + renderer + '_' + hash sysid = sysid.lower() @@ -233,7 +235,6 @@ TESTLOG elif t.type=='png': tmp = t.actualfile.replace(builddir,'') wikiname_a = wikify_filename(tmp,wiki_rootpath,sysid) - # erase /home/whatever/openscad/tests/regression tmp = t.expectedfile.replace(os.path.dirname(builddir),'') wikiname_e = wikify_filename(tmp,wiki_rootpath,sysid) imgs[wikiname_e] = t.expectedfile_data @@ -265,7 +266,7 @@ TESTLOG mainpage_wikiname = wiki_rootpath + '_' + sysid + '_test_report' txtpages[ mainpage_wikiname ] = s for mf in sorted(makefiles.keys()): - txtpages[ makefiles_wikinames[ mf ] ] = '
\n'+makefiles[mf]+'\n
' + txtpages[ makefiles_wikinames[ mf ] ] = '\n*Subreport from [['+mainpage_wikiname+']]\n\n\n
\n'+makefiles[mf]+'\n
' return imgs, txtpages -- cgit v0.10.1 From 40815157a49892078905d3e55ca70722cbb89ac5 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 30 Nov 2011 05:15:57 -0600 Subject: add 'finis' diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6931c35..62ed062 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -8,7 +8,8 @@ # python test_pretty_print.py --upload # todo -# do something if tests for opencsg extensions fail (fail, no image production) +# repair html output +# do something if tests for GL extensions for OpenCSG fail (test fail, no image production) # copy all images, sysinfo.txt to bundle for html/upload (images # can be altered by subsequent runs) # figure out hwo to make the thing run after the test @@ -16,7 +17,9 @@ # why is hash differing # instead of having special '-info' prerun, put it as yet-another-test # and parse the log - +# fix windows so that it won't keep asking 'this program crashed' over and over. +# (you can set this in the registry to never happen, but itd be better if the program +# itself was able to disable that temporarily in it's own process) import string,sys,re,os,hashlib,subprocess,textwrap @@ -215,7 +218,6 @@ TESTLOG passed_tests = filter(lambda x: x.passed, tests) failed_tests = filter(lambda x: not x.passed, tests) percent = str(int(100.0*len(passed_tests) / len(tests))) - manifest = {} s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) @@ -271,6 +273,7 @@ TESTLOG return imgs, txtpages def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): + # temporarily defunct/broken head = ''+wiki_rootpath+' test run for '+sysid +'' revmanifest = dict((val,key) for key, val in manifest.iteritems()) x=re.sub('\{\|(.*?)\n','\n',wikidata) @@ -364,6 +367,8 @@ def main(): upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', 'tobdacsnepo',wikidir,dryrun=dry) + print 'test_pretty_print complete' + #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' wikisite = 'cakebaby.wikia.com' -- cgit v0.10.1 From b1b46e80707e0ca79f1dfb6aad67f44c7a8d719e Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 30 Nov 2011 22:24:14 -0600 Subject: fix up testing, add opencsg version info diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ac021e5..58df471 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,11 +27,7 @@ endif() if(WIN32_STATIC_BUILD) if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(EMSG "\nTo build Win32 STATIC OpenSCAD tests you must run") - set(EMSG "${EMSG} \ncmake .. -DCMAKE_BUILD_TYPE=Release") - set(EMSG "${EMSG} \nthen replace /MD with /MT in CMakeCache.txt") - set(EMSG "${EMSG} \ni.e. sed -i s/\\/MD/\\/MT/ CMakeCache.txt") - set(EMSG "${EMSG} \nthen re-run cmake ..") + set(EMSG "\nTo build Win32 STATIC OpenSCAD please see doc/testing.txt") message(FATAL_ERROR ${EMSG}) endif() endif() @@ -158,7 +154,9 @@ include_directories(${OPENCSG_INCLUDE_DIR}) # GLEW -if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") +if (NOT $ENV{GLEW_DIR} STREQUAL "") + set(GLEW_DIR "$ENV{GLEW_DIR}") +elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(GLEW_DIR "$ENV{MACOSX_DEPLOY_DIR}") endif() @@ -195,8 +193,13 @@ elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(CGAL_DIR "$ENV{MACOSX_DEPLOY_DIR}/lib/CGAL") set(CMAKE_MODULE_PATH "${CGAL_DIR}") endif() +message(STATUS "CGAL_DIR: " ${CGAL_DIR}) find_package(CGAL REQUIRED) -message(STATUS "CGAL found in ${CGAL_USE_FILE} ${CGAL_INCLUDE_DIRS} ${CGAL_LIBRARIES_DIR}") +message(STATUS "CGAL config found in " ${CGAL_USE_FILE} ) +foreach(cgal_incdir ${CGAL_INCLUDE_DIRS}) + message(STATUS "CGAL include found in " ${cgal_incdir} ) +endforeach() +message(STATUS "CGAL libraries found in " ${CGAL_LIBRARIES_DIR} ) if("${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}" VERSION_LESS 3.6) message(FATAL_ERROR "CGAL >= 3.6 required") endif() @@ -255,7 +258,7 @@ set(NOCGAL_SOURCES set(CGAL_SOURCES ${NOCGAL_SOURCES} - ../src/CSGTermEvaluator.cc + ../src/CSGTermEvaluator.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc ../src/CGALEvaluator.cc @@ -459,13 +462,12 @@ enable_testing() # set up custom pretty printing of results set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") -set(PRETTYCMD "\"${PYTHON_EXECUTABLE} test_pretty_print.py\"") +set(PRETTYCMD "\"${PYTHON_EXECUTABLE} test_pretty_print.py --builddir=${CMAKE_CURRENT_BINARY_DIR}\"") set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) set(CTEST_CUSTOM_TXT "\n message(\"running 'opencsgtest --info' to generate sysinfo.txt\")\n ${INFOCMD}\n - # set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n # doesn't work. log is written - # after all tests run. + set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n ") file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) @@ -476,6 +478,7 @@ endforeach() set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake") + # Find all scad files file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad) file(GLOB FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/*.scad) @@ -523,6 +526,9 @@ disable_tests(dumptest_transform-tests # Reenable it when this is improved disable_tests(opencsgtest_child-background) +# FIXME: This single test takes over an hour to run on a 2.7 GHz P4 +disable_tests(opencsgtest_example006) + # These tests only makes sense in OpenCSG mode disable_tests(cgalpngtest_child-background cgalpngtest_highlight-and-background-modifier diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index 32c2d6e..8093ed3 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -44,7 +44,8 @@ ENDIF (WIN32) IF (GLEW_INCLUDE_PATH) SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") - MESSAGE(STATUS "GLEW found in " ${GLEW_INCLUDE_PATH} " " ${GLEW_LIBRARY}) + MESSAGE(STATUS "GLEW include found in " ${GLEW_INCLUDE_PATH} ) + MESSAGE(STATUS "GLEW library found in " ${GLEW_LIBRARY} ) ELSE (GLEW_INCLUDE_PATH) SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") ENDIF (GLEW_INCLUDE_PATH) diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 354c197..cd4d4b4 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -87,6 +87,10 @@ string info_dump(OffscreenView *glview) #define compiler_info "unknown compiler" #endif +#ifndef OPENCSG_VERSION_STRING +#define OPENCSG_VERSION_STRING "unknown, <1.3.2" +#endif + std::stringstream out; #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) @@ -97,7 +101,7 @@ string info_dump(OffscreenView *glview) << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << "\nCGAL version: " << TOSTRING(CGAL_VERSION) - // << "\nOpenCSG" << ??? + << "\nOpenCSG version: " << OPENCSG_VERSION_STRING << "\n" << glview->getInfo() << "\n"; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6931c35..df29fe7 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -1,4 +1,21 @@ #!/usr/bin/python + +# Copyright (C) 2011 Don Bright +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + # # This program 'pretty prints' the ctest output, namely # files from builddir/Testing/Temporary. @@ -6,6 +23,12 @@ # wiki uploading is available by running # # python test_pretty_print.py --upload +# +# Design philosophy +# +# 1. parse the data (images, logs) into easy-to-use data structures +# 2. wikifiy the data +# 3. save the wikified data to disk # todo # do something if tests for opencsg extensions fail (fail, no image production) @@ -197,14 +220,18 @@ TESTLOG '''Failed text tests''' -{|border=1 cellspacing=0 cellpadding=1 -! Testname +{|border=1 cellspacing=0 cellpadding=1 |- | FTESTNAME - |} +
+TESTLOG
+
+ + + '''build.make and flags.make''' *[[MAKEFILE_NAME]] @@ -225,12 +252,10 @@ TESTLOG 'NUMTESTS':len(tests), 'NUMPASSED':len(passed_tests), 'PERCENTPASSED':percent } for key in dic.keys(): s = s.replace(key,str(dic[key])) - testlogs = '' for t in failed_tests: - testlogs += '\n\n'+t.fulltestlog if t.type=='txt': - newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) newchunk = re.sub('FTESTNAME',t.fullname,repeat2) + newchunk = newchunk.replace('TESTLOG',t.fulltestlog) s = s.replace(repeat2, newchunk+repeat2) elif t.type=='png': tmp = t.actualfile.replace(builddir,'') @@ -336,12 +361,21 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= def findlogfile(builddir): logpath = os.path.join(builddir,'Testing','Temporary') - logfilename = os.path.join(logpath,'LastTest.log') + logfilename = os.path.join(logpath,'LastTest.log.tmp') + if not os.path.isfile(logfilename): + logfilename = os.path.join(logpath,'LastTest.log') + if not os.path.isfile(logfilename): + print 'cant find and/or open logfile',logfilename + sys.exit() return logpath, logfilename def main(): dry = False + print 'running test_pretty_print' if '--dryrun' in sys.argv: dry=True + suffix = ezsearch('--suffix=(.*?) ',string.join(sys.argv)+' ') + builddir = ezsearch('--builddir=(.*?) ',string.join(sys.argv)+' ') + if builddir=='': builddir=os.getcwd() print 'build dir set to', builddir sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) @@ -355,7 +389,7 @@ def main(): imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) - wikidir = os.path.join(logpath,'wiki') + wikidir = os.path.join(logpath,sysid+'_wiki') print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', wikidir for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) -- cgit v0.10.1 From 750f3c8fc94744d6cc4c62de6ac86595cb2b38b6 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 18:56:58 -0600 Subject: cleanup diff --git a/doc/testing.txt b/doc/testing.txt index 61f6d75..9391832 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -1,7 +1,7 @@ Running regression tests: ------------------------- -Prerequisites: cmake, python, OpenCSG with FBO patch from ../patches applied +Prerequisites: cmake, python, ImageMagick 6.5.9.3 or newer A) Building test environment @@ -16,25 +16,14 @@ First, get a normal build working by following instructions at http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Windows Then, from the QT command prompt: -$ cd tests -$ cmake . -DCMAKE_BUILD_TYPE=Release -$ sed -i s/\/MD/\/MT/ CMakeCache.txt -$ cmake . -$ nmake -f Makefile +> cd tests +> cmake . -DCMAKE_BUILD_TYPE=Release +> sed -i s/\/MD/\/MT/ CMakeCache.txt +> cmake . +> nmake -f Makefile B) Running tests -Easy version: -$ make test - -Windows: -$ nmake -f Makefile test - -Headless unix servers (no X11): -$ Xvfb :5 -screen 0 800x600x24 & -$ DISPLAY=:5 make test - -Partial or extended test runs: $ ctest Runs tests enabled by default $ ctest -R Runs only matching tests, e.g. ctest -R dxf $ ctest -C Adds extended tests belonging to configs. @@ -44,6 +33,10 @@ $ ctest -C Adds extended tests belonging to configs. Examples - test all examples All - test everything +Headless unix servers (no X11): +$ Xvfb :5 -screen 0 800x600x24 & +$ DISPLAY=:5 ctest + Adding a new regression test: ------------------------------ @@ -58,13 +51,16 @@ Adding a new regression test: 7) run the test normally and verify that it passes: $ ctest -R mytest -Troubleshooting a failed test: +Troubleshooting: ------------------------------ +To helping CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use the +-D option. Here are some examples: + + cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 + cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 + Logs of test runs are found in tests/build/Testing/Temporary +Pretty-printed html output is in a subdir of tests/build/Testing/Temporary Expected results are found in tests/regression/* Actual results are found in tests/build/testname-output/* - -You can also compile a single test program: - - $ make cgalpngtest diff --git a/patches/OpenCSG-1.3.1-FBO.patch b/patches/OpenCSG-1.3.1-FBO.patch deleted file mode 100644 index f4b3fcc..0000000 --- a/patches/OpenCSG-1.3.1-FBO.patch +++ /dev/null @@ -1,153 +0,0 @@ -Only in OpenCSG-1.3.1-fbopatch/: lib -diff -ur OpenCSG-1.3.1/Makefile OpenCSG-1.3.1-fbopatch/Makefile ---- OpenCSG-1.3.1/Makefile 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/Makefile 2011-11-23 21:44:21.285641445 -0600 -@@ -1,4 +1,4 @@ --SUBDIRS = glew src example -+SUBDIRS = src - - all: - for X in $(SUBDIRS); do make -C $$X ; done -Only in OpenCSG-1.3.1-fbopatch/src: area.o -Only in OpenCSG-1.3.1-fbopatch/src: batch.o -Only in OpenCSG-1.3.1-fbopatch/src: channelManager.o -Only in OpenCSG-1.3.1-fbopatch/src: context.o -diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp ---- OpenCSG-1.3.1/src/frameBufferObject.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp 2011-11-23 22:19:33.545641258 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -59,6 +59,7 @@ - glGenRenderbuffers(1, &depthID); - glGenTextures(1, &textureID); - -+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFramebufferID); - glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); - glBindTexture(GL_TEXTURE_2D, textureID); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); -@@ -78,7 +79,7 @@ - return false; - } - -- glBindFramebuffer(GL_FRAMEBUFFER, 0); -+ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); - glBindTexture(GL_TEXTURE_2D, 0); - - textureTarget = GL_TEXTURE_2D; -@@ -135,7 +136,7 @@ - // Unbinds frame buffer texture. - bool FrameBufferObject::EndCapture() - { -- glBindFramebuffer(GL_FRAMEBUFFER, 0); -+ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); - return true; - } - -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp ---- OpenCSG-1.3.1/src/frameBufferObjectExt.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp 2011-11-23 21:43:17.701638949 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -60,6 +60,7 @@ - glGenRenderbuffersEXT(1, &depthID); - glGenTextures(1, &textureID); - -+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &oldFramebufferID); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID); - glBindTexture(GL_TEXTURE_2D, textureID); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); -@@ -79,7 +80,7 @@ - return false; - } - -- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); - glBindTexture(GL_TEXTURE_2D, 0); - - textureTarget = GL_TEXTURE_2D; -@@ -136,7 +137,7 @@ - // Unbinds frame buffer texture. - bool FrameBufferObjectExt::EndCapture() - { -- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); - return true; - } - -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h ---- OpenCSG-1.3.1/src/frameBufferObjectExt.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h 2011-11-23 21:43:17.701638949 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -85,6 +85,7 @@ - unsigned int depthID; - - unsigned int framebufferID; -+ int oldFramebufferID; - - bool initialized; - }; -Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObjectExt.o -diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h ---- OpenCSG-1.3.1/src/frameBufferObject.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h 2011-11-23 21:43:17.701638949 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -85,6 +85,7 @@ - unsigned int depthID; - - unsigned int framebufferID; -+ int oldFramebufferID; - - bool initialized; - }; -Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObject.o -Only in OpenCSG-1.3.1-fbopatch/src: occlusionQuery.o -Only in OpenCSG-1.3.1-fbopatch/src: offscreenBuffer.o -Only in OpenCSG-1.3.1-fbopatch/src: opencsgRender.o -Only in OpenCSG-1.3.1-fbopatch/src: openglHelper.o -Only in OpenCSG-1.3.1-fbopatch/src: pBufferTexture.o -Only in OpenCSG-1.3.1-fbopatch/src: primitiveHelper.o -Only in OpenCSG-1.3.1-fbopatch/src: primitive.o -Only in OpenCSG-1.3.1-fbopatch/src: renderGoldfeather.o -Only in OpenCSG-1.3.1-fbopatch/src: renderSCS.o -Only in OpenCSG-1.3.1-fbopatch/src: RenderTexture.o -Only in OpenCSG-1.3.1-fbopatch/src: scissorMemo.o -Only in OpenCSG-1.3.1-fbopatch/src: settings.o -Only in OpenCSG-1.3.1-fbopatch/src: stencilManager.o diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 58df471..314b51f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -462,7 +462,7 @@ enable_testing() # set up custom pretty printing of results set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") -set(PRETTYCMD "\"${PYTHON_EXECUTABLE} test_pretty_print.py --builddir=${CMAKE_CURRENT_BINARY_DIR}\"") +set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_pretty_print.py --builddir=${CMAKE_CURRENT_BINARY_DIR}\"") set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) set(CTEST_CUSTOM_TXT "\n message(\"running 'opencsgtest --info' to generate sysinfo.txt\")\n @@ -471,14 +471,13 @@ set(CTEST_CUSTOM_TXT "\n ") file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) -foreach(FILE test_pretty_print.py) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE} - ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY) -endforeach() +#foreach(FILE test_pretty_print.py) +# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE} +# ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY) +#endforeach() set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake") - # Find all scad files file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad) file(GLOB FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/*.scad) @@ -527,7 +526,7 @@ disable_tests(dumptest_transform-tests disable_tests(opencsgtest_child-background) # FIXME: This single test takes over an hour to run on a 2.7 GHz P4 -disable_tests(opencsgtest_example006) +disable_tests(opencsgtest_example006 cgalpngtest_example006) # These tests only makes sense in OpenCSG mode disable_tests(cgalpngtest_child-background diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 8f519d7..e2193e2 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -59,7 +59,7 @@ def tryread(filename): def trysave(filename,data): try: if not os.path.isdir(os.path.dirname(filename)): - print 'creating',os.path.dirname(filename) + #print 'creating',os.path.dirname(filename) os.mkdir(os.path.dirname(filename)) f=open(filename,'wb') f.write(data) @@ -386,14 +386,14 @@ def main(): logpath, logfilename = findlogfile(builddir) testlog = tryread(logfilename) startdate, tests, enddate = parselog(testlog) - print 'found sysinfo.txt' - print 'found', len(makefiles),'makefiles' + print 'found sysinfo.txt,', + print 'found', len(makefiles),'makefiles,', print 'found', len(tests),'test results' imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) wikidir = os.path.join(logpath,sysid+'_wiki') - print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', wikidir + print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', '.'+wikidir.replace(os.getcwd(),'') for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) -- cgit v0.10.1 From 32a3831ce9c8894a24d9a5f05c46c3fba458d34c Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 6 Dec 2011 19:15:04 -0800 Subject: alternate comparison for systems where imagemagick convert crashes diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index ebe802e..916694f 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -48,7 +48,7 @@ def verify_test(testname, cmd): def execute_and_redirect(cmd, params, outfile): retval = -1 try: - proc = subprocess.Popen([cmd] + params, stdout=outfile) + proc = subprocess.Popen([cmd] + params, stdout=outfile, stderr=subprocess.STDOUT) out = proc.communicate()[0] retval = proc.wait() except: @@ -76,27 +76,40 @@ def compare_default(resultfilename): return True def compare_png(resultfilename): + compare_method = 'pixel' #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-blur", "2", "-threshold", "30%", "-format", "%[fx:w*h*mean]", "info:"] #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-morphology", "Erode", "Square", "-format", "%[fx:w*h*mean]", "info:"] - # 'morphology' is only available in newer versions of ImageMagick. + + # for systems with older imagemagick that doesnt support '-morphology' # http://www.imagemagick.org/Usage/morphology/#alturnative - args = [expectedfilename, resultfilename, "-alpha", "Off", - "-compose", "difference", "-composite", "-threshold", "10%", - #"-morphology", "Erode", "Square", - "-gaussian-blur","3x65535", "-threshold","99.999%", - "-format", "%[fx:w*h*mean]", "info:"] - print >> sys.stderr, 'ImageMagick image comparison: convert ', ' '.join(args[2:]) - print >> sys.stderr, ' expected image: ', expectedfilename + # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-format", "%[fx:w*h*mean]", "info:"] + + # for systems where imagemagick crashes when using the above comparators + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] + options.convert_exec = 'compare' + compare_method = 'NCC' + + msg = 'ImageMagick image comparison: ' + msg += os.path.basename(options.convert_exec) + ' '.join(args) + msg += ' expected image: ' + expectedfilename + print >> sys.stderr, msg if not resultfilename: print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" return False print >> sys.stderr, ' actual image: ', resultfilename (retval, output) = execute_and_redirect(options.convert_exec, args, subprocess.PIPE) + print "Imagemagick return", retval, "output:", output if retval == 0: - pixelerr = int(float(output.strip())) - if pixelerr < 32: return True - else: print >> sys.stderr, pixelerr, ' pixel errors' + if compare_method=='pixel': + pixelerr = int(float(output.strip())) + if pixelerr < 32: return True + else: print >> sys.stderr, pixelerr, ' pixel errors' + elif compare_method=='NCC': + thresh = 0.99 + ncc_err = float(output.strip()) + if ncc_err > thresh: return True + else: print >> sys.stderr, ncc_err, ' Images differ: NCC comparison < ', thresh return False def compare_with_expected(resultfilename): -- cgit v0.10.1 From 61bfb8f058e8935432fed6098a1d70dba194f6bf Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 21:48:19 -0600 Subject: fix errors with flaky wiki sites. cleanup diff --git a/doc/testing.txt b/doc/testing.txt index 9391832..df77073 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -33,10 +33,6 @@ $ ctest -C Adds extended tests belonging to configs. Examples - test all examples All - test everything -Headless unix servers (no X11): -$ Xvfb :5 -screen 0 800x600x24 & -$ DISPLAY=:5 ctest - Adding a new regression test: ------------------------------ @@ -54,13 +50,22 @@ Adding a new regression test: Troubleshooting: ------------------------------ -To helping CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use the --D option. Here are some examples: +0. Headless unix servers (no X11): + +$ Xvfb :5 -screen 0 800x600x24 & +$ DISPLAY=:5 ctest + +1. To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use + the -D option. See CMakeLists.txt for more information. Examples: cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 + +2. Logs Logs of test runs are found in tests/build/Testing/Temporary Pretty-printed html output is in a subdir of tests/build/Testing/Temporary Expected results are found in tests/regression/* Actual results are found in tests/build/testname-output/* + +3. Cross-compiling of tests has not been automated nor tested. diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 916694f..480584c 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -82,16 +82,16 @@ def compare_png(resultfilename): # for systems with older imagemagick that doesnt support '-morphology' # http://www.imagemagick.org/Usage/morphology/#alturnative - # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-format", "%[fx:w*h*mean]", "info:"] + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-threshold", "99.99%", "-format", "%[fx:w*h*mean]", "info:"] # for systems where imagemagick crashes when using the above comparators - args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] - options.convert_exec = 'compare' - compare_method = 'NCC' + # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] + # options.convert_exec = 'compare' + # compare_method = 'NCC' msg = 'ImageMagick image comparison: ' - msg += os.path.basename(options.convert_exec) + ' '.join(args) - msg += ' expected image: ' + expectedfilename + msg += os.path.basename(options.convert_exec) + ' ' + ' '.join(args) + msg += '\nexpected image: ' + expectedfilename + '\n' print >> sys.stderr, msg if not resultfilename: print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" @@ -106,7 +106,7 @@ def compare_png(resultfilename): if pixelerr < 32: return True else: print >> sys.stderr, pixelerr, ' pixel errors' elif compare_method=='NCC': - thresh = 0.99 + thresh = 0.95 ncc_err = float(output.strip()) if ncc_err > thresh: return True else: print >> sys.stderr, ncc_err, ' Images differ: NCC comparison < ', thresh diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index e2193e2..d297caf 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -44,7 +44,7 @@ # (you can set this in the registry to never happen, but itd be better if the program # itself was able to disable that temporarily in it's own process) -import string,sys,re,os,hashlib,subprocess,textwrap +import string,sys,re,os,hashlib,subprocess,textwrap,time def tryread(filename): data = None @@ -254,7 +254,7 @@ TESTLOG 'NUMTESTS':len(tests), 'NUMPASSED':len(passed_tests), 'PERCENTPASSED':percent } for key in dic.keys(): s = s.replace(key,str(dic[key])) - for t in failed_tests: + for t in tests: if t.type=='txt': newchunk = re.sub('FTESTNAME',t.fullname,repeat2) newchunk = newchunk.replace('TESTLOG',t.fulltestlog) @@ -314,26 +314,55 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("\[\[(.*?)\]\]","\\1",x) return head + x + '' +def wiki_login(wikiurl,api_php_path,botname,botpass): + site = mwclient.Site(wikiurl,api_php_path) + site.login(botname,botpass) + return site + +def wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikipgname): + counter = 0 + done = False + descrip = 'test' + time.sleep(1) + while not done: + try: + print 'login',botname,'to',wikiurl + site = wiki_login(wikiurl,api_php_path,botname,botpass) + if wikipgname.endswith('png'): + site.upload(filedata,wikipgname,descrip,ignore=True) + else: + page = site.Pages[wikipgname] + text = page.edit() + page.save(filedata) + done = True + except Exception, e: + print 'Error:', type(e),e + counter += 1 + if counter>maxretry: + print 'giving up. please try a different wiki site' + done = True + else: + print 'wiki',wikiurl,'down. retrying in 15 seconds' + time.sleep(15) + def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname='cakebaby',botpass='anniew',wikidir='.',dryrun=True): wetrun = not dryrun if dryrun: print 'dry run' try: + global mwclient import mwclient except: - print 'please download mwclient and unpack here:', os.getcwd() + print 'please download mwclient 0.6.5 and unpack here:', os.getcwd() sys.exit() - print 'opening site:',wikiurl - if wetrun: - site = mwclient.Site(wikiurl,api_php_path) - - print 'bot login:', botname - if wetrun: site.login(botname,botpass) + + if wetrun: site = wiki_login(wikiurl,api_php_path,botname,botpass) wikifiles = os.listdir(wikidir) testreport_page = filter( lambda x: 'test_report' in x, wikifiles ) if (len(testreport_page)>1): print 'multiple test reports found, please clean dir',wikidir sys.exit() + rootpage = testreport_page[0] print 'add',rootpage,' to main report page ',wiki_rootpath if wetrun: @@ -347,21 +376,9 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= for wikiname in wikifiles: filename = os.path.join(wikidir,wikiname) filedata = tryread(filename) - print 'upload',len(filedata),'bytes from',wikiname,'...', - sys.stdout.flush() - if wikiname.endswith('.png'): - localf = open(filename,'rb') # mwclient needs file handle - descrip = wiki_rootpath + ' test' - if wetrun: - site.upload(localf,wikiname,descrip,ignore=True) - print 'image uploaded' - else: # textpage - if wetrun: - page = site.Pages[wikiname] - text = page.edit() - page.save(filedata) - print 'text page uploaded' - + print 'upload',len(filedata),'bytes from',wikiname,'...' + if wetrun: + wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikiname) def findlogfile(builddir): logpath = os.path.join(builddir,'Testing','Temporary') logfilename = os.path.join(logpath,'LastTest.log.tmp') @@ -374,26 +391,27 @@ def findlogfile(builddir): def main(): dry = False - print 'running test_pretty_print' + if verbose: print 'running test_pretty_print' if '--dryrun' in sys.argv: dry=True suffix = ezsearch('--suffix=(.*?) ',string.join(sys.argv)+' ') builddir = ezsearch('--builddir=(.*?) ',string.join(sys.argv)+' ') if builddir=='': builddir=os.getcwd() - print 'build dir set to', builddir + if verbose: print 'build dir set to', builddir sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) makefiles = load_makefiles(builddir) logpath, logfilename = findlogfile(builddir) testlog = tryread(logfilename) startdate, tests, enddate = parselog(testlog) - print 'found sysinfo.txt,', - print 'found', len(makefiles),'makefiles,', - print 'found', len(tests),'test results' + if verbose: + print 'found sysinfo.txt,', + print 'found', len(makefiles),'makefiles,', + print 'found', len(tests),'test results' imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) - wikidir = os.path.join(logpath,sysid+'_wiki') - print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', '.'+wikidir.replace(os.getcwd(),'') + wikidir = os.path.join(logpath,sysid+'_report') + print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) @@ -401,7 +419,7 @@ def main(): upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', 'tobdacsnepo',wikidir,dryrun=dry) - print 'test_pretty_print complete' + if verbose: print 'test_pretty_print complete' #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' @@ -409,5 +427,7 @@ wikisite = 'cakebaby.wikia.com' wiki_api_path = '/' wiki_rootpath = 'OpenSCAD' builddir = os.getcwd() # os.getcwd()+'/build' +verbose = False +maxretry = 10 main() -- cgit v0.10.1 From c0cb1cde4d560972a40c358b6eb7f129d6a58800 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 7 Dec 2011 05:19:14 +0100 Subject: Updated Qt URL diff --git a/README b/README index a818bf3..8c000fa 100644 --- a/README +++ b/README @@ -35,7 +35,7 @@ numbers in brackets specify the versions which have been used for development. Other versions may or may not work as well.. * Qt4 (4.4 - 4.7): - http://www.qtsoftware.com/ + http://www.qt.nokia.com/ * CGAL (3.6 - 3.9): http://www.cgal.org/ -- cgit v0.10.1 From 9d296acf67a24f5f6120ab8b0dc628f097a5920e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 7 Dec 2011 05:19:45 +0100 Subject: Added some OpenGL notes diff --git a/doc/TODO.txt b/doc/TODO.txt index 4212c21..ca2aa85 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -71,6 +71,8 @@ o 3D View thicknesses, distances, slot thicknesses etc. - Add option to change lights, e.g. add an optional camera light - 2D objects are rendered at z = -0.1 - why? + - Rewrite to use VBOs or smth. - avoid inline calculations + - Rewrite to a higher-level library (e.g. OSG)? o Editor wishlist - More infrastructure for external editor (allow communication from the outside) - Preferences GUI for the features below -- cgit v0.10.1 From d26effccf4c9fabfe19355d6da4903291d8dd599 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 6 Dec 2011 20:20:17 -0800 Subject: allow alternate image comparison using option to cmake diff --git a/doc/testing.txt b/doc/testing.txt index df77073..c2d3ccf 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -50,13 +50,15 @@ Adding a new regression test: Troubleshooting: ------------------------------ -0. Headless unix servers (no X11): +0. Headless unix servers (no X11) $ Xvfb :5 -screen 0 800x600x24 & $ DISPLAY=:5 ctest -1. To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use - the -D option. See CMakeLists.txt for more information. Examples: +1. Trouble finding libraries + + To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use + the -D option. See CMakeLists.txt for more information. Examples: cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 @@ -68,4 +70,11 @@ Pretty-printed html output is in a subdir of tests/build/Testing/Temporary Expected results are found in tests/regression/* Actual results are found in tests/build/testname-output/* -3. Cross-compiling of tests has not been automated nor tested. +3. Cross-compiling + +Cross-compiling of tests has not been automated nor tested + +4. Testing images takes forever, they fail, and it says 'return -11' + +Imagemagick may have crashed. Try passing -DCOMPARATOR=ncc to cmake + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 314b51f..04be773 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -422,6 +422,12 @@ function(get_test_fullname TESTCMD FILENAME FULLNAME) set(${FULLNAME} ${${FULLNAME}} PARENT_SCOPE) endfunction() +# comparison method to use +if (NOT $ENV{COMPARATOR} STREQUAL "") + set(COMPARATOR "$ENV{COMPARATOR}") +endif() +message(STATUS "COMPARATOR: " ${COMPARATOR}) + # # This functions adds cmd-line tests given files. # Files are sent as the parameters following TESTSUFFIX @@ -452,7 +458,7 @@ macro(add_cmdline_test TESTCMD TESTSUFFIX) set(CONFARG CONFIGURATIONS) set(CONFVAL ${FOUNDCONFIGS}) - add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}") + add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}") endif() endforeach() endmacro() diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 480584c..dace3f5 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -78,16 +78,18 @@ def compare_default(resultfilename): def compare_png(resultfilename): compare_method = 'pixel' #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-blur", "2", "-threshold", "30%", "-format", "%[fx:w*h*mean]", "info:"] - #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-morphology", "Erode", "Square", "-format", "%[fx:w*h*mean]", "info:"] + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-morphology", "Erode", "Square", "-format", "%[fx:w*h*mean]", "info:"] # for systems with older imagemagick that doesnt support '-morphology' # http://www.imagemagick.org/Usage/morphology/#alturnative - args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-threshold", "99.99%", "-format", "%[fx:w*h*mean]", "info:"] + if options.comparator == 'old': + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-threshold", "99.99%", "-format", "%[fx:w*h*mean]", "info:"] - # for systems where imagemagick crashes when using the above comparators - # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] - # options.convert_exec = 'compare' - # compare_method = 'NCC' + if options.comparator == 'ncc': + # for systems where imagemagick crashes when using the above comparators + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] + options.convert_exec = 'compare' + compare_method = 'NCC' msg = 'ImageMagick image comparison: ' msg += os.path.basename(options.convert_exec) + ' ' + ' '.join(args) @@ -168,7 +170,7 @@ def usage(): if __name__ == '__main__': # Handle command-line arguments try: - opts, args = getopt.getopt(sys.argv[1:], "gs:c:t:", ["generate", "convexec=", "suffix=", "test="]) + opts, args = getopt.getopt(sys.argv[1:], "gs:c:t:m:", ["generate", "convexec=", "suffix=", "test=", "comparator="]) except getopt.GetoptError, err: usage() sys.exit(2) @@ -186,8 +188,10 @@ if __name__ == '__main__': else: options.suffix = a elif o in ("-t", "--test"): options.testname = a - elif o in ("-c", "--convexec"): + elif o in ("-c", "--convexec"): options.convert_exec = os.path.normpath( a ) + elif o in ("-m", "--comparator"): + options.comparator = a # and if len(args) < 2: diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index d297caf..ca6af5f 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -19,11 +19,13 @@ # # This program 'pretty prints' the ctest output, namely # files from builddir/Testing/Temporary. -# html & wiki output are produced in Testing/Temporary/wiki -# wiki uploading is available by running +# html & wiki output are produced in Testing/Temporary/sysid_report +# +# experimental wiki uploading is available by running # # python test_pretty_print.py --upload # + # Design philosophy # # 1. parse the data (images, logs) into easy-to-use data structures -- cgit v0.10.1 From 679b8d05c8e25ce95e655b2c0f0e2793e408c368 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 7 Dec 2011 05:21:11 +0100 Subject: bugfix: 2D hull() now works with for loops. Thanks to nophead to reasserting this bug. diff --git a/openscad.pro b/openscad.pro index 4a1c0f3..e88a94b 100644 --- a/openscad.pro +++ b/openscad.pro @@ -274,7 +274,6 @@ SOURCES += src/cgalutils.cc \ src/CGALRenderer.cc \ src/CGAL_Nef_polyhedron.cc \ src/CGAL_Nef_polyhedron_DxfData.cc \ - src/cgaladv_convexhull2.cc \ src/cgaladv_minkowski2.cc } diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 1772354..684ab42 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -116,13 +116,12 @@ CGAL_Nef_polyhedron CGALEvaluator::applyToChildren(const AbstractNode &node, CGA return N; } -extern CGAL_Nef_polyhedron2 *convexhull2(std::list a); - CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) { CGAL_Nef_polyhedron N; std::list polys; - std::list points; + std::list points2d; + std::list points3d; int dim = 0; BOOST_FOREACH(const ChildItem &item, this->visitedchildren[node.index()]) { const AbstractNode *chnode = item.first; @@ -137,23 +136,32 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) continue; } if (dim == 2) { - polys.push_back(chN.p2.get()); + CGAL_Nef_polyhedron2::Explorer explorer = chN.p2->explorer(); + BOOST_FOREACH(const CGAL_Nef_polyhedron2::Explorer::Vertex &vh, + std::make_pair(explorer.vertices_begin(), explorer.vertices_end())) { + if (explorer.is_standard(&vh)) { + points2d.push_back(explorer.point(&vh)); + } + } } else if (dim == 3) { CGAL_Polyhedron P; chN.p3->convert_to_Polyhedron(P); - std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points), + std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points3d), boost::bind(static_cast(&CGAL_Polyhedron::Vertex::point), _1)); } chnode->progress_report(); } if (dim == 2) { - N = CGAL_Nef_polyhedron(convexhull2(polys)); + std::list result; + CGAL::convex_hull_2(points2d.begin(), points2d.end(),std:: back_inserter(result)); + N = CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron2(result.begin(), result.end(), + CGAL_Nef_polyhedron2::INCLUDED)); } else if (dim == 3) { CGAL_Polyhedron P; - CGAL::convex_hull_3(points.begin(), points.end(), P); + CGAL::convex_hull_3(points3d.begin(), points3d.end(), P); N = CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron3(P)); } return N; diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc deleted file mode 100644 index 492df3c..0000000 --- a/src/cgaladv_convexhull2.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * OpenSCAD (www.openscad.org) - * Copyright (C) 2009-2011 Clifford Wolf and - * Marius Kintel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * As a special exception, you have permission to link this program - * with the CGAL library and distribute executables, as long as you - * follow the requirements of the GNU GPL in regard to all of the - * software in the executable aside from CGAL. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef ENABLE_CGAL - -#include "cgal.h" -#include - -extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); - -CGAL_Nef_polyhedron2 *convexhull2(std::list a) -{ - std::list points; - - std::list::iterator i; - for (i=a.begin(); i!=a.end(); i++) { - CGAL_Poly2 ap=nef2p2(**i); - for (size_t j=0;j result; - CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result)); - - return new CGAL_Nef_polyhedron2(result.begin(),result.end(),CGAL_Nef_polyhedron2::INCLUDED); -} - -#endif diff --git a/testdata/scad/features/hull2-tests.scad b/testdata/scad/features/hull2-tests.scad index 3bea3c5..e656e6a 100644 --- a/testdata/scad/features/hull2-tests.scad +++ b/testdata/scad/features/hull2-tests.scad @@ -13,7 +13,6 @@ module concave2dSimple() { } } -// Works correctly module convex2dHole() { hull() { translate([15,10,0]) circle(10); @@ -24,7 +23,15 @@ module convex2dHole() { } } +module hull2dForLoop() { + hull() { + for(x = [0,10]) + for(y=[0,10]) + translate([x,y]) circle(3); + } +} convex2dHole(); translate([40,0,0]) convex2dSimple(); translate([0,-20,0]) concave2dSimple(); +translate([30,-25,0]) hull2dForLoop(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 29f8b25..a2e3c34 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -246,8 +246,7 @@ set(CGAL_SOURCES ../src/CGALCache.cc ../src/PolySetCGALEvaluator.cc ../src/CGAL_Nef_polyhedron_DxfData.cc - ../src/cgaladv_minkowski2.cc - ../src/cgaladv_convexhull2.cc) + ../src/cgaladv_minkowski2.cc) set(COMMON_SOURCES ../src/nodedumper.cc diff --git a/tests/regression/cgalpngtest/hull2-tests-expected.png b/tests/regression/cgalpngtest/hull2-tests-expected.png index 256b349..508974f 100644 Binary files a/tests/regression/cgalpngtest/hull2-tests-expected.png and b/tests/regression/cgalpngtest/hull2-tests-expected.png differ diff --git a/tests/regression/dumptest/hull2-tests-expected.txt b/tests/regression/dumptest/hull2-tests-expected.txt index 87365a6..d060d1d 100644 --- a/tests/regression/dumptest/hull2-tests-expected.txt +++ b/tests/regression/dumptest/hull2-tests-expected.txt @@ -32,4 +32,28 @@ } } } + multmatrix([[1, 0, 0, 30], [0, 1, 0, -25], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + hull() { + group() { + group() { + multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + } + group() { + multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + multmatrix([[1, 0, 0, 10], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + } + } + } + } + } diff --git a/tests/regression/opencsgtest/hull2-tests-expected.png b/tests/regression/opencsgtest/hull2-tests-expected.png index 66ee6b2..46b266b 100644 Binary files a/tests/regression/opencsgtest/hull2-tests-expected.png and b/tests/regression/opencsgtest/hull2-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/hull2-tests-expected.png b/tests/regression/throwntogethertest/hull2-tests-expected.png index 221cbaf..46b266b 100644 Binary files a/tests/regression/throwntogethertest/hull2-tests-expected.png and b/tests/regression/throwntogethertest/hull2-tests-expected.png differ -- cgit v0.10.1 From b8ca57233809d32b31342914000c6291b0bdc683 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 22:31:59 -0600 Subject: tweak --upload of pretty print. cleanup diff --git a/doc/testing.txt b/doc/testing.txt index c2d3ccf..b94fd93 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -78,3 +78,7 @@ Cross-compiling of tests has not been automated nor tested Imagemagick may have crashed. Try passing -DCOMPARATOR=ncc to cmake +5. Testing images fails with 'morphology' not found for ImageMagick + +Your version of imagemagick is old. Upgrade, or pass -DCOMPARATOR=old to cmake. +The comparison will be of lowered reliability. diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index ca6af5f..abb50fc 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -330,6 +330,7 @@ def wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikipgname): try: print 'login',botname,'to',wikiurl site = wiki_login(wikiurl,api_php_path,botname,botpass) + print 'uploading...', if wikipgname.endswith('png'): site.upload(filedata,wikipgname,descrip,ignore=True) else: @@ -337,6 +338,7 @@ def wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikipgname): text = page.edit() page.save(filedata) done = True + print 'transfer ok' except Exception, e: print 'Error:', type(e),e counter += 1 @@ -378,7 +380,7 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= for wikiname in wikifiles: filename = os.path.join(wikidir,wikiname) filedata = tryread(filename) - print 'upload',len(filedata),'bytes from',wikiname,'...' + print 'upload',len(filedata),'bytes from',wikiname if wetrun: wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikiname) def findlogfile(builddir): @@ -413,6 +415,8 @@ def main(): imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) wikidir = os.path.join(logpath,sysid+'_report') + if verbose: print 'erasing files in',wikidir + map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) @@ -420,7 +424,8 @@ def main(): if '--upload' in sys.argv: upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', 'tobdacsnepo',wikidir,dryrun=dry) - + print 'upload attempt complete' + if verbose: print 'test_pretty_print complete' #wikisite = 'cakebaby.referata.com' -- cgit v0.10.1 From c2d4f7558e43891df11709a0a9aa049e93560c30 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 22:53:58 -0600 Subject: fix html output of test results diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index abb50fc..3d42901 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -299,22 +299,59 @@ TESTLOG return imgs, txtpages -def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): - # temporarily defunct/broken +def tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles): + # kludge. assume wiki stuff has alreayd run and dumped files properly head = ''+wiki_rootpath+' test run for '+sysid +'' - revmanifest = dict((val,key) for key, val in manifest.iteritems()) - x=re.sub('\{\|(.*?)\n','
\n',wikidata) - x=re.sub('\|(.*?colspan.*?)\|','
',x) - x=re.sub("'''(.*?)'''","\\1",x) - filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) - for f in filestrs: - newfile_html='' - x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) - dic = { '|}':'
', '|-':'
', '|':'', - '!!':'', '!':'
', '\n\n':'\n

\n'} #order matters - for key in dic: x=x.replace(key,dic[key]) - x=re.sub("\[\[(.*?)\]\]","\\1",x) - return head + x + '' + tail = '' + + passed_tests = filter(lambda x: x.passed, tests) + failed_tests = filter(lambda x: not x.passed, tests) + percent = str(int(100.0*len(passed_tests) / len(tests))) + + s='' + + s+= '\n

'
+	s+= '\nSYSINFO\n'+ sysinfo
+	s+= '\n

' + + s+= '\n

'
+	s+= '\nSTARTDATE: '+ startdate
+	s+= '\nENDDATE: '+ enddate
+	s+= '\nWIKI_ROOTPATH: '+ wiki_rootpath
+	s+= '\nSYSID: '+sysid
+	s+= '\nNUMTESTS: '+str(len(tests))
+	s+= '\nNUMPASSED: '+str(len(passed_tests))
+	s+= '\nPERCENTPASSED: '+ percent
+	s+= '\n
' + + for t in tests: + if t.type=='txt': + s+='\n
'+t.fullname+'
\n' + s+='

'+t.fulltestlog+'
\n\n' + elif t.type=='png': + tmp = t.actualfile.replace(builddir,'') + wikiname_a = wikify_filename(tmp,wiki_rootpath,sysid) + tmp = t.expectedfile.replace(os.path.dirname(builddir),'') + wikiname_e = wikify_filename(tmp,wiki_rootpath,sysid) + s+='' + s+='\n
'+t.fullname + s+='\n
ExpectedActual' + s+='\n
' + s+='\n ' + s+='\n
' + s+='\n
'
+			s+=t.fulltestlog
+			s+='\n
' + + s+='\n\n

\n\n' + makefiles_wikinames = {} + for mf in sorted(makefiles.keys()): + tmp = mf.replace('CMakeFiles','').replace('.dir','') + wikiname = wikify_filename(tmp,wiki_rootpath,sysid) + s += '\n'+wikiname+'
' + s+='\n' + + return head + s + tail def wiki_login(wikiurl,api_php_path,botname,botpass): site = mwclient.Site(wikiurl,api_php_path) @@ -418,8 +455,11 @@ def main(): if verbose: print 'erasing files in',wikidir map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') - for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) - for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) + for pgname in sorted(imgs): trysave( os.path.join(wikidir,pgname), imgs[pgname]) + for pgname in sorted(txtpages): trysave( os.path.join(wikidir,pgname), txtpages[pgname]) + + htmldata = tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) + trysave( os.path.join(wikidir,'index.html'), htmldata ) if '--upload' in sys.argv: upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', -- cgit v0.10.1 From 067ebee76ac5bc5e00eb02244d7f7dbd7e6e2797 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 23:00:45 -0600 Subject: now uploads all images not just failed. diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 3d42901..5e8092b 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -202,7 +202,7 @@ SYSINFO start time: STARTDATE
end time : ENDDATE
-'''Failed image tests''' +'''Image tests''' {| border=1 cellspacing=0 cellpadding=1 @@ -223,7 +223,7 @@ TESTLOG -'''Failed text tests''' +'''Text tests''' {|border=1 cellspacing=0 cellpadding=1 @@ -413,6 +413,8 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= page.save(text +'\n*[['+rootpage+']]\n') wikifiles = os.listdir(wikidir) + wikifiles = filter(lambda x: not x.endswith('html'), wikifiles) + print 'upload wiki pages:' for wikiname in wikifiles: filename = os.path.join(wikidir,wikiname) @@ -420,6 +422,7 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= print 'upload',len(filedata),'bytes from',wikiname if wetrun: wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikiname) + def findlogfile(builddir): logpath = os.path.join(builddir,'Testing','Temporary') logfilename = os.path.join(logpath,'LastTest.log.tmp') -- cgit v0.10.1 From 20a3eaa0971530643d74a95507341d0bc278ddb1 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 23:10:44 -0600 Subject: tweak diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 5e8092b..2a92bb4 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -235,6 +235,7 @@ TESTLOG TESTLOG + '''build.make and flags.make''' -- cgit v0.10.1 From 462a4f4f44543d89be829eac6bb64a33854a4dd9 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 7 Dec 2011 00:02:34 -0600 Subject: fix crash bug diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 2a92bb4..955d021 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -457,7 +457,8 @@ def main(): wikidir = os.path.join(logpath,sysid+'_report') if verbose: print 'erasing files in',wikidir - map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) + try: map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) + except: pass print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') for pgname in sorted(imgs): trysave( os.path.join(wikidir,pgname), imgs[pgname]) for pgname in sorted(txtpages): trysave( os.path.join(wikidir,pgname), txtpages[pgname]) -- cgit v0.10.1 From 9a665075c9df74fd646ad187636bc242a9a8816c Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 6 Dec 2011 22:36:33 -0800 Subject: update FindBoost from cmake git. improve crash handling + boost finding diff --git a/doc/testing.txt b/doc/testing.txt index b94fd93..6b0f0d2 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -61,7 +61,7 @@ $ DISPLAY=:5 ctest the -D option. See CMakeLists.txt for more information. Examples: cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 - cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 + cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_DIR=c:\boost_1_46_0 2. Logs @@ -76,7 +76,8 @@ Cross-compiling of tests has not been automated nor tested 4. Testing images takes forever, they fail, and it says 'return -11' -Imagemagick may have crashed. Try passing -DCOMPARATOR=ncc to cmake +Imagemagick may have crashed. You can try using the alternate comparison +based on Normalized Cross Correlation. Pass -DCOMPARATOR=ncc to cmake 5. Testing images fails with 'morphology' not found for ImageMagick diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 04be773..e668db3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -71,14 +71,24 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") endif() +if (NOT $ENV{BOOST_DIR} STREQUAL "") + set(BOOST_DIR "$ENV{BOOST_DIR}") +endif() + +if (NOT ${BOOST_DIR} STREQUAL "") + set(BOOST_ROOT ${BOOST_DIR}) + message(STATUS "BOOST_ROOT: " ${BOOST_ROOT}) + set(Boost_NO_SYSTEM_PATHS "TRUE") + set(Boost_DEBUG TRUE) +endif() + + if (WIN32) set(Boost_USE_STATIC_LIBS TRUE) set(BOOST_STATIC TRUE) set(BOOST_THREAD_USE_LIB TRUE) endif() -#set(Boost_DEBUG TRUE) -set(Boost_NO_SYSTEM_PATHS TRUE) set(Boost_ADDITIONAL_VERSIONS "1.47.0" "1.46.0") find_package( Boost 1.35.0 COMPONENTS thread program_options ) if(Boost_FOUND) diff --git a/tests/FindBoost.cmake b/tests/FindBoost.cmake index dfaf660..ea60354 100644 --- a/tests/FindBoost.cmake +++ b/tests/FindBoost.cmake @@ -17,8 +17,9 @@ # # == Using actual libraries from within Boost: == # -# set(Boost_USE_STATIC_LIBS ON) -# set(Boost_USE_MULTITHREADED ON) +# set(Boost_USE_STATIC_LIBS ON) +# set(Boost_USE_MULTITHREADED ON) +# set(Boost_USE_STATIC_RUNTIME OFF) # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... ) # # if(Boost_FOUND) @@ -33,7 +34,7 @@ # Boost that contain header files only (e.g. foreach) you do not need to # specify COMPONENTS. # -# You should provide a minimum version number that should be used. If you provide this +# You should provide a minimum version number that should be used. If you provide this # version number and specify the REQUIRED attribute, this module will fail if it # can't find the specified or a later version. If you specify a version number this is # automatically put into the considered list of version numbers and thus doesn't need @@ -63,14 +64,15 @@ # Currently this module searches for the following version numbers: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, -# 1.40, 1.40.0, 1.41, 1.41.0 +# 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0, +# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories # omit the 3rd version number from include paths if it is 0 although not all # binary Boost releases do so. # -# SET(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0") +# set(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0") # # ===================================== ============= ======================== # @@ -84,6 +86,43 @@ # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static # boost libraries. Defaults to OFF. # +# Boost_NO_SYSTEM_PATHS Set to TRUE to suppress searching in system +# paths (or other locations outside of BOOST_ROOT +# or BOOST_INCLUDEDIR). Useful when specifying +# BOOST_ROOT. Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_NO_BOOST_CMAKE Do not do a find_package call in config mode +# before searching for a regular boost install. +# This will avoid finding boost-cmake installs. +# Defaults to OFF. +# [Since CMake 2.8.6] +# +# Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries +# linked against a static C++ standard library +# ('s' ABI tag). This option should be set to +# ON or OFF because the default behavior +# if not specified is platform dependent +# for backwards compatibility. +# [Since CMake 2.8.3] +# +# Boost_USE_DEBUG_PYTHON If enabled, searches for boost libraries +# compiled against a special debug build of +# Python ('y' ABI tag). Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_USE_STLPORT If enabled, searches for boost libraries +# compiled against the STLPort standard +# library ('p' ABI tag). Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS +# If enabled, searches for boost libraries +# compiled against the deprecated STLPort +# "native iostreams" feature ('n' ABI tag). +# Defaults to OFF. +# [Since CMake 2.8.3] +# # Other Variables used by this module which you may want to set. # # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching @@ -101,17 +140,58 @@ # unless this is set to TRUE or the REQUIRED # keyword is specified in find_package(). # [Since CMake 2.8.0] -# +# # Boost_COMPILER Set this to the compiler suffix used by Boost # (e.g. "-gcc43") if FindBoost has problems finding # the proper Boost installation # +# Boost_THREADAPI When building boost.thread, sometimes the name of the +# library contains an additional "pthread" or "win32" +# string known as the threadapi. This can happen when +# compiling against pthreads on Windows or win32 threads +# on Cygwin. You may specify this variable and if set +# when FindBoost searches for the Boost threading library +# it will first try to match the threadapi you specify. +# For Example: libboost_thread_win32-mgw45-mt-1_43.a +# might be found if you specified "win32" here before +# falling back on libboost_thread-mgw45-mt-1_43.a. +# [Since CMake 2.8.3] +# +# Boost_REALPATH Resolves symbolic links for discovered boost libraries +# to assist with packaging. For example, instead of +# Boost_SYSTEM_LIBRARY_RELEASE being resolved to +# "/usr/lib/libboost_system.so" it would be +# "/usr/lib/libboost_system.so.1.42.0" instead. +# This does not affect linking and should not be +# enabled unless the user needs this information. +# [Since CMake 2.8.3] +# + + +# # These last three variables are available also as environment variables: +# Also, note they are completely UPPERCASE, except Boost_DIR. # -# BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for -# Boost. Set this if the module has problems finding +# Boost_DIR or The preferred installation prefix for searching for +# BOOST_ROOT or BOOSTROOT Boost. Set this if the module has problems finding # the proper Boost installation. # +# Note that Boost_DIR behaves exactly as _DIR +# variables are documented to behave in find_package's +# Config mode. That is, if it is set as a -D argument +# to CMake, it must point to the location of the +# BoostConfig.cmake or Boost-config.cmake file. If it +# is set as an environment variable, it must point to +# the root of the boost installation. BOOST_ROOT and +# BOOSTROOT, on the other hand, will point to the root +# in either case. +# +# To prevent falling back on the system paths, set +# Boost_NO_SYSTEM_PATHS to true. +# +# To avoid finding boost-cmake installations, set +# Boost_NO_BOOST_CMAKE to true. +# # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation # @@ -165,7 +245,7 @@ # Copyright 2007 Wengo # Copyright 2007 Mike Jackson # Copyright 2008 Andreas Pakulat -# Copyright 2008-2009 Philip Lowman +# Copyright 2008-2010 Philip Lowman # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -174,9 +254,46 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) + +#------------------------------------------------------------------------------- +# Before we go searching, check whether boost-cmake is avaialble, unless the +# user specifically asked NOT to search for boost-cmake. +# +# If Boost_DIR is set, this behaves as any find_package call would. If not, +# it looks at BOOST_ROOT and BOOSTROOT to find Boost. +# +if (NOT Boost_NO_BOOST_CMAKE) + # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives, + # since these are more conventional for Boost. + if ("$ENV{Boost_DIR}" STREQUAL "") + if (NOT "$ENV{BOOST_ROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOST_ROOT}) + elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOSTROOT}) + endif() + endif() + + # Do the same find_package call but look specifically for the CMake version. + # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no + # need to delegate them to this find_package call. + find_package(Boost QUIET NO_MODULE) + + # If we found boost-cmake, then we're done. Print out what we found. + # Otherwise let the rest of the module try to find it. + if (Boost_FOUND) + message("Boost ${Boost_FIND_VERSION} found.") + if (Boost_FIND_COMPONENTS) + message("Found Boost components:") + message(" ${Boost_FIND_COMPONENTS}") + endif() + return() + endif() +endif() + + #------------------------------------------------------------------------------- # FindBoost functions & macros # @@ -192,59 +309,65 @@ # And ELSE/ENDIF pairs were removed for readability. ######################################################################### -MACRO (_Boost_ADJUST_LIB_VARS basename) - IF (Boost_INCLUDE_DIR ) - IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE) +macro(_Boost_ADJUST_LIB_VARS basename) + if(Boost_INCLUDE_DIR ) + if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE) # if the generator supports configuration types then set # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) - ELSE() + if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) + else() # if there are no configuration types and CMAKE_BUILD_TYPE has no value # then just use the release libraries - SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) - ENDIF() + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) + endif() # FIXME: This probably should be set for both cases - SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) - ENDIF() + set(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) + endif() # if only the release version was found, set the debug variable also to the release version - IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG) - SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE}) - SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE}) - SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE}) - ENDIF() + if(Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG) + set(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE}) + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE}) + set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE}) + endif() # if only the debug version was found, set the release variable also to the debug version - IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE) - SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG}) - SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG}) - SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG}) - ENDIF() - - IF (Boost_${basename}_LIBRARY) + if(Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE) + set(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG}) + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG}) + set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG}) + endif() + + # If the debug & release library ends up being the same, omit the keywords + if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG}) + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) + set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} ) + endif() + + if(Boost_${basename}_LIBRARY) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") # Remove superfluous "debug" / "optimized" keywords from # Boost_LIBRARY_DIRS - FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY}) - GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH) - LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path}) - ENDFOREACH() - LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) + foreach(_boost_my_lib ${Boost_${basename}_LIBRARY}) + get_filename_component(_boost_my_lib_path "${_boost_my_lib}" PATH) + list(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path}) + endforeach() + list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory") - SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found") - ENDIF(Boost_${basename}_LIBRARY) + set(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found") + endif(Boost_${basename}_LIBRARY) - ENDIF (Boost_INCLUDE_DIR ) + endif(Boost_INCLUDE_DIR ) # Make variables changeble to the advanced user - MARK_AS_ADVANCED( + mark_as_advanced( Boost_${basename}_LIBRARY Boost_${basename}_LIBRARY_RELEASE Boost_${basename}_LIBRARY_DEBUG ) -ENDMACRO (_Boost_ADJUST_LIB_VARS) +endmacro(_Boost_ADJUST_LIB_VARS) #------------------------------------------------------------------------------- @@ -252,17 +375,17 @@ ENDMACRO (_Boost_ADJUST_LIB_VARS) # Runs compiler with "-dumpversion" and parses major/minor # version with a regex. # -FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) +function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) - EXEC_PROGRAM(${CMAKE_CXX_COMPILER} + exec_program(${CMAKE_CXX_COMPILER} ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion OUTPUT_VARIABLE _boost_COMPILER_VERSION ) - STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" + string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION}) - SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE) -ENDFUNCTION() + set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE) +endfunction() # # A convenience function for marking desired components @@ -276,16 +399,45 @@ function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no) endfunction() # +# Take a list of libraries with "thread" in it +# and prepend duplicates with "thread_${Boost_THREADAPI}" +# at the front of the list +# +function(_Boost_PREPEND_LIST_WITH_THREADAPI _output) + set(_orig_libnames ${ARGN}) + string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames ${_orig_libnames}) + set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE) +endfunction() + +# +# If a library is found, replace its cache entry with its REALPATH +# +function(_Boost_SWAP_WITH_REALPATH _library _docstring) + if(${_library}) + get_filename_component(_boost_filepathreal ${${_library}} REALPATH) + unset(${_library} CACHE) + set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}") + endif() +endfunction() + +function(_Boost_CHECK_SPELLING _var) + if(${_var}) + string(TOUPPER ${_var} _var_UC) + message(FATAL_ERROR "ERROR: ${_var} is not the correct spelling. The proper spelling is ${_var_UC}.") + endif() +endfunction() + +# # End functions/macros -# +# #------------------------------------------------------------------------------- -IF(NOT DEFINED Boost_USE_MULTITHREADED) - SET(Boost_USE_MULTITHREADED TRUE) -ENDIF() +if(NOT DEFINED Boost_USE_MULTITHREADED) + set(Boost_USE_MULTITHREADED TRUE) +endif() if(Boost_FIND_VERSION_EXACT) # The version may appear in a directory with or without the patch @@ -297,6 +449,8 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} + "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" + "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") @@ -325,49 +479,47 @@ endif(Boost_FIND_VERSION_EXACT) # Boost. set(Boost_ERROR_REASON) -SET( _boost_IN_CACHE TRUE) -IF(Boost_INCLUDE_DIR) +set( _boost_IN_CACHE TRUE) +if(Boost_INCLUDE_DIR) # On versions < 1.35, remove the System library from the considered list # since it wasn't added until 1.35. if(Boost_VERSION AND Boost_FIND_COMPONENTS) - math(EXPR _boost_maj "${Boost_VERSION} / 100000") - math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000") - if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35) + if(Boost_VERSION LESS 103500) list(REMOVE_ITEM Boost_FIND_COMPONENTS system) endif() endif() - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} COMPONENT) - IF(NOT Boost_${COMPONENT}_FOUND) - SET( _boost_IN_CACHE FALSE) - ENDIF(NOT Boost_${COMPONENT}_FOUND) - ENDFOREACH(COMPONENT) -ELSE(Boost_INCLUDE_DIR) - SET( _boost_IN_CACHE FALSE) -ENDIF(Boost_INCLUDE_DIR) - -IF (_boost_IN_CACHE) + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} COMPONENT) + if(NOT Boost_${COMPONENT}_FOUND) + set( _boost_IN_CACHE FALSE) + endif(NOT Boost_${COMPONENT}_FOUND) + endforeach(COMPONENT) +else(Boost_INCLUDE_DIR) + set( _boost_IN_CACHE FALSE) +endif(Boost_INCLUDE_DIR) + +if(_boost_IN_CACHE) # in cache already - SET(Boost_FOUND TRUE) - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} COMPONENT) + set(Boost_FOUND TRUE) + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} COMPONENT) _Boost_ADJUST_LIB_VARS( ${COMPONENT} ) - SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY}) - ENDFOREACH(COMPONENT) - SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) - IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") - MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") - MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") - MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") - ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + set(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY}) + endforeach(COMPONENT) + set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) + if(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") + math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") + math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") + endif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} " - "is already in the cache. For debugging messages, please clear the cache.") + "is already in the cache. To view debugging messages, please clear the cache.") endif() -ELSE (_boost_IN_CACHE) +else(_boost_IN_CACHE) # Need to search for boost if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " @@ -379,9 +531,15 @@ ELSE (_boost_IN_CACHE) "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}") endif() - IF(WIN32) + if(WIN32) # In windows, automatic linking is performed, so you do not have # to specify the libraries. If you are linking to a dynamic # runtime, then you can choose to link to either a static or a @@ -390,20 +548,20 @@ ELSE (_boost_IN_CACHE) # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be # linked dynamically. Alternatively you can force all Boost # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. - + # This feature can be disabled for Boost library "whatever" by # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining # BOOST_ALL_NO_LIB. - + # If you want to observe which libraries are being linked against # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking # code to emit a #pragma message each time a library is selected # for linking. - SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS + set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define") - ENDIF(WIN32) + endif(WIN32) - SET(_boost_INCLUDE_SEARCH_DIRS + set(_boost_INCLUDE_SEARCH_DIRS_SYSTEM C:/boost/include C:/boost "$ENV{ProgramFiles}/boost/include" @@ -411,29 +569,38 @@ ELSE (_boost_IN_CACHE) /sw/local/include ) + _Boost_CHECK_SPELLING(Boost_ROOT) + _Boost_CHECK_SPELLING(Boost_LIBRARYDIR) + _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) + + # If BOOST_ROOT was defined in the environment, use it. + if (NOT BOOST_ROOT AND NOT $ENV{Boost_DIR} STREQUAL "") + set(BOOST_ROOT $ENV{Boost_DIR}) + endif() + # If BOOST_ROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOST_ROOT}) - endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") + endif() # If BOOSTROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOSTROOT}) - endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") + endif() # If BOOST_INCLUDEDIR was defined in the environment, use it. - IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) + if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR}) - ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) - + endif() + # If BOOST_LIBRARYDIR was defined in the environment, use it. - IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) + if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR}) - ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) - - IF( BOOST_ROOT ) + endif() + + if( BOOST_ROOT ) file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT) - ENDIF( BOOST_ROOT ) + endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " @@ -448,50 +615,54 @@ ELSE (_boost_IN_CACHE) "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") endif() - IF( BOOST_ROOT ) - SET(_boost_INCLUDE_SEARCH_DIRS - ${BOOST_ROOT}/include + if( Boost_NO_SYSTEM_PATHS) + set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + else() + set(_boost_INCLUDE_SEARCH_DIRS ${_boost_INCLUDE_SEARCH_DIRS_SYSTEM}) + endif() + + if( BOOST_ROOT ) + set(_boost_INCLUDE_SEARCH_DIRS + ${BOOST_ROOT}/include ${BOOST_ROOT} ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( BOOST_ROOT ) + endif() - IF( BOOST_INCLUDEDIR ) + # prepend BOOST_INCLUDEDIR to search path if specified + if( BOOST_INCLUDEDIR ) file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR) - SET(_boost_INCLUDE_SEARCH_DIRS + set(_boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( BOOST_INCLUDEDIR ) + endif( BOOST_INCLUDEDIR ) # ------------------------------------------------------------------------ - # Search for Boost include DIR + # Search for Boost include DIR # ------------------------------------------------------------------------ # Try to find Boost by stepping backwards through the Boost versions # we know about. - IF( NOT Boost_INCLUDE_DIR ) + if( NOT Boost_INCLUDE_DIR ) # Build a list of path suffixes for each version. - SET(_boost_PATH_SUFFIXES) - FOREACH(_boost_VER ${_boost_TEST_VERSIONS}) + set(_boost_PATH_SUFFIXES) + foreach(_boost_VER ${_boost_TEST_VERSIONS}) # Add in a path suffix, based on the required version, ideally # we could read this from version.hpp, but for that to work we'd # need to know the include dir already set(_boost_BOOSTIFIED_VERSION) # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0 - IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" + if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_BOOSTIFIED_VERSION ${_boost_VER}) - ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" + elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_BOOSTIFIED_VERSION ${_boost_VER}) - ENDIF() - - list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}") - if(WIN32) - # For BoostPro's underscores (and others?) - list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") endif() - ENDFOREACH(_boost_VER) - + list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}") + list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") + + endforeach(_boost_VER) + if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Include debugging info:") @@ -502,61 +673,62 @@ ELSE (_boost_IN_CACHE) endif() # Look for a standard boost header file. - FIND_PATH(Boost_INCLUDE_DIR + find_path(Boost_INCLUDE_DIR NAMES boost/config.hpp HINTS ${_boost_INCLUDE_SEARCH_DIRS} PATH_SUFFIXES ${_boost_PATH_SUFFIXES} + ${_boost_FIND_OPTIONS} ) - ENDIF( NOT Boost_INCLUDE_DIR ) - + endif( NOT Boost_INCLUDE_DIR ) + # ------------------------------------------------------------------------ # Extract version information from version.hpp # ------------------------------------------------------------------------ - IF(Boost_INCLUDE_DIR) + if(Boost_INCLUDE_DIR) # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp # Read the whole file: # - SET(BOOST_VERSION 0) - SET(BOOST_LIB_VERSION "") - FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS) + set(BOOST_VERSION 0) + set(BOOST_LIB_VERSION "") + file(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") endif() - - STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}") - STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}") - - SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries") - SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries") - - IF(NOT "${Boost_VERSION}" STREQUAL "0") - MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") - MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") - MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") + + string(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}") + string(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}") + + set(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries") + set(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries") + + if(NOT "${Boost_VERSION}" STREQUAL "0") + math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") + math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") + math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") set(Boost_ERROR_REASON "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") - ENDIF(NOT "${Boost_VERSION}" STREQUAL "0") + endif(NOT "${Boost_VERSION}" STREQUAL "0") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "version.hpp reveals boost " "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") endif() - ELSE(Boost_INCLUDE_DIR) + else(Boost_INCLUDE_DIR) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") - ENDIF(Boost_INCLUDE_DIR) - + endif(Boost_INCLUDE_DIR) + # ------------------------------------------------------------------------ # Suffix initialization and compiler suffix detection. # ------------------------------------------------------------------------ # Setting some more suffixes for the library - SET (Boost_LIB_PREFIX "") - if ( WIN32 AND Boost_USE_STATIC_LIBS ) - SET (Boost_LIB_PREFIX "lib") + set(Boost_LIB_PREFIX "") + if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) + set(Boost_LIB_PREFIX "lib") endif() if (Boost_COMPILER) @@ -571,62 +743,64 @@ ELSE (_boost_IN_CACHE) # please report them and use the Boost_COMPILER variable # to work around the problems. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" - OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" + OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") if(WIN32) set (_boost_COMPILER "-iw") else() set (_boost_COMPILER "-il") endif() - elseif (MSVC90) - SET (_boost_COMPILER "-vc90") + elseif (MSVC11) + set(_boost_COMPILER "-vc110") elseif (MSVC10) - SET (_boost_COMPILER "-vc100") + set(_boost_COMPILER "-vc100") + elseif (MSVC90) + set(_boost_COMPILER "-vc90") elseif (MSVC80) - SET (_boost_COMPILER "-vc80") + set(_boost_COMPILER "-vc80") elseif (MSVC71) - SET (_boost_COMPILER "-vc71") + set(_boost_COMPILER "-vc71") elseif (MSVC70) # Good luck! - SET (_boost_COMPILER "-vc7") # yes, this is correct + set(_boost_COMPILER "-vc7") # yes, this is correct elseif (MSVC60) # Good luck! - SET (_boost_COMPILER "-vc6") # yes, this is correct + set(_boost_COMPILER "-vc6") # yes, this is correct elseif (BORLAND) - SET (_boost_COMPILER "-bcb") + set(_boost_COMPILER "-bcb") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro") set(_boost_COMPILER "-sw") elseif (MINGW) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) - SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 + set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) - SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") + set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") endif() elseif (UNIX) if (CMAKE_COMPILER_IS_GNUCXX) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) - SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 + set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) # Determine which version of GCC we have. - IF(APPLE) - IF(Boost_MINOR_VERSION) - IF(${Boost_MINOR_VERSION} GREATER 35) + if(APPLE) + if(Boost_MINOR_VERSION) + if(${Boost_MINOR_VERSION} GREATER 35) # In Boost 1.36.0 and newer, the mangled compiler name used # on Mac OS X/Darwin is "xgcc". - SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") - ELSE(${Boost_MINOR_VERSION} GREATER 35) + set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") + else(${Boost_MINOR_VERSION} GREATER 35) # In Boost <= 1.35.0, there is no mangled compiler name for # the Mac OS X/Darwin version of GCC. - SET(_boost_COMPILER "") - ENDIF(${Boost_MINOR_VERSION} GREATER 35) - ELSE(Boost_MINOR_VERSION) + set(_boost_COMPILER "") + endif(${Boost_MINOR_VERSION} GREATER 35) + else(Boost_MINOR_VERSION) # We don't know the Boost version, so assume it's # pre-1.36.0. - SET(_boost_COMPILER "") - ENDIF(Boost_MINOR_VERSION) - ELSE() - SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") - ENDIF() + set(_boost_COMPILER "") + endif(Boost_MINOR_VERSION) + else() + set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") + endif() endif() endif (CMAKE_COMPILER_IS_GNUCXX) endif() @@ -636,7 +810,7 @@ ELSE (_boost_IN_CACHE) endif() endif(Boost_COMPILER) - SET (_boost_MULTITHREADED "-mt") + set (_boost_MULTITHREADED "-mt") if( NOT Boost_USE_MULTITHREADED ) set (_boost_MULTITHREADED "") endif() @@ -645,32 +819,67 @@ ELSE (_boost_IN_CACHE) "_boost_MULTITHREADED = ${_boost_MULTITHREADED}") endif() - SET( _boost_STATIC_TAG "") - set( _boost_ABI_TAG "") - IF (WIN32) - IF(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" + #====================== + # Systematically build up the Boost ABI tag + # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming + set( _boost_RELEASE_ABI_TAG "-") + set( _boost_DEBUG_ABI_TAG "-") + # Key Use this library when: + # s linking statically to the C++ standard library and + # compiler runtime support libraries. + if(Boost_USE_STATIC_RUNTIME) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s") + endif() + # g using debug versions of the standard and runtime + # support libraries + if(WIN32) + if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") - SET (_boost_ABI_TAG "g") - ENDIF() - IF( Boost_USE_STATIC_LIBS ) - SET( _boost_STATIC_TAG "-s") - ENDIF( Boost_USE_STATIC_LIBS ) - ENDIF(WIN32) - SET (_boost_ABI_TAG "${_boost_ABI_TAG}d") + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") + endif() + endif() + # y using special debug build of python + if(Boost_USE_DEBUG_PYTHON) + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y") + endif() + # d using a debug version of your code + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d") + # p using the STLport standard library rather than the + # default one supplied with your compiler + if(Boost_USE_STLPORT) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p") + endif() + # n using the STLport deprecated "native iostreams" feature + if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n") + endif() + if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_STATIC_TAG = ${_boost_STATIC_TAG}") + "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_ABI_TAG = ${_boost_ABI_TAG}") + "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}") endif() # ------------------------------------------------------------------------ # Begin finding boost libraries # ------------------------------------------------------------------------ - SET(_boost_LIBRARIES_SEARCH_DIRS + if(BOOST_ROOT) + set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS + ${BOOST_ROOT}/lib + ${BOOST_ROOT}/stage/lib) + endif() + set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS + ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS} ${Boost_INCLUDE_DIR}/lib ${Boost_INCLUDE_DIR}/../lib + ${Boost_INCLUDE_DIR}/stage/lib + ) + set(_boost_LIBRARY_SEARCH_DIRS_SYSTEM C:/boost/lib C:/boost "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib" @@ -679,78 +888,158 @@ ELSE (_boost_IN_CACHE) "$ENV{ProgramFiles}/boost" /sw/local/lib ) - IF( BOOST_ROOT ) - SET(_boost_LIBRARIES_SEARCH_DIRS - ${BOOST_ROOT}/lib - ${BOOST_ROOT}/stage/lib - ${_boost_LIBRARIES_SEARCH_DIRS}) - ENDIF( BOOST_ROOT ) - - IF( BOOST_LIBRARYDIR ) + set(_boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS}) + if( Boost_NO_SYSTEM_PATHS ) + set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + else() + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_SYSTEM}) + endif() + + # prepend BOOST_LIBRARYDIR to search path if specified + if( BOOST_LIBRARYDIR ) file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR) - SET(_boost_LIBRARIES_SEARCH_DIRS - ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS}) - ENDIF( BOOST_LIBRARYDIR ) + set(_boost_LIBRARY_SEARCH_DIRS + ${BOOST_LIBRARYDIR} ${_boost_LIBRARY_SEARCH_DIRS}) + endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}") - endif() - - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) - SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) - SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) - SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") - - # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES - IF( Boost_USE_STATIC_LIBS ) - SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - IF(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - ELSE(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - ENDIF(WIN32) - ENDIF( Boost_USE_STATIC_LIBS ) - - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG} - HINTS ${_boost_LIBRARIES_SEARCH_DIRS} + "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}") + endif() + + # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES + if( Boost_USE_STATIC_LIBS ) + set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + endif() + endif() + + # We want to use the tag inline below without risking double dashes + if(_boost_RELEASE_ABI_TAG) + if(${_boost_RELEASE_ABI_TAG} STREQUAL "-") + set(_boost_RELEASE_ABI_TAG "") + endif() + endif() + if(_boost_DEBUG_ABI_TAG) + if(${_boost_DEBUG_ABI_TAG} STREQUAL "-") + set(_boost_DEBUG_ABI_TAG "") + endif() + endif() + + # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled + # on WIN32 was to: + # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found) + # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found) + # We maintain this behavior since changing it could break people's builds. + # To disable the ambiguous behavior, the user need only + # set Boost_USE_STATIC_RUNTIME either ON or OFF. + set(_boost_STATIC_RUNTIME_WORKAROUND false) + if(WIN32 AND Boost_USE_STATIC_LIBS) + if(NOT DEFINED Boost_USE_STATIC_RUNTIME) + set(_boost_STATIC_RUNTIME_WORKAROUND true) + endif() + endif() + + + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + set( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) + set( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) + set( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") + + set( _boost_docstring_release "Boost ${COMPONENT} library (release)") + set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)") + + # + # Find RELEASE libraries + # + set(_boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") + endif() + find_library(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE + NAMES ${_boost_RELEASE_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + ${_boost_FIND_OPTIONS} + DOC "${_boost_docstring_release}" ) - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG} - HINTS ${_boost_LIBRARIES_SEARCH_DIRS} + # + # Find DEBUG libraries + # + set(_boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") + endif() + find_library(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG + NAMES ${_boost_DEBUG_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + ${_boost_FIND_OPTIONS} + DOC "${_boost_docstring_debug}" ) + if(Boost_REALPATH) + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}") + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" ) + endif() + _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) - IF( Boost_USE_STATIC_LIBS ) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - ENDIF( Boost_USE_STATIC_LIBS ) - ENDFOREACH(COMPONENT) + + endforeach(COMPONENT) + + # Restore the original find library ordering + if( Boost_USE_STATIC_LIBS ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() # ------------------------------------------------------------------------ # End finding boost libraries # ------------------------------------------------------------------------ - SET(Boost_INCLUDE_DIRS + set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR} ) - SET(Boost_FOUND FALSE) - IF(Boost_INCLUDE_DIR) - SET( Boost_FOUND TRUE ) + set(Boost_FOUND FALSE) + if(Boost_INCLUDE_DIR) + set( Boost_FOUND TRUE ) # Check the version of Boost against the requested version. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) @@ -785,7 +1074,7 @@ ELSE (_boost_IN_CACHE) if (NOT Boost_FIND_VERSION_PATCH) set(Boost_FIND_VERSION_PATCH 0) endif (NOT Boost_FIND_VERSION_PATCH) - + # We'll set Boost_FOUND true again if we have an exact version match. set(Boost_FOUND FALSE) _Boost_MARK_COMPONENTS_FOUND(OFF) @@ -804,7 +1093,7 @@ ELSE (_boost_IN_CACHE) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") if (Boost_FIND_VERSION_PATCH) - set(Boost_ERROR_REASON + set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}") endif (Boost_FIND_VERSION_PATCH) if (NOT Boost_FIND_VERSION_EXACT) @@ -823,7 +1112,7 @@ ELSE (_boost_IN_CACHE) string(TOLOWER ${COMPONENT} COMPONENT) list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) set( Boost_FOUND FALSE) - endif(NOT Boost_${COMPONENT}_FOUND) + endif() endforeach(COMPONENT) if(Boost_DEBUG) @@ -844,67 +1133,67 @@ ELSE (_boost_IN_CACHE) list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) endif (_Boost_MISSING_COMPONENTS) - IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) + if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) # Compatibility Code for backwards compatibility with CMake # 2.4's FindBoost module. # Look for the boost library path. # Note that the user may not have installed any libraries # so it is quite possible the Boost_LIBRARY_PATH may not exist. - SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) - - IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") - GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) - ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") - - IF("${_boost_LIB_DIR}" MATCHES "/include$") + set(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) + + if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") + get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) + endif() + + if("${_boost_LIB_DIR}" MATCHES "/include$") # Strip off the trailing "/include" in the path. - GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) - ENDIF("${_boost_LIB_DIR}" MATCHES "/include$") - - IF(EXISTS "${_boost_LIB_DIR}/lib") - SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib) - ELSE(EXISTS "${_boost_LIB_DIR}/lib") - IF(EXISTS "${_boost_LIB_DIR}/stage/lib") - SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib) - ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib") - SET(_boost_LIB_DIR "") - ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib") - ENDIF(EXISTS "${_boost_LIB_DIR}/lib") - - IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") - SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory") - ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") - - ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) - - ELSE(Boost_INCLUDE_DIR) - SET( Boost_FOUND FALSE) - ENDIF(Boost_INCLUDE_DIR) - - IF (Boost_FOUND) - IF (NOT Boost_FIND_QUIETLY) - MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") + get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) + endif() + + if(EXISTS "${_boost_LIB_DIR}/lib") + set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib) + else() + if(EXISTS "${_boost_LIB_DIR}/stage/lib") + set(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib) + else() + set(_boost_LIB_DIR "") + endif() + endif() + + if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") + set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory") + endif() + + endif( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) + + else(Boost_INCLUDE_DIR) + set( Boost_FOUND FALSE) + endif(Boost_INCLUDE_DIR) + + if(Boost_FOUND) + if(NOT Boost_FIND_QUIETLY) + message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") if(Boost_FIND_COMPONENTS) message(STATUS "Found the following Boost libraries:") endif() - ENDIF(NOT Boost_FIND_QUIETLY) - FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} ) - STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT ) - IF ( Boost_${UPPERCOMPONENT}_FOUND ) - IF (NOT Boost_FIND_QUIETLY) - MESSAGE (STATUS " ${COMPONENT}") - ENDIF(NOT Boost_FIND_QUIETLY) - SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY}) - ENDIF ( Boost_${UPPERCOMPONENT}_FOUND ) - ENDFOREACH(COMPONENT) + endif(NOT Boost_FIND_QUIETLY) + foreach( COMPONENT ${Boost_FIND_COMPONENTS} ) + string( TOUPPER ${COMPONENT} UPPERCOMPONENT ) + if( Boost_${UPPERCOMPONENT}_FOUND ) + if(NOT Boost_FIND_QUIETLY) + message (STATUS " ${COMPONENT}") + endif(NOT Boost_FIND_QUIETLY) + set(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY}) + endif( Boost_${UPPERCOMPONENT}_FOUND ) + endforeach(COMPONENT) else() if(Boost_FIND_REQUIRED) message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}") @@ -924,9 +1213,8 @@ ELSE (_boost_IN_CACHE) endif() # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view - MARK_AS_ADVANCED(Boost_INCLUDE_DIR + mark_as_advanced(Boost_INCLUDE_DIR Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS ) -ENDIF(_boost_IN_CACHE) - +endif(_boost_IN_CACHE) diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index dace3f5..848a6eb 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -26,6 +26,7 @@ import re import getopt import shutil import platform +import string def initialize_environment(): if not options.generate: options.generate = bool(os.getenv("TEST_GENERATE")) @@ -91,8 +92,7 @@ def compare_png(resultfilename): options.convert_exec = 'compare' compare_method = 'NCC' - msg = 'ImageMagick image comparison: ' - msg += os.path.basename(options.convert_exec) + ' ' + ' '.join(args) + msg = 'ImageMagick image comparison: ' + options.convert_exec + ' '+ ' '.join(args[2:]) msg += '\nexpected image: ' + expectedfilename + '\n' print >> sys.stderr, msg if not resultfilename: -- cgit v0.10.1 From b23c60d320f744f0e585992ba32226daa685d6cb Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 7 Dec 2011 00:47:15 -0600 Subject: add notice about NDEBUG and CMakeCache.txt to fix cgalpngtest errors diff --git a/doc/testing.txt b/doc/testing.txt index 6b0f0d2..403ef4a 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -83,3 +83,8 @@ based on Normalized Cross Correlation. Pass -DCOMPARATOR=ncc to cmake Your version of imagemagick is old. Upgrade, or pass -DCOMPARATOR=old to cmake. The comparison will be of lowered reliability. + +6. Many cgalpngtests are failing with weird assertion errors. + +Edit CMakeCache.txt and replace '-DNDEBUG' or '/D NDEBUG' with blank spaces + diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 955d021..fa8b390 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -33,7 +33,6 @@ # 3. save the wikified data to disk # todo -# repair html output # do something if tests for GL extensions for OpenCSG fail (test fail, no image production) # copy all images, sysinfo.txt to bundle for html/upload (images # can be altered by subsequent runs) -- cgit v0.10.1 From faae7882e26c048b0ae2bf7a54065d31d0edbc31 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 7 Dec 2011 00:56:40 -0600 Subject: fix pretty diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e668db3..bb05ce7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -487,10 +487,10 @@ set(CTEST_CUSTOM_TXT "\n ") file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) -#foreach(FILE test_pretty_print.py) -# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE} -# ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY) -#endforeach() +foreach(FILE test_pretty_print.py) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE} + ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY) +endforeach() set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake") -- cgit v0.10.1 From 577359073769db76d174284f490de96046abb428 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 7 Dec 2011 21:34:30 +0100 Subject: sync diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 2681482..1bf3d8a 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -4,6 +4,7 @@ OpenSCAD 20xx.yy Features: o The MCAD library is now bundled with OpenSCAD o hull() Now supports 3D objects +o hull() with 2D object can now use for loops and boolean operations as children o Added import and export of the OFF file format o New import() statement reads the correct file format based on the filename extension (.stl, .dxf and .off is supported) diff --git a/doc/TODO.txt b/doc/TODO.txt index ca2aa85..560e270 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -140,7 +140,6 @@ o 2D Subsystem o Built-in modules - extrude*: Allow the base 2D primitive to have a Z value - rotate_extrude(): Allow for specification of start/stop/sweep angle? - - Convex hull of 3D objects o Advanced Transformations - Add statement for refinement via surface subdivision - Add statement for intersections in cartesian product of childs @@ -238,7 +237,6 @@ MISSING TESTS: o all functions o mirror o scale -o 3D hull o open polyline from dxf using new method o linear_extrude DXF o rotate_extrude DXF -- cgit v0.10.1 From e3bfaca222d41a54f3d7946d4d3117054bb052ad Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 7 Dec 2011 22:20:06 +0100 Subject: killed a warning diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 4cdc5d8..3ea0e36 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -327,7 +327,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) csgInfo.root_chain = new CSGChain(); csgInfo.root_chain->import(csgInfo.root_norm_term); - fprintf(stderr, "Normalized CSG tree has %d elements\n", csgInfo.root_chain->polysets.size()); + fprintf(stderr, "Normalized CSG tree has %d elements\n", int(csgInfo.root_chain->polysets.size())); if (csgInfo.highlight_terms.size() > 0) { cerr << "Compiling highlights (" << csgInfo.highlight_terms.size() << " CSG Trees)...\n"; -- cgit v0.10.1 From cc4f6ac1846882adbc5214157e1d7b5a1994a9db Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 7 Dec 2011 22:20:24 +0100 Subject: Machine/OS info for Mac diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index eb06615..ea46275 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -2,9 +2,11 @@ #include "imageutils.h" #include "fbo.h" #include +#include #import // for NSOpenGL... - +#include +#include #define REPORTGLERROR(task) { GLenum tGLErr = glGetError(); if (tGLErr != GL_NO_ERROR) { std::cout << "OpenGL error " << tGLErr << " while " << task << "\n"; } } @@ -17,13 +19,27 @@ struct OffscreenContext fbo_t *fbo; }; -string offscreen_context_getinfo(OffscreenContext *ctx) +std::string offscreen_context_getinfo(OffscreenContext *ctx) { - stringstream out; + std::stringstream out; + + struct utsname name; + uname(&name); + + SInt32 majorVersion,minorVersion,bugFixVersion; + + Gestalt(gestaltSystemVersionMajor, &majorVersion); + Gestalt(gestaltSystemVersionMinor, &minorVersion); + Gestalt(gestaltSystemVersionBugFix, &bugFixVersion); + + char *arch = "unknown"; + if (sizeof(int*) == 4) arch = "32-bit"; + else if (sizeof(int*) == 8) arch = "64-bit"; + out << "GL context creator: Cocoa / CGL\n" << "PNG generator: Core Foundation\n" - << "OS info: Mac OSX\n" - << "Machine: Apple(TM) Mac(TM)\n"; + << "OS info: Mac OS X " << majorVersion << "." << minorVersion << "." << bugFixVersion << " (" << name.machine << " kernel)\n" + << "Machine: " << arch << "\n"; return out.str(); } -- cgit v0.10.1 From f577f91d25071f5ad1a9fdb6ed7c6dd3aa4c1008 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 9 Dec 2011 03:43:06 +0100 Subject: Better warnings and GL info related to OpenCSG capabilities and OpenGL 1.x diff --git a/openscad.pro b/openscad.pro index e88a94b..31c1e15 100644 --- a/openscad.pro +++ b/openscad.pro @@ -159,7 +159,8 @@ include(boost.pri) FORMS += src/MainWindow.ui \ - src/Preferences.ui + src/Preferences.ui \ + src/OpenCSGWarningDialog.ui HEADERS += src/renderer.h \ src/ThrownTogetherRenderer.h \ @@ -168,6 +169,7 @@ HEADERS += src/renderer.h \ src/GLView.h \ src/MainWindow.h \ src/Preferences.h \ + src/OpenCSGWarningDialog.h \ src/builtin.h \ src/context.h \ src/csgterm.h \ @@ -247,6 +249,7 @@ SOURCES += src/openscad.cc \ src/highlighter.cc \ src/printutils.cc \ src/Preferences.cc \ + src/OpenCSGWarningDialog.cc \ src/progress.cc \ src/editor.cc \ src/traverser.cc \ diff --git a/src/GLView.h b/src/GLView.h index c31e7af..5552e4b 100644 --- a/src/GLView.h +++ b/src/GLView.h @@ -32,7 +32,8 @@ public: void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; } bool orthoMode() const { return this->orthomode; } void setOrthoMode(bool enabled) { this->orthomode = enabled; } - + const QString &getRendererInfo() const { return this->rendererInfo; } + public: QLabel *statusLabel; double object_rot_x; @@ -52,6 +53,8 @@ private: void init(); Renderer *renderer; + QString rendererInfo; + bool showfaces; bool showedges; bool showaxes; diff --git a/src/MainWindow.h b/src/MainWindow.h index b2d0f60..0f2a922 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -86,6 +86,8 @@ private: void loadViewSettings(); void loadDesignSettings(); + class QMessageBox *openglbox; + private slots: void actionNew(); void actionOpen(); @@ -156,6 +158,7 @@ public slots: void helpAbout(); void helpHomepage(); void helpManual(); + void helpOpenGL(); void quit(); void actionReloadCompile(); void checkAutoReload(); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index dc73c05..d1bdb00 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -218,6 +218,7 @@ + @@ -666,6 +667,11 @@ Export as CSG... + + + OpenGL info + + diff --git a/src/OpenCSGWarningDialog.cc b/src/OpenCSGWarningDialog.cc new file mode 100644 index 0000000..fdaaa50 --- /dev/null +++ b/src/OpenCSGWarningDialog.cc @@ -0,0 +1,23 @@ +#include "OpenCSGWarningDialog.h" +#include "Preferences.h" + +OpenCSGWarningDialog::OpenCSGWarningDialog(QWidget *parent) +{ + setupUi(this); + + connect(this->showBox, SIGNAL(toggled(bool)), + Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool))); + connect(this->showBox, SIGNAL(toggled(bool)), + Preferences::inst(), SLOT(openCSGWarningChanged(bool))); + + connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)), + Preferences::inst()->enableOpenCSGBox, SLOT(setChecked(bool))); + connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)), + Preferences::inst(), SLOT(enableOpenCSGChanged(bool))); +} + +void OpenCSGWarningDialog::setText(const QString &text) +{ + this->warningText->setPlainText(text); +} + diff --git a/src/OpenCSGWarningDialog.h b/src/OpenCSGWarningDialog.h new file mode 100644 index 0000000..5d9c8fa --- /dev/null +++ b/src/OpenCSGWarningDialog.h @@ -0,0 +1,16 @@ +#ifndef OPENCSGWARNINGDIALOG_H_ +#define OPENCSGWARNINGDIALOG_H_ + +#include "ui_OpenCSGWarningDialog.h" + +class OpenCSGWarningDialog : public QDialog, public Ui::OpenCSGWarningDialog +{ + Q_OBJECT; +public: + OpenCSGWarningDialog(QWidget *parent); + +public slots: + void setText(const QString &text); +}; + +#endif diff --git a/src/OpenCSGWarningDialog.ui b/src/OpenCSGWarningDialog.ui new file mode 100644 index 0000000..f902521 --- /dev/null +++ b/src/OpenCSGWarningDialog.ui @@ -0,0 +1,93 @@ + + + OpenCSGWarningDialog + + + + 0 + 0 + 412 + 275 + + + + OpenGL Warning + + + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> + + + + + + + Enable OpenCSG + + + + + + + + + Show this message again + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + + + + + closeButton + clicked() + OpenCSGWarningDialog + accept() + + + 361 + 246 + + + 205 + 137 + + + + + diff --git a/src/Preferences.cc b/src/Preferences.cc index d240a9f..577ed4a 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -40,7 +40,8 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text(); this->defaultmap["editor/fontfamily"] = this->fontChooser->currentText(); this->defaultmap["editor/fontsize"] = this->fontSize->currentText().toUInt(); - this->defaultmap["editor/opengl20_warning_show"] = true; + this->defaultmap["advanced/opencsg_show_warning"] = true; + this->defaultmap["advanced/enable_opencsg_opengl1x"] = false; // Toolbar QActionGroup *group = new QActionGroup(this); @@ -98,7 +99,7 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this, SLOT(fontFamilyChanged(const QString &))); connect(this->fontSize, SIGNAL(editTextChanged(const QString &)), this, SLOT(fontSizeChanged(const QString &))); - connect(this->openCSGWarningBox, SIGNAL(clicked(bool)), + connect(this->openCSGWarningBox, SIGNAL(toggled(bool)), this, SLOT(openCSGWarningChanged(bool))); updateGUI(); } @@ -154,7 +155,14 @@ void Preferences::openCSGWarningChanged(bool state) { QSettings settings; - settings.setValue("editor/opengl20_warning_show",state); + settings.setValue("advanced/opencsg_show_warning",state); +} + +void +Preferences::enableOpenCSGChanged(bool state) +{ + QSettings settings; + settings.setValue("advanced/enable_opencsg_opengl1x", state); } void Preferences::keyPressEvent(QKeyEvent *e) @@ -215,7 +223,8 @@ void Preferences::updateGUI() this->fontSize->setEditText(fontsize); } - this->openCSGWarningBox->setChecked(getValue("editor/opengl20_warning_show").toBool()); + this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool()); + this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool()); } void Preferences::apply() const diff --git a/src/Preferences.h b/src/Preferences.h index bdc707d..add1a11 100644 --- a/src/Preferences.h +++ b/src/Preferences.h @@ -35,6 +35,7 @@ public slots: void fontFamilyChanged(const QString &); void fontSizeChanged(const QString &); void openCSGWarningChanged(bool); + void enableOpenCSGChanged(bool); signals: void requestRedraw() const; diff --git a/src/Preferences.ui b/src/Preferences.ui index 556172c..6b80674 100644 --- a/src/Preferences.ui +++ b/src/Preferences.ui @@ -185,6 +185,16 @@ Show OpenCSG capability warning + + true + + + + + + + Enable OpenCSG for OpenGL 1.x + @@ -239,7 +249,7 @@ true - + :/icons/prefs3DView.png:/icons/prefs3DView.png @@ -251,7 +261,7 @@ true - + :/icons/prefsAdvanced.png:/icons/prefsAdvanced.png @@ -263,7 +273,7 @@ true - + :/icons/prefsEditor.png:/icons/prefsEditor.png @@ -272,7 +282,7 @@ - + diff --git a/src/glview.cc b/src/glview.cc index bc287b5..bd53b1b 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -39,6 +39,9 @@ #include #include #include +#include +#include "OpenCSGWarningDialog.h" + #include "mathc99.h" #include @@ -133,31 +136,45 @@ void GLView::initializeGL() fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); } + this->rendererInfo.sprintf("GLEW version %s\n" + "OpenGL version %s\n" + "%s (%s)\n\n" + "Extensions:\n" + "%s\n", + glewGetString(GLEW_VERSION), + glGetString(GL_RENDERER), + glGetString(GL_VENDOR), + glGetString(GL_VERSION), + glGetString(GL_EXTENSIONS)); + + const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20"); if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) { openscad_disable_gl20_env = NULL; } // All OpenGL 2 contexts are OpenCSG capable - if (GLEW_VERSION_2_0 && !openscad_disable_gl20_env) this->is_opencsg_capable = true; - // If OpenGL < 2, check for extensions - else if (GLEW_ARB_framebuffer_object) this->is_opencsg_capable = true; - else if (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil) { - this->is_opencsg_capable = true; + if (GLEW_VERSION_2_0) { + if (!openscad_disable_gl20_env) { + this->is_opencsg_capable = true; + this->has_shaders = true; + } } + // If OpenGL < 2, check for extensions + else { + if (GLEW_ARB_framebuffer_object) this->is_opencsg_capable = true; + else if (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil) { + this->is_opencsg_capable = true; + } #ifdef WIN32 - else if (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format) this->is_opencsg_capable = true; + else if (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format) this->is_opencsg_capable = true; #elif !defined(__APPLE__) - else if (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig) this->is_opencsg_capable = true; + else if (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig) this->is_opencsg_capable = true; #endif + } - if (GLEW_VERSION_2_0 && !openscad_disable_gl20_env) this->has_shaders = true; - - if (!this->is_opencsg_capable) { - opencsg_support = false; - QSettings settings; - // FIXME: This should be an OpenCSG capability warning, not an OpenGL 2 warning - if (settings.value("editor/opengl20_warning_show",true).toBool()) { + if (!GLEW_VERSION_2_0 || !this->is_opencsg_capable) { + if (Preferences::inst()->getValue("advanced/opencsg_show_warning").toBool()) { QTimer::singleShot(0, this, SLOT(display_opencsg_warning())); } } @@ -252,9 +269,19 @@ void GLView::initializeGL() #ifdef ENABLE_OPENCSG void GLView::display_opencsg_warning() { - // data - QString title = QString("OpenGL context is not OpenCSG capable"); + OpenCSGWarningDialog *dialog = new OpenCSGWarningDialog(this); + QString message; + if (this->is_opencsg_capable) { + message += "Warning: You may experience OpenCSG rendering errors.\n\n"; + } + else { + message += "Warning: Missing OpenGL capabilities for OpenCSG - OpenCSG has been disabled.\n\n"; + dialog->enableOpenCSGBox->hide(); + } + message += "It is highly recommended to use OpenSCAD on a system with " + "OpenGL 2.0 or later.\n" + "Your renderer information is as follows:\n"; QString rendererinfo; rendererinfo.sprintf("GLEW version %s\n" "%s (%s)\n" @@ -262,44 +289,13 @@ void GLView::display_opencsg_warning() glewGetString(GLEW_VERSION), glGetString(GL_RENDERER), glGetString(GL_VENDOR), glGetString(GL_VERSION)); + message += rendererinfo; - QString message = QString("Warning: Missing OpenGL capabilities for OpenCSG - OpenCSG has been disabled.\n\n" - "It is highly recommended to use OpenSCAD on a system with OpenGL 2.0, " - "or support for the framebuffer_object or pbuffer extensions. " - "Your renderer information is as follows:\n\n%1").arg(rendererinfo); - - QString note = QString("Uncheck to hide this message in the future"); - - // presentation - QDialog *dialog = new QDialog(this); - dialog->setSizeGripEnabled(true); - dialog->setWindowTitle(title); - dialog->resize(500,300); - - QVBoxLayout *layout = new QVBoxLayout(dialog); - dialog->setLayout(layout); - - QTextEdit *textEdit = new QTextEdit(dialog); - textEdit->setPlainText(message); - layout->addWidget(textEdit); - - QCheckBox *checkbox = new QCheckBox(note,dialog); - checkbox->setCheckState(Qt::Checked); - layout->addWidget(checkbox); - - QDialogButtonBox *buttonbox = - new QDialogButtonBox( QDialogButtonBox::Ok, Qt::Horizontal,dialog); - layout->addWidget(buttonbox); - buttonbox->button(QDialogButtonBox::Ok)->setFocus(); - buttonbox->button(QDialogButtonBox::Ok)->setDefault(true); - - // action - connect(buttonbox, SIGNAL(accepted()), dialog, SLOT(accept())); - connect(checkbox, SIGNAL(clicked(bool)), - Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool))); - connect(checkbox, SIGNAL(clicked(bool)), - Preferences::inst(), SLOT(openCSGWarningChanged(bool))); + dialog->setText(message); + dialog->enableOpenCSGBox->setChecked(Preferences::inst()->getValue("advanced/enable_opencsg_opengl1x").toBool()); dialog->exec(); + + opencsg_support = this->is_opencsg_capable && Preferences::inst()->getValue("advanced/enable_opencsg_opengl1x").toBool(); } #endif diff --git a/src/mainwin.cc b/src/mainwin.cc index c81f2f2..4b4321d 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -312,6 +312,7 @@ MainWindow::MainWindow(const QString &filename) connect(this->helpActionAbout, SIGNAL(triggered()), this, SLOT(helpAbout())); connect(this->helpActionHomepage, SIGNAL(triggered()), this, SLOT(helpHomepage())); connect(this->helpActionManual, SIGNAL(triggered()), this, SLOT(helpManual())); + connect(this->helpActionOpenGLInfo, SIGNAL(triggered()), this, SLOT(helpOpenGL())); console->setReadOnly(true); @@ -1752,6 +1753,18 @@ MainWindow::helpManual() QDesktopServices::openUrl(QUrl("http://en.wikibooks.org/wiki/OpenSCAD_User_Manual")); } +void MainWindow::helpOpenGL() +{ + if (!this->openglbox) { + this->openglbox = new QMessageBox(QMessageBox::Information, + "OpenGL Info", "Detailed OpenGL Info", + QMessageBox::Ok, this); + + } + this->openglbox->setDetailedText(this->glview->getRendererInfo()); + this->openglbox->show(); +} + /*! FIXME: In MDI mode, should this be called on both reload functions? */ @@ -1822,3 +1835,4 @@ void MainWindow::clearCurrentOutput() { set_output_handler(NULL, NULL); } + -- cgit v0.10.1 From ccb15d52b9de9cdf2ad25a90a59faa7ba9bd4485 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 9 Dec 2011 13:17:35 +0100 Subject: Added pixelformat info to OpenGL info diff --git a/src/glview.cc b/src/glview.cc index bd53b1b..d0b3517 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -136,15 +136,26 @@ void GLView::initializeGL() fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); } + GLint rbits, gbits, bbits, abits, dbits, sbits; + glGetIntegerv(GL_RED_BITS, &rbits); + glGetIntegerv(GL_GREEN_BITS, &gbits); + glGetIntegerv(GL_BLUE_BITS, &bbits); + glGetIntegerv(GL_ALPHA_BITS, &abits); + glGetIntegerv(GL_DEPTH_BITS, &dbits); + glGetIntegerv(GL_STENCIL_BITS, &sbits); + + this->rendererInfo.sprintf("GLEW version %s\n" "OpenGL version %s\n" "%s (%s)\n\n" + "RGBA(%d%d%d%d), depth(%d), stencil(%d)\n" "Extensions:\n" "%s\n", glewGetString(GLEW_VERSION), glGetString(GL_RENDERER), glGetString(GL_VENDOR), glGetString(GL_VERSION), + rbits, gbits, bbits, abits, dbits, sbits, glGetString(GL_EXTENSIONS)); -- cgit v0.10.1 From 51f24b998ba555d15f924ccd4fb5b46219f6537b Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 9 Dec 2011 09:47:13 -0600 Subject: MSVC compile fix diff --git a/src/CGALRenderer.cc b/src/CGALRenderer.cc index 95bcba1..bac25a6 100644 --- a/src/CGALRenderer.cc +++ b/src/CGALRenderer.cc @@ -24,6 +24,11 @@ * */ +#ifdef _MSC_VER +// Boost conflicts with MPFR under MSVC (google it) +#include +#endif + // dxfdata.h must come first for Eigen SIMD alignment issues #include "dxfdata.h" #include "polyset.h" -- cgit v0.10.1 From 647fdf5f98f6337955972375a17837aede922988 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 9 Dec 2011 17:56:56 +0100 Subject: bugfix: forgot to initialize openglbox diff --git a/src/mainwin.cc b/src/mainwin.cc index 4b4321d..228e981 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -145,6 +145,7 @@ MainWindow::MainWindow(const QString &filename) register_builtin(root_ctx); + this->openglbox = NULL; root_module = NULL; absolute_root_node = NULL; root_chain = NULL; -- cgit v0.10.1 From fcf172de5034c8d9f45eb6984d72cea6416458d9 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 9 Dec 2011 11:31:18 -0600 Subject: modify test_pretty_print to allow showing of only failed tests diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index fa8b390..85f4ec7 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -246,6 +246,10 @@ TESTLOG imgs = {} passed_tests = filter(lambda x: x.passed, tests) failed_tests = filter(lambda x: not x.passed, tests) + + tests_to_report = tests + if failed_only: tests_to_report = failed_tests + percent = str(int(100.0*len(passed_tests) / len(tests))) s = wiki_template repeat1 = ezsearch('(.*?)',s) @@ -256,7 +260,8 @@ TESTLOG 'NUMTESTS':len(tests), 'NUMPASSED':len(passed_tests), 'PERCENTPASSED':percent } for key in dic.keys(): s = s.replace(key,str(dic[key])) - for t in tests: + + for t in tests_to_report: if t.type=='txt': newchunk = re.sub('FTESTNAME',t.fullname,repeat2) newchunk = newchunk.replace('TESTLOG',t.fulltestlog) @@ -308,6 +313,9 @@ def tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles): failed_tests = filter(lambda x: not x.passed, tests) percent = str(int(100.0*len(passed_tests) / len(tests))) + tests_to_report = tests + if failed_only: tests_to_report = failed_tests + s='' s+= '\n

'
@@ -324,7 +332,7 @@ def tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles):
 	s+= '\nPERCENTPASSED: '+ percent
 	s+= '\n
' - for t in tests: + for t in tests_to_report: if t.type=='txt': s+='\n
'+t.fullname+'
\n' s+='

'+t.fulltestlog+'
\n\n' @@ -481,4 +489,7 @@ builddir = os.getcwd() # os.getcwd()+'/build' verbose = False maxretry = 10 +failed_only = False +if '--failed-only' in sys.argv: failed_only = True + main() -- cgit v0.10.1 From 9ed8d9a6732e1eea0265ff84917278a82d81e2dd Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 11 Dec 2011 23:45:14 +0100 Subject: Some small refactoring of color handling to support using the color() module to change only alpha diff --git a/openscad.pro b/openscad.pro index 31c1e15..80dd7d9 100644 --- a/openscad.pro +++ b/openscad.pro @@ -163,6 +163,7 @@ FORMS += src/MainWindow.ui \ src/OpenCSGWarningDialog.ui HEADERS += src/renderer.h \ + src/rendersettings.h \ src/ThrownTogetherRenderer.h \ src/CGAL_renderer.h \ src/OGL_helper.h \ @@ -217,6 +218,8 @@ HEADERS += src/renderer.h \ SOURCES += src/openscad.cc \ src/mainwin.cc \ src/handle_dep.cc \ + src/renderer.cc \ + src/rendersettings.cc \ src/ThrownTogetherRenderer.cc \ src/glview.cc \ src/export.cc \ diff --git a/src/OpenCSGRenderer.cc b/src/OpenCSGRenderer.cc index a1aafc5..233124b 100644 --- a/src/OpenCSGRenderer.cc +++ b/src/OpenCSGRenderer.cc @@ -40,11 +40,11 @@ public: OpenCSG::Primitive(operation, convexity) { } shared_ptr ps; Transform3d m; - int csgmode; + PolySet::csgmode_e csgmode; virtual void render() { glPushMatrix(); glMultMatrixd(m.data()); - ps->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m); + ps->render_surface(csgmode, m); glPopMatrix(); } }; @@ -89,24 +89,23 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo, double *c = chain->colors[j]; glPushMatrix(); glMultMatrixd(m.data()); - int csgmode = chain->types[j] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; + PolySet::csgmode_e csgmode = chain->types[j] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; if (highlight) { - chain->polysets[j]->render_surface(PolySet::COLORMODE_HIGHLIGHT, PolySet::csgmode_e(csgmode + 20), m, shaderinfo); - } else if (background) { - chain->polysets[j]->render_surface(PolySet::COLORMODE_BACKGROUND, PolySet::csgmode_e(csgmode + 10), m, shaderinfo); - } else if (c[0] >= 0 || c[1] >= 0 || c[2] >= 0) { - // User-defined color from source - glColor4dv(c); - if (shaderinfo) { - glUniform4f(shaderinfo[1], c[0], c[1], c[2], c[3]); - glUniform4f(shaderinfo[2], (c[0]+1)/2, (c[1]+1)/2, (c[2]+1)/2, 1.0); - } - chain->polysets[j]->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m, shaderinfo); + setColor(COLORMODE_HIGHLIGHT, shaderinfo); + csgmode = PolySet::csgmode_e(csgmode + 20); + } + else if (background) { + setColor(COLORMODE_BACKGROUND, shaderinfo); + csgmode = PolySet::csgmode_e(csgmode + 10); + } else if (c[0] >= 0 || c[1] >= 0 || c[2] >= 0 || c[3] >= 0) { + // User-defined color or alpha from source + setColor(c, shaderinfo); } else if (chain->types[j] == CSGTerm::TYPE_DIFFERENCE) { - chain->polysets[j]->render_surface(PolySet::COLORMODE_CUTOUT, PolySet::csgmode_e(csgmode), m, shaderinfo); + setColor(COLORMODE_CUTOUT, shaderinfo); } else { - chain->polysets[j]->render_surface(PolySet::COLORMODE_MATERIAL, PolySet::csgmode_e(csgmode), m, shaderinfo); + setColor(COLORMODE_MATERIAL, shaderinfo); } + chain->polysets[j]->render_surface(csgmode, m, shaderinfo); glPopMatrix(); } if (shaderinfo) glUseProgram(0); @@ -124,8 +123,8 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo, prim->ps = chain->polysets[i]; prim->m = chain->matrices[i]; prim->csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; - if (highlight) prim->csgmode += 20; - else if (background) prim->csgmode += 10; + if (highlight) prim->csgmode = PolySet::csgmode_e(prim->csgmode + 20); + else if (background) prim->csgmode = PolySet::csgmode_e(prim->csgmode + 10); primitives.push_back(prim); } std::for_each(primitives.begin(), primitives.end(), del_fun()); diff --git a/src/Preferences.cc b/src/Preferences.cc index 577ed4a..aefbd12 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -54,38 +54,38 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this->actionTriggered(this->prefsAction3DView); // 3D View pane - this->colorschemes["Cornfield"][BACKGROUND_COLOR] = QColor(0xff, 0xff, 0xe5); - this->colorschemes["Cornfield"][OPENCSG_FACE_FRONT_COLOR] = QColor(0xf9, 0xd7, 0x2c); - this->colorschemes["Cornfield"][OPENCSG_FACE_BACK_COLOR] = QColor(0x9d, 0xcb, 0x51); - this->colorschemes["Cornfield"][CGAL_FACE_FRONT_COLOR] = QColor(0xf9, 0xd7, 0x2c); - this->colorschemes["Cornfield"][CGAL_FACE_BACK_COLOR] = QColor(0x9d, 0xcb, 0x51); - this->colorschemes["Cornfield"][CGAL_FACE_2D_COLOR] = QColor(0x00, 0xbf, 0x99); - this->colorschemes["Cornfield"][CGAL_EDGE_FRONT_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Cornfield"][CGAL_EDGE_BACK_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Cornfield"][CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Cornfield"][CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); - - this->colorschemes["Metallic"][BACKGROUND_COLOR] = QColor(0xaa, 0xaa, 0xff); - this->colorschemes["Metallic"][OPENCSG_FACE_FRONT_COLOR] = QColor(0xdd, 0xdd, 0xff); - this->colorschemes["Metallic"][OPENCSG_FACE_BACK_COLOR] = QColor(0xdd, 0x22, 0xdd); - this->colorschemes["Metallic"][CGAL_FACE_FRONT_COLOR] = QColor(0xdd, 0xdd, 0xff); - this->colorschemes["Metallic"][CGAL_FACE_BACK_COLOR] = QColor(0xdd, 0x22, 0xdd); - this->colorschemes["Metallic"][CGAL_FACE_2D_COLOR] = QColor(0x00, 0xbf, 0x99); - this->colorschemes["Metallic"][CGAL_EDGE_FRONT_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Metallic"][CGAL_EDGE_BACK_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Metallic"][CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Metallic"][CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); - - this->colorschemes["Sunset"][BACKGROUND_COLOR] = QColor(0xaa, 0x44, 0x44); - this->colorschemes["Sunset"][OPENCSG_FACE_FRONT_COLOR] = QColor(0xff, 0xaa, 0xaa); - this->colorschemes["Sunset"][OPENCSG_FACE_BACK_COLOR] = QColor(0x88, 0x22, 0x33); - this->colorschemes["Sunset"][CGAL_FACE_FRONT_COLOR] = QColor(0xff, 0xaa, 0xaa); - this->colorschemes["Sunset"][CGAL_FACE_BACK_COLOR] = QColor(0x88, 0x22, 0x33); - this->colorschemes["Sunset"][CGAL_FACE_2D_COLOR] = QColor(0x00, 0xbf, 0x99); - this->colorschemes["Sunset"][CGAL_EDGE_FRONT_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Sunset"][CGAL_EDGE_BACK_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Sunset"][CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); - this->colorschemes["Sunset"][CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); + this->colorschemes["Cornfield"][RenderSettings::BACKGROUND_COLOR] = QColor(0xff, 0xff, 0xe5); + this->colorschemes["Cornfield"][RenderSettings::OPENCSG_FACE_FRONT_COLOR] = QColor(0xf9, 0xd7, 0x2c); + this->colorschemes["Cornfield"][RenderSettings::OPENCSG_FACE_BACK_COLOR] = QColor(0x9d, 0xcb, 0x51); + this->colorschemes["Cornfield"][RenderSettings::CGAL_FACE_FRONT_COLOR] = QColor(0xf9, 0xd7, 0x2c); + this->colorschemes["Cornfield"][RenderSettings::CGAL_FACE_BACK_COLOR] = QColor(0x9d, 0xcb, 0x51); + this->colorschemes["Cornfield"][RenderSettings::CGAL_FACE_2D_COLOR] = QColor(0x00, 0xbf, 0x99); + this->colorschemes["Cornfield"][RenderSettings::CGAL_EDGE_FRONT_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Cornfield"][RenderSettings::CGAL_EDGE_BACK_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Cornfield"][RenderSettings::CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Cornfield"][RenderSettings::CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); + + this->colorschemes["Metallic"][RenderSettings::BACKGROUND_COLOR] = QColor(0xaa, 0xaa, 0xff); + this->colorschemes["Metallic"][RenderSettings::OPENCSG_FACE_FRONT_COLOR] = QColor(0xdd, 0xdd, 0xff); + this->colorschemes["Metallic"][RenderSettings::OPENCSG_FACE_BACK_COLOR] = QColor(0xdd, 0x22, 0xdd); + this->colorschemes["Metallic"][RenderSettings::CGAL_FACE_FRONT_COLOR] = QColor(0xdd, 0xdd, 0xff); + this->colorschemes["Metallic"][RenderSettings::CGAL_FACE_BACK_COLOR] = QColor(0xdd, 0x22, 0xdd); + this->colorschemes["Metallic"][RenderSettings::CGAL_FACE_2D_COLOR] = QColor(0x00, 0xbf, 0x99); + this->colorschemes["Metallic"][RenderSettings::CGAL_EDGE_FRONT_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Metallic"][RenderSettings::CGAL_EDGE_BACK_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Metallic"][RenderSettings::CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Metallic"][RenderSettings::CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); + + this->colorschemes["Sunset"][RenderSettings::BACKGROUND_COLOR] = QColor(0xaa, 0x44, 0x44); + this->colorschemes["Sunset"][RenderSettings::OPENCSG_FACE_FRONT_COLOR] = QColor(0xff, 0xaa, 0xaa); + this->colorschemes["Sunset"][RenderSettings::OPENCSG_FACE_BACK_COLOR] = QColor(0x88, 0x22, 0x33); + this->colorschemes["Sunset"][RenderSettings::CGAL_FACE_FRONT_COLOR] = QColor(0xff, 0xaa, 0xaa); + this->colorschemes["Sunset"][RenderSettings::CGAL_FACE_BACK_COLOR] = QColor(0x88, 0x22, 0x33); + this->colorschemes["Sunset"][RenderSettings::CGAL_FACE_2D_COLOR] = QColor(0x00, 0xbf, 0x99); + this->colorschemes["Sunset"][RenderSettings::CGAL_EDGE_FRONT_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Sunset"][RenderSettings::CGAL_EDGE_BACK_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Sunset"][RenderSettings::CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); + this->colorschemes["Sunset"][RenderSettings::CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); // Editor pane QFontDatabase db; @@ -102,6 +102,8 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) connect(this->openCSGWarningBox, SIGNAL(toggled(bool)), this, SLOT(openCSGWarningChanged(bool))); updateGUI(); + + RenderSettings::inst()->setColors(this->colorschemes[getValue("3dview/colorscheme").toString()]); } Preferences::~Preferences() @@ -125,15 +127,13 @@ Preferences::actionTriggered(QAction *action) void Preferences::colorSchemeChanged() { + QString scheme = this->colorSchemeChooser->currentItem()->text(); QSettings settings; - settings.setValue("3dview/colorscheme", this->colorSchemeChooser->currentItem()->text()); + settings.setValue("3dview/colorscheme", scheme); - emit requestRedraw(); -} + RenderSettings::inst()->setColors(this->colorschemes[scheme]); -const QColor &Preferences::color(RenderColor idx) -{ - return this->colorschemes[getValue("3dview/colorscheme").toString()][idx]; + emit requestRedraw(); } void Preferences::fontFamilyChanged(const QString &family) diff --git a/src/Preferences.h b/src/Preferences.h index add1a11..7e22e63 100644 --- a/src/Preferences.h +++ b/src/Preferences.h @@ -4,6 +4,7 @@ #include #include #include "ui_Preferences.h" +#include "rendersettings.h" class Preferences : public QMainWindow, public Ui::Preferences { @@ -13,19 +14,6 @@ public: ~Preferences(); static Preferences *inst() { if (!instance) instance = new Preferences(); return instance; } - enum RenderColor { - BACKGROUND_COLOR, - OPENCSG_FACE_FRONT_COLOR, - OPENCSG_FACE_BACK_COLOR, - CGAL_FACE_FRONT_COLOR, - CGAL_FACE_2D_COLOR, - CGAL_FACE_BACK_COLOR, - CGAL_EDGE_FRONT_COLOR, - CGAL_EDGE_BACK_COLOR, - CGAL_EDGE_2D_COLOR, - CROSSHAIR_COLOR - }; - const QColor &color(RenderColor idx); QVariant getValue(const QString &key) const; void apply() const; @@ -48,7 +36,7 @@ private: void removeDefaultSettings(); QSettings::SettingsMap defaultmap; - QHash > colorschemes; + QHash > colorschemes; static Preferences *instance; }; diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc index 3ab13ea..36f7b95 100644 --- a/src/ThrownTogetherRenderer.cc +++ b/src/ThrownTogetherRenderer.cc @@ -70,51 +70,48 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight, double *c = chain->colors[i]; glPushMatrix(); glMultMatrixd(m.data()); - int csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; + PolySet::csgmode_e csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL; if (highlight) { - chain->polysets[i]->render_surface(PolySet::COLORMODE_HIGHLIGHT, PolySet::csgmode_e(csgmode + 20), m); + csgmode = PolySet::csgmode_e(csgmode + 20); + setColor(COLORMODE_HIGHLIGHT); + chain->polysets[i]->render_surface(csgmode, m); if (showedges) { - glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLORMODE_HIGHLIGHT, PolySet::csgmode_e(csgmode + 20)); - glEnable(GL_LIGHTING); + setColor(COLORMODE_HIGHLIGHT_EDGES); + chain->polysets[i]->render_edges(csgmode); } } else if (background) { - chain->polysets[i]->render_surface(PolySet::COLORMODE_BACKGROUND, PolySet::csgmode_e(csgmode + 10), m); + csgmode = PolySet::csgmode_e(csgmode + 10); + setColor(COLORMODE_BACKGROUND); + chain->polysets[i]->render_surface(csgmode, m); if (showedges) { - glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLORMODE_BACKGROUND, PolySet::csgmode_e(csgmode + 10)); - glEnable(GL_LIGHTING); + setColor(COLORMODE_BACKGROUND_EDGES); + chain->polysets[i]->render_edges(csgmode); } } else if (fberror) { - if (highlight) { - chain->polysets[i]->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode + 20), m); - } else if (background) { - chain->polysets[i]->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode + 10), m); - } else { - chain->polysets[i]->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m); - } - } else if (c[0] >= 0 || c[1] >= 0 || c[2] >= 0) { - glColor4dv(c); - chain->polysets[i]->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m); + if (highlight) csgmode = PolySet::csgmode_e(csgmode + 20); + else if (background) csgmode = PolySet::csgmode_e(csgmode + 10); + else csgmode = PolySet::csgmode_e(csgmode); + chain->polysets[i]->render_surface(csgmode, m); + } else if (c[0] >= 0 || c[1] >= 0 || c[2] >= 0 || c[3] >= 0) { + setColor(c); + chain->polysets[i]->render_surface(csgmode, m); if (showedges) { - glDisable(GL_LIGHTING); glColor4d((c[0]+1)/2, (c[1]+1)/2, (c[2]+1)/2, 1.0); - chain->polysets[i]->render_edges(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode)); - glEnable(GL_LIGHTING); + chain->polysets[i]->render_edges(csgmode); } } else if (chain->types[i] == CSGTerm::TYPE_DIFFERENCE) { - chain->polysets[i]->render_surface(PolySet::COLORMODE_CUTOUT, PolySet::csgmode_e(csgmode), m); + setColor(COLORMODE_CUTOUT); + chain->polysets[i]->render_surface(csgmode, m); if (showedges) { - glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLORMODE_CUTOUT, PolySet::csgmode_e(csgmode)); - glEnable(GL_LIGHTING); + setColor(COLORMODE_CUTOUT_EDGES); + chain->polysets[i]->render_edges(csgmode); } } else { - chain->polysets[i]->render_surface(PolySet::COLORMODE_MATERIAL, PolySet::csgmode_e(csgmode), m); + setColor(COLORMODE_MATERIAL); + chain->polysets[i]->render_surface(csgmode, m); if (showedges) { - glDisable(GL_LIGHTING); - chain->polysets[i]->render_edges(PolySet::COLORMODE_MATERIAL, PolySet::csgmode_e(csgmode)); - glEnable(GL_LIGHTING); + setColor(COLORMODE_MATERIAL_EDGES); + chain->polysets[i]->render_edges(csgmode); } } glPopMatrix(); diff --git a/src/glview.cc b/src/glview.cc index d0b3517..6836e3b 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -27,6 +27,7 @@ #include "GLView.h" #include "Preferences.h" #include "renderer.h" +#include "rendersettings.h" #include #include @@ -190,6 +191,28 @@ void GLView::initializeGL() } } if (opencsg_support && this->has_shaders) { + /* + Uniforms: + 1 color1 - face color + 2 color2 - edge color + 7 xscale + 8 yscale + + Attributes: + 3 trig + 4 pos_b + 5 pos_c + 6 mask + + Other: + 9 width + 10 height + + Outputs: + tp + tr + shading + */ const char *vs_source = "uniform float xscale, yscale;\n" "attribute vec3 pos_b, pos_c;\n" @@ -215,6 +238,11 @@ void GLView::initializeGL() " shading = abs(dot(normal, lightDir));\n" "}\n"; + /* + Inputs: + tp && tr - if any components of tp < tr, use color2 (edge color) + shading - multiplied by color1. color2 is is without lighting + */ const char *fs_source = "uniform vec4 color1, color2;\n" "varying vec3 tp, tr, tmp;\n" @@ -351,7 +379,7 @@ void GLView::paintGL() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - const QColor &bgcol = Preferences::inst()->color(Preferences::BACKGROUND_COLOR); + const QColor &bgcol = RenderSettings::inst()->color(RenderSettings::BACKGROUND_COLOR); glClearColor(bgcol.redF(), bgcol.greenF(), bgcol.blueF(), 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -369,7 +397,7 @@ void GLView::paintGL() if (showcrosshairs) { glLineWidth(3); - const QColor &col = Preferences::inst()->color(Preferences::CROSSHAIR_COLOR); + const QColor &col = RenderSettings::inst()->color(RenderSettings::CROSSHAIR_COLOR); glColor3f(col.redF(), col.greenF(), col.blueF()); glBegin(GL_LINES); for (double xf = -1; xf <= +1; xf += 2) @@ -470,7 +498,7 @@ void GLView::paintGL() // FIXME: This was an attempt to keep contrast with background, but is suboptimal // (e.g. nearly invisible against a gray background). int r,g,b; - bgcol.getRgb(&r, &g, &b); +// bgcol.getRgb(&r, &g, &b); glColor3d((255.0-r)/255.0, (255.0-g)/255.0, (255.0-b)/255.0); glBegin(GL_LINES); // X Label diff --git a/src/polyset.cc b/src/polyset.cc index 742e425..481cbec 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -108,52 +108,9 @@ static void gl_draw_triangle(GLint *shaderinfo, const Vector3d &p0, const Vector } } -void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, const Transform3d &m, GLint *shaderinfo) const +void PolySet::render_surface(csgmode_e csgmode, const Transform3d &m, GLint *shaderinfo) const { bool mirrored = m.matrix().determinant() < 0; - - if (colormode == COLORMODE_MATERIAL) { -// FIXME: Reenable/rewrite - don't be dependant on GUI -// const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_FRONT_COLOR); - const QColor &col = QColor(0xf9, 0xd7, 0x2c); - glColor3f(col.redF(), col.greenF(), col.blueF()); -#ifdef ENABLE_OPENCSG - if (shaderinfo) { - glUniform4f(shaderinfo[1], col.redF(), col.greenF(), col.blueF(), 1.0f); - glUniform4f(shaderinfo[2], 255 / 255.0f, 236 / 255.0f, 94 / 255.0f, 1.0f); - } -#endif /* ENABLE_OPENCSG */ - } - if (colormode == COLORMODE_CUTOUT) { -// FIXME: Reenable/rewrite - don't be dependant on GUI -// const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_BACK_COLOR); - const QColor &col = QColor(0x9d, 0xcb, 0x51); - glColor3f(col.redF(), col.greenF(), col.blueF()); -#ifdef ENABLE_OPENCSG - if (shaderinfo) { - glUniform4f(shaderinfo[1], 157 / 255.0f, 203 / 255.0f, 81 / 255.0f, 1.0f); - glUniform4f(shaderinfo[2], 171 / 255.0f, 216 / 255.0f, 86 / 255.0f, 1.0f); - } -#endif /* ENABLE_OPENCSG */ - } - if (colormode == COLORMODE_HIGHLIGHT) { - glColor4ub(255, 157, 81, 128); -#ifdef ENABLE_OPENCSG - if (shaderinfo) { - glUniform4f(shaderinfo[1], 255 / 255.0f, 157 / 255.0f, 81 / 255.0f, 0.5f); - glUniform4f(shaderinfo[2], 255 / 255.0f, 171 / 255.0f, 86 / 255.0f, 0.5f); - } -#endif /* ENABLE_OPENCSG */ - } - if (colormode == COLORMODE_BACKGROUND) { - glColor4ub(180, 180, 180, 128); -#ifdef ENABLE_OPENCSG - if (shaderinfo) { - glUniform4f(shaderinfo[1], 180 / 255.0f, 180 / 255.0f, 180 / 255.0f, 0.5f); - glUniform4f(shaderinfo[2], 150 / 255.0f, 150 / 255.0f, 150 / 255.0f, 0.5f); - } -#endif /* ENABLE_OPENCSG */ - } #ifdef ENABLE_OPENCSG if (shaderinfo) { glUniform1f(shaderinfo[7], shaderinfo[9]); @@ -248,16 +205,9 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, const Tra } } -void PolySet::render_edges(colormode_e colormode, csgmode_e csgmode) const +void PolySet::render_edges(csgmode_e csgmode) const { - if (colormode == COLORMODE_MATERIAL) - glColor3ub(255, 236, 94); - if (colormode == COLORMODE_CUTOUT) - glColor3ub(171, 216, 86); - if (colormode == COLORMODE_HIGHLIGHT) - glColor4ub(255, 171, 86, 128); - if (colormode == COLORMODE_BACKGROUND) - glColor4ub(150, 150, 150, 128); + glDisable(GL_LIGHTING); if (this->is2d) { double zbase = csgmode; for (double z = -zbase/2; z < zbase; z += zbase) @@ -293,6 +243,7 @@ void PolySet::render_edges(colormode_e colormode, csgmode_e csgmode) const glEnd(); } } + glEnable(GL_LIGHTING); } BoundingBox PolySet::getBoundingBox() const diff --git a/src/polyset.h b/src/polyset.h index 57f5057..5698621 100644 --- a/src/polyset.h +++ b/src/polyset.h @@ -27,14 +27,6 @@ public: BoundingBox getBoundingBox() const; - enum colormode_e { - COLORMODE_NONE, - COLORMODE_MATERIAL, - COLORMODE_CUTOUT, - COLORMODE_HIGHLIGHT, - COLORMODE_BACKGROUND - }; - enum csgmode_e { CSGMODE_NONE, CSGMODE_NORMAL = 1, @@ -45,8 +37,8 @@ public: CSGMODE_HIGHLIGHT_DIFFERENCE = 22 }; - void render_surface(colormode_e colormode, csgmode_e csgmode, const Transform3d &m, GLint *shaderinfo = NULL) const; - void render_edges(colormode_e colormode, csgmode_e csgmode) const; + void render_surface(csgmode_e csgmode, const Transform3d &m, GLint *shaderinfo = NULL) const; + void render_edges(csgmode_e csgmode) const; }; #endif diff --git a/src/renderer.cc b/src/renderer.cc new file mode 100644 index 0000000..b791673 --- /dev/null +++ b/src/renderer.cc @@ -0,0 +1,66 @@ +#include "renderer.h" +#include "rendersettings.h" +#include + +void Renderer::setColor(const double color[4], GLint *shaderinfo) const +{ + QColor col = RenderSettings::inst()->color(RenderSettings::OPENCSG_FACE_FRONT_COLOR); + double c[4] = {color[0], color[1], color[2], color[3]}; + if (c[0] < 0) c[0] = col.redF(); + if (c[1] < 0) c[1] = col.greenF(); + if (c[2] < 0) c[2] = col.blueF(); + if (c[3] < 0) c[3] = col.alphaF(); + glColor4dv(c); + if (shaderinfo) { + glUniform4f(shaderinfo[1], c[0], c[1], c[2], c[3]); + glUniform4f(shaderinfo[2], (c[0]+1)/2, (c[1]+1)/2, (c[2]+1)/2, 1.0); + } +} + +void Renderer::setColor(ColorMode colormode, GLint *shaderinfo) const +{ + QColor col; + switch (colormode) { + case COLORMODE_NONE: + return; + break; + case COLORMODE_MATERIAL: + col = RenderSettings::inst()->color(RenderSettings::OPENCSG_FACE_FRONT_COLOR); + break; + case COLORMODE_CUTOUT: + col = RenderSettings::inst()->color(RenderSettings::OPENCSG_FACE_BACK_COLOR); + break; + case COLORMODE_HIGHLIGHT: + col.setRgb(255, 157, 81, 128); + break; + case COLORMODE_BACKGROUND: + col.setRgb(180, 180, 180, 128); + break; + case COLORMODE_MATERIAL_EDGES: + col.setRgb(255, 236, 94); + break; + case COLORMODE_CUTOUT_EDGES: + col.setRgb(171, 216, 86); + break; + case COLORMODE_HIGHLIGHT_EDGES: + col.setRgb(255, 171, 86, 128); + break; + case COLORMODE_BACKGROUND_EDGES: + col.setRgb(150, 150, 150, 128); + break; + default: + break; + } + float rgba[4]; + rgba[0] = col.redF(); + rgba[1] = col.greenF(); + rgba[2] = col.blueF(); + rgba[3] = col.alphaF(); + glColor4fv(rgba); +#ifdef ENABLE_OPENCSG + if (shaderinfo) { + glUniform4f(shaderinfo[1], col.redF(), col.greenF(), col.blueF(), 1.0f); + glUniform4f(shaderinfo[2], (col.redF()+1)/2, (col.greenF()+1)/2, (col.blueF()+1)/2, 1.0f); + } +#endif +} diff --git a/src/renderer.h b/src/renderer.h index 3c25e98..e978080 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -1,11 +1,28 @@ #ifndef RENDERER_H_ #define RENDERER_H_ +#include "system-gl.h" + class Renderer { public: virtual ~Renderer() {} virtual void draw(bool showfaces, bool showedges) const = 0; + + enum ColorMode { + COLORMODE_NONE, + COLORMODE_MATERIAL, + COLORMODE_CUTOUT, + COLORMODE_HIGHLIGHT, + COLORMODE_BACKGROUND, + COLORMODE_MATERIAL_EDGES, + COLORMODE_CUTOUT_EDGES, + COLORMODE_HIGHLIGHT_EDGES, + COLORMODE_BACKGROUND_EDGES + }; + + virtual void setColor(const double color[4], GLint *shaderinfo = NULL) const; + virtual void setColor(ColorMode colormode, GLint *shaderinfo = NULL) const; }; #endif // RENDERER_H diff --git a/src/rendersettings.cc b/src/rendersettings.cc new file mode 100644 index 0000000..ee57c34 --- /dev/null +++ b/src/rendersettings.cc @@ -0,0 +1,35 @@ +#include "rendersettings.h" + +RenderSettings *RenderSettings::inst(bool erase) +{ + static RenderSettings *instance = new RenderSettings; + if (erase) { + delete instance; + instance = NULL; + } + return instance; +} + +RenderSettings::RenderSettings() +{ + this->colors[BACKGROUND_COLOR] = QColor(0xff, 0xff, 0xe5); + this->colors[OPENCSG_FACE_FRONT_COLOR] = QColor(0xf9, 0xd7, 0x2c); + this->colors[OPENCSG_FACE_BACK_COLOR] = QColor(0x9d, 0xcb, 0x51); + this->colors[CGAL_FACE_FRONT_COLOR] = QColor(0xf9, 0xd7, 0x2c); + this->colors[CGAL_FACE_BACK_COLOR] = QColor(0x9d, 0xcb, 0x51); + this->colors[CGAL_FACE_2D_COLOR] = QColor(0x00, 0xbf, 0x99); + this->colors[CGAL_EDGE_FRONT_COLOR] = QColor(0xff, 0x00, 0x00); + this->colors[CGAL_EDGE_BACK_COLOR] = QColor(0xff, 0x00, 0x00); + this->colors[CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); + this->colors[CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); +} + +QColor RenderSettings::color(RenderColor idx) const +{ + return this->colors[idx]; +} + +void RenderSettings::setColors(const QMap &colors) +{ + this->colors = colors; +} diff --git a/src/rendersettings.h b/src/rendersettings.h new file mode 100644 index 0000000..32e56f1 --- /dev/null +++ b/src/rendersettings.h @@ -0,0 +1,35 @@ +#ifndef RENDERSETTINGS_H_ +#define RENDERSETTINGS_H_ + +#include +#include + +class RenderSettings +{ +public: + static RenderSettings *inst(bool erase = false); + + enum RenderColor { + BACKGROUND_COLOR, + OPENCSG_FACE_FRONT_COLOR, + OPENCSG_FACE_BACK_COLOR, + CGAL_FACE_FRONT_COLOR, + CGAL_FACE_2D_COLOR, + CGAL_FACE_BACK_COLOR, + CGAL_EDGE_FRONT_COLOR, + CGAL_EDGE_BACK_COLOR, + CGAL_EDGE_2D_COLOR, + CROSSHAIR_COLOR + }; + + void setColors(const QMap &colors); + QColor color(RenderColor idx) const; + +private: + RenderSettings(); + ~RenderSettings() {} + + QMap colors; +}; + +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 585c3b1..61e0ef0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -351,7 +351,7 @@ target_link_libraries(cgaltest tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRA # # cgalpngtest # -add_executable(cgalpngtest cgalpngtest.cc bboxhelp.cc ../src/CGALRenderer.cc) +add_executable(cgalpngtest cgalpngtest.cc bboxhelp.cc ../src/CGALRenderer.cc ../src/renderer.cc ../src/rendersettings.cc) set_target_properties(cgalpngtest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") target_link_libraries(cgalpngtest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) @@ -359,7 +359,7 @@ target_link_libraries(cgalpngtest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${C # opencsgtest # -add_executable(opencsgtest opencsgtest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc) +add_executable(opencsgtest opencsgtest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc ../src/renderer.cc ../src/rendersettings.cc) set_target_properties(opencsgtest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") target_link_libraries(opencsgtest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENCSG_LIBRARY} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) @@ -367,7 +367,7 @@ target_link_libraries(opencsgtest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${C # throwntogethertest # -add_executable(throwntogethertest throwntogethertest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc) +add_executable(throwntogethertest throwntogethertest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc ../src/renderer.cc ../src/rendersettings.cc) set_target_properties(throwntogethertest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENCSG_LIBRARY} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${Boost_LIBRARIES}) diff --git a/tests/regression/opencsgtest/color-tests-expected.png b/tests/regression/opencsgtest/color-tests-expected.png index b2ef8dd..82ba36a 100644 Binary files a/tests/regression/opencsgtest/color-tests-expected.png and b/tests/regression/opencsgtest/color-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/color-tests-expected.png b/tests/regression/throwntogethertest/color-tests-expected.png index 6b50080..5d4ed89 100644 Binary files a/tests/regression/throwntogethertest/color-tests-expected.png and b/tests/regression/throwntogethertest/color-tests-expected.png differ -- cgit v0.10.1 From f211077d25c6dd50c3e1e9ef868aefaa1e955634 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 12 Dec 2011 00:48:07 +0100 Subject: Fixed render() crash reported by tjhowse. It still fails, but at least doesn't crash anymore diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index 8c65777..6ed2d90 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -71,6 +71,8 @@ int CGAL_Nef_polyhedron::weight() const This method is not const since convert_to_Polyhedron() wasn't const in earlier versions of CGAL. + + Note: Can return NULL if an error occurred */ PolySet *CGAL_Nef_polyhedron::convertToPolyset() { @@ -85,9 +87,16 @@ PolySet *CGAL_Nef_polyhedron::convertToPolyset() delete dd; } else if (this->dim == 3) { - CGAL_Polyhedron P; - this->p3->convert_to_Polyhedron(P); - ps = createPolySetFromPolyhedron(P); + CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); + try { + CGAL_Polyhedron P; + this->p3->convert_to_Polyhedron(P); + ps = createPolySetFromPolyhedron(P); + } + catch (CGAL::Precondition_exception e) { + PRINTF("CGAL error in CGAL_Nef_polyhedron::convertToPolyset(): %s", e.what()); + } + CGAL::set_error_behaviour(old_behaviour); } return ps; } diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 78d5704..7a9566b 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -396,8 +396,13 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const RenderNode &node) CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(node); PolySet *ps = NULL; if (!N.empty()) { - ps = N.convertToPolyset(); - ps->convexity = node.convexity; + if (!N.p3->is_simple()) { + PRINTF("WARNING: Body of render() isn't valid 2-manifold!"); + } + else { + ps = N.convertToPolyset(); + ps->convexity = node.convexity; + } } return ps; } -- cgit v0.10.1 From e58ffa958be2c23b9931b82fa5587bc8f0fdd5b3 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 12 Dec 2011 01:13:17 +0100 Subject: bugfix: Default font size was set to 0 - will now be 12 diff --git a/src/Preferences.cc b/src/Preferences.cc index aefbd12..59f8d23 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -36,6 +36,15 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) { setupUi(this); + // Editor pane + QFontDatabase db; + foreach(int size, db.standardSizes()) { + this->fontSize->addItem(QString::number(size)); + if (size == 12) { + this->fontSize->setCurrentIndex(this->fontSize->count()-1); + } + } + // Setup default settings this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text(); this->defaultmap["editor/fontfamily"] = this->fontChooser->currentText(); @@ -87,12 +96,6 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this->colorschemes["Sunset"][RenderSettings::CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); this->colorschemes["Sunset"][RenderSettings::CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); - // Editor pane - QFontDatabase db; - foreach(int size, db.standardSizes()) { - this->fontSize->addItem(QString::number(size)); - } - connect(this->colorSchemeChooser, SIGNAL(itemSelectionChanged()), this, SLOT(colorSchemeChanged())); connect(this->fontChooser, SIGNAL(activated(const QString &)), diff --git a/src/mainwin.cc b/src/mainwin.cc index 228e981..3243847 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -177,7 +177,7 @@ MainWindow::MainWindow(const QString &filename) editor->setTabStopWidth(30); #endif editor->setLineWrapping(true); // Not designable - setFont("", 0); // Init default font + setFont("", 12); // Init default font this->glview->statusLabel = new QLabel(this); statusBar()->addWidget(this->glview->statusLabel); -- cgit v0.10.1 From f76b77ae90d52f98969ce76e9a5ea548a31b329f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 12 Dec 2011 02:55:13 +0100 Subject: notepad++ syntax highlighting byt tjhowse diff --git a/contrib/OpenSCAD.xml b/contrib/OpenSCAD.xml new file mode 100644 index 0000000..7c6cf76 --- /dev/null +++ b/contrib/OpenSCAD.xml @@ -0,0 +1,36 @@ + + + + + + + + + 000000 + { + } + # % ( ) ; [ ] < > + 1/* 2*/ 0// + abs acos asin atan atan ceil cos exp floor ln log lookup max min pow rands round sign sin sqrt tan str scale rotate translate mirror multmatrix color minkowski hull union difference intersection render echo use include module builtin_dxf_cross for intersection_for if else assign surface + sphere cylinder polyhedron cube + + + + + + + + + + + + + + + + + + + + + -- cgit v0.10.1 From 67b2b8be1f89b79425cb5b2199e2890417d2e78b Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 12 Dec 2011 21:52:36 +0100 Subject: added note about auto-indent diff --git a/doc/TODO.txt b/doc/TODO.txt index 560e270..cfdacdc 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -90,6 +90,7 @@ o Editor wishlist in the source code in the 3D view - Tabbed editor for designs including other files - C-c/C-v should work on the focused widget, not always in the editor + - Auto-indent on enter and on tab o Error reporting/debugging - Provide better error messages when polygon ordering causes CGAL errors: o Supply syntax highlighting of the exact polygon indices which are -- cgit v0.10.1 From 4251775d3b5fdec23761572313aa95e4f4543375 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 12 Dec 2011 21:53:21 +0100 Subject: bugfix: Make include also search librarydir diff --git a/src/lexer.l b/src/lexer.l index 2760b07..c799028 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -200,35 +200,39 @@ QDir sourcepath() return QDir(parser_source_path); } +/* + Rules for include + 1) include + 2) include + */ void includefile() { - if(filename.isEmpty()) - return; - - if(filepath.isEmpty()) { - path_stack.push(sourcepath()); - } else { - QFileInfo dirinfo(sourcepath(),filepath); - path_stack.push(dirinfo.dir()); - filepath.clear(); - } - - QFileInfo finfo(sourcepath(), filename); - if (!finfo.exists()) { - finfo = QFileInfo(QDir(librarydir), filename); - } - - handle_dep(finfo.absoluteFilePath().toStdString()); - yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); - if (!yyin) { - PRINTA("WARNING: Can't open input file `%1'.", filename); - path_stack.pop(); - return; - } - openfiles.append(yyin); - filename.clear(); - - yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); + if (filename.isEmpty()) return; + + QDir dirinfo(sourcepath()); + if (!filepath.isEmpty()) { + dirinfo.cd(filepath); + } + + QFileInfo finfo(dirinfo, filename); + if (!finfo.exists()) { + finfo = QFileInfo(QFileInfo(QDir(librarydir), filepath).dir(), filename); + } + + filepath.clear(); + path_stack.push(dirinfo); + + handle_dep(finfo.absoluteFilePath().toStdString()); + yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); + if (!yyin) { + PRINTA("WARNING: Can't open input file `%1'.", filename); + path_stack.pop(); + return; + } + openfiles.append(yyin); + filename.clear(); + + yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE)); } /*! -- cgit v0.10.1 From 05e2e6ba2db49f5e3a7bd1355880c295c0f4daef Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 12 Dec 2011 21:55:18 +0100 Subject: sync diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 1bf3d8a..21adc18 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -28,6 +28,7 @@ o Dropping a file into the editor under Windows didn't work (double C:/C:/ probl o On some platforms it was possible to insertion rich text in the editor, causing confusion. o Less crashes due to CGAL assertions o OpenCSG should now work on systems with OpenGL 1.x, given that the right extensions are available +o include now searches librarydir Deprecations: o dxf_linear_extrude() and dxf_rotate_extrude() are now deprecated. -- cgit v0.10.1 From d61b274dad6928c4b8ea1e449594453e46d0452d Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 13 Dec 2011 01:22:33 +0100 Subject: Started documenting env. variables diff --git a/openscad.pro b/openscad.pro index 80dd7d9..5487fc9 100644 --- a/openscad.pro +++ b/openscad.pro @@ -1,3 +1,13 @@ +# Environment variables which can be set to specify library locations: +# MPIRDIR +# MPFRDIR +# BOOSTDIR +# CGALDIR +# EIGEN2DIR +# GLEWDIR +# OPENCSGDIR +# MACOSX_DEPLOY_DIR +# isEmpty(QT_VERSION) { error("Please use qmake for Qt 4 (probably qmake-qt4)") -- cgit v0.10.1 From ed06583ecad27126861122798a661aa6ef464907 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 13 Dec 2011 01:23:39 +0100 Subject: Use the same env. variables as in openscad.pro. NB\! This may break some build scripts\! diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 61e0ef0..d795951 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -71,8 +71,8 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") endif() -if (NOT $ENV{BOOST_DIR} STREQUAL "") - set(BOOST_DIR "$ENV{BOOST_DIR}") +if (NOT $ENV{BOOSTDIR} STREQUAL "") + set(BOOST_DIR "$ENV{BOOSTDIR}") endif() if (NOT ${BOOST_DIR} STREQUAL "") @@ -140,8 +140,8 @@ endif() include_directories(${EIGEN2_INCLUDE_DIR}) # OpenCSG -if (NOT $ENV{OPENCSG_DIR} STREQUAL "") - set(OPENCSG_DIR "$ENV{OPENCSG_DIR}") +if (NOT $ENV{OPENCSGDIR} STREQUAL "") + set(OPENCSG_DIR "$ENV{OPENCSGDIR}") elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(OPENCSG_DIR "$ENV{MACOSX_DEPLOY_DIR}") endif() @@ -164,8 +164,8 @@ include_directories(${OPENCSG_INCLUDE_DIR}) # GLEW -if (NOT $ENV{GLEW_DIR} STREQUAL "") - set(GLEW_DIR "$ENV{GLEW_DIR}") +if (NOT $ENV{GLEWDIR} STREQUAL "") + set(GLEW_DIR "$ENV{GLEWDIR}") elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(GLEW_DIR "$ENV{MACOSX_DEPLOY_DIR}") endif() @@ -197,8 +197,8 @@ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/parser_yacc.c PROPERTIES # CGAL -if (NOT $ENV{CGAL_DIR} STREQUAL "") - set(CGAL_DIR "$ENV{CGAL_DIR}") +if (NOT $ENV{CGALDIR} STREQUAL "") + set(CGAL_DIR "$ENV{CGALDIR}") elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(CGAL_DIR "$ENV{MACOSX_DEPLOY_DIR}/lib/CGAL") set(CMAKE_MODULE_PATH "${CGAL_DIR}") -- cgit v0.10.1 From a020b54dc2bb037e90bc93dbc81f44d26f35de52 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 13 Dec 2011 01:24:15 +0100 Subject: Don't run if TEST_GENERATE is set diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 85f4ec7..80a887a 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -489,6 +489,8 @@ builddir = os.getcwd() # os.getcwd()+'/build' verbose = False maxretry = 10 +if bool(os.getenv("TEST_GENERATE")): sys.exit(0) + failed_only = False if '--failed-only' in sys.argv: failed_only = True -- cgit v0.10.1 From 3f6a2f0fbb084267171c3798718d7184f5892355 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 13 Dec 2011 01:24:53 +0100 Subject: Improved sphere tesselation for low resolution spheres diff --git a/src/primitives.cc b/src/primitives.cc index 67e19c3..b3fa45f 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -327,7 +327,7 @@ PolySet *PrimitiveNode::evaluate_polyset(class PolySetEvaluator *) const }; int fragments = get_fragments_from_r(r1, fn, fs, fa); - int rings = fragments/2; + int rings = (fragments+1)/2; // Uncomment the following three lines to enable experimental sphere tesselation // if (rings % 2 == 0) rings++; // To ensure that the middle ring is at phi == 0 degrees diff --git a/tests/regression/opencsgtest/sphere-tests-expected.png b/tests/regression/opencsgtest/sphere-tests-expected.png index 06161f3..d11e3bf 100644 Binary files a/tests/regression/opencsgtest/sphere-tests-expected.png and b/tests/regression/opencsgtest/sphere-tests-expected.png differ diff --git a/tests/regression/opencsgtest/testcolornames-expected.png b/tests/regression/opencsgtest/testcolornames-expected.png index 6fc6569..6c1b107 100644 Binary files a/tests/regression/opencsgtest/testcolornames-expected.png and b/tests/regression/opencsgtest/testcolornames-expected.png differ diff --git a/tests/regression/throwntogethertest/sphere-tests-expected.png b/tests/regression/throwntogethertest/sphere-tests-expected.png index 4792668..d11e3bf 100644 Binary files a/tests/regression/throwntogethertest/sphere-tests-expected.png and b/tests/regression/throwntogethertest/sphere-tests-expected.png differ -- cgit v0.10.1 From 51c5789516751fab63fad07cb7a2a25125261c23 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 13 Dec 2011 01:50:36 +0100 Subject: Added note about GL deprecation diff --git a/src/glview.cc b/src/glview.cc index 6836e3b..c96fe01 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -158,7 +158,9 @@ void GLView::initializeGL() glGetString(GL_VERSION), rbits, gbits, bbits, abits, dbits, sbits, glGetString(GL_EXTENSIONS)); - +// FIXME: glGetString(GL_EXTENSIONS) is deprecated in OpenGL 3.0. +// Use: glGetIntegerv(GL_NUM_EXTENSIONS, &NumberOfExtensions) and +// glGetStringi(GL_EXTENSIONS, i) const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20"); if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) { -- cgit v0.10.1 From 72000cbd58deecaa4f1c5f9d5900fe1b74f56572 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 13 Dec 2011 01:52:55 +0100 Subject: sync diff --git a/doc/TODO.txt b/doc/TODO.txt index cfdacdc..6bb3a15 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -245,7 +245,7 @@ o import_stl o import_off o import_* - open polylines -o include: test subdirs under librarydir (e.g. include doesn't work +o include: test subdirs under librarydir (e.g. include ) o use: Basically same tests as include. + use restrictions o include and use: remember filenames with space o variants of module transparent() { %child(); } -- cgit v0.10.1 From e01b9a56665e52ddb119c850fec4fb0c35c4e137 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Mon, 12 Dec 2011 19:57:39 -0600 Subject: fix div by zero bug in test_pretty_print diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 80a887a..d0c24c6 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -250,7 +250,8 @@ TESTLOG tests_to_report = tests if failed_only: tests_to_report = failed_tests - percent = str(int(100.0*len(passed_tests) / len(tests))) + try: percent = str(int(100.0*len(passed_tests) / len(tests))) + except ZeroDivisionError: percent = 'n/a' s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) @@ -311,7 +312,8 @@ def tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles): passed_tests = filter(lambda x: x.passed, tests) failed_tests = filter(lambda x: not x.passed, tests) - percent = str(int(100.0*len(passed_tests) / len(tests))) + try: percent = str(int(100.0*len(passed_tests) / len(tests))) + except ZeroDivisionError: percent = 'n/a' tests_to_report = tests if failed_only: tests_to_report = failed_tests -- cgit v0.10.1 From 7781ae7015ae4fd107f6593e831bf6c3101f116f Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 13 Dec 2011 17:53:12 -0600 Subject: fix cmake path bugs. rewrite testing to match non-underscore DIR variables. diff --git a/doc/testing.txt b/doc/testing.txt index 403ef4a..d44d801 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -33,7 +33,7 @@ $ ctest -C Adds extended tests belonging to configs. Examples - test all examples All - test everything -Adding a new regression test: +Adding a new regression test: ------------------------------ 1) create a test file at an appropriate location under testdata/ @@ -58,15 +58,19 @@ $ DISPLAY=:5 ctest 1. Trouble finding libraries To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use - the -D option. See CMakeLists.txt for more information. Examples: + environment variables, just like for the main qmake & openscad.pro. Examples: - cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 - cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_DIR=c:\boost_1_46_0 + OPENCSGDIR=~/OpenCSG-1.3.2 EIGEN2DIR=~/eigen2 cmake . + CGALDIR=c:\CGAL-3.7 BOOSTDIR=c:\boost_1_46_0 cmake . + + Valid variables are as follows (see CMakeLists.txt for more info): + + BOOSTDIR, CGALDIR, EIGEN2DIR, GLEWDIR, OPENCSGDIR, MACOSX_DEPLOY_DIR 2. Logs Logs of test runs are found in tests/build/Testing/Temporary -Pretty-printed html output is in a subdir of tests/build/Testing/Temporary +Pretty-printed index.html is in a subdir of tests/build/Testing/Temporary Expected results are found in tests/regression/* Actual results are found in tests/build/testname-output/* @@ -74,17 +78,22 @@ Actual results are found in tests/build/testname-output/* Cross-compiling of tests has not been automated nor tested -4. Testing images takes forever, they fail, and it says 'return -11' +4. Image-based tests takes a long time, they fail, and it says 'return -11' -Imagemagick may have crashed. You can try using the alternate comparison +Imagemagick may have crashed. You can try using the alternate IM comparator based on Normalized Cross Correlation. Pass -DCOMPARATOR=ncc to cmake 5. Testing images fails with 'morphology' not found for ImageMagick -Your version of imagemagick is old. Upgrade, or pass -DCOMPARATOR=old to cmake. -The comparison will be of lowered reliability. +Your version of imagemagick is old. Upgrade, or pass -DCOMPARATOR=old to +cmake. The comparison will be of lowered reliability. -6. Many cgalpngtests are failing with weird assertion errors. +6. Unexplained or bizarre errors. -Edit CMakeCache.txt and replace '-DNDEBUG' or '/D NDEBUG' with blank spaces +This can happen on dynamic-library systems (linux) where you try to use +your own version of a library while the system still has another version +under the system paths. You can diagnose this by looking at your cmake +log as well as your sysinfo.txt file, as well as running 'ldd' against +your binaries, to make sure that the proper versions of libraries are +getting compiled and linked with the test binaries. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d795951..6f776d2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,5 @@ +# instructions - see ../doc/testing.txt + cmake_minimum_required(VERSION 2.8) if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) # Explicitly use new include policy to avoid globally shadowing included modules @@ -125,11 +127,13 @@ endif() if (NOT EIGEN2_INCLUDE_DIR) find_path(EIGEN2_INCLUDE_DIR Eigen/Core - PATHS ENV EIGEN2DIR /opt/local/include/eigen2 /usr/include/eigen2) + HINTS ENV EIGEN2DIR + PATHS /opt/local/include/eigen2 /usr/include/eigen2) if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") find_path(EIGEN2_INCLUDE_DIR Eigen/Core - PATHS ENV EIGEN2DIR /usr/local/include/eigen2 ) + HINTS ENV EIGEN2DIR + PATHS /usr/local/include/eigen2 ) endif() if (NOT EIGEN2_INCLUDE_DIR) message(FATAL_ERROR "Eigen2 not found") diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index 8093ed3..fa3071f 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -32,12 +32,14 @@ IF (WIN32) ELSE (WIN32) message(STATUS "GLEW_DIR: " ${GLEW_DIR}) FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h - PATHS ${GLEW_DIR}/include /usr/include /usr/local/include + HINTS ${GLEW_DIR}/include + PATHS /usr/include /usr/local/include NO_DEFAULT_PATH DOC "The directory where GL/glew.h resides") FIND_LIBRARY( GLEW_LIBRARY NAMES GLEW glew - PATHS ${GLEW_DIR}/lib /usr/lib /usr/local/lib + HINTS ${GLEW_DIR}/lib + PATHS /usr/lib /usr/local/lib NO_DEFAULT_PATH DOC "The GLEW library") ENDIF (WIN32) -- cgit v0.10.1 From 21c4bbe7d46c19efe4d49d58c5fb11492275e4fe Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 14 Dec 2011 02:36:37 -0600 Subject: fix windows MSVC build, fix testing.txt to reflect win32 build diff --git a/doc/testing.txt b/doc/testing.txt index d44d801..04768cb 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -61,7 +61,6 @@ $ DISPLAY=:5 ctest environment variables, just like for the main qmake & openscad.pro. Examples: OPENCSGDIR=~/OpenCSG-1.3.2 EIGEN2DIR=~/eigen2 cmake . - CGALDIR=c:\CGAL-3.7 BOOSTDIR=c:\boost_1_46_0 cmake . Valid variables are as follows (see CMakeLists.txt for more info): diff --git a/src/renderer.h b/src/renderer.h index e978080..8deabe8 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -3,6 +3,10 @@ #include "system-gl.h" +#ifdef _MSC_VER // NULL +#include +#endif + class Renderer { public: -- cgit v0.10.1 From 1f790437ea8992b996cac2e1399af9ae62291115 Mon Sep 17 00:00:00 2001 From: don Date: Wed, 14 Dec 2011 15:02:55 -0600 Subject: fix freebsd build, improve test_pretty_print error handle, improve documentation diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6f776d2..5be321d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,16 +59,11 @@ if(WIN32) # you have to pass -DCMAKE_VERBOSE_MAKEFILE=ON to cmake when you run it. endif() - # # Build test apps # # Boost -# -# usually it's found automatically, but some systems may need a custom install. -# in that case, run cmake with -DBOOST_ROOT=/path/to/boost/install -# (being the same path you passed to boost's --prefix when you built it) if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") endif() @@ -111,10 +106,20 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # Qt4 + +if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + # make /usr/local/include/qt4 come before /usr/local/include (QT4 vs QT3) + set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) +endif() + find_package(OpenGL) find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) include(${QT_USE_FILE}) +if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF) +endif() + # Eigen2 # Turn off Eigen SIMD optimization diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index d0c24c6..6fdc663 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -33,19 +33,16 @@ # 3. save the wikified data to disk # todo +# deal better with the situation where Offscreen rendering fails # do something if tests for GL extensions for OpenCSG fail (test fail, no image production) # copy all images, sysinfo.txt to bundle for html/upload (images # can be altered by subsequent runs) -# figure out hwo to make the thing run after the test -# figure out how CTEST treats the logfiles. # why is hash differing -# instead of having special '-info' prerun, put it as yet-another-test -# and parse the log # fix windows so that it won't keep asking 'this program crashed' over and over. # (you can set this in the registry to never happen, but itd be better if the program # itself was able to disable that temporarily in it's own process) -import string,sys,re,os,hashlib,subprocess,textwrap,time +import string,sys,re,os,hashlib,subprocess,textwrap,time,platform def tryread(filename): data = None @@ -88,7 +85,12 @@ def read_gitinfo(): def read_sysinfo(filename): data = tryread(filename) - if not data: return 'sysinfo: unknown' + if not data: + sinfo = platform.sys.platform + sinfo += '\nsystem cannot create offscreen GL framebuffer object' + sinfo += '\nsystem cannot create images' + sysid = platform.sys.platform+'_no_images' + return sinfo, sysid machine = ezsearch('Machine:(.*?)\n',data) machine = machine.replace(' ','-').replace('/','-') @@ -468,7 +470,7 @@ def main(): if verbose: print 'erasing files in',wikidir try: map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) except: pass - print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') + print 'writing',len(imgs),'images, ',len(txtpages)-1,'text pages, and index.html to:\n', ' .'+wikidir.replace(os.getcwd(),'') for pgname in sorted(imgs): trysave( os.path.join(wikidir,pgname), imgs[pgname]) for pgname in sorted(txtpages): trysave( os.path.join(wikidir,pgname), txtpages[pgname]) -- cgit v0.10.1 From 30e1747f5e605e04acef640c7e112d890fb65557 Mon Sep 17 00:00:00 2001 From: don Date: Wed, 14 Dec 2011 18:23:07 -0600 Subject: fix EIGEN2DIR cmake syntax diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5be321d..d79925a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -132,12 +132,12 @@ endif() if (NOT EIGEN2_INCLUDE_DIR) find_path(EIGEN2_INCLUDE_DIR Eigen/Core - HINTS ENV EIGEN2DIR + HINTS $ENV{EIGEN2DIR} PATHS /opt/local/include/eigen2 /usr/include/eigen2) if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") find_path(EIGEN2_INCLUDE_DIR Eigen/Core - HINTS ENV EIGEN2DIR + HINTS $ENV{EIGEN2DIR} PATHS /usr/local/include/eigen2 ) endif() if (NOT EIGEN2_INCLUDE_DIR) -- cgit v0.10.1 From b74bb392afbeee062b9654dac78950fc85c4c884 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 15 Dec 2011 04:59:15 +0100 Subject: generalized MACOSX_DEPLOY_DIR into the platform-independent OPENSCAD_LIBRARIES diff --git a/bison.pri b/bison.pri index 003e09b..b1f3292 100644 --- a/bison.pri +++ b/bison.pri @@ -1,17 +1,17 @@ -#setup bison for qmake -bison.name = Bison ${QMAKE_FILE_IN} -bison.input = BISONSOURCES -bison.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp -bison.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} -bison.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h -bison.CONFIG += target_predeps -bison.variable_out = GENERATED_SOURCES -silent:bison.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands -QMAKE_EXTRA_COMPILERS += bison -bison_header.input = BISONSOURCES -bison_header.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h -bison_header.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} -bison_header.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h -bison_header.CONFIG += target_predeps no_link -silent:bison_header.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands -QMAKE_EXTRA_COMPILERS += bison_header +#setup bison for qmake +bison.name = Bison ${QMAKE_FILE_IN} +bison.input = BISONSOURCES +bison.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp +bison.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} +bison.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h +bison.CONFIG += target_predeps +bison.variable_out = GENERATED_SOURCES +silent:bison.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands +QMAKE_EXTRA_COMPILERS += bison +bison_header.input = BISONSOURCES +bison_header.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h +bison_header.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} +bison_header.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h +bison_header.CONFIG += target_predeps no_link +silent:bison_header.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands +QMAKE_EXTRA_COMPILERS += bison_header diff --git a/boost.pri b/boost.pri index d93b738..79fa0e3 100644 --- a/boost.pri +++ b/boost.pri @@ -1,13 +1,13 @@ boost { - isEmpty(DEPLOYDIR) { + isEmpty(OPENSCAD_LIBDIR) { # Optionally specify location of boost using the # BOOSTDIR env. variable BOOST_DIR = $$(BOOSTDIR) !isEmpty(BOOST_DIR) { - INCLUDEPATH += $$BOOST_DIR + QMAKE_INCDIR += $$BOOST_DIR message("boost location: $$BOOST_DIR") - win32:LIBS += -L$$BOOST_DIR/lib + win32:QMAKE_LIBDIR += -L$$BOOST_DIR/lib } } diff --git a/cgal.pri b/cgal.pri index 1d9ef22..56fb17b 100644 --- a/cgal.pri +++ b/cgal.pri @@ -1,14 +1,14 @@ cgal { DEFINES += ENABLE_CGAL - isEmpty(DEPLOYDIR) { + isEmpty(OPENSCAD_LIBDIR) { # Optionally specify location of CGAL using the # CGALDIR env. variable CGAL_DIR = $$(CGALDIR) !isEmpty(CGAL_DIR) { - INCLUDEPATH += $$CGAL_DIR/include - win32: INCLUDEPATH += $$CGAL_DIR/auxiliary/gmp/include - LIBS += -L$$CGAL_DIR/lib + QMAKE_INCDIR += $$CGAL_DIR/include + win32: QMAKE_INCDIR += $$CGAL_DIR/auxiliary/gmp/include + QMAKE_LIBDIR += $$CGAL_DIR/lib message("CGAL location: $$CGAL_DIR") } } @@ -17,7 +17,7 @@ cgal { LIBS += -lgmp -lmpfr -lCGAL QMAKE_CXXFLAGS += -frounding-math } else { - windows { + win32 { *-g++* { QMAKE_CXXFLAGS += -frounding-math } diff --git a/common.pri b/common.pri new file mode 100644 index 0000000..d8620ed --- /dev/null +++ b/common.pri @@ -0,0 +1,7 @@ +include(win32.pri) +include(flex.pri) +include(bison.pri) +include(cgal.pri) +include(opencsg.pri) +include(eigen2.pri) +include(boost.pri) diff --git a/doc/testing.txt b/doc/testing.txt index 04768cb..67d14ba 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -64,7 +64,7 @@ $ DISPLAY=:5 ctest Valid variables are as follows (see CMakeLists.txt for more info): - BOOSTDIR, CGALDIR, EIGEN2DIR, GLEWDIR, OPENCSGDIR, MACOSX_DEPLOY_DIR + BOOSTDIR, CGALDIR, EIGEN2DIR, GLEWDIR, OPENCSGDIR, OPENSCAD_LIBRARIES 2. Logs diff --git a/eigen2.pri b/eigen2.pri index 4c71749..8b955e3 100644 --- a/eigen2.pri +++ b/eigen2.pri @@ -1,15 +1,24 @@ -# Optionally specify location of Eigen2 using the -# EIGEN2DIR env. variable -EIGEN2_DIR = $$(EIGEN2DIR) -!isEmpty(EIGEN2_DIR) { - INCLUDEPATH += $$EIGEN2_DIR -} -else { - CONFIG(mingw-cross-env) { - INCLUDEPATH += mingw-cross-env/include/eigen2 - } else { - freebsd-g++: INCLUDEPATH += /usr/local/include/eigen2 - macx: INCLUDEPATH += /opt/local/include/eigen2 - !macx:!freebsd-g++:INCLUDEPATH += /usr/include/eigen2 +eigen2 { + # Optionally specify location of Eigen2 using the + # EIGEN2DIR env. variable + EIGEN2_DIR = $$(EIGEN2DIR) + !isEmpty(EIGEN2_DIR) { + INCLUDEPATH += $$EIGEN2_DIR + } + else { + CONFIG(mingw-cross-env) { + INCLUDEPATH += mingw-cross-env/include/eigen2 + } else { + freebsd-g++: INCLUDEPATH += /usr/local/include/eigen2 + macx: INCLUDEPATH += /opt/local/include/eigen2 + !macx:!freebsd-g++:INCLUDEPATH += /usr/include/eigen2 + } + } + + # disable Eigen SIMD optimizations for non-Mac OSX + !macx { + !freebsd-g++ { + QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN + } } } diff --git a/flex.pri b/flex.pri index 2042952..ef0b742 100644 --- a/flex.pri +++ b/flex.pri @@ -1,10 +1,15 @@ -#setup flex for qmake - -flex.name = Flex ${QMAKE_FILE_IN} -flex.input = FLEXSOURCES -flex.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp -flex.commands = flex -P ${QMAKE_FILE_BASE} -o${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp ${QMAKE_FILE_IN} -flex.CONFIG += target_predeps -flex.variable_out = GENERATED_SOURCES -silent:flex.commands = @echo Lex ${QMAKE_FILE_IN} && $$flex.commands -QMAKE_EXTRA_COMPILERS += flex +win32 { + flex.name = Flex ${QMAKE_FILE_IN} + flex.input = FLEXSOURCES + flex.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp + flex.commands = flex -P ${QMAKE_FILE_BASE} -o${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp ${QMAKE_FILE_IN} + flex.CONFIG += target_predeps + flex.variable_out = GENERATED_SOURCES + silent:flex.commands = @echo Lex ${QMAKE_FILE_IN} && $$flex.commands + QMAKE_EXTRA_COMPILERS += flex +} + +unix:freebsd-g++ { + QMAKE_LEX = /usr/local/bin/flex + QMAKE_YACC = /usr/local/bin/bison +} diff --git a/glew.pri b/glew.pri index 84d9449..b9c0c14 100644 --- a/glew.pri +++ b/glew.pri @@ -1,5 +1,5 @@ glew { - isEmpty(DEPLOYDIR) { + isEmpty(OPENSCAD_LIBDIR) { # Optionally specify location of GLEW using the # GLEWDIR env. variable GLEW_DIR = $$(GLEWDIR) @@ -8,8 +8,8 @@ glew { macx: GLEW_DIR = /opt/local } !isEmpty(GLEW_DIR) { - INCLUDEPATH += $$GLEW_DIR/include - LIBS += -L$$GLEW_DIR/lib + QMAKE_INCDIR += $$GLEW_DIR/include + QMAKE_LIBDIR += -L$$GLEW_DIR/lib message("GLEW location: $$GLEW_DIR") } } @@ -18,4 +18,3 @@ glew { win32:LIBS += -lglew32s CONFIG(mingw-cross-env):DEFINES += GLEW_STATIC } - diff --git a/mingw-cross-env.pri b/mingw-cross-env.pri new file mode 100644 index 0000000..b0735a2 --- /dev/null +++ b/mingw-cross-env.pri @@ -0,0 +1,13 @@ +# cross compilation unix->win32 +CONFIG(mingw-cross-env) { + LIBS += mingw-cross-env/lib/libglew32s.a + LIBS += mingw-cross-env/lib/libglut.a + LIBS += mingw-cross-env/lib/libopengl32.a + LIBS += mingw-cross-env/lib/libGLEW.a + LIBS += mingw-cross-env/lib/libglaux.a + LIBS += mingw-cross-env/lib/libglu32.a + LIBS += mingw-cross-env/lib/libopencsg.a + LIBS += mingw-cross-env/lib/libmpfr.a + LIBS += mingw-cross-env/lib/libCGAL.a + QMAKE_CXXFLAGS += -fpermissive +} diff --git a/opencsg.pri b/opencsg.pri index d34f11b..9713410 100644 --- a/opencsg.pri +++ b/opencsg.pri @@ -6,13 +6,13 @@ opencsg { HEADERS += src/OpenCSGRenderer.h SOURCES += src/OpenCSGRenderer.cc - isEmpty(DEPLOYDIR) { + isEmpty(OPENSCAD_LIBDIR) { # Optionally specify location of OpenCSG using the # OPENCSGDIR env. variable OPENCSG_DIR = $$(OPENCSGDIR) !isEmpty(OPENCSG_DIR) { - INCLUDEPATH += $$OPENCSG_DIR/include - LIBS += -L$$OPENCSG_DIR/lib + QMAKE_INCDIR += $$OPENCSG_DIR/include + QMAKE_LIBDIR += $$OPENCSG_DIR/lib message("OpenCSG location: $$OPENCSG_DIR") } } diff --git a/openscad.pro b/openscad.pro index 5487fc9..026db5b 100644 --- a/openscad.pro +++ b/openscad.pro @@ -6,7 +6,7 @@ # EIGEN2DIR # GLEWDIR # OPENCSGDIR -# MACOSX_DEPLOY_DIR +# OPENSCAD_LIBRARIES # isEmpty(QT_VERSION) { @@ -28,69 +28,10 @@ include(version.pri) # for debugging link problems (use nmake -f Makefile.Release > log.txt) win32 { - # QMAKE_LFLAGS += -VERBOSE + # QMAKE_LFLAGS += -VERBOSE } debug: DEFINES += DEBUG -# cross compilation unix->win32 - -CONFIG(mingw-cross-env) { - LIBS += mingw-cross-env/lib/libglew32s.a - LIBS += mingw-cross-env/lib/libglut.a - LIBS += mingw-cross-env/lib/libopengl32.a - LIBS += mingw-cross-env/lib/libGLEW.a - LIBS += mingw-cross-env/lib/libglaux.a - LIBS += mingw-cross-env/lib/libglu32.a - LIBS += mingw-cross-env/lib/libopencsg.a - LIBS += mingw-cross-env/lib/libmpfr.a - LIBS += mingw-cross-env/lib/libCGAL.a - QMAKE_CXXFLAGS += -fpermissive -} - -#configure lex / yacc -unix:freebsd-g++ { - QMAKE_LEX = /usr/local/bin/flex - QMAKE_YACC = /usr/local/bin/bison -} -win32 { - include(flex.pri) - include(bison.pri) - FLEXSOURCES = src/lexer.l - BISONSOURCES = src/parser.y -} else { - LEXSOURCES += src/lexer.l - YACCSOURCES += src/parser.y -} - -#configure additional directories -win32 { - INCLUDEPATH += $$(MPIRDIR) - INCLUDEPATH += $$(MPFRDIR) -} - -DEFINES += OPENSCAD_VERSION=$$VERSION OPENSCAD_YEAR=$$VERSION_YEAR OPENSCAD_MONTH=$$VERSION_MONTH -!isEmpty(VERSION_DAY): DEFINES += OPENSCAD_DAY=$$VERSION_DAY -win32:DEFINES += _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS YY_NO_UNISTD_H - -# disable MSVC warnings that are of very low importance -win32:*msvc* { - # disable warning about too long decorated names - QMAKE_CXXFLAGS += -wd4503 - # CGAL casting int to bool - QMAKE_CXXFLAGS += -wd4800 - # CGAL's unreferenced formal parameters - QMAKE_CXXFLAGS += -wd4100 - # lexer uses strdup() & other POSIX stuff - QMAKE_CXXFLAGS += -D_CRT_NONSTDC_NO_DEPRECATE -} - -# disable Eigen SIMD optimizations for non-Mac OSX -!macx { - !freebsd-g++ { - QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN - } -} - TEMPLATE = app RESOURCES = openscad.qrc @@ -100,12 +41,15 @@ UI_DIR = objects RCC_DIR = objects INCLUDEPATH += src +# Handle custom library location. +# Used when manually installing 3rd party libraries +OPENSCAD_LIBDIR = $$(OPENSCAD_LIBRARIES) +!isEmpty(OPENSCAD_LIBDIR) { + QMAKE_INCDIR += $$OPENSCAD_LIBDIR/include + QMAKE_LIBDIR += $$OPENSCAD_LIBDIR/lib +} + macx { - DEPLOYDIR = $$(MACOSX_DEPLOY_DIR) - !isEmpty(DEPLOYDIR) { - INCLUDEPATH += $$DEPLOYDIR/include - LIBS += -L$$DEPLOYDIR/lib - } # add CONFIG+=deploy to the qmake command-line to make a deployment build deploy { message("Building deployment version") @@ -135,17 +79,18 @@ QT += opengl macx:CONFIG += mdi CONFIG += cgal CONFIG += opencsg -CONFIG += progresswidget CONFIG += boost +CONFIG += eigen2 #Uncomment the following line to enable QCodeEdit #CONFIG += qcodeedit mdi { - # MDI needs an OpenCSG library that is compiled with OpenCSG-Reset-Hack.patch applied DEFINES += ENABLE_MDI } +# FIXME: This can be made default by now +CONFIG += progresswidget progresswidget { DEFINES += USE_PROGRESSWIDGET FORMS += src/ProgressWidget.ui @@ -153,20 +98,15 @@ progresswidget { SOURCES += src/ProgressWidget.cc } -include(cgal.pri) -include(opencsg.pri) -include(eigen2.pri) -include(boost.pri) - -# Standard include path for misc external libs -#macx { -# INCLUDEPATH += /opt/local/include -#} - -# QMAKE_CFLAGS += -pg -# QMAKE_CXXFLAGS += -pg -# QMAKE_LFLAGS += -pg +include(common.pri) +win32 { + FLEXSOURCES = src/lexer.l + BISONSOURCES = src/parser.y +} else { + LEXSOURCES += src/lexer.l + YACCSOURCES += src/parser.y +} FORMS += src/MainWindow.ui \ src/Preferences.ui \ diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index e69d594..bc42058 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -190,7 +190,7 @@ build_opencsg() tar xzf OpenCSG-$version.tar.gz cd OpenCSG-$version patch -p1 < $OPENSCADDIR/patches/OpenCSG-$version-MacOSX-port.patch - MACOSX_DEPLOY_DIR=$DEPLOYDIR qmake -r CONFIG+="x86 x86_64" + OPENSCAD_LIBRARIES=$DEPLOYDIR qmake -r CONFIG+="x86 x86_64" make install } diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index 2036e3b..e559cb8 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -7,7 +7,7 @@ VERSION=`date "+%Y.%m.%d"` PATH=${PATH//\/opt\/local\/libexec\/ccache:} # This is the same location as DEPLOYDIR in macosx-build-dependencies.sh -export MACOSX_DEPLOY_DIR=$PWD/../libraries/install +export OPENSCAD_LIBRARIES=$PWD/../libraries/install `dirname $0`/release-common.sh -v $VERSION if [[ $? != 0 ]]; then diff --git a/setenv_mjau.sh b/setenv_mjau.sh index f6a16d2..599be0e 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -1,4 +1,4 @@ -export MACOSX_DEPLOY_DIR=$PWD/../libraries/install +export OPENSCAD_LIBRARIES=$PWD/../libraries/install export DYLD_LIBRARY_PATH=$MACOSX_DEPLOY_DIR/lib #export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 diff --git a/version.pri b/version.pri index 195c51a..c94ab82 100644 --- a/version.pri +++ b/version.pri @@ -62,3 +62,6 @@ isEmpty(VERSION) { VERSION_MONTH=$${VERSION_MONTH}.0 VERSION_DAY=$${VERSION_DAY}.0 } + +DEFINES += OPENSCAD_VERSION=$$VERSION OPENSCAD_YEAR=$$VERSION_YEAR OPENSCAD_MONTH=$$VERSION_MONTH +!isEmpty(VERSION_DAY): DEFINES += OPENSCAD_DAY=$$VERSION_DAY diff --git a/win32.pri b/win32.pri new file mode 100644 index 0000000..7a020d7 --- /dev/null +++ b/win32.pri @@ -0,0 +1,20 @@ +# win32-specific general settings + +win32 { + #configure additional directories + INCLUDEPATH += $$(MPIRDIR) + INCLUDEPATH += $$(MPFRDIR) + + DEFINES += _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS YY_NO_UNISTD_H + + # disable MSVC warnings that are of very low importance + # disable warning about too long decorated names + QMAKE_CXXFLAGS += -wd4503 + # CGAL casting int to bool + QMAKE_CXXFLAGS += -wd4800 + # CGAL's unreferenced formal parameters + QMAKE_CXXFLAGS += -wd4100 + # lexer uses strdup() & other POSIX stuff + QMAKE_CXXFLAGS += -D_CRT_NONSTDC_NO_DEPRECATE + +} \ No newline at end of file -- cgit v0.10.1 From 6aa1a6d4c8fab520d2951ccfddb141ea5825acc1 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 15 Dec 2011 05:17:04 +0100 Subject: Some more build system cleaning diff --git a/boost.pri b/boost.pri index 79fa0e3..46cbb83 100644 --- a/boost.pri +++ b/boost.pri @@ -1,14 +1,12 @@ boost { - isEmpty(OPENSCAD_LIBDIR) { - # Optionally specify location of boost using the - # BOOSTDIR env. variable - BOOST_DIR = $$(BOOSTDIR) - !isEmpty(BOOST_DIR) { - QMAKE_INCDIR += $$BOOST_DIR - message("boost location: $$BOOST_DIR") - win32:QMAKE_LIBDIR += -L$$BOOST_DIR/lib - } + # Optionally specify location of boost using the + # BOOSTDIR env. variable + BOOST_DIR = $$(BOOSTDIR) + !isEmpty(BOOST_DIR) { + QMAKE_INCDIR += $$BOOST_DIR + message("boost location: $$BOOST_DIR") + win32:QMAKE_LIBDIR += -L$$BOOST_DIR/lib } CONFIG(mingw-cross-env) { diff --git a/cgal.pri b/cgal.pri index 56fb17b..7cd5389 100644 --- a/cgal.pri +++ b/cgal.pri @@ -1,16 +1,14 @@ cgal { DEFINES += ENABLE_CGAL - isEmpty(OPENSCAD_LIBDIR) { - # Optionally specify location of CGAL using the - # CGALDIR env. variable - CGAL_DIR = $$(CGALDIR) - !isEmpty(CGAL_DIR) { - QMAKE_INCDIR += $$CGAL_DIR/include - win32: QMAKE_INCDIR += $$CGAL_DIR/auxiliary/gmp/include - QMAKE_LIBDIR += $$CGAL_DIR/lib - message("CGAL location: $$CGAL_DIR") - } + # Optionally specify location of CGAL using the + # CGALDIR env. variable + CGAL_DIR = $$(CGALDIR) + !isEmpty(CGAL_DIR) { + QMAKE_INCDIR += $$CGAL_DIR/include + win32: QMAKE_INCDIR += $$CGAL_DIR/auxiliary/gmp/include + QMAKE_LIBDIR += $$CGAL_DIR/lib + message("CGAL location: $$CGAL_DIR") } CONFIG(mingw-cross-env) { @@ -27,5 +25,4 @@ cgal { QMAKE_CXXFLAGS += -frounding-math } } - } diff --git a/common.pri b/common.pri index d8620ed..d6e8480 100644 --- a/common.pri +++ b/common.pri @@ -1,7 +1,13 @@ +OBJECTS_DIR = objects +MOC_DIR = objects +UI_DIR = objects +RCC_DIR = objects + include(win32.pri) include(flex.pri) include(bison.pri) include(cgal.pri) include(opencsg.pri) +include(glew.pri) include(eigen2.pri) include(boost.pri) diff --git a/glew.pri b/glew.pri index b9c0c14..981d14b 100644 --- a/glew.pri +++ b/glew.pri @@ -1,17 +1,11 @@ glew { - isEmpty(OPENSCAD_LIBDIR) { - # Optionally specify location of GLEW using the - # GLEWDIR env. variable - GLEW_DIR = $$(GLEWDIR) - isEmpty(GLEW_DIR) { - # Default to MacPorts on Mac OS X - macx: GLEW_DIR = /opt/local - } - !isEmpty(GLEW_DIR) { - QMAKE_INCDIR += $$GLEW_DIR/include - QMAKE_LIBDIR += -L$$GLEW_DIR/lib - message("GLEW location: $$GLEW_DIR") - } + # Optionally specify location of GLEW using the + # GLEWDIR env. variable + GLEW_DIR = $$(GLEWDIR) + !isEmpty(GLEW_DIR) { + QMAKE_INCDIR += $$GLEW_DIR/include + QMAKE_LIBDIR += $$GLEW_DIR/lib + message("GLEW location: $$GLEW_DIR") } unix:LIBS += -lGLEW diff --git a/opencsg.pri b/opencsg.pri index 9713410..ff3bc4d 100644 --- a/opencsg.pri +++ b/opencsg.pri @@ -1,20 +1,14 @@ opencsg { DEFINES += ENABLE_OPENCSG CONFIG += glew - include(glew.pri) - HEADERS += src/OpenCSGRenderer.h - SOURCES += src/OpenCSGRenderer.cc - - isEmpty(OPENSCAD_LIBDIR) { - # Optionally specify location of OpenCSG using the - # OPENCSGDIR env. variable - OPENCSG_DIR = $$(OPENCSGDIR) - !isEmpty(OPENCSG_DIR) { - QMAKE_INCDIR += $$OPENCSG_DIR/include - QMAKE_LIBDIR += $$OPENCSG_DIR/lib - message("OpenCSG location: $$OPENCSG_DIR") - } + # Optionally specify location of OpenCSG using the + # OPENCSGDIR env. variable + OPENCSG_DIR = $$(OPENCSGDIR) + !isEmpty(OPENCSG_DIR) { + QMAKE_INCDIR += $$OPENCSG_DIR/include + QMAKE_LIBDIR += $$OPENCSG_DIR/lib + message("OpenCSG location: $$OPENCSG_DIR") } LIBS += -lopencsg diff --git a/openscad.pro b/openscad.pro index 026db5b..ac4200e 100644 --- a/openscad.pro +++ b/openscad.pro @@ -33,12 +33,7 @@ win32 { debug: DEFINES += DEBUG TEMPLATE = app -RESOURCES = openscad.qrc -OBJECTS_DIR = objects -MOC_DIR = objects -UI_DIR = objects -RCC_DIR = objects INCLUDEPATH += src # Handle custom library location. @@ -48,6 +43,13 @@ OPENSCAD_LIBDIR = $$(OPENSCAD_LIBRARIES) QMAKE_INCDIR += $$OPENSCAD_LIBDIR/include QMAKE_LIBDIR += $$OPENSCAD_LIBDIR/lib } +else { + macx { + # Default to MacPorts on Mac OS X + QMAKE_INCDIR = /opt/local/include + QMAKE_LIBDIR = /opt/local/lib + } +} macx { # add CONFIG+=deploy to the qmake command-line to make a deployment build @@ -108,6 +110,8 @@ win32 { YACCSOURCES += src/parser.y } +RESOURCES = openscad.qrc + FORMS += src/MainWindow.ui \ src/Preferences.ui \ src/OpenCSGWarningDialog.ui @@ -213,6 +217,11 @@ SOURCES += src/openscad.cc \ src/PolySetCache.cc \ src/PolySetEvaluator.cc +opencsg { + HEADERS += src/OpenCSGRenderer.h + SOURCES += src/OpenCSGRenderer.cc +} + cgal { HEADERS += src/cgal.h \ src/cgalfwd.h \ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d79925a..edd89aa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -64,8 +64,8 @@ endif() # # Boost -if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") - set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") +if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") + set(BOOST_ROOT "$ENV{OPENSCAD_LIBRARIES}") endif() if (NOT $ENV{BOOSTDIR} STREQUAL "") @@ -151,8 +151,8 @@ include_directories(${EIGEN2_INCLUDE_DIR}) # OpenCSG if (NOT $ENV{OPENCSGDIR} STREQUAL "") set(OPENCSG_DIR "$ENV{OPENCSGDIR}") -elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") - set(OPENCSG_DIR "$ENV{MACOSX_DEPLOY_DIR}") +elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") + set(OPENCSG_DIR "$ENV{OPENSCAD_LIBRARIES}") endif() if (NOT OPENCSG_INCLUDE_DIR) message(STATUS "OPENCSG_DIR: " ${OPENCSG_DIR}) @@ -175,8 +175,8 @@ include_directories(${OPENCSG_INCLUDE_DIR}) if (NOT $ENV{GLEWDIR} STREQUAL "") set(GLEW_DIR "$ENV{GLEWDIR}") -elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") - set(GLEW_DIR "$ENV{MACOSX_DEPLOY_DIR}") +elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") + set(GLEW_DIR "$ENV{OPENSCAD_LIBRARIES}") endif() find_package(GLEW REQUIRED) @@ -208,8 +208,8 @@ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/parser_yacc.c PROPERTIES if (NOT $ENV{CGALDIR} STREQUAL "") set(CGAL_DIR "$ENV{CGALDIR}") -elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") - set(CGAL_DIR "$ENV{MACOSX_DEPLOY_DIR}/lib/CGAL") +elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "") + set(CGAL_DIR "$ENV{OPENSCAD_LIBRARIES}/lib/CGAL") set(CMAKE_MODULE_PATH "${CGAL_DIR}") endif() message(STATUS "CGAL_DIR: " ${CGAL_DIR}) -- cgit v0.10.1 From b8be38ce8b2a146e48cbadaddef3cba4475c03e4 Mon Sep 17 00:00:00 2001 From: don Date: Fri, 16 Dec 2011 21:51:42 -0600 Subject: improve OPENSCAD_LIBRARIES for freebsd diff --git a/openscad.pro b/openscad.pro index ac4200e..60870be 100644 --- a/openscad.pro +++ b/openscad.pro @@ -40,8 +40,8 @@ INCLUDEPATH += src # Used when manually installing 3rd party libraries OPENSCAD_LIBDIR = $$(OPENSCAD_LIBRARIES) !isEmpty(OPENSCAD_LIBDIR) { - QMAKE_INCDIR += $$OPENSCAD_LIBDIR/include - QMAKE_LIBDIR += $$OPENSCAD_LIBDIR/lib + INCLUDEPATH = $$OPENSCAD_LIBDIR/include $$INCLUDEPATH + QMAKE_LIBDIR = $$OPENSCAD_LIBDIR/lib $$QMAKE_LIBDIR } else { macx { -- cgit v0.10.1 From b6a01a76b98377983a562b36a757483a01d3cfa2 Mon Sep 17 00:00:00 2001 From: don bright Date: Fri, 16 Dec 2011 17:33:31 -0800 Subject: fix compilation on Fedora: boost, flex, and OPENSCAD_LIBRARIES diff --git a/boost.pri b/boost.pri index 46cbb83..168e64c 100644 --- a/boost.pri +++ b/boost.pri @@ -9,18 +9,34 @@ boost { win32:QMAKE_LIBDIR += -L$$BOOST_DIR/lib } + ORIGINAL_LIBS_VALUE = $$LIBS + + win32 { + LIBS += -llibboost_thread-vc90-mt-s-1_46_1 -llibboost_program_options-vc90-mt-s-1_46_1 + } + + exists(/usr/lib64/libboost*thread-mt*) { + LIBS += -lboost_thread-mt -lboost_program_options-mt + BOOST_IS_MT = true + } + + exists(/usr/lib/libboost*thread-mt*) { + LIBS *= -lboost_thread-mt -lboost_program_options-mt + BOOST_IS_MT = true + } + + isEmpty(BOOST_IS_MT) { + unix|macx { + LIBS += -lboost_thread -lboost_program_options + } + } + CONFIG(mingw-cross-env) { + LIBS = $$ORIGINAL_LIBS_VALUE # erase, start over DEFINES += BOOST_STATIC DEFINES += BOOST_THREAD_USE_LIB DEFINES += Boost_USE_STATIC_LIBS LIBS += -lboost_thread_win32-mt -lboost_program_options-mt - } else { - win32 { - LIBS += -llibboost_thread-vc90-mt-s-1_46_1 -llibboost_program_options-vc90-mt-s-1_46_1 - } else { - # some platforms have only '-mt' versions. uncomment if needed. - # LIBS += -lboost_thread-mt -lboost_program_options-mt - LIBS += -lboost_thread -lboost_program_options - } - } + } + } diff --git a/flex.pri b/flex.pri index ef0b742..ce78b98 100644 --- a/flex.pri +++ b/flex.pri @@ -10,6 +10,16 @@ win32 { } unix:freebsd-g++ { + # on bsd /usr/bin/bison is outdated, dont use it QMAKE_LEX = /usr/local/bin/flex QMAKE_YACC = /usr/local/bin/bison } + +unix:linux* { + exists(/usr/bin/flex) { + QMAKE_LEX = /usr/bin/flex + } + exists(/usr/bin/bison) { + QMAKE_YACC = /usr/bin/bison + } +} diff --git a/openscad.pro b/openscad.pro index 60870be..80687f0 100644 --- a/openscad.pro +++ b/openscad.pro @@ -40,8 +40,8 @@ INCLUDEPATH += src # Used when manually installing 3rd party libraries OPENSCAD_LIBDIR = $$(OPENSCAD_LIBRARIES) !isEmpty(OPENSCAD_LIBDIR) { - INCLUDEPATH = $$OPENSCAD_LIBDIR/include $$INCLUDEPATH - QMAKE_LIBDIR = $$OPENSCAD_LIBDIR/lib $$QMAKE_LIBDIR + QMAKE_INCDIR_QT = $$OPENSCAD_LIBDIR/include $$QMAKE_INCDIR_QT + QMAKE_LIBDIR_QT = $$OPENSCAD_LIBDIR/lib $$QMAKE_LIBDIR_QT } else { macx { @@ -77,6 +77,10 @@ win32 { CONFIG += qt QT += opengl +linux*:exists(/usr/lib64/libGLU*)|linux*:exists(/usr/lib/libGLU*) { + LIBS += -lGLU # Fedora + DSO +} + # Application configuration macx:CONFIG += mdi CONFIG += cgal -- cgit v0.10.1 From a7ebe941998768fe1015fc1b6d528690bdf19701 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 16 Dec 2011 21:03:10 -0600 Subject: fix qmake under mingw-cross-compile diff --git a/openscad.pro b/openscad.pro index 160eaa1..e38251a 100644 --- a/openscad.pro +++ b/openscad.pro @@ -77,8 +77,13 @@ win32 { CONFIG += qt QT += opengl +# Fedora Linux + DSO fix linux*:exists(/usr/lib64/libGLU*)|linux*:exists(/usr/lib/libGLU*) { - LIBS += -lGLU # Fedora + DSO + LIBS += -lGLU +} + +CONFIG(mingw-cross-env) { + include(mingw-cross-env.pri) } # Application configuration diff --git a/win32.pri b/win32.pri index 7a020d7..bb41b09 100644 --- a/win32.pri +++ b/win32.pri @@ -1,6 +1,6 @@ -# win32-specific general settings +# win32-specific MSVC compiler general settings -win32 { +win32*msvc* { #configure additional directories INCLUDEPATH += $$(MPIRDIR) INCLUDEPATH += $$(MPFRDIR) @@ -17,4 +17,4 @@ win32 { # lexer uses strdup() & other POSIX stuff QMAKE_CXXFLAGS += -D_CRT_NONSTDC_NO_DEPRECATE -} \ No newline at end of file +} -- cgit v0.10.1 From 609e59d4ccd73ec8e9d6c3e691352623d58d8cba Mon Sep 17 00:00:00 2001 From: don Date: Sat, 17 Dec 2011 01:56:24 -0600 Subject: fix OPENSCAD_LIBRARIES on FreeBSD diff --git a/openscad.pro b/openscad.pro index 80687f0..160eaa1 100644 --- a/openscad.pro +++ b/openscad.pro @@ -41,7 +41,7 @@ INCLUDEPATH += src OPENSCAD_LIBDIR = $$(OPENSCAD_LIBRARIES) !isEmpty(OPENSCAD_LIBDIR) { QMAKE_INCDIR_QT = $$OPENSCAD_LIBDIR/include $$QMAKE_INCDIR_QT - QMAKE_LIBDIR_QT = $$OPENSCAD_LIBDIR/lib $$QMAKE_LIBDIR_QT + QMAKE_LIBDIR = $$OPENSCAD_LIBDIR/lib $$QMAKE_LIBDIR } else { macx { -- cgit v0.10.1 From 6bccf5be43af0947103cdd6ebac5a30615f55c84 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 16 Dec 2011 21:51:07 -0600 Subject: make EIGEN2DIR prepend to -I not append. make boost MT detection use BOOSTDIR diff --git a/boost.pri b/boost.pri index 168e64c..42fe529 100644 --- a/boost.pri +++ b/boost.pri @@ -9,34 +9,32 @@ boost { win32:QMAKE_LIBDIR += -L$$BOOST_DIR/lib } - ORIGINAL_LIBS_VALUE = $$LIBS - - win32 { + win32:!CONFIG(mingw-cross-env) { LIBS += -llibboost_thread-vc90-mt-s-1_46_1 -llibboost_program_options-vc90-mt-s-1_46_1 - } - - exists(/usr/lib64/libboost*thread-mt*) { - LIBS += -lboost_thread-mt -lboost_program_options-mt - BOOST_IS_MT = true - } - - exists(/usr/lib/libboost*thread-mt*) { - LIBS *= -lboost_thread-mt -lboost_program_options-mt - BOOST_IS_MT = true } - isEmpty(BOOST_IS_MT) { - unix|macx { - LIBS += -lboost_thread -lboost_program_options - } - } - CONFIG(mingw-cross-env) { - LIBS = $$ORIGINAL_LIBS_VALUE # erase, start over DEFINES += BOOST_STATIC DEFINES += BOOST_THREAD_USE_LIB DEFINES += Boost_USE_STATIC_LIBS LIBS += -lboost_thread_win32-mt -lboost_program_options-mt } + unix* { + BMT_TEST1 = /usr/lib64/libboost*thread-mt* + BMT_TEST2 = /usr/lib/libboost*thread-mt* + BMT_TEST3 = $$BOOST_DIR/lib/libboost*thread-mt* + + exists($$BMT_TEST1)|exists($$BMT_TEST2)|exists($$BMT_TEST3) { + LIBS += -lboost_thread-mt -lboost_program_options-mt + BOOST_IS_MT = true + } + } + + unix*|macx { + isEmpty(BOOST_IS_MT) { + LIBS += -lboost_thread -lboost_program_options + } + } + } diff --git a/eigen2.pri b/eigen2.pri index 8b955e3..3d7017b 100644 --- a/eigen2.pri +++ b/eigen2.pri @@ -3,19 +3,22 @@ eigen2 { # EIGEN2DIR env. variable EIGEN2_DIR = $$(EIGEN2DIR) !isEmpty(EIGEN2_DIR) { - INCLUDEPATH += $$EIGEN2_DIR + EIGEN2_INCLUDEPATH = $$EIGEN2_DIR } else { CONFIG(mingw-cross-env) { - INCLUDEPATH += mingw-cross-env/include/eigen2 + EIGEN2_INCLUDEPATH = mingw-cross-env/include/eigen2 } else { - freebsd-g++: INCLUDEPATH += /usr/local/include/eigen2 - macx: INCLUDEPATH += /opt/local/include/eigen2 - !macx:!freebsd-g++:INCLUDEPATH += /usr/include/eigen2 + freebsd-g++: EIGEN2_INCLUDEPATH *= /usr/local/include/eigen2 + macx: EIGEN2_INCLUDEPATH *= /opt/local/include/eigen2 + !macx:!freebsd-g++:EIGEN2_INCLUDEPATH *= /usr/include/eigen2 } } - # disable Eigen SIMD optimizations for non-Mac OSX + # eigen2 being under 'include/eigen2' needs special prepending + QMAKE_INCDIR_QT = $$EIGEN2_INCLUDEPATH $$QMAKE_INCDIR_QT + + # disable Eigen SIMD optimizations for platforms where it breaks compilation !macx { !freebsd-g++ { QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN -- cgit v0.10.1 From fd0e4297152a1ce07d7582720d0acf95d0a3defa Mon Sep 17 00:00:00 2001 From: Don Bright Date: Fri, 16 Dec 2011 22:36:54 -0600 Subject: fix bug boost.pri (unix* -> unix) diff --git a/boost.pri b/boost.pri index 42fe529..25d47e7 100644 --- a/boost.pri +++ b/boost.pri @@ -31,7 +31,7 @@ boost { } } - unix*|macx { + unix|macx { isEmpty(BOOST_IS_MT) { LIBS += -lboost_thread -lboost_program_options } -- cgit v0.10.1 From 9573fabdb8d1acc18ae6530b78c120070ae59e0e Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 17 Dec 2011 04:52:13 -0600 Subject: remove /usr/include from win32-MSVC eigen path diff --git a/eigen2.pri b/eigen2.pri index 3d7017b..44649f8 100644 --- a/eigen2.pri +++ b/eigen2.pri @@ -11,7 +11,7 @@ eigen2 { } else { freebsd-g++: EIGEN2_INCLUDEPATH *= /usr/local/include/eigen2 macx: EIGEN2_INCLUDEPATH *= /opt/local/include/eigen2 - !macx:!freebsd-g++:EIGEN2_INCLUDEPATH *= /usr/include/eigen2 + !macx:!freebsd-g++:!win32:EIGEN2_INCLUDEPATH *= /usr/include/eigen2 } } -- cgit v0.10.1 From 6bba101f694afa3c4d97f3507b8b805e3c552590 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 17 Dec 2011 05:06:34 -0600 Subject: mt bug fix diff --git a/boost.pri b/boost.pri index 25d47e7..c2f5d8e 100644 --- a/boost.pri +++ b/boost.pri @@ -20,7 +20,7 @@ boost { LIBS += -lboost_thread_win32-mt -lboost_program_options-mt } - unix* { + unix { BMT_TEST1 = /usr/lib64/libboost*thread-mt* BMT_TEST2 = /usr/lib/libboost*thread-mt* BMT_TEST3 = $$BOOST_DIR/lib/libboost*thread-mt* -- cgit v0.10.1 From de282d1ae85f835fa582c9117b83824cdb1a9144 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 17 Dec 2011 14:47:11 +0100 Subject: Compile tests with -O2 -g as default diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index edd89aa..986076e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,7 +12,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") # Build debug build as default if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Debug) + set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") -- cgit v0.10.1 From 320fe7d54d067a40b737f78f973aa682abda73f5 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 17 Dec 2011 17:58:32 +0100 Subject: Killed warning diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index ea46275..990d3a4 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -32,7 +32,7 @@ std::string offscreen_context_getinfo(OffscreenContext *ctx) Gestalt(gestaltSystemVersionMinor, &minorVersion); Gestalt(gestaltSystemVersionBugFix, &bugFixVersion); - char *arch = "unknown"; + const char *arch = "unknown"; if (sizeof(int*) == 4) arch = "32-bit"; else if (sizeof(int*) == 8) arch = "64-bit"; -- cgit v0.10.1 From 02457d7b6d52378bbd6be9b15461b55a2433e803 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 17 Dec 2011 18:04:09 +0100 Subject: bison fix diff --git a/bison.pri b/bison.pri index b1f3292..7d3bed0 100644 --- a/bison.pri +++ b/bison.pri @@ -1,17 +1,29 @@ -#setup bison for qmake -bison.name = Bison ${QMAKE_FILE_IN} -bison.input = BISONSOURCES -bison.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp -bison.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} -bison.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h -bison.CONFIG += target_predeps -bison.variable_out = GENERATED_SOURCES -silent:bison.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands -QMAKE_EXTRA_COMPILERS += bison -bison_header.input = BISONSOURCES -bison_header.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h -bison_header.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} -bison_header.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h -bison_header.CONFIG += target_predeps no_link -silent:bison_header.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands -QMAKE_EXTRA_COMPILERS += bison_header +win32 { + bison.name = Bison ${QMAKE_FILE_IN} + bison.input = BISONSOURCES + bison.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp + bison.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} + bison.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h + bison.CONFIG += target_predeps + bison.variable_out = GENERATED_SOURCES + silent:bison.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands + QMAKE_EXTRA_COMPILERS += bison + bison_header.input = BISONSOURCES + bison_header.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h + bison_header.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN} + bison_header.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h + bison_header.CONFIG += target_predeps no_link + silent:bison_header.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands + QMAKE_EXTRA_COMPILERS += bison_header +} + +unix:freebsd-g++ { + # on bsd /usr/bin/bison is outdated, dont use it + QMAKE_YACC = /usr/local/bin/bison +} + +unix:linux* { + exists(/usr/bin/bison) { + QMAKE_YACC = /usr/bin/bison + } +} diff --git a/flex.pri b/flex.pri index ce78b98..2e1559e 100644 --- a/flex.pri +++ b/flex.pri @@ -10,16 +10,11 @@ win32 { } unix:freebsd-g++ { - # on bsd /usr/bin/bison is outdated, dont use it QMAKE_LEX = /usr/local/bin/flex - QMAKE_YACC = /usr/local/bin/bison } unix:linux* { exists(/usr/bin/flex) { QMAKE_LEX = /usr/bin/flex } - exists(/usr/bin/bison) { - QMAKE_YACC = /usr/bin/bison - } } -- cgit v0.10.1 From ef29553226ddb3f8f0565dbd6004d76e26c80ddc Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 17 Dec 2011 18:42:45 +0100 Subject: Minor release preparations diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 21adc18..ac89511 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,24 +1,24 @@ -OpenSCAD 20xx.yy +OpenSCAD 2011.12 ================ Features: o The MCAD library is now bundled with OpenSCAD +o Added len() function. Takes one vector or string parameter and returns its length. +o The index operator [] now works on strings +o The version() function will return the OpenSCAD version as a vector, e.g. [2011, 09] +o The version_num() function will return the OpenSCAD version as a number, e.g. 20110923 o hull() Now supports 3D objects o hull() with 2D object can now use for loops and boolean operations as children -o Added import and export of the OFF file format o New import() statement reads the correct file format based on the filename extension (.stl, .dxf and .off is supported) o The color() statement now supports an alpha parameter, e.g. color(c=[1,0,0], alpha=0.4) o The color() statement now supports specifying colors as strings, e.g. color("Red") o if()/else() and the ternary operator can now take any value type as parameter. false, 0, empty string and empty vector or illegal value type will evaluate as false, everything else as true. o Strings can now be lexographically compared using the <, <=, >, >= operators -o The version() function will return the OpenSCAD version as a vector, e.g. [2011, 09] -o The version_num() function will return the OpenSCAD version as a number, e.g. 20110923 o Added PI constant. -o Now uses standard shortcuts for save, reload and quit on Linux and Windows. F2/F3 will still work but is deprecated. o Number literals in scientific notation are now accepted by the parser -o Added len() function. Takes one vector or string parameter and returns its length. -o The index operator [] now works on strings +o Added import and export of the OFF file format +o Now uses standard shortcuts for save, reload and quit on Linux and Windows. F2/F3 will still work but is deprecated. Bugfixes: o square() crashed if any of the dimensions were zero diff --git a/doc/release-checklist.txt b/doc/release-checklist.txt index a455ca9..2ff9593 100644 --- a/doc/release-checklist.txt +++ b/doc/release-checklist.txt @@ -9,24 +9,24 @@ o Update version o Update RELEASE_NOTES o Tag release - git tag "openscad-2011.01" + git tag "openscad-2011.12" o build source package - git archive --format=tar openscad-2011.01 --prefix=openscad-2011.01/ | gzip > openscad-2011.01.src.tar.gz + git archive --format=tar openscad-2011.12 --prefix=openscad-2011.12/ | gzip > openscad-2011.12.src.tar.gz o build binaries - tar xzf openscad-2011.01.src.tar.gz - cd openscad-2011.01 + tar xzf openscad-2011.12.src.tar.gz + cd openscad-2011.12 Mac OS X - For Qt-4.7.3: Remove /Developers/Applications/Qt/plugins/qmltooling - ./scripts/publish-macosx.sh -> OpenSCAD-2011.01.dmg + (For Qt-4.7.3: Remove /Developers/Applications/Qt/plugins/qmltooling) + ./scripts/publish-macosx.sh -> OpenSCAD-2011.12.dmg Linux: FIXME 32 vs. 64 bit ./scripts/release-linux.sh Windows: FIXME 32 vs. 64 bit o FIXME: Run some tests -o Set back version: release-linux.sh, publish-macosx.sh, FIXME: Windows +o Set back version to being date-tagged: release-linux.sh, publish-macosx.sh, FIXME: Windows o git push --tags @@ -37,3 +37,7 @@ o Upload o Update web page o Write email to mailing list +o Update external resources: + - http://en.wikipedia.org/wiki/OpenSCAD +o Notify package managers + - Ubuntu: https://launchpad.net/~chrysn diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index e559cb8..a2451fa 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -1,7 +1,7 @@ #!/bin/sh VERSION=`date "+%Y.%m.%d"` -#VERSION=2011.06 +#VERSION=2011.12 # Turn off ccache, just for safety PATH=${PATH//\/opt\/local\/libexec\/ccache:} diff --git a/scripts/release-linux.sh b/scripts/release-linux.sh index 7675c07..e1eb001 100755 --- a/scripts/release-linux.sh +++ b/scripts/release-linux.sh @@ -2,7 +2,7 @@ # WARNING: This script might only work with the authors setup... VERSION=`date "+%Y.%m.%d"` -#VERSION=2011.06 +#VERSION=2011.12 set -ex -- cgit v0.10.1 From bb62bf4ad90184190ca9d666ec6f2457955a2ef9 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sat, 17 Dec 2011 15:39:07 -0600 Subject: fix pretty print bug that was printing error message during ctest diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 3ea0e36..a58c1fd 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -290,7 +290,8 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) } QFileInfo fileInfo(filename); - QDir::setCurrent(fileInfo.absolutePath()); + if (!sysinfo_dump) + QDir::setCurrent(fileInfo.absolutePath()); AbstractNode::resetIndexCounter(); AbstractNode *absolute_root_node = root_module->evaluate(&root_ctx, &root_inst); -- cgit v0.10.1 From d900ae9a843a5191666c3e3fc34639087bf7aa09 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 18 Dec 2011 11:37:37 -0600 Subject: fix bug in test_pretty_print, dont try to upload 0 byte files diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6fdc663..53fcc37 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -432,8 +432,10 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= filename = os.path.join(wikidir,wikiname) filedata = tryread(filename) print 'upload',len(filedata),'bytes from',wikiname - if wetrun: + if wetrun and len(filedata)>0: wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikiname) + if len(filedata)==0: + print 'cancelling empty upload' def findlogfile(builddir): logpath = os.path.join(builddir,'Testing','Temporary') -- cgit v0.10.1 From 638743e2201c6869b48857dd2db5ec01df665162 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 18 Dec 2011 21:50:02 -0600 Subject: remove unneeded debugging cout<< from cgalpngtest diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc index 608fb08..800a829 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -172,19 +172,16 @@ int main(int argc, char **argv) BoundingBox bbox; if (cgalRenderer.polyhedron) { - std::cout << "polyhedron\n" ; CGAL::Bbox_3 cgalbbox = cgalRenderer.polyhedron->bbox(); bbox = BoundingBox(Vector3d(cgalbbox.xmin(), cgalbbox.ymin(), cgalbbox.zmin()), Vector3d(cgalbbox.xmax(), cgalbbox.ymax(), cgalbbox.zmax())); } else if (cgalRenderer.polyset) { - std::cout << "polyset\n" ; bbox = cgalRenderer.polyset->getBoundingBox(); } Vector3d center = getBoundingCenter(bbox); double radius = getBoundingRadius(bbox); - std::cout << "radius: " << radius << "\n"; Vector3d cameradir(1, 1, -0.5); Vector3d camerapos = center - radius*2*cameradir; -- cgit v0.10.1