chore: add support for Windows builds in Makefile (#1079)

This commits introduces the following Windows rules:

- `electron-installer-zip`
- `electron-installer-nsis`

Other changes:

- Remove `scripts/build/windows.bat`
- Update `docs/RUNNING-LOCALLY.md` to point to Makefile
- Update `docs/PUBLISHING.md` to point to Makefile
- Remove `7z` from `docs/RUNNING-LOCALLY.md` pre-requisites

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
Juan Cruz Viotti 2017-02-09 14:30:39 -04:00 committed by GitHub
parent 79ea4d4983
commit 108a43512d
6 changed files with 154 additions and 251 deletions

View File

@ -305,6 +305,24 @@ $(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME_LOWERCASE)-electron_$(APPLICATION_V
./scripts/build/electron-installer-debian-linux.sh -p $< -r "$(TARGET_ARCH)" -o $| \ ./scripts/build/electron-installer-debian-linux.sh -p $< -r "$(TARGET_ARCH)" -o $| \
-c scripts/build/debian/config.json -c scripts/build/debian/config.json
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-win32-$(TARGET_ARCH).zip: \
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-win32-$(TARGET_ARCH) \
| $(BUILD_OUTPUT_DIRECTORY)
./scripts/build/electron-installer-zip-win32.sh -a $< -o $@
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-win32-$(TARGET_ARCH).exe: \
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-win32-$(TARGET_ARCH) \
| $(BUILD_OUTPUT_DIRECTORY) $(BUILD_TEMPORARY_DIRECTORY)
./scripts/build/electron-installer-nsis-win32.sh -n $(APPLICATION_NAME) -a $< -t $(BUILD_TEMPORARY_DIRECTORY) -o $@
ifdef CODE_SIGN_CERTIFICATE
ifdef CODE_SIGN_CERTIFICATE_PASSWORD
./scripts/build/electron-sign-exe.sh -f $@ \
-d "$(APPLICATION_NAME) - $(APPLICATION_VERSION)"
-c $(CODE_SIGN_CERTIFICATE) \
-p $(CODE_SIGN_CERTIFICATE_PASSWORD)
endif
endif
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Phony targets # Phony targets
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
@ -342,6 +360,17 @@ PUBLISH_BINTRAY_DEBIAN += \
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME_LOWERCASE)-electron_$(APPLICATION_VERSION_DEBIAN)_$(TARGET_ARCH_DEBIAN).deb $(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME_LOWERCASE)-electron_$(APPLICATION_VERSION_DEBIAN)_$(TARGET_ARCH_DEBIAN).deb
endif endif
ifeq ($(TARGET_PLATFORM),win32)
electron-installer-zip: $(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-$(TARGET_PLATFORM)-$(TARGET_ARCH).zip
electron-installer-nsis: $(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-win32-$(TARGET_ARCH).exe
TARGETS += \
electron-installer-zip \
electron-installer-nsis
PUBLISH_AWS_S3 += \
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-$(TARGET_PLATFORM)-$(TARGET_ARCH).zip \
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-win32-$(TARGET_ARCH).exe
endif
ifdef PUBLISH_AWS_S3 ifdef PUBLISH_AWS_S3
publish-aws-s3: $(PUBLISH_AWS_S3) publish-aws-s3: $(PUBLISH_AWS_S3)
$(foreach publishable,$^,$(call execute-command,./scripts/publish/aws-s3.sh \ $(foreach publishable,$^,$(call execute-command,./scripts/publish/aws-s3.sh \

View File

@ -57,7 +57,8 @@ The resulting installers will be saved to `release/out`.
Run the following command: Run the following command:
```sh ```sh
> .\scripts\build\windows.bat all <x64|x86> make electron-installer-zip
make electron-installer-nsis
``` ```
The resulting installers will be saved to `etcher-release/installers`. The resulting installers will be saved to `etcher-release/installers`.

View File

@ -23,7 +23,6 @@ Prerequisites
- [Rimraf](https://github.com/isaacs/rimraf) - [Rimraf](https://github.com/isaacs/rimraf)
- [NSIS v2.51](http://nsis.sourceforge.net/Main_Page) (v3.x won't work) - [NSIS v2.51](http://nsis.sourceforge.net/Main_Page) (v3.x won't work)
- [Visual Studio Community 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48146) (free) (other editions, like Professional and Enterprise, should work too) - [Visual Studio Community 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48146) (free) (other editions, like Professional and Enterprise, should work too)
- [7z](http://www.7-zip.org) (command line version)
- [MinGW](http://www.mingw.org) - [MinGW](http://www.mingw.org)
The following MinGW packages are required: The following MinGW packages are required:
@ -58,27 +57,14 @@ than simply running `npm install` given that we need to do extra configuration
to make sure native dependencies are correctly compiled for Electron, otherwise to make sure native dependencies are correctly compiled for Electron, otherwise
the application might not run successfully. the application might not run successfully.
### OS X If you're on Windows, **run the command from the _Developer Command Prompt for
VS2015_**, to ensure all Visual Studio command utilities are available in the
`%PATH%`.
```sh ```sh
make electron-develop make electron-develop
``` ```
### GNU/Linux
```sh
make electron-develop
```
### Windows
**Run the following command from the _Developer Command Prompt for VS2015_**,
to ensure all Visual Studio command utilities are available in the `%PATH%`:
```sh
.\scripts\build\windows.bat install <x64|x86>
```
Running the application Running the application
----------------------- -----------------------

View File

@ -0,0 +1,68 @@
#!/bin/bash
###
# Copyright 2016 resin.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
set -u
set -e
set -x
./scripts/build/check-dependency.sh zip
function usage() {
echo "Usage: $0"
echo ""
echo "Options"
echo ""
echo " -n <application name>"
echo " -a <application package directory>"
echo " -t <temporary directory>"
echo " -o <output>"
exit 1
}
ARGV_APPLICATION_NAME=""
ARGV_APPLICATION=""
ARGV_TEMPORARY_DIRECTORY=""
ARGV_OUTPUT=""
while getopts ":n:a:t:o:" option; do
case $option in
n) ARGV_APPLICATION_NAME="$OPTARG" ;;
a) ARGV_APPLICATION="$OPTARG" ;;
t) ARGV_TEMPORARY_DIRECTORY="$OPTARG" ;;
o) ARGV_OUTPUT="$OPTARG" ;;
*) usage ;;
esac
done
if [ -z "$ARGV_APPLICATION_NAME" ] ||
[ -z "$ARGV_APPLICATION" ] ||
[ -z "$ARGV_TEMPORARY_DIRECTORY" ] ||
[ -z "$ARGV_OUTPUT" ]; then
usage
fi
if [ ! -d "$PWD/node_modules" ]; then
echo "Looks like you forgot to install the dependencies first!" 1>&2
exit 1
fi
./node_modules/.bin/electron-builder "$ARGV_APPLICATION" \
--platform=win \
--out="$ARGV_TEMPORARY_DIRECTORY"
mv "$ARGV_TEMPORARY_DIRECTORY/$ARGV_APPLICATION_NAME Setup.exe" "$ARGV_OUTPUT"

View File

@ -0,0 +1,52 @@
#!/bin/bash
###
# Copyright 2016 resin.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
set -u
set -e
./scripts/build/check-dependency.sh zip
function usage() {
echo "Usage: $0"
echo ""
echo "Options"
echo ""
echo " -a <application package directory>"
echo " -o <output>"
exit 1
}
ARGV_APPLICATION=""
ARGV_OUTPUT=""
while getopts ":a:o:" option; do
case $option in
a) ARGV_APPLICATION="$OPTARG" ;;
o) ARGV_OUTPUT="$OPTARG" ;;
*) usage ;;
esac
done
if [ -z "$ARGV_APPLICATION" ] || [ -z "$ARGV_OUTPUT" ]; then
usage
fi
CWD=$(pwd)
pushd "$ARGV_APPLICATION"
zip -r -9 "$CWD/$ARGV_OUTPUT" *
popd

View File

@ -1,233 +0,0 @@
@echo off
::::
:: Copyright 2016 resin.io
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::::
set command=%1
set arch=%2
set output_build_directory=etcher-release
set output_directory=%output_build_directory%\installers
set certificate_file=certificate.p12
set certificate_pass=1234
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Validate arguments
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if "%arch%"=="" (
echo Usage: %0 [command] [arch] 1>&2
exit /b 1
)
if "%command%"=="" (
echo Usage: %0 [command] [arch] 1>&2
exit /b 1
)
:: Batch conditionals don't support logical operators.
:: Simulate "and" with nested conditions.
if not "%arch%"=="x86" (
if not "%arch%"=="x64" (
echo Unknown architecture: %arch% 1>&2
exit /b 1
)
)
if not "%command%"=="install" (
if not "%command%"=="package" (
if not "%command%"=="all" (
echo Unknown command: %command% 1>&2
exit /b 1
)
)
)
:: Check that rimraf is installed.
:: We make use of this command line tool to clear
:: saved dependencies since doing so with `del`
:: might return errors due to long paths.
where rimraf >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Dependency missing: rimraf 1>&2
exit /b 1
)
:: Check that makensis is installed.
where makensis >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Dependency missing: nsis 1>&2
exit /b 1
)
:: Check that upx is installed.
where upx >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Dependency missing: upx 1>&2
exit /b 1
)
:: Check that asar is installed.
where asar >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Dependency missing: asar 1>&2
exit /b 1
)
:: Check that python is installed.
where python >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Dependency missing: python 1>&2
exit /b 1
)
:: Check that 7z is installed.
where 7z >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Dependency missing: 7z 1>&2
exit /b 1
)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Global variables
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set electron_packager=.\node_modules\.bin\electron-packager.cmd
set electron_builder=.\node_modules\.bin\electron-builder.cmd
set company_name="Resinio Ltd"
if "%arch%"=="x86" (
set electron_arch=ia32
)
if "%arch%"=="x64" (
set electron_arch=x64
)
for /f %%i in (' "node -e ""console.log(require('./package.json').devDependencies['electron-prebuilt'])""" ') do (
set electron_version=%%i
)
for /f %%i in (' "node -e ""console.log(require('./package.json').displayName)""" ') do (
set application_name=%%i
)
for /f "delims=" %%i in (' "node -e ""console.log(require('./package.json').description)""" ') do (
set application_description=%%i
)
for /f %%i in (' "node -e ""console.log(require('./package.json').copyright)""" ') do (
set application_copyright=%%i
)
for /f %%i in (' "node -e ""console.log(require('./package.json').version)""" ') do (
set etcher_version=%%i
)
for /f %%i in (' "node -v" ') do (
set node_version=%%i
)
set package_name=Etcher-%etcher_version%-win32-%arch%
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Install dependencies
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if not "%command%"=="package" (
call bash.exe scripts\build\dependencies-npm.sh^
-r %arch%^
-v %electron_version%^
-t electron^
-s win32
call bash.exe scripts\build\dependencies-bower.sh
)
if "%command%"=="install" (
exit /b 0
)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Package application
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
for /f %%i in (' "node .\scripts\packageignore.js" ') do (
set electron_ignore="%%i"
)
call %electron_packager% . %application_name%^
--platform=win32^
--arch=%electron_arch%^
--version=%electron_version%^
--ignore=%electron_ignore%^
--icon="assets/icon.ico"^
--app-copyright=%application_copyright%^
--app-version=%etcher_version%^
--build-version=%etcher_version%^
--version-string.CompanyName=%company_name%^
--version-string.FileDescription=%application_name%^
--version-string.OriginalFilename=%package_name%^
--version-string.ProductName="%application_name% -- %application_description%"^
--version-string.InternalName=%application_name%^
--overwrite^
--out=%output_build_directory%
set package_output=%output_build_directory%\%package_name%
if not "%arch%"=="%electron_arch%" (
move %output_build_directory%\Etcher-win32-%electron_arch% %output_build_directory%\Etcher-win32-%arch%
)
move %output_build_directory%\Etcher-win32-%arch% %package_output%
call bash.exe scripts\build\electron-create-asar.sh^
-d %package_output%\resources\app^
-o %package_output%\resources\app.asar
call rimraf %package_output%\resources\app
call bash.exe scripts\build\electron-sign-exe-win32.sh^
-c %certificate_file%^
-p %certificate_pass%^
-f %package_output%\Etcher.exe^
-d "%application_name% - %etcher_version%"
upx -9 %package_output%\*.dll
cd %package_output%^
&& 7z a -tzip ..\installers\%package_name%.zip *^
&& cd ..\..
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Generate installer
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set installer_tmp_output=%output_build_directory%\win32-%arch%-tmp-installer
set installer_output=%output_directory%\%package_name%.exe
call %electron_builder% %package_output%^
--platform=win^
--out=%installer_tmp_output%
mkdir "%output_directory%"
move "%installer_tmp_output%\%application_name% Setup.exe" "%installer_output%"
rd /s /q "%installer_tmp_output%"
call bash.exe scripts\build\electron-sign-exe-win32.sh^
-c %certificate_file%^
-p %certificate_pass%^
-f %installer_output%^
-d "%application_name% - %etcher_version%"