From af1f3c9b499b5e46a319b5c9f7cacdd2dadb6d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nick=20=C3=98stergaard?= Date: Sun, 12 Jul 2015 20:06:50 -0400 Subject: [PATCH 1/6] Add git build version header support. * Add CreateGitVersionHeader.cmake to extract git version information to create the kicad version header. * Add check for .git folder in source path to trigger git version CMake macro. --- CMakeModules/CreateGitVersionHeader.cmake | 105 ++++++++++++++++++++++ CMakeModules/WriteVersionHeader.cmake | 12 ++- 2 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 CMakeModules/CreateGitVersionHeader.cmake diff --git a/CMakeModules/CreateGitVersionHeader.cmake b/CMakeModules/CreateGitVersionHeader.cmake new file mode 100644 index 0000000000..42cf4b4726 --- /dev/null +++ b/CMakeModules/CreateGitVersionHeader.cmake @@ -0,0 +1,105 @@ +# +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2010 Wayne Stambaugh +# Copyright (C) 2010-2015 Kicad Developers, see AUTHORS.txt for contributors. +# +# 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, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +macro( create_git_version_header _git_src_path ) + # If bzr is not found or an error occurs using the git commands to determine the repo + # version, set the build version string to "no-git" + set( KICAD_BUILD_VERSION "no-git" ) + + # Include Git support to automagically create version header file. + find_package( Git ) + + if( GIT_FOUND ) + set( _Git_SAVED_LC_ALL "$ENV{LC_ALL}" ) + set( ENV{LC_ALL} C ) + + # Get latest commit hash + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%H + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_LONG_HASH + ERROR_VARIABLE _git_log_error + RESULT_VARIABLE _git_log_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if( ${_git_log_result} EQUAL 0 ) + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%h + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_SHORT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%cn + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_LAST_COMITTER + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%cd --date=short + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_LAST_CHANGE_LOG + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND + ${GIT_EXECUTABLE} rev-list HEAD --count + --first-parent + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_SERIAL + OUTPUT_STRIP_TRAILING_WHITESPACE) + + message(STATUS "Git hash: ${_git_LONG_HASH}") + + if( ${_git_log_result} EQUAL 0 ) + string( REGEX REPLACE "^(.*\n)?revno: ([^ \n]+).*" + "\\2" Kicad_REPO_REVISION "BZR ${_git_SERIAL}, Git ${_git_SHORT_HASH}" ) + string( REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*" + "\\2" Kicad_REPO_LAST_CHANGED_AUTHOR "${_git_LAST_COMITTER}") + string( REGEX REPLACE "^(.*\n)?timestamp: [a-zA-Z]+ ([^ \n]+).*" + "\\2" Kicad_REPO_LAST_CHANGED_DATE "${_git_LAST_CHANGE_LOG}") + endif() + endif() + + set( ENV{LC_ALL} ${_Git_SAVED_LC_ALL} ) + endif( GIT_FOUND ) + + # Check to make sure 'git' command did not fail. Otherwise fallback + # to "no-git" as the revision. + if( Kicad_REPO_LAST_CHANGED_DATE ) + string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3" + _kicad_git_date ${Kicad_REPO_LAST_CHANGED_DATE} ) + set( KICAD_BUILD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" ) + endif() + + set( KICAD_BUILD_VERSION ${KICAD_BUILD_VERSION} ) +endmacro() diff --git a/CMakeModules/WriteVersionHeader.cmake b/CMakeModules/WriteVersionHeader.cmake index 9637546309..c08c61ed3e 100644 --- a/CMakeModules/WriteVersionHeader.cmake +++ b/CMakeModules/WriteVersionHeader.cmake @@ -23,17 +23,23 @@ # # Automagically create version header file if the version string was not defined during -# the build configuration. If CreateBzrVersionHeader cannot determine the current repo, -# version, a version.h file is still created with KICAD_BUILD_VERSION set to "no-bzr". +# the build configuration. If CreateBzrVersionHeader or CreateGitVersionHeader cannot +# determine the current repo version, a version.h file is still created with +# KICAD_BUILD_VERSION set to "no-vcs-found". if( NOT KICAD_BUILD_VERSION ) set( _wvh_version_str "no-vcs-found" ) - # If the code is managed by Bazaar, used bzr to determine the version string. + # Detect the appropiate VCS and set the version string. if( EXISTS "${SRC_PATH}/.bzr" ) message( STATUS "Using Bazaar to determine build version string." ) include( ${CMAKE_MODULE_PATH}/CreateBzrVersionHeader.cmake ) create_bzr_version_header( ${SRC_PATH} ) set( _wvh_version_str ${KICAD_BUILD_VERSION} ) + elseif( EXISTS "${SRC_PATH}/.git" ) + message( STATUS "Using Git to determine build version string." ) + include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake ) + create_git_version_header( ${SRC_PATH} ) + set( _wvh_version_str ${KICAD_BUILD_VERSION} ) endif() else() set( _wvh_version_str ${KICAD_BUILD_VERSION} ) From 1c9115ee9177b406ed82c8c4e4077cd4ee840416 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 13 Jul 2015 10:46:05 +0200 Subject: [PATCH 2/6] opengl_gal: fix a strange but already encountered issue on Ubuntu/Unity when switching to GAL: the dialog which test the opengl version was never raised, and the Pcb editor frame partially no more responding to menu events. Also fix a bug: this test dialog was never destroyed. --- common/gal/opengl/opengl_gal.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 73b164a868..46681454a2 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -959,11 +959,11 @@ unsigned int OPENGL_GAL::getNewGroupNumber() bool OPENGL_GAL::runTest() { - wxDialog* dialog = new wxDialog( GetParent(), -1, wxT( "opengl test" ), - wxPoint( 50, 50 ), wxSize( 50, 50 ) ); - OPENGL_TEST* test = new OPENGL_TEST( dialog, this ); + wxDialog dlgtest( GetParent(), -1, wxT( "opengl test" ), wxPoint( 50, 50 ), wxSize( 50, 50 ) ); + OPENGL_TEST* test = new OPENGL_TEST( &dlgtest, this ); - dialog->ShowModal(); + dlgtest.Raise(); // on Linux, on some windows managers (Unity for instance) this is needed to actually show the dialog + dlgtest.ShowModal(); bool result = test->IsOk(); if( !result ) From a3a0db9be9e6a1c6514c7bc8672ad96ed6146ffd Mon Sep 17 00:00:00 2001 From: Andrew Zonenberg Date: Sat, 11 Jul 2015 15:31:01 -0700 Subject: [PATCH 3/6] Fixed bug where GAL module editor does not release mouse capture after exiting text tool --- pcbnew/tools/drawing_tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 719e386984..b46e06eca7 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1350,7 +1350,7 @@ int DRAWING_TOOL::placeTextModule() m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); - m_controls->CaptureCursor( true ); + m_controls->CaptureCursor( false ); m_view->Remove( &preview ); m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); From 1ea566b59d30a894cf49ec0718ae07e685a36328 Mon Sep 17 00:00:00 2001 From: Andrew Zonenberg Date: Sat, 11 Jul 2015 16:03:07 -0700 Subject: [PATCH 4/6] Fixed bug where GAL text tool was overzealously capturing the cursor when not necessary --- pcbnew/tools/drawing_tool.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index b46e06eca7..3681044686 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1251,8 +1251,7 @@ int DRAWING_TOOL::placeTextModule() m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); - m_controls->SetAutoPan( true ); - m_controls->CaptureCursor( true ); + // do not capture or auto-pan until we start placing some text Activate(); m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); @@ -1267,6 +1266,8 @@ int DRAWING_TOOL::placeTextModule() { preview.Clear(); preview.ViewUpdate(); + m_controls->SetAutoPan( false ); + m_controls->CaptureCursor( false ); m_controls->ShowCursor( true ); if( !placing || evt->IsActivate() ) @@ -1307,7 +1308,9 @@ int DRAWING_TOOL::placeTextModule() if( !placing ) continue; - + + m_controls->CaptureCursor( true ); + m_controls->SetAutoPan( true ); m_controls->ShowCursor( false ); text->SetParent( m_board->m_Modules ); // it has to set after the settings dialog // otherwise the dialog stores it in undo buffer @@ -1331,6 +1334,8 @@ int DRAWING_TOOL::placeTextModule() m_frame->OnModify(); preview.Remove( text ); + m_controls->CaptureCursor( false ); + m_controls->SetAutoPan( false ); m_controls->ShowCursor( true ); text = new TEXTE_MODULE( NULL ); @@ -1370,8 +1375,7 @@ int DRAWING_TOOL::placeTextPcb() m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); - m_controls->SetAutoPan( true ); - m_controls->CaptureCursor( true ); + // do not capture or auto-pan until we start placing some text Activate(); m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); @@ -1391,6 +1395,8 @@ int DRAWING_TOOL::placeTextPcb() preview.Clear(); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + m_controls->SetAutoPan( false ); + m_controls->CaptureCursor( false ); m_controls->ShowCursor( true ); } else @@ -1424,6 +1430,8 @@ int DRAWING_TOOL::placeTextPcb() if( text == NULL ) continue; + m_controls->CaptureCursor( true ); + m_controls->SetAutoPan( true ); m_controls->ShowCursor( false ); preview.Add( text ); } @@ -1441,6 +1449,8 @@ int DRAWING_TOOL::placeTextPcb() m_frame->SaveCopyInUndoList( text, UR_NEW ); preview.Remove( text ); + m_controls->CaptureCursor( false ); + m_controls->SetAutoPan( false ); m_controls->ShowCursor( true ); text = NULL; From 6775cf392ad3ec824ab11e17186eaa219512f97c Mon Sep 17 00:00:00 2001 From: Andrew Zonenberg Date: Sat, 11 Jul 2015 16:50:31 -0700 Subject: [PATCH 5/6] Removed leading space --- pcbnew/tools/drawing_tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 3681044686..769e1c689f 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1308,7 +1308,7 @@ int DRAWING_TOOL::placeTextModule() if( !placing ) continue; - + m_controls->CaptureCursor( true ); m_controls->SetAutoPan( true ); m_controls->ShowCursor( false ); From 561a962977cb5d0c87ea13e861fd9e2e4fd6c148 Mon Sep 17 00:00:00 2001 From: Andrew Zonenberg Date: Sat, 11 Jul 2015 17:03:50 -0700 Subject: [PATCH 6/6] Fixed bug where "add text" tool in module editor did not update the toolbar radio buttons correctly --- pcbnew/tools/drawing_tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 769e1c689f..4dbc4e8fda 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1254,7 +1254,7 @@ int DRAWING_TOOL::placeTextModule() // do not capture or auto-pan until we start placing some text Activate(); - m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); + m_frame->SetToolID( ID_MODEDIT_TEXT_TOOL, wxCURSOR_PENCIL, _( "Add text" ) ); bool placing = false; // Main loop: keep receiving events