Hi there...
I don't think this has been done before (if yes then sorry for redundancy). Here is my modified update.bat script I've been using on Windows to update my codeblocks environment to the latest SVN source. This should work OOTB if you have already compiled the svn sources before (built wxwidgets and so on...) and have working command-line svn client and zip in your PATH. The script can be run from everywhere.
It is based on the original update.bat script used during the build process on the windows platform. The script will :
- Update your svn repository
- Build codeblocks base and plugins
- Pack, copy and strip the files (like before)
- Replace your previous working environment
Feel to comment, improve,...
With regards,
Billy
Updates:
16.03.10
- Added: Check if codeblocks is present before doing anything
- Bugfix: make sure all paths are given "abolute"
- Bugfix: type in copying exchndl.dll in the devel folder
- Optimization: Avoid copying zip files if haven't changed
13.03.10
- Code cleanup
- Feature:Option to set up codeblocks in a 2nd folder (e.g. network install)
- Feature:Option to create an archive of the installation folder
23.01.10
- Updated to match rev. 6104
- Corrected bug where core UI resources not being packed correctly led to codeblocks not closing correctly
03.12.09
30.09.09:
- Fixed:svn cleanup fails if script is run outside the repository
26.09.09:
- Builds only if svn rev. changed
- Abort on SVN or build error
- Ask whether to Run "svn cleanup" and retry checkout if 1st attempt failed
24.09.09:
::------------------------
:: Parameters are set here
::------------------------
@echo off
title Codeblocks SVN update
REM SETLOCAL assures environment variables created in a batch file are not exported to its calling environment
setlocal
:: you might want to modify those two variables
set CB_DEVEL_DIR="D:\devel\codeblocks_32_c++"
set CB_OUTPUT_DIR=C:\codeblocks32
set SEVENZCMD="C:\Program Files\7-zip\7z.exe"
set ZIPCMD=zip
:: this shouldn't change normally
set CB_DEVEL_RESDIR=%CB_DEVEL_DIR%\src\devel\share\CodeBlocks
set CB_OUTPUT_RESDIR=%CB_OUTPUT_DIR%\share\CodeBlocks
:: additional stuff
set setup_additonal_target=Y
set ASL_DIR="P:\My documents\Programs\Codeblocks"
set ASL_RESDIR=%ASL_DIR%\share\CodeBlocks
set make_7z_archive=Y
::-------------------
echo Environment checking
::-------------------
if not exist %CB_OUTPUT_DIR%\codeblocks.exe (
echo error: You need a working codeblocks to use this script
goto env_error )
if "%make_7z_archive%"=="Y" ( if not exist %SEVENZCMD% (
echo error: Couldn't find 7zip, aborting...
goto env_error ) )
::-------------------
:: SVN update section
::-------------------
:svn_update
for /f "delims=" %%A in ('svn info %CB_DEVEL_DIR% ^| find "Revision"') do @set OLD_REV=%%A
echo Current revision is %OLD_REV%
echo Updating repository
svn update %CB_DEVEL_DIR%
if errorlevel 1 goto svn_error
for /f "delims=" %%A in ('svn info %CB_DEVEL_DIR% ^| find "Revision"') do @set NEW_REV=%%A
if "%NEW_REV%"=="%OLD_REV%" goto nothing_to_do
::----------------
:: Codeblocks build section
::----------------
echo Building Code::blocks Base
%CB_OUTPUT_DIR%\codeblocks --build %CB_DEVEL_DIR%\src\Codeblocks.cbp
if errorlevel 1 goto build_error_base
echo Building Code::blocks Plugins
%CB_OUTPUT_DIR%\codeblocks --build %CB_DEVEL_DIR%\src\ContribPlugins.workspace
if errorlevel 1 goto build_error_plugin
::---------------------------------
echo Creating output directory tree
::---------------------------------
if not exist %CB_OUTPUT_DIR% md %CB_OUTPUT_DIR%\
if not exist %CB_OUTPUT_DIR%\share md %CB_OUTPUT_DIR%\share\
if not exist %CB_OUTPUT_RESDIR% md %CB_OUTPUT_RESDIR%\
if not exist %CB_OUTPUT_RESDIR%\lexers md %CB_OUTPUT_RESDIR%\lexers\
if not exist %CB_OUTPUT_RESDIR%\images md %CB_OUTPUT_RESDIR%\images\
if not exist %CB_OUTPUT_RESDIR%\images\settings md %CB_OUTPUT_RESDIR%\images\settings\
if not exist %CB_OUTPUT_RESDIR%\images\16x16 md %CB_OUTPUT_RESDIR%\images\16x16\
if not exist %CB_OUTPUT_RESDIR%\images\codecompletion md %CB_OUTPUT_RESDIR%\images\codecompletion\
if not exist %CB_OUTPUT_RESDIR%\plugins md %CB_OUTPUT_RESDIR%\plugins\
if not exist %CB_OUTPUT_RESDIR%\templates md %CB_OUTPUT_RESDIR%\templates\
if not exist %CB_OUTPUT_RESDIR%\templates\wizard md %CB_OUTPUT_RESDIR%\templates\wizard\
if not exist %CB_OUTPUT_RESDIR%\scripts md %CB_OUTPUT_RESDIR%\scripts\
if not exist %CB_DEVEL_DIR%\src\devel md devel\
if not exist %CB_DEVEL_DIR%\src\devel\share md devel\share\
if not exist %CB_DEVEL_RESDIR% md %CB_DEVEL_RESDIR%\
if not exist %CB_DEVEL_RESDIR%\lexers md %CB_DEVEL_RESDIR%\lexers\
if not exist %CB_DEVEL_RESDIR%\images md %CB_DEVEL_RESDIR%\images\
if not exist %CB_DEVEL_RESDIR%\images\settings md %CB_DEVEL_RESDIR%\images\settings\
if not exist %CB_DEVEL_RESDIR%\images\16x16 md %CB_DEVEL_RESDIR%\images\16x16\
if not exist %CB_DEVEL_RESDIR%\images\codecompletion md %CB_DEVEL_RESDIR%\images\codecompletion\
if not exist %CB_DEVEL_RESDIR%\plugins md %CB_DEVEL_RESDIR%\plugins\
if not exist %CB_DEVEL_RESDIR%\templates md %CB_DEVEL_RESDIR%\templates\
if not exist %CB_DEVEL_RESDIR%\templates\wizard md %CB_DEVEL_RESDIR%\templates\wizard\
if not exist %CB_DEVEL_RESDIR%\scripts md %CB_DEVEL_RESDIR%\scripts\
::--------------------------------
echo Compressing core UI resources
::--------------------------------
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\resources.zip %CB_DEVEL_DIR%\src\src\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\manager_resources.zip %CB_DEVEL_DIR%\src\sdk\resources\*.xrc %CB_DEVEL_DIR%\src\sdk\resources\images\*.png > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\start_here.zip %CB_DEVEL_DIR%\src\src\resources\start_here\*.html %CB_DEVEL_DIR%\src\src\resources\start_here\*.png > nul
echo Compressing plugins UI resources
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\astyle.zip %CB_DEVEL_DIR%\src\plugins\astyle\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\astyle\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\autosave.zip %CB_DEVEL_DIR%\src\plugins\autosave\manifest.xml %CB_DEVEL_DIR%\src\plugins\autosave\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\classwizard.zip %CB_DEVEL_DIR%\src\plugins\classwizard\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\classwizard\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\codecompletion.zip %CB_DEVEL_DIR%\src\plugins\codecompletion\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\codecompletion\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\compiler.zip %CB_DEVEL_DIR%\src\plugins\compilergcc\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\compilergcc\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\debugger.zip %CB_DEVEL_DIR%\src\plugins\debuggergdb\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\debuggergdb\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\defaultmimehandler.zip %CB_DEVEL_DIR%\src\plugins\defaultmimehandler\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\defaultmimehandler\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\openfileslist.zip %CB_DEVEL_DIR%\src\plugins\openfileslist\manifest.xml > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\projectsimporter.zip %CB_DEVEL_DIR%\src\plugins\projectsimporter\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\projectsimporter\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\scriptedwizard.zip %CB_DEVEL_DIR%\src\plugins\scriptedwizard\resources\manifest.xml > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\todo.zip %CB_DEVEL_DIR%\src\plugins\todo\resources\manifest.xml %CB_DEVEL_DIR%\src\plugins\todo\resources\*.xrc > nul
%ZIPCMD% -jqu9 %CB_DEVEL_RESDIR%\xpmanifest.zip %CB_DEVEL_DIR%\src\plugins\xpmanifest\manifest.xml > nul
echo Packaging core UI bitmaps
cd %CB_DEVEL_DIR%\src\src\resources
%ZIPCMD% -0 -qu %CB_DEVEL_RESDIR%\resources.zip %CB_DEVEL_DIR%\src\src\resources\images\*.png %CB_DEVEL_DIR%\src\src\resources\images\16x16\*.png > nul
cd %CB_DEVEL_DIR%\src\sdk\resources
%ZIPCMD% -0 -qu %CB_DEVEL_RESDIR%\manager_resources.zip %CB_DEVEL_DIR%\src\src\resources\images\*.png > nul
echo Packing plugins UI bitmaps
cd %CB_DEVEL_DIR%\src\plugins\compilergcc\resources
%ZIPCMD% -0 -qu %CB_DEVEL_RESDIR%\compiler.zip images\*.png %CB_DEVEL_DIR%\src\src\resources\images\16x16\*.png > nul
cd %CB_DEVEL_DIR%\src\plugins\debuggergdb\resources
%ZIPCMD% -0 -qu %CB_DEVEL_RESDIR%\debugger.zip images\*.png %CB_DEVEL_DIR%\src\src\resources\images\16x16\*.png > nul
cd ..\..\..
::---------------------------------------------------------
:: Overwriting and updating the current codeblocks environment
::---------------------------------------------------------
echo We will now setup your updated codeblocks ! (This will overwrite your current code::blocks environment)
PAUSE
echo Copying external exception handler
xcopy /D /y %CB_DEVEL_DIR%\src\exchndl.dll %CB_OUTPUT_DIR% > nul
xcopy /D /y %CB_DEVEL_DIR%\src\exchndl.dll %CB_DEVEL_DIR%\src\devel > nul
echo Copying files
xcopy /D /y %CB_DEVEL_RESDIR%\*.zip %CB_OUTPUT_RESDIR% > nul
xcopy /D /y %CB_DEVEL_DIR%\src\sdk\resources\lexers\lexer_* %CB_DEVEL_RESDIR%\lexers > nul
xcopy /D /y %CB_DEVEL_DIR%\src\sdk\resources\lexers\lexer_* %CB_OUTPUT_RESDIR%\lexers > nul
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\*.png %CB_DEVEL_RESDIR%\images > nul
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\settings\*.png %CB_DEVEL_RESDIR%\images\settings > nul
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\*.png %CB_OUTPUT_RESDIR%\images > nul
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\settings\*.png %CB_OUTPUT_RESDIR%\images\settings > nul
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\16x16\*.png %CB_DEVEL_RESDIR%\images\16x16 > nul
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\16x16\*.png %CB_OUTPUT_RESDIR%\images\16x16 > nul
xcopy /D /y %CB_DEVEL_DIR%\src\plugins\codecompletion\resources\images\*.png %CB_DEVEL_RESDIR%\images\codecompletion > nul
xcopy /D /y %CB_DEVEL_DIR%\src\plugins\codecompletion\resources\images\*.png %CB_OUTPUT_RESDIR%\images\codecompletion > nul
echo Makefile.am > excludes.txt
echo Makefile.in >> excludes.txt
echo \.svn\ >> excludes.txt
echo *.gdb >> excludes.txt
xcopy /D /y /s %CB_DEVEL_DIR%\src\plugins\scriptedwizard\resources\* %CB_DEVEL_RESDIR%\templates\wizard /EXCLUDE:excludes.txt >nul
xcopy /D /y /s %CB_DEVEL_DIR%\src\plugins\scriptedwizard\resources\* %CB_OUTPUT_RESDIR%\templates\wizard /EXCLUDE:excludes.txt >nul
xcopy /D /y %CB_DEVEL_DIR%\src\templates\common\* %CB_OUTPUT_RESDIR%\templates /EXCLUDE:excludes.txt > nul
xcopy /D /y %CB_DEVEL_DIR%\src\templates\win32\* %CB_OUTPUT_RESDIR%\templates /EXCLUDE:excludes.txt > nul
xcopy /D /y %CB_DEVEL_DIR%\src\templates\common\* %CB_DEVEL_RESDIR%\templates /EXCLUDE:excludes.txt > nul
xcopy /D /y %CB_DEVEL_DIR%\src\templates\win32\* %CB_DEVEL_RESDIR%\templates /EXCLUDE:excludes.txt > nul
xcopy /D /y %CB_DEVEL_DIR%\src\scripts\*.gdb %CB_OUTPUT_RESDIR% > nul
xcopy /D /y %CB_DEVEL_DIR%\src\scripts\* %CB_DEVEL_RESDIR%\scripts /EXCLUDE:excludes.txt > nul
xcopy /D /y %CB_DEVEL_DIR%\src\scripts\* %CB_OUTPUT_RESDIR%\scripts /EXCLUDE:excludes.txt > nul
if /i "%setup_additonal_target%"=="N" del %CB_DEVEL_DIR%\excludes.txt
xcopy /D /y %CB_DEVEL_DIR%\src\tips.txt %CB_OUTPUT_RESDIR% > nul
xcopy /D /y %CB_DEVEL_DIR%\src\tools\ConsoleRunner\cb_console_runner*.exe %CB_OUTPUT_DIR% > nul
xcopy /D /y %CB_DEVEL_DIR%\src\devel\*.exe %CB_OUTPUT_DIR% > nul
xcopy /D /y %CB_DEVEL_DIR%\src\devel\*.dll %CB_OUTPUT_DIR% > nul
xcopy /D /y %CB_DEVEL_RESDIR%\plugins\*.dll %CB_OUTPUT_RESDIR%\plugins > nul
echo Stripping debug info from output tree
strip %CB_OUTPUT_DIR%\*.exe
strip %CB_OUTPUT_DIR%\*.dll
strip %CB_OUTPUT_RESDIR%\plugins\*.dll
echo CodeBlocks has been successfully updated to SVN %NEW_REV%
goto ADDITIONAL_STUFF
::----------------
:: Cleanup section
::----------------
:svn_error
echo ERROR: SVN Checkout failed
echo Do you want to try a cleanup and try again ? [Y/N] (Enter for yes)
set try_cleanup=Y
set /P try_cleanup=
if /i "%try_cleanup%"=="Y" (
svn cleanup %CB_DEVEL_DIR%
goto svn_update ) else goto END
::-------------
:: Verbose part
::-------------
:build_error_base
echo ERROR: failed to build Code::Blocks Base
goto END
:build_error_plugin
echo ERROR: failed to build Code::Blocks Contrib plugins
goto END
:env_error
echo Please fix your environment and try again
goto END
:nothing_to_do
echo Your Code::Blocks environnement is already up to date
goto END
::-------------------
:ADDITIONAL_STUFF
::-------------------
if /i "%make_7z_archive%"=="Y" ( if not exist %SEVENZCMD% (
echo error: Couldn't find 7zip, skipping... ) else (
echo Archiving the codeblocks install folder
%SEVENZCMD% u %CB_DEVEL_DIR%\Codeblocks-svn.7z %CB_OUTPUT_DIR% > nul ) )
if /i "%setup_additonal_target%"=="Y" ( if not exist %ASL_DIR% (
echo Can't reach %ASL_DIR%, skipping... ) else (
echo Additional Setup: Copying external exception handler
xcopy /D /y %CB_OUTPUT_DIR%\exchndl.dll %ASL%
echo Additional Setup: Copying files
xcopy /D /y %CB_OUTPUT_RESDIR%\*.zip %ASL_RESDIR%
xcopy /D /y %CB_DEVEL_DIR%\src\sdk\resources\lexers\lexer_* %ASL_RESDIR%\lexers
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\*.png %ASL_RESDIR%\images
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\settings\*.png %ASL_RESDIR%\images\settings
xcopy /D /y %CB_DEVEL_DIR%\src\src\resources\images\16x16\*.png %ASL_RESDIR%\images\16x16
xcopy /D /y %CB_DEVEL_DIR%\src\plugins\codecompletion\resources\images\*.png %ASL_RESDIR%\images\codecompletion
xcopy /D /y /s plugins\scriptedwizard\resources\* %ASL_RESDIR%\templates\wizard /EXCLUDE:%CB_DEVEL_DIR%\excludes.txt
xcopy /D /y %CB_DEVEL_DIR%\src\templates\common\* %ASL_RESDIR%\templates /EXCLUDE:%CB_DEVEL_DIR%\excludes.txt
xcopy /D /y %CB_DEVEL_DIR%\src\templates\win32\* %ASL_RESDIR%\templates /EXCLUDE:%CB_DEVEL_DIR%\excludes.txt
xcopy /D /y %CB_DEVEL_DIR%\src\scripts\*.gdb %ASL_RESDIR%
xcopy /D /y %CB_DEVEL_DIR%\src\scripts\* %ASL_RESDIR%\scripts /EXCLUDE:%CB_DEVEL_DIR%\excludes.txt
del %CB_DEVEL_DIR%\excludes.txt
xcopy /D /y tips.txt %ASL_RESDIR%
xcopy /D /y %CB_OUTPUT_DIR%\*.exe %ASL_DIR%
xcopy /D /y %CB_OUTPUT_DIR%\*.dll %ASL_DIR%
xcopy /D /y %CB_OUTPUT_RESDIR%\plugins\*.dll %ASL_RESDIR%\plugins ) )
:END
PAUSE
Thanks for sharing the update.bat file.
echo Updating repository
svn update %CB_DEVEL_DIR%
My comments: If the update failed, for example, I have changed my local copy and it has conflict when updating. I think the script should stop here.
We have manually solve the conflict, then continue the build process.