Upstream version 8.37.187.0
[platform/framework/web/crosswalk.git] / src / xwalk / tools / packaging / bootstrapped / win / create_windows_installer.bat
1 @echo off\r
2 setlocal enabledelayedexpansion\r
3 set THIS_SCRIPT=%0\r
4 set WXS_TEMPL_FILE="%~dp0\app.wxs.templ"\r
5 set GUID_GEN="%~dp0\guid.vbs"\r
6 :loop\r
7 set DASHED_PARAM=%1\r
8 set PARAM=!DASHED_PARAM:--=!\r
9 if "!PARAM!" == "!DASHED_PARAM!" (\r
10   set APP_PATH=!PARAM!\r
11 ) else (\r
12     if x%2==x (set !PARAM!=true) else (set !PARAM!=%2)\r
13     shift\r
14 )\r
15 @shift\r
16     \r
17 @if not "%~1"=="" goto loop\r
18 \r
19 if not x%HELP%==x (\r
20     echo.\r
21     echo usage: %THIS_SCRIPT% [options] [app_path]\r
22     echo.\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
26     echo.\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
45     exit /b\r
46 \r
47 )\r
48 if x%WIX_BIN_PATH%==x (\r
49     FOR /F "tokens=*" %%A IN ('where candle') DO SET WIX_BIN_PATH="%%A"\r
50 )\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
58     exit /b\r
59   )\r
60 )\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
69           set XWALK_PATH=%CD%\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
74             \r
75             exit /b\r
76         )\r
77       )\r
78   )\r
79 )\r
80 if x%APP_NAME%==x  (\r
81     for %%F in (%APP_PATH%) do set APP_NAME=%%~nF\r
82 )\r
83 if x%PUBLISHER%==x set PUBLISHER=Me\r
84 \r
85 set MAIN_OBJ_FILE=%TEMP%\%APP_NAME%.wixobj\r
86 \r
87 pushd %XWALK_PATH%\r
88 set XWALK_PATH=%CD%\r
89 popd\r
90 pushd %APP_PATH%\r
91 set APP_PATH=%CD%\r
92 popd\r
93 set PACKAGING_INI="%APP_PATH%\_packaging.ini"\r
94 \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
98 ) else (\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
102     ) else (\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
107     )\r
108 )\r
109 set WXS_FILES=\r
110 set OBJ_FILES=\r
111 if not exist %GUID_GEN% (\r
112     echo.\r
113     echo File not found: %GUID_GEN%\r
114     echo Please make sure all the supporting files are in the script folder!\r
115     exit /b\r
116 )\r
117 if x%OUT%==x (\r
118     set OUT=%APP_NAME%.msi\r
119     if exist !OUT! (\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
123         echo.\r
124         echo Installer not created!\r
125         exit /b\r
126         :yes\r
127         del !OUT!\r
128     )\r
129 )\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
137 )\r
138 \r
139 if exist %PACKAGING_INI% (\r
140     for /f "delims=" %%x in ( 'type %PACKAGING_INI%') do (set "%%x")\r
141 )\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
145 )\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