페이지

2010년 11월 29일 월요일

Extracting VS2005 sln dependencies information

I have 220+ projects in my VS2005 solution file. My task is to create a new solution file by cutting some features. New one have 160+ projects and i need to set up dependencies between the projects.

To simplify these process i made Powershell script printing dependencies information. It worked as i expected. It will certainly ease your setting dependency work.

this script prints something like this:

projectA: projectB, base
projectB: base
...



Save the following script as Extract-VS2005Dependency.ps1
[sourcecode language="powershell"]
# usage
# powershell .Extract-VS2005Dependency -slnFile c:my.sln
param(
[string] $slnFile = $(throw 'need slnFile path')
)

$projects = @{}
switch -regex -file $slnFile
{
"^Project.*= ""(w+)"",.*vcproj"", ""(.*)""" {
#$_ ;
$projects[$Matches[2]] = $Matches[1]
}

}
#$projects
#$projects.count

switch -regex -file $slnFile
{
"^Project.*= ""(w+)"",.*vcproj"", ""(.*)""" {
#$_ ;
$curProject = $Matches[1]
""
write-host "$($curProject):" -nonewline
}
"({[A-Fa-f0-9-]+}) = 1" {
# $_
# $Matches[1]
write-host $projects[$Matches[1]]"," -nonewline
}

}
[/sourcecode]

2010년 11월 25일 목요일

converting vcproj to CMakeLists.txt

In official CMake wiki, there was several ruby script converters.
 
But the functionality I want is absent:
- Not supporting project configuration; converting 'debug|win32' configuration or 'release|win32' ?
- Not supporting exclude from build for each File configuration.
 
Since I have 150+ projects to convert , I write my own script using Powershell. It worked well for me. You don't need to install Powershell if you are using Windows7. it's already installed!
 
Note that this script supports only VS2005 project file only.
How to use:
  • Save powershell script in some directory(let's say c:tools)
  • Change your current directory to c:tools
  • Invoke following command.
  • CMakeLists.txt will be created in directory where vcproj located.

powershell .vcproj2cmake.ps1 c:xxx.vcproj -conf  'Debug'

2010년 11월 3일 수요일

mingw make patch for parallel build(-jN) on Windows

최근에 mingw make와 gcc 를 사용해서 프로젝을 빌드하는 프로젝트가 있다. 헌데 이놈이 맘에 안드는게 make -j를 지원하지 않는다. 그래서 4개나 되는 코아를 다 사용하지 못하니 빌드 시간이 오래 걸리고 컴이 놀게 된다.  -jN을 쓰지 못하면 너무 아깝지 않은가..
그래서 분석하기 시작!

I've been working on a project using mingw-make on Windows. but mingw-make doesn't support parallel build natively. Since my computers have 4 +cores, totally ineffective! so i'm digging about -jN options.

그래서 cmake로 Generator를 'MSYS Makefiles"로 바꿔서  parallel build(-j)에는 성공했지만, 버그때문인지 불규칙적으로 hang이 걸린다.  그래서 다른 방법을 찾아 보다가 찾은것이 Mingw job server를 제대로! 포팅한 패치가 있길래 mingw-make 3.82버전을 mingw환경에서 빌드해서 돌려보니 어라 잘 된다.

Using cmake's MSYS Generator was my first try. it did work. but there was some side effect. it irregularly caused deadlock.

I've found useful patch for supporting jobserver on Windows. i download mingw-make v3.82 and patch it. it gracefully works. no deadlock probelm.

또 유용한 patch를 발견했는데 이것은  parallel 하게 job이 수행되고 있는 중에 하나의 job이 실패하면 바로 리턴하는 patch. CI에선 거의 필수라 하겠다. 빠른 피드백이 중요하니까.
사실 윈도우에선 위 링크대로 하면 deadlock이 걸리길래 바로 'exit(4)'를 불러줬다.  그러니 child process들도 잘 죽는다.

i've found another useful patch which makes return at a first failure. default behavior is waiting for another job to be finished. the patch doesn't work on Windows. so instead i add 'exit(4)'. it killed all processes belonging to top process make.

혹시몰라 build & strip된 gnumake.exe를 첨부하려고 했으나
...  wordpress는 어떻게 첨부파일 어떻게 올리는건지 모르겠다..  zip같은건 원래 불가 ?