Skip to content

Commit

Permalink
FS-11400: [Build-System] FreeSWITCH Sound packages on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
andywolk committed Sep 20, 2018
1 parent 1d6f53a commit 5409a47
Show file tree
Hide file tree
Showing 9 changed files with 924 additions and 20 deletions.
22 changes: 2 additions & 20 deletions Freeswitch.2017.sln.bat
Expand Up @@ -13,7 +13,7 @@
@REM default build
@REM change these variables if you want to build differently by default
@set configuration=Release
@set platform=Win32
@set platform=x64


@REM if commandline parameters contain "ebug" and/or "64 and/or 32"
Expand Down Expand Up @@ -48,25 +48,7 @@
@set /a procs -= 1

@REM check and set VS2017 environment
rem VS2017U2 contains vswhere.exe
if "%VSWHERE%"=="" set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"

rem Use %ProgramFiles% in a 32-bit program prior to Windows 10)
If Not Exist "%VSWHERE%" set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"

If Not Exist "%VSWHERE%" (
echo "WARNING: Can't find vswhere.exe. It is a part of VS 2017 version 15.2 or later. Trying known path..."
set "InstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
) ELSE (
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)
)

echo Install dir is "%InstallDir%"
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
set msbuild="%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe"
)
CALL msbuild.cmd

if exist %msbuild% (
%msbuild% Freeswitch.2017.sln /m:%procs% /verbosity:normal /property:Configuration=%configuration% /property:Platform=%platform% /fl /flp:logfile=vs2017%platform%%configuration%.log;verbosity=normal
Expand Down
10 changes: 10 additions & 0 deletions build/sounds_upgradecode.txt
@@ -0,0 +1,10 @@
music c0dcf85a-d07d-4c73-97ca-c327d9755830 85f85500-b86d-4f51-abf5-3cd63a2cc52d 596734ef-4b7e-416c-beff-ec005dbb3786 a4e045a1-f6d2-49ae-a784-81bd4455f103
en-us-callie deb95334-fcd2-4b8a-91e7-a7828b99389d 249bfdc8-cb08-4ad5-9e38-06094e231d35 ef6db7d9-df8d-43e2-a3ec-16dd3fe1ac1b d515dc88-08df-4499-a6af-434cc5f68f86
en-us-allison 61179bb5-2289-4ae1-8a74-4e3d2821b691 2754130e-8896-4180-9227-a4ca2102c7c3 5b78a401-7244-438d-b83e-c944073842fd 13b50511-6f6d-43cf-a8b1-515c83708527
ru-RU-elena 9e0697a5-57b5-4f79-b95a-c85957f2a327 e52ebf36-ef86-41a5-8adf-1fcff6c42366 bfa6fdd6-fd24-4c9e-889d-88bcbbd173aa c088aedf-45ee-4cd5-8bfb-a64834affa9f
en-ca-june 649e7650-8298-4eba-ad59-2e0c49c0f79d f3134354-4b8e-4838-a2b6-62d8ffc2e877 e84dbde6-272c-472b-ab67-307c4b4ca0d0 79fb31f3-1f2f-4f5c-983b-1fe98b56af11
fr-ca-june 5ad7d0be-5164-416a-a86c-8d04eed94612 ed777145-13bd-44b1-bdbb-475f90ddfcb0 d98b2cfb-2a16-49de-8bda-10aa20845c0a 5c8a40ea-f2fa-463a-8e80-fbb2be65d7b4
pt-BR-karina 967a03cd-0df7-42ff-a396-8fe03c2c2fa3 79e264fb-0515-442d-900e-b7b979957faa 8801315b-5f27-4088-8b66-44d1fc4b1584 5152ae5e-bf0e-4f86-abf4-ecc8f0887932
sv-se-jakob ee23c4fa-63c9-4ab5-a11c-ec9d124664b9 d2af540d-6544-45e0-8443-f3c39d983cbd f8130d60-6cce-4cac-a2d1-dd046691accd f404fbe3-13c7-4cff-96a0-14634b7f8543
zh-cn-sinmei 15f500b5-21ed-4bfc-b56c-a0edefb26d73 c1108f48-7989-4e73-a645-a9b4539122ba bfc753d1-d0cc-4741-a773-55806f0bddde 8f4dda0a-10c0-4034-a137-8bd63b020f88
zh-hk-sinmei f4bf0d3e-bdef-4e70-80d7-3b619630f339 50346cc8-56d2-40da-a9e5-c151c298f1b0 d2108147-cab0-46e6-b95b-7702a58fe67a b37bfca9-8d41-4fb2-aeda-e1be2bb08ec7
689 changes: 689 additions & 0 deletions docs/COPYING.rtf

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions msbuild.cmd
@@ -0,0 +1,20 @@
@REM check and set VS2017 environment
rem VS2017U2 contains vswhere.exe
if "%VSWHERE%"=="" set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"

rem Use %ProgramFiles% in a 32-bit program prior to Windows 10)
If Not Exist "%VSWHERE%" set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"

If Not Exist "%VSWHERE%" (
echo "WARNING: Can't find vswhere.exe. It is a part of VS 2017 version 15.2 or later. Trying known path..."
set "InstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
) ELSE (
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)
)

echo Install dir is "%InstallDir%"
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
set msbuild="%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe"
)
3 changes: 3 additions & 0 deletions w32/Setup/Sounds/.gitignore
@@ -0,0 +1,3 @@
Fragments
bin
obj
29 changes: 29 additions & 0 deletions w32/Setup/Sounds/Product.wxs
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Platform specific variables -->
<?define ProductName = "FreeSWITCH Sounds - $(var.SoundPrimaryName) $(var.SoundQuality)Hz $(var.SoundVersion)" ?>
<?define ComponentGroup = "FreeSWITCHSoundFiles$(var.SoundSuffix)" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.SoundVersion)" Manufacturer="FreeSWITCH" UpgradeCode="$(var.SoundUpgradeCode)">
<Package InstallerVersion="200" Compressed="yes" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

<MediaTemplate EmbedCab="yes" />

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="FREESWITCHFOLDER" Name="FreeSWITCH">
<Directory Id="SOUNDLOCATION" Name="sounds">
</Directory>
</Directory>
</Directory>
</Directory>

<Feature Id="ProductFeature" Title="$(var.ProductName)" Level="1">
<ComponentGroupRef Id="$(var.ComponentGroup)" />
</Feature>

<UIRef Id="WixUI_Minimal" />
<WixVariable Id="WixUILicenseRtf" Value="$(var.BaseDir)/docs/COPYING.rtf" />
</Product>
</Wix>
19 changes: 19 additions & 0 deletions w32/Setup/Sounds/Setup.Sounds.2017.sln
@@ -0,0 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup.Sounds.2017", "Setup.Sounds.2017.wixproj", "{4B082D46-C1B0-4DBB-8D8D-AC0D0FDCDBDA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4B082D46-C1B0-4DBB-8D8D-AC0D0FDCDBDA}.Release|x64.ActiveCfg = Release|x64
{4B082D46-C1B0-4DBB-8D8D-AC0D0FDCDBDA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
117 changes: 117 additions & 0 deletions w32/Setup/Sounds/Setup.Sounds.2017.wixproj
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="LoadDynamicVariables" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
<Import Project="../../basedir.props" Condition=" '$(BaseDirImported)' == ''" />
<Import Project="../../downloadpackage.task" Condition=" '$(downloadpackagetask_Imported)' == '' " />
</ImportGroup>
<PropertyGroup>
<SoundPrimaryName Condition=" '$(SoundPrimaryName)' == '' ">en-us-callie</SoundPrimaryName>
<SoundQuality Condition=" '$(SoundQuality)' == '' ">8000</SoundQuality>
</PropertyGroup>
<PropertyGroup>
<SoundVersionFile Condition=" '$(SoundPrimaryName)' == 'music' ">moh_version.txt</SoundVersionFile>
<SoundVersionFile Condition=" '$(SoundPrimaryName)' != 'music' ">sounds_version.txt</SoundVersionFile>
<OutputName>Freeswitch-Sounds-$(SoundPrimaryName)-$(SoundQuality)Hz</OutputName>
<SoundSuffix>$(SoundPrimaryName.Replace("-","_"))$(SoundQuality)</SoundSuffix>
<CodeIndex Condition=" $(SoundQuality) == '8000' ">1</CodeIndex>
<CodeIndex Condition=" $(SoundQuality) == '16000' ">2</CodeIndex>
<CodeIndex Condition=" $(SoundQuality) == '32000' ">3</CodeIndex>
<CodeIndex Condition=" $(SoundQuality) == '48000' ">4</CodeIndex>
</PropertyGroup>
<PropertyGroup>
<ProjectGuid>4b082d46-c1b0-4dbb-8d8d-ac0d0fdcdbda</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" $(Platform) == 'x64' ">
<OutputPath>bin\x64\release\</OutputPath>
<IntermediateOutputPath>obj\X64\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Fragments\FreeSWITCHSoundFiles$(SoundSuffix).wxs" />
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</ItemGroup>
<ItemGroup>
<Folder Include="Fragments" />
</ItemGroup>
<ItemGroup>
<Content Include="../filter.xslt">
<Link>filter.xslt</Link>
</Content>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<PropertyGroup>
<PreBuildEvent>"$(WixToolPath)\heat.exe" dir "$(BaseDir)libs\sounds\$(SoundSuffix)" -cg FreeSWITCHSoundFiles$(SoundSuffix) -gg -scom -sreg -sfrag -srd -dr SOUNDLOCATION -var var.FreeSWITCHSoundFilesDir -out "$(ProjectDir)Fragments\FreeSWITCHSoundFiles$(SoundSuffix).wxs"</PreBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<DefineConstants>SoundPrimaryName=music;SoundQuality=8000</DefineConstants>
</PropertyGroup>
<Target Name="LoadDynamicVariables">
<ReadLinesFromFile File="$(BaseDir)build/$(SoundVersionFile)">
<Output TaskParameter="Lines" ItemName="LinesFromFile" />
</ReadLinesFromFile>
<CreateProperty Value="$([System.String]::Copy('%(LinesFromFile.Identity)').Split(' ')[1])" Condition=" $([System.String]::Copy('%(LinesFromFile.Identity)').Split(' ')[0]) == '$(SoundPrimaryName)'">
<Output TaskParameter="Value" PropertyName="SoundVersion" />
</CreateProperty>
<CreateProperty Value="%(LinesFromFile.Identity)" Condition=" $(SoundPrimaryName) == 'music' ">
<Output TaskParameter="Value" PropertyName="SoundVersion" />
</CreateProperty>
<Message Importance="High" Text="SoundVersion is $(SoundVersion)" />
<ReadLinesFromFile File="$(BaseDir)build/sounds_upgradecode.txt">
<Output TaskParameter="Lines" ItemName="LinesFromCodeFile" />
</ReadLinesFromFile>
<CreateProperty Value="$([System.String]::Copy('%(LinesFromCodeFile.Identity)').Split(' ')[$(CodeIndex)])" Condition=" $([System.String]::Copy('%(LinesFromCodeFile.Identity)').Split(' ')[0]) == '$(SoundPrimaryName)'">
<Output TaskParameter="Value" PropertyName="SoundUpgradeCode" />
</CreateProperty>
<Message Importance="High" Text="SoundUpgradeCode is $(SoundUpgradeCode)" />
<Message Importance="High" Text="SoundSuffix is '$(SoundSuffix)'" />
<PropertyGroup>
<SoundFileName>freeswitch-sounds-$(SoundPrimaryName)-$(SoundQuality)-$(SoundVersion).tar.gz</SoundFileName>
<DefineConstants>BaseDir=$(BaseDir);SoundUpgradeCode=$(SoundUpgradeCode);SoundVersion=$(SoundVersion);SoundSuffix=$(SoundSuffix);SoundPrimaryName=$(SoundPrimaryName);SoundQuality=$(SoundQuality);FreeSWITCHSoundFilesDir=$(BaseDir)libs\sounds\$(SoundSuffix);</DefineConstants>
</PropertyGroup>
<CreateProperty Condition="'$(Platform)'=='x64'" Value="x64">
<Output TaskParameter="Value" PropertyName="UserFriendlyPlatform" />
</CreateProperty>
<CreateProperty Value="$(BaseDir)$(UserFriendlyPlatform)\FreeSWITCH-Sounds-$(SoundPrimaryName)-$(SoundVersion)-$(SoundQuality)Hz.msi">
<Output TaskParameter="Value" PropertyName="DestinationFileName" />
</CreateProperty>
</Target>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
-->
<Target Name="BeforeBuild" DependsOnTargets="7za">
<!--
Download Target.
Name must be unique.
By design, targets are executed only once per project.
Usage:
package: URI
expectfileordirectory: Skips the download and extraction if exists
outputfolder: Folder to store a downloaded file.
By default "$(BaseDir)libs", if empty
outputfilename: If not empty, overrides filename from URI.
.exe files don't get extracted
extractto: Folder to extract an archive to
-->
<DownloadPackageTask package="http://files.freeswitch.org/releases/sounds/$(SoundFileName)" expectfileordirectory="$(BaseDir)libs\download-always" outputfolder="" outputfilename="" extractto="$(BaseDir)libs\sounds\$(SoundSuffix)\" />
</Target>
<Target Name="AfterBuild">
<Copy SourceFiles="$(OutputPath)$(OutputName).msi" DestinationFiles="$(DestinationFileName)" />
<Message Importance="High" Condition="Exists('$(DestinationFileName)')" Text="Success. An output MSI has been copied to $(DestinationFileName)" />
</Target>
</Project>
35 changes: 35 additions & 0 deletions w32/Setup/Sounds/build_sounds.cmd
@@ -0,0 +1,35 @@
@ECHO OFF
SETLOCAL

CALL ..\..\..\msbuild.cmd
if exist %msbuild% (

for /F "tokens=*" %%A in (%cd%\..\..\..\build\sounds_upgradecode.txt) do (
for /F "tokens=1 delims= " %%a in ("%%A") do (
CALL :Build %%a
)
)

) ELSE (
echo "echo ERROR: Cannot find msbuild. You need Visual Studio 2017 to compile this solution."
EXIT /B 1
)


REM CALL :Build music
REM CALL :Build en-us-callie

:: force execution to quit at the end of the "main" logic
EXIT /B %ERRORLEVEL%

:Build
set SoundPrimaryName=%1
set SoundQuality=8000
cmd /C %msbuild% %solution% /p:SoundPrimaryName=%SoundPrimaryName% /p:SoundQuality=%SoundQuality% /p:Configuration=Release /p:Platform=x64 /t:Build /p:PlatformToolset=v141 /verbosity:normal /fl /flp:logfile=..\..\..\x64\sound_logs\sounds_%SoundPrimaryName%_%SoundQuality%.log;verbosity=normal
set SoundQuality=16000
cmd /C %msbuild% %solution% /p:SoundPrimaryName=%SoundPrimaryName% /p:SoundQuality=%SoundQuality% /p:Configuration=Release /p:Platform=x64 /t:Build /p:PlatformToolset=v141 /verbosity:normal /fl /flp:logfile=..\..\..\x64\sound_logs\sounds_%SoundPrimaryName%_%SoundQuality%.log;verbosity=normal
set SoundQuality=32000
cmd /C %msbuild% %solution% /p:SoundPrimaryName=%SoundPrimaryName% /p:SoundQuality=%SoundQuality% /p:Configuration=Release /p:Platform=x64 /t:Build /p:PlatformToolset=v141 /verbosity:normal /fl /flp:logfile=..\..\..\x64\sound_logs\sounds_%SoundPrimaryName%_%SoundQuality%.log;verbosity=normal
set SoundQuality=48000
cmd /C %msbuild% %solution% /p:SoundPrimaryName=%SoundPrimaryName% /p:SoundQuality=%SoundQuality% /p:Configuration=Release /p:Platform=x64 /t:Build /p:PlatformToolset=v141 /verbosity:normal /fl /flp:logfile=..\..\..\x64\sound_logs\sounds_%SoundPrimaryName%_%SoundQuality%.log;verbosity=normal
EXIT /B 0

0 comments on commit 5409a47

Please sign in to comment.