{section: TJ's simple scripts} {subsection: sort_ads.pl} A script to sort a collection of classads by key without reordering the ads. What it actually does is accumulate lines from stdin until it gets to a blank line, then prints out those lines sorted. {file: sort_ads.pl} #!/usr/bin/env perl use strict; use warnings; my %ad; for my $line ( ) { if ($line =~ /^\s*$/) { # print out the previous add sorted by key then reset the hash for a new ad. if (%ad) { for (sort keys %ad) { print $_; } undef %ad; } } $ad{$line} = 1; } # print the last ad sorted by key if (%ad) { for (sort keys %ad) { print $_; } undef %ad; } {endfile} Example {term} condor_status -long | perl sort_ads.pl {endterm} {section: Scripts for building on Windows} {subsection: cmakeit.bat} run this script to create a condor.prj file in the current directory. Does much the same thing as configure_uw, but works on Windows. If sources are not in the current directory, it depends on the environment variable GIT_HOME to find them. This script will refuse to run if the current directory is a git repo. Optional arguments are *: regen - don't suppress cmake regeneration *: analyze - enable MSVC static code analysis for the build (take 3x longer) *: buildid - set the build id {file: cmakeit.bat} @echo off setlocal set _noregen=-DCMAKE_SUPPRESS_REGENERATION:BOOL=TRUE if "%1"=="regen" ( shift set _noregen=-DCMAKE_SUPPRESS_REGENERATION:BOOL=FALSE ) if "%1"=="analyze" ( shift set _analyze=-DMSVC_ANALYZE:BOOL=TRUE ) if "%1"=="noanalyze" ( shift set _analyze=-DMSVC_ANALYZE:BOOL=FALSE ) if "%1"=="tests" ( shift set _test=-DBUILD_TESTING:BOOL=TRUE -DWITH_BOOST:BOOL=TRUE ) if "%1"=="buildid" ( set _buildid=-DBUILDID:STRING="%~2" shift shift ) if exist .\.git\config goto :nothere if exist .gitignore goto :nothere if exist .\src\condor_utils\condor_api.h ( set _src= ) else ( set _src=%GIT_HOME% choice /M "no sources in current dir, use %GIT_HOME%" if errorlevel 2 goto :EOF ) set _gen="Visual Studio 9 2008" if "%VS_DIR%"=="C:\vs110" set _gen="Visual Studio 11" REM set _gen="NMake Makefiles" if NOT ~%1==~ set _gen=%1 @echo on cmake -LA CMakeLists.txt -G %_gen% %_noregen% %_analyze% %_test% %_buildid% -D_VERBOSE:BOOL=TRUE %_src% @goto :EOF :nothere @echo You don't want to run this when the current directory is a git repository. {endfile} Example {term} copy cmakeit.bat c:\scratch\build set GIT_HOME=c:\scratch\master\CONDOR_SRC mkdir c:\scratch\build\master cd c:\scratch\build\master ..\cmakeit {endterm} {subsection: rebuild.bat} run this script while in your build directory (the one with condor.sln) to build and/or release HTCondor. Optional arguments are *: build - do minimal build, default is full rebuild *: con|console - send output to console, default is to send it to rebuild.out *: debug|retail|RelWithDebInfo - set build type, default is retail *: package|externals|install - build the given target. ALL_BUILD is the default build target. *: release [test] - after build, invoke the release.bat script, which will release into release_dir subdir unless the test argument is passed, then it will release into the test subdir. {file: rebuild.bat} @echo off setlocal for %%I in (wget.exe) do if "%%~f$PATH:I"=="" ( echo WGET is not in the path - aborting exit /b 1 ) if not exist condor.sln ( echo There is no Condor.sln file in the current directory echo did you forget to run cmakeit.bat? exit /b 1 ) set _scriptdir_=%~sdp0 set _counterrs_=call %~sdp0counterrs.bat :top if "~%1"=="~" goto doit goto %1 :debug set _bldtype_=Debug goto next :con :console set _console_=true goto next :build set _rebuild_=Build goto next :relwithdebinfo :retail set _bldtype_=RelWithDebInfo goto next :package set _target_=PACKAGE goto next :externals set _target_=ALL_EXTERN goto next :install set _target_=INSTALL goto next :release set _release_=call %_scriptdir_%release.bat if "%2"=="test" ( set _release_=%_release_% test shift ) if "%_bldtype_%"=="Debug" ( set _release_=%_release_% debug ) goto next :next shift goto top :doit if ~%_rebuild_%==~ set _rebuild_=Rebuild if ~%_bldtype_%==~ set _bldtype_=RelWithDebInfo if ~%_target_%==~ set _target_=ALL_BUILD set _counterrs_=call %_scriptdir_%counterrs.bat %_rebuild_%.out ::@echo '%_counterrs_%' @if NOT "%_console_%"=="true" goto :build_to_log @echo on devenv condor.sln /%_rebuild_% %_bldtype_% /project %_target_% @echo off goto :EOF :build_to_log @echo on devenv condor.sln /%_rebuild_% %_bldtype_% /project %_target_% > %_rebuild_%.out @echo off %_counterrs_% %_release_% {endfile} Example {term} copy rebuild.bat c:\scratch\build cd c:\scratch\build\master mkdir c:\scratch\build\master\test ..\rebuild build debug release test {endterm}