2 setlocal enabledelayedexpansion
\r
4 set WXS_TEMPL_FILE="%~dp0\app.wxs.templ"
\r
5 set GUID_GEN="%~dp0\guid.vbs"
\r
8 set PARAM=!DASHED_PARAM:--=!
\r
9 if "!PARAM!" == "!DASHED_PARAM!" (
\r
10 set APP_PATH=!PARAM!
\r
12 if x%2==x (set !PARAM!=true) else (set !PARAM!=%2)
\r
17 @if not "%~1"=="" goto loop
\r
21 echo usage: %THIS_SCRIPT% [options] [app_path]
\r
23 echo This script is used to create a standalone installer for Crosswalk applications. It
\r
24 echo depends on Wix toolset and Crosswalk to function properly.
\r
25 echo The following options are supported:
\r
27 echo app_path Path to the Crosswalk application. If not specified, the
\r
28 echo current directory is used.
\r
29 echo --wix_bin_path=^<path^> Path to Wix toolset binaries. If not specified, the
\r
30 echo script will try to find them through PATH
\r
31 echo --xwalk_path=^<path^> Path to Crosswalk binaries. If not specified, the script
\r
32 echo will try to find them through PATH, the app path, or
\r
33 echo the current directory.
\r
34 echo --app_name=^<name^> Name of the application. If not specified, the name
\r
35 echo of the application directory is used.
\r
36 echo --version=^<version^> The version of the application, defaults to 1.0.0
\r
37 echo --app_index=^<args^> Path of app index file, relative to app_path. If not
\r
38 echo specified, "index.html" is used.
\r
39 echo --app_arguments=^<args^> Arguments to be passed into Crosswalk executable.
\r
40 echo Example: --app_arguments=--allow-file-access-from-files
\r
41 echo --out=^<pathname^> File Path of the output installer file, defaults to the
\r
42 echo current directory with %%app_name%%.msi as its name.
\r
43 echo --publisher=^<name^> The manufacturer of this application, defaults to "Me"
\r
44 echo --help Print this message
\r
48 if x%WIX_BIN_PATH%==x (
\r
49 FOR /F "tokens=*" %%A IN ('where candle') DO SET WIX_BIN_PATH="%%A"
\r
51 if not x%WIX_BIN_PATH%==x set WIX_BIN_PATH=!WIX_BIN_PATH:\candle.exe=!
\r
52 if x%WIX_BIN_PATH%==x (
\r
53 set WIX_BIN_PATH="C:\Program Files (x86)\WiX Toolset v3.7\bin"
\r
54 if not exist "!WIX_BIN_PATH!\candle.exe" (
\r
55 echo Please make sure you have installed Wix and setup the PATH enviroment variable on
\r
56 echo your system properly. Or you can specify the wix path through --wix_bin_path
\r
57 echo command line parameter. You can download Wix from http://wixtoolset.org
\r
61 if x%APP_PATH%==x set APP_PATH=%CD%
\r
62 if x%APP_INDEX%==x set APP_INDEX=index.html
\r
63 if x%VERSION%==x set VERSION=1.0.0
\r
64 if x%XWALK_PATH%==x (
\r
65 FOR /F "tokens=*" %%A IN ('where xwalk') DO SET XWALK_PATH="%%A"
\r
66 if x%XWALK_PATH%==x (
\r
67 set XWALK_PATH=%APP_PATH%
\r
68 if not exist "!XWALK_PATH!\xwalk.exe" (
\r
70 if not exist "!XWALK_PATH!\xwalk.exe" (
\r
71 echo Please make sure you have installed Crosswalk and setup the PATH enviroment variable
\r
72 echo on your system properly. Or you can specify the Crosswalk path through --xwalk_path
\r
73 echo command line parameter.
\r
81 for %%F in (%APP_PATH%) do set APP_NAME=%%~nF
\r
83 if x%PUBLISHER%==x set PUBLISHER=Me
\r
85 set MAIN_OBJ_FILE=%TEMP%\%APP_NAME%.wixobj
\r
93 set PACKAGING_INI="%APP_PATH%\_packaging.ini"
\r
95 if not "x!APP_PATH:%XWALK_PATH%=!"=="x%APP_PATH%" (
\r
96 set __DIRS.1="%APP_PATH%"
\r
97 set __HARV_FILES.1=appFiles
\r
99 if not "x!XWALK_PATH:%APP_PATH%=!"=="x%XWALK_PATH%" (
\r
100 set __DIRS.1="%XWALK_PATH%"
\r
101 set __HARV_FILES.1=xwalkFiles
\r
103 set __DIRS.1="%APP_PATH%"
\r
104 set __HARV_FILES.1=appFiles
\r
105 set __DIRS.2="%XWALK_PATH%"
\r
106 set __HARV_FILES.2=xwalkFiles
\r
111 if not exist %GUID_GEN% (
\r
113 echo File not found: %GUID_GEN%
\r
114 echo Please make sure all the supporting files are in the script folder!
\r
118 set OUT=%APP_NAME%.msi
\r
120 set /p CONFIRM_DEL="The output file !OUT! already exists, replace it(Y/N)?" %=%
\r
121 if /I Y==!CONFIRM_DEL! goto :yes
\r
122 if /I YES==!CONFIRM_DEL! goto :yes
\r
124 echo Installer not created!
\r
130 for /f "tokens=2* delims=.=" %%A IN ('"SET __HARV_FILES."') do (
\r
131 set WXS_FILE=%TEMP%\%%B.wxs
\r
132 set OBJ_FILE=%TEMP%\%%B.wixobj
\r
133 %WIX_BIN_PATH%\heat dir !__DIRS.%%A! -gg -cg %%BGroup -srd -dr INSTALLDIR -var var.%%BDir -o !WXS_FILE!
\r
134 %WIX_BIN_PATH%\candle -dappFilesDir="%APP_PATH%" -dxwalkFilesDir="%XWALK_PATH%" !WXS_FILE! -o !OBJ_FILE!
\r
135 set "WXS_FILES=!WXS_FILES! !WXS_FILE!"
\r
136 set "OBJ_FILES=!OBJ_FILES! !OBJ_FILE!"
\r
139 if exist %PACKAGING_INI% (
\r
140 for /f "delims=" %%x in ( 'type %PACKAGING_INI%') do (set "%%x")
\r
142 FOR /F "tokens=*" %%A IN ('cscript //nologo %GUID_GEN% %UPGRADE_CODE%') DO (
\r
143 SET UPGRADE_CODE=%%A
\r
144 echo UPGRADE_CODE=!UPGRADE_CODE!>%PACKAGING_INI%
\r
146 %WIX_BIN_PATH%\candle -dappFilesDir="%APP_PATH%" -dxwalkFilesDir="%XWALK_PATH%" %WXS_TEMPL_FILE% -o %MAIN_OBJ_FILE%
\r
147 %WIX_BIN_PATH%\light -spdb %MAIN_OBJ_FILE% %OBJ_FILES% -o %OUT%
\r