Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Support Windows build, use official ICU src (for now)
COUCHDB-1994
  • Loading branch information
wohali committed Apr 19, 2014
1 parent 985a7f8 commit 3a8f260a246928e20048bcdbe69a078f1d306865
Showing 5 changed files with 113 additions and 8 deletions.
@@ -0,0 +1,2 @@
* -text

@@ -2,3 +2,6 @@ ebin
t/*.beam
.dists
.libs
*.pdb
*~
priv
@@ -0,0 +1,71 @@
param([switch]$clean)

$ICU_ZIP = "icu4c-4_8_1-Win32-msvc10.zip"
$ICU_URL="http://download.icu-project.org/files/icu4c/4.8.1"

$DISTDIR="${pwd}\.dists"
$STATICLIBS="${pwd}\.libs"
$ICUDIR="${STATICLIBS}\icu"

#
# improved remove-item -recurse -force
# thanks to http://serverfault.com/questions/199921/powershell-remove-force
#
function rmrf($directory = $(throw "Required parameter missing")) {
if ((test-path $directory) -and -not
(gi $directory | ? { $_.PSIsContainer })) {
throw ("rmrf called on non-directory.");
}

$finished = $false;
$attemptsLeft = 3;

do {
if (test-path $directory) {
rm $directory -recurse -force 2>&1 | out-null
}
if (test-path $directory) {
Start-Sleep -Milliseconds 500
$attemptsLeft = $attemptsLeft - 1
} else {
$finished = $true
}
} while (-not $finished -and $attemptsLeft -gt 0)

if (test-path $directory) {
throw ("Unable to fully remove directory " + $directory)
}
}


#
# main
#
if ($clean -eq $true) {
write-host "==> icu (clean)"
rmrf($STATICLIBS)
rmrf($DISTDIR)
} else {
write-host "==> icu (binary-download)"
rmrf($STATICLIBS)
rmrf($DISTDIR)
md $STATICLIBS -ea silentlycontinue > $null
md $DISTDIR -ea silentlycontinue > $null

# download the zip
$source = "${ICU_URL}/${ICU_ZIP}"
$dest = "${DISTDIR}\${ICU_ZIP}"
if (-not (test-path $dest)) {
write-host "==> Fetch ${ICU_ZIP} to ${dest}"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($source, $dest)
}

# unpack the zip
$shell = new-object -com shell.application
$zip = $shell.NameSpace($dest)
foreach($item in $zip.items())
{
$shell.Namespace($STATICLIBS).copyhere($item)
}
}
@@ -20,7 +20,7 @@ DISTDIR=$CORE_TOP/.dists
# icu sources
ICU_VER=4.4.2
ICU_DISTNAME=icu4c-4_4_2-src.tgz
ICU_SITE=http://dl.refuge.io
ICU_SITE=http://download.icu-project.org/files/icu4c/4.4.2
ICUDIR=$STATICLIBS/icu


@@ -42,10 +42,15 @@ IsDarwin = case os:type() of
_ -> false
end,

IsWindows = case os:type() of
{win32, nt} -> true;
_ -> false
end,

UseSystemIcu = IsDarwin andalso os:getenv("USE_STATIC_ICU") /= "1",

PortEnv = case {UseSystemIcu, BuildStatic} of
{true, _} ->
PortEnv = case {UseSystemIcu, BuildStatic, IsWindows} of
{true, _, false} ->
CFLAGS = GetFlag1("ICU_CFLAGS",
"-Iplatform/osx/icu -I/usr/include -fPIC"),
LDFLAGS = GetFlag1("ICU_LDFLAGS",
@@ -55,8 +60,7 @@ PortEnv = case {UseSystemIcu, BuildStatic} of
{"CFLAGS", "$DRV_CFLAGS " ++ CFLAGS},
{"LDFLAGS", LDFLAGS}
];

{_, true} ->
{_, true, false} ->
CFLAGS = GetFlag1("ICU_CFLAGS", "-I.libs/icu/include"),
LDFLAGS = GetFlag1("ICU_LDFLAGS", ".libs/icu/lib/libicui18n.a " ++
".libs/icu/lib/libicuuc.a " ++
@@ -67,12 +71,26 @@ PortEnv = case {UseSystemIcu, BuildStatic} of
{"CFLAGS", "$DRV_CFLAGS " ++ CFLAGS},
{"LDFLAGS", "-lstdc++ -fPIC $DRV_LDFLAGS " ++ LDFLAGS}
];
{_, false} ->
{_, true, true} ->
throw("Static builds not supported on Windows.");
{_, false, false} ->
ICUCFLAGS = GetFlag("ICU_CFLAGS", "--cflags"),
ICUCXXFLAGS = GetFlag("ICU_CXXFLAGS", "--cxxflags"),
ICULDFLAGS = GetFlag("ICU_LDFLAGS", "--ldflags"),
ICUINCPATH = GetFlag("ICU_INCPATH", "--cppflags-searchpath"),

[
{"CFLAGS", ICUCFLAGS ++ " $CFLAGS " ++ ICUINCPATH},
{"CXXFLAGS", ICUCXXFLAGS ++ " $CXXFLAGS " ++ ICUINCPATH},
{"LDFLAGS", ICULDFLAGS ++ " $LDFLAGS"}
];
{_, false, true} ->
ICUCFLAGS = "",
ICUCXXFLAGS = "",
ICUINCPATH = "/I.libs\\icu\\include",
ICULDFLAGS = ".libs\\icu\\lib\\icuin.lib " ++
".libs\\icu\\lib\\icuuc.lib " ++
".libs\\icu\\lib\\icudt.lib",
[
{"CFLAGS", ICUCFLAGS ++ " $CFLAGS " ++ ICUINCPATH},
{"CXXFLAGS", ICUCXXFLAGS ++ " $CXXFLAGS " ++ ICUINCPATH},
@@ -84,7 +102,18 @@ PortInfo = [{port_env, PortEnv},
{port_specs, [
{filename:join(["priv", Arch, "couch_collate.so"]),
["c_src/*.c"]}]},
{pre_hooks, [{compile, "./build_icu.sh"}]},
{post_hooks, [{clean, "./build_icu.sh clean"}]}],
{pre_hooks, [
{"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin)",
compile, "./build_icu.sh"},
{"(win32|win64)", compile,
"powershell ./build_icu.ps1"}
]},
{post_hooks, [
{"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin)",
clean, "./build_icu.sh clean"},
{"(win32|win64)", clean,
"powershell ./build_icu.ps1 -clean"}
]}
],

lists:keymerge(1,lists:keysort(1, PortInfo), lists:keysort(1, CONFIG)).

0 comments on commit 3a8f260

Please sign in to comment.