Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Rebase omaha #25

Open
wants to merge 170 commits into
base: master
from
Open
Changes from 1 commit
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
6b6e79f
Update DeveloperSetupGuide.md
patmanpm Feb 7, 2018
62d5459
Fixed Spelling.
jimmycasey Jul 26, 2018
a924f48
Fixed Spelling.
jimmycasey Jul 29, 2018
b05f7b4
Trivial tyop fix.
da4089 Oct 4, 2018
4e135f6
Merge pull request #139 from da4089/patch-1
sorinj Oct 10, 2018
349504f
fingerprint→fp in SeverProtocolDocV3
jpawlicki Dec 5, 2018
441e209
Integrate from Omaha mainline up to 226393814.
sorinj Dec 21, 2018
64b8b8b
Update CHANGELOG.txt
sorinj Dec 21, 2018
5f5207f
Update DeveloperSetupGuide.md
sorinj Dec 21, 2018
0a5f6c6
Merge pull request #137 from jimmycasey/master
sorinj Jan 8, 2019
bfcd89a
Merge pull request #129 from patmanpm/patch-1
sorinj Jan 8, 2019
3709c70
Update README.md
sorinj Jan 8, 2019
bae57b1
DeveloperSetupGuide.md protobuf version required.
hologramas Jan 11, 2019
4619c08
Merge pull request #141 from hologramas/patch-1
sorinj Jan 11, 2019
7b2b1ef
Added missing ApplyTag.exe
sorinj Feb 14, 2019
7b05396
Define NTDDI_VERSION correctly
macqm Mar 4, 2019
e8e7057
Set WIN_VER and _WIN32_WINNT to 0x0502
macqm Mar 5, 2019
b9874f7
Merge pull request #145 from macqm/master
sorinj Mar 7, 2019
2a60846
Merge pull request #1 from google/master
macqm Mar 9, 2019
e4cf932
Update DeveloperSetupGuide required tools
macqm Mar 11, 2019
c05961a
Set WINVER and _WIN32_WINNT to _WIN32_WINNT_WIN7
macqm Mar 11, 2019
82beaaa
Update docs to instruct to use python 2.7
macqm Mar 11, 2019
a3c2996
Merge pull request #147 from macqm/use_python_27
sorinj Mar 15, 2019
ede44c3
Merge pull request #146 from macqm/fix_winver
sorinj Mar 15, 2019
03e83a6
commit at CL 239258006
sorinj Mar 19, 2019
9c9d7bd
Merge branch 'master' of https://github.com/google/omaha
sorinj Mar 19, 2019
3996c52
Update CHANGELOG.txt CL 239101811 (Omaha 1.3.34.7)
sorinj Mar 19, 2019
0cca9ea
Update CHANGELOG.txt
sorinj Mar 19, 2019
a72a8e4
Update DeveloperSetupGuide.md
GitHubGanesh Mar 19, 2019
89da7d0
Merge pull request #149 from GitHubGanesh/patch-2
sorinj Mar 20, 2019
c8e4661
fix long lines
sorinj Mar 20, 2019
90f91ea
fix trailing spaces
sorinj Mar 20, 2019
ab8107b
Remove unreferences headers
macqm Apr 9, 2019
2e5a039
Remove headers that are not used outside of its cc and UTs
macqm Apr 9, 2019
e657a04
Fixing build break caused by new dependency on libzip
hologramas Apr 10, 2019
03c72bd
Revert "Fixing build break caused by new dependency on libzip"
hologramas Apr 10, 2019
75a9cf0
ICU_DECODE causes the URL parts to be unescaped. For our case, this c…
hologramas Apr 10, 2019
c78ccfc
Fix missing zipconf.h
sorinj Apr 11, 2019
55241d3
Updated documentation for using libzip 1.5.2
sorinj Apr 11, 2019
0fda114
Merge branch 'master' of https://github.com/google/omaha
sorinj Apr 11, 2019
cc97694
Upstream changes at CL 243143382
sorinj Apr 11, 2019
91d8119
Update CHANGELOG.txt at 243143382
sorinj Apr 11, 2019
60871c4
Merge pull request #157 from hologramas/omaha/httpdecode
sorinj Apr 11, 2019
8bea9cc
Merge pull request #156 from macqm/remove_unused_headers
sorinj Apr 11, 2019
479a57c
Update Getting started guide for VS2017 15.9.11
sorinj Apr 12, 2019
570347a
Fix markup
sorinj Apr 12, 2019
c32ef3d
Fix the concurrent hammer -j builds
sorinj Apr 12, 2019
cebf560
Remove unused disk related methods from disk.h and system.h
macqm Apr 13, 2019
bf30e5c
Remove unused code from shell.h
macqm Apr 13, 2019
6d96fa6
Remove unused methods from path.h
macqm Apr 13, 2019
083473b
Remove unused constants
macqm Apr 13, 2019
f55676e
Remove IsGoogleUpdate2OrLater
macqm Apr 13, 2019
eb85507
Remove Shell::DeleteDirectory (copy of utils::DeleteDirectory)
macqm Apr 13, 2019
19f9508
Remove unused PinModuleIntoProcess method
macqm Apr 13, 2019
2cbf616
Remove unused method from UserRights class
macqm Apr 13, 2019
54926c0
Cleanup vistautil.h
macqm Apr 13, 2019
09ab123
Clean up vista_utils
macqm Apr 13, 2019
cd891a6
Clean up thread.h
macqm Apr 13, 2019
6fa7caf
Clean up time.h
macqm Apr 13, 2019
0f7005c
Remove unused TimerScope
macqm Apr 13, 2019
7d536d9
Clean up system.h
macqm Apr 13, 2019
9337f3e
Merged PR 3125329: Remove stray submodule references
lashtear Apr 10, 2019
7505314
Merge pull request #160 from lashtear/user/embackes/fix-stray-submodules
sorinj Apr 15, 2019
aead7c5
Fix a leaked pointer in XmlParser::VisitElement
macqm Apr 16, 2019
38abf3d
Merge pull request #162 from macqm/fix_leak_response_handler
sorinj Apr 17, 2019
fa7741d
Fix gitignore
sorinj Apr 18, 2019
0f13fa5
Merge pull request #163 from sorinj/gitignore
sorinj Apr 18, 2019
ef119da
Support VS2019 builds
lashtear Apr 3, 2019
23058ae
Merge pull request #158 from macqm/dead_code_cleanup
sorinj Apr 18, 2019
c20748e
Merge pull request #161 from lashtear/user/embackes/vs2019-on-github
sorinj Apr 23, 2019
127658a
Fix .gitignore one more time.
sorinj Apr 23, 2019
d8af765
Remove DISALLOW_EVIL_CONSTRUCTORS macro
macqm Apr 28, 2019
7e34efc
Merge pull request #164 from macqm/remove_evil_ctor_macro
sorinj May 2, 2019
8163da9
Ignore .vscode folder
macqm May 3, 2019
fd128ef
Remove references to the BHO
macqm May 3, 2019
b55e9ef
Build the Protocol Buffer Compiler executable protoc.exe from source.
sorinj May 6, 2019
41d638b
Device Registration in Google Update during install.
sorinj May 7, 2019
0a480b2
Use GYP to build protocol buffers code.
sorinj May 7, 2019
3493b55
This is a bunch of changes including:
sorinj May 8, 2019
3275f45
Remove precompile header support.
sorinj May 8, 2019
8b546d4
Add support for VS2019.
sorinj May 9, 2019
4fdaaab
App-specific disclaimers for RollbackToTargetVersion policy.
sorinj May 9, 2019
3930b68
Update DeveloperSetupGuide.md
sorinj May 10, 2019
315fc06
Update CHANGELOG.txt at 247089588
sorinj May 10, 2019
088edf7
fix typos
sorinj May 10, 2019
b155fb6
Remove weak crypto hash algorithms from Omaha client.
sorinj May 15, 2019
92c1014
Produce 3 consecutive versions of some of the Omaha build artifacts.
sorinj May 16, 2019
6a4e7a9
Allow C++17 language features.
sorinj May 16, 2019
6fc7bfb
Enable '/permissive-' as a compiler switch.
sorinj May 17, 2019
32d2611
Fix for ICE with 16.1.0 toolchain
sorinj May 22, 2019
3a79b04
Update DeveloperSetupGuide.md
sorinj May 22, 2019
e86b5a0
Update DeveloperSetupGuide.md
sorinj May 28, 2019
a49912e
Update tools path and set LocalAppData for Go 1.12
Baternest May 29, 2019
3dca61c
Scoped_ptr to unique_ptr
macqm May 30, 2019
7eab2fe
Remove scoped_array
macqm May 30, 2019
6cdba60
scoped_ptr_malloc to use unique_ptr
macqm May 31, 2019
a1dab51
Use STL's shared_ptr
macqm May 31, 2019
cee090c
Delete scoped_ptr.h
macqm May 31, 2019
4ff7812
Use make_unique
macqm May 31, 2019
dabb33f
Fix broken test StringFormatterTest.FormatMessageTest
sorinj Jun 3, 2019
5540cad
Perform best-effort registration with the DMServer during UpdateApps …
sorinj Jun 5, 2019
ed71525
Implement the Omaha Cloud Policies Fetcher.
sorinj Jun 5, 2019
c12dff5
Remove obsolete smartany wrappers.
sorinj Jun 5, 2019
84d8ce7
Update CHANGELOG.txt up to CL 251531419.
sorinj Jun 5, 2019
641a16a
Added text removed accidentally (CHANGELOG.txt up to CL 251531419).
sorinj Jun 5, 2019
8bd27b7
Update DeveloperSetupGuide.md
sorinj Jun 5, 2019
87a0936
Add .clang-format file to the root.
macqm Jun 12, 2019
911a110
Update DeveloperSetupGuide.md
sorinj Jun 14, 2019
ca96900
Fix to pass buffer size.
sudoudaisuke Jun 21, 2019
f844ac0
Fix a race in the Scheduler dtor after unique_ptr change (#180)
macqm Jun 25, 2019
d02dd5e
Remove extra quotation mark from .clang-format (#186)
macqm Jun 28, 2019
f6d8839
minor whitespace changes
sorinj Jun 28, 2019
0a40738
Fix line endings in core/scheduler_unittest.cc
sorinj Jun 28, 2019
9b66147
Remove unused /netdiags mode
macqm Jul 11, 2019
da069b2
Add LZMA obj folder and .vs folder to .gitignore
macqm Jul 11, 2019
288c5d8
Remove unused QuotedPrintableUnescape
macqm Jul 11, 2019
10e3c7e
Remove localization.h and related unused string helpers
macqm Jul 11, 2019
c471bbb
Remove unused String_PathFindExtension
macqm Jul 11, 2019
d42417a
Replace SafeStrCat with wcscat_s
macqm Jul 11, 2019
5b0ca38
Remove unused string helpers
macqm Jul 11, 2019
30c4a4c
Remove unused JoinStrings* helpers
macqm Jul 11, 2019
1471431
remove RegSplitKeyvalueName and String_ReverseFindChar
macqm Jul 11, 2019
ff5be16
Remove unused StringToBuffer and BufferToString helpers
macqm Jul 11, 2019
850f763
Remove more unused string helpers
macqm Jul 11, 2019
2c6f94e
Signature verification infrastructure in preparation for full signatu…
sorinj Jul 12, 2019
ef08333
Omaha moved to Python 2.7, so a standalone hashlib implementation is …
sorinj Jul 12, 2019
77a94ba
Ping freshness must be initialized at app install time.
sorinj Jul 12, 2019
22bb7a4
Implement signature verification of the policy data with the new publ…
sorinj Jul 12, 2019
ed108d1
Implement signature rotation of new public keys received from the ser…
sorinj Jul 12, 2019
3e2a9f9
Change DeleteObsoletePolicies to do a case insensitive comparison.
sorinj Jul 12, 2019
f7dce5c
Small syntax changes for Python 2->3 migration.
sorinj Jul 12, 2019
e47ff20
Rolling back setup_google_update.cc to the old code before the <set> …
sorinj Jul 12, 2019
dcd93a0
Move to using enterprise_management::PublicKeyVerificationData instea…
sorinj Jul 12, 2019
58b681d
Switch to validating, using and storing PublicKeyVerificationData for…
sorinj Jul 12, 2019
785a2fa
Validate the timestamp, dmtoken, and deviceid in the policy fetch res…
sorinj Jul 15, 2019
7bdbbd1
Update CHANGELOG.txt
sorinj Jul 15, 2019
50ea11e
Use Brave for global company name variables in main.scons
simonhong May 20, 2018
3a856b2
Replace Google with Brave in string value from *.rc files
simonhong May 20, 2018
20bb2a3
Replace uuids
simonhong May 20, 2018
e8cef3a
Replace Omaha/OmahaCompanyName to Brave of constant values
simonhong May 20, 2018
067e2b5
Change update client appid
simonhong May 20, 2018
3d503fb
Build executable files with brave naming
simonhong May 20, 2018
e484ab5
Change company name to BraveSoftware
simonhong May 24, 2018
d13a014
Setting CUP
simonhong Jun 8, 2018
7d32b52
Use test server
simonhong Jun 8, 2018
2dea3f3
Including port number to update server address
simonhong Jun 12, 2018
4140445
Use http scheme with update server address
simonhong Jun 12, 2018
d1f09fc
Use bravesoftware.com domain for update server url
simonhong Jun 15, 2018
15bf20b
Add link for build instruction
simonhong Jun 22, 2018
2f3e509
Set new updater url
RyanJarv Jul 11, 2018
765b9ca
Update cup key for unofficial release
RyanJarv Jul 12, 2018
57d2c97
Store original path to registry to deliver promocode to installer
simonhong Oct 12, 2018
3aead25
Update help url
simonhong Oct 16, 2018
7c7593a
Updated with customizations and signing-related changes
emerick Oct 17, 2018
921d2e0
Integrate omaha to brave_core
simonhong Oct 23, 2018
98b5d2d
Make omaha build w/o admin priv
simonhong Nov 5, 2018
63e1616
Pass cert and password parameters to hammer-brave.bat
mbacchi Nov 5, 2018
bb54cbb
Use default 'prefers' for needsadmin tag in standalone installer.
mbacchi Nov 5, 2018
8212534
Remove unused CLI arg
mbacchi Nov 5, 2018
f32d3a4
Make release build only as a default
simonhong Nov 7, 2018
07cd9df
Create silent/untagged stub and standalone installers
mbacchi Nov 27, 2018
495ba66
Introduce silent tag for silent installer
simonhong Dec 5, 2018
42dfe9d
Send stats ping during startup, download, and installation
emerick Jan 7, 2019
1cdfcae
Fix stats ping
emerick Jan 12, 2019
e334519
Make copyright string empty
simonhong Feb 5, 2019
9ab252f
Fix signing server error
mbacchi Jul 11, 2019
f3ddd7f
Spacing mini-fix
mbacchi Jul 11, 2019
64d8c08
Update hammer-brave.bat
simonhong Jul 18, 2019
4f73c60
Add missing headers
simonhong Jul 18, 2019
ac33cf4
Add libzip and zlib
simonhong Jul 18, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Support VS2019 builds

Do not merge!

This may require additional work to sort through necessary prior
commits, like the Scons3 work.

The included new python files in

    omaha/site_scons/site_tools/*_vc16_*.py

are almost entirely derivative of prior versions of those files,
so the copyrights are copied unchanged.

Additional breakpad fixes are necessary, but might be resolved
with more warnings disabled.
  • Loading branch information
lashtear committed Apr 3, 2019
commit ef119dacbce59ef6bd001bdb5ef65885bb636e39
@@ -16,6 +16,11 @@
*.idb
*.pdb
*.pyc
*~
.p4config
.vscode
BRANCH_OWNERS
omaha/*.idb
omaha/common/omaha_customization_proxy_clsid.h
omaha/proxy_clsids.txt
omaha/scons-out/**
@@ -6,11 +6,13 @@ We are striving to make the code build with the latest Windows toolchain from Mi

#### Currently, the supported toolchain is Visual Studio 2017 Update 15.9.11 and Windows SDK 10.0.17763.0. ####

But VS2019 should now work.

# Required Downloads/Tools #

The following packages are required to build Omaha:
* A copy of the Omaha source code. This can be done by cloning this repository.
* Microsoft Visual Studio 2017. The free Visual Studio Community edition is sufficient to build.
* Microsoft Visual Studio 2017 or 2019. The free Visual Studio Community edition is sufficient to build.
* Download [here](https://visualstudio.microsoft.com/downloads)
* ATL Server headers
* Download [here](http://atlserver.codeplex.com). Omaha needs this library for regular expression support.
@@ -17,6 +17,7 @@
#define OMAHA_BASE_STRING_H_

#include <windows.h>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "omaha/base/constants.h"
@@ -14,6 +14,7 @@
// ========================================================================

#include "omaha/common/xml_parser.h"
#include <memory>
#include <stdlib.h>
#include <vector>
#include "base/basictypes.h"
@@ -16,11 +16,13 @@ rem -- Set all environment variables used by Hammer and Omaha. --
:: VS2013/VC12 is 1800.
:: VS2015/VC14 is 1900.
:: VS2017/VC14.1 is 1910.
:: VS2019/VC16.0 is 1920.

if "%VisualStudioVersion%"=="" goto error_no_vc
if "%VisualStudioVersion%"=="12.0" goto vc120
if "%VisualStudioVersion%"=="14.0" goto vc140
if "%VisualStudioVersion%"=="15.0" goto vc141
if "%VisualStudioVersion%"=="16.0" goto vc160
goto error_vc_not_supported

:vc120
@@ -35,6 +37,10 @@ goto set_env_variables
set OMAHA_MSC_VER=1910
goto set_env_variables

:vc160
set OMAHA_MSC_VER=1920
goto set_env_variables

:set_env_variables

:: Change these variables to match the local build environment.
@@ -101,16 +101,16 @@ _BUILD_SERVER_CERTIFICATE_HASH = 'CB7E84887F3C6015FE7EDFB4F8F36DF7DC10590E'
# The set of expected values are in omaha_version_utils.
# Defaults to VC140 if the environment variable is not specified.
_msc_ver = int(os.getenv('OMAHA_MSC_VER', "1900"))

_default_sdk_dir = ('$THIRD_PARTY/%s/files' %
{omaha_version_utils.VC141:'windows_sdk/windows_sdk_10',
_sdk_dir = os.getenv('WindowsSdkDir', os.getenv('OMAHA_PLATFORM_SDK_DIR'))
if (_sdk_dir is None):
_sdk_dir = ('$THIRD_PARTY/%s/files' %
{ omaha_version_utils.VC160:'windows_sdk/windows_sdk_10',
omaha_version_utils.VC141:'windows_sdk/windows_sdk_10',
omaha_version_utils.VC140:'windows_sdk/windows_sdk_10',
omaha_version_utils.VC120:'windows_sdk_8_1',
omaha_version_utils.VC100:'platformsdk_vc_10_0',
omaha_version_utils.VC80:'platformsdk/v6_1' }[_msc_ver])

_sdk_dir = os.getenv('OMAHA_PLATFORM_SDK_DIR', _default_sdk_dir)

_sdk_version = os.getenv('OMAHA_WINDOWS_SDK_10_0_VERSION', None)

_atl_server_dir = os.getenv('OMAHA_ATL_SERVER_DIR',
@@ -131,14 +131,16 @@ win_env = Environment(
tools=[
'component_setup',
'target_platform_windows',
{ omaha_version_utils.VC141:'windows_vc14_1',
{ omaha_version_utils.VC160:'windows_vc16_0',
omaha_version_utils.VC141:'windows_vc14_1',
omaha_version_utils.VC140:'windows_vc14_0',
omaha_version_utils.VC120:'windows_vc12_0',
omaha_version_utils.VC100:'windows_vc10_0',
omaha_version_utils.VC80:'target_platform_windows' }[_msc_ver],
'masm', # Use 'masm' to override the 'as' tool currently
# used by default in 'target_platform_windows'
{ omaha_version_utils.VC141:'atlmfc_vc14_1',
{ omaha_version_utils.VC160:'atlmfc_vc16_0',
omaha_version_utils.VC141:'atlmfc_vc14_1',
omaha_version_utils.VC140:'atlmfc_vc14_0',
omaha_version_utils.VC120:'atlmfc_vc12_0',
omaha_version_utils.VC100:'atlmfc_vc10_0',
@@ -98,6 +98,7 @@
VC120 = 1800 # VC2013/VC12
VC140 = 1900 # VC2015/VC14
VC141 = 1910 # VC2017/VC15
VC160 = 1920 # VS2019/VC16

def _IsSupportedOmaha2Version(omaha_version):
"""Returns true if omaha_version is an Omaha 2 version and is supported."""
@@ -32,14 +32,15 @@

// Suppress warning "C5031: #pragma warning(pop): likely mismatch, popping
// warning state pushed in different file." This works around a problem
// in winioctl.h introduced with VS 2017 15.9.
#if (_MSC_VER == 1916)
// in winioctl.h in the Windows SDK since somewhere between 10.0.15063
// and 10.0.16399. See #20584780.
#if (_MSC_VER >= 1916)
#pragma warning(push)
#pragma warning(disable:5031)
#endif
#include <winioctl.h>
#if (_MSC_VER == 1916)
#pragma warning(pop)
#if (_MSC_VER >= 1916)
#pragma warning(pop) // See above; winsdk workaround
#pragma warning(pop) // #pragma warning(disable:5031)
#endif

@@ -0,0 +1,46 @@
# Copyright 2015 Google Inc.
#
# 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.
# ========================================================================

"""Windows ATL MFC for VC16 (Visual Studio 2019) tool for SCons.
Note that ATL MFC requires the commercial (non-free) version of Visual Studio
2019.
"""

import os


def _FindLocalInstall():
"""Returns the directory containing the local install of the tool.
Returns:
Path to tool (as a string), or None if not found.
"""
default_dir = os.environ['VCToolsInstallDir'] + 'atlmfc'
if os.path.exists(default_dir):
return default_dir
else:
return None


def generate(env):
# NOTE: SCons requires the use of this name, which fails gpylint.
"""SCons entry point for this tool."""

if not env.get('ATLMFC_VC16_0_DIR'):
env['ATLMFC_VC16_0_DIR'] = _FindLocalInstall()

env.AppendENVPath('INCLUDE', env.Dir('$ATLMFC_VC16_0_DIR/include').abspath)
env.AppendENVPath('LIB', env.Dir('$ATLMFC_VC16_0_DIR/lib/x86').abspath)
@@ -411,6 +411,10 @@ def ConfigureEnvFor64Bit(env):
'$ATLMFC_VC14_1_DIR/lib/x64',
platform_sdk_lib_dir + '/um/x64',
platform_sdk_lib_dir + '/ucrt/x64',],
omaha_version_utils.VC160: [ '$VC16_0_DIR/lib/x64',
'$ATLMFC_VC16_0_DIR/lib/x64',
platform_sdk_lib_dir + '/um/x64',
platform_sdk_lib_dir + '/ucrt/x64',],
}[env['msc_ver']]

env.Prepend(LIBPATH=lib_paths)
@@ -421,7 +425,8 @@ def ConfigureEnvFor64Bit(env):
omaha_version_utils.VC100 : '$VC10_0_DIR/vc/bin/x86_amd64',
omaha_version_utils.VC120 : '$VC12_0_DIR/vc/bin/x86_amd64',
omaha_version_utils.VC140 : '$VC14_0_DIR/vc/bin/x86_amd64',
omaha_version_utils.VC141 : '$VC14_1_DIR/bin/HostX64/x64'}
omaha_version_utils.VC141 : '$VC14_1_DIR/bin/HostX64/x64',
omaha_version_utils.VC160 : '$VC16_0_DIR/bin/HostX64/x64'}
[env['msc_ver']]))

# Filter x86 options that are not supported or conflict with x86-x64 options.
@@ -0,0 +1,122 @@
#!/usr/bin/python2.4
#
# Copyright 2015 Google Inc.
#
# 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.
# ========================================================================

"""Tool-specific initialization for Visual Studio 2019.
NOTE: This tool is order-dependent, and must be run before
any other tools that modify the binary, include, or lib paths because it will
wipe out any existing values for those variables.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""

import os
import SCons


def _SetMsvcCompiler(
env, vc_flavor='x86'):
"""When run on a non-Windows system, this function does nothing.
When run on a Windows system, this function wipes the binary, include
and lib paths so that any non-hermetic tools won't be used.
These paths will be set up by target_platform_windows and other tools.
By wiping the paths here, we make the adding the other tools
order-independent.
Args:
env: The SCons environment in question.
vc_flavor: Defaults to x86, can be 'x86', 'amd64' or 'x86_amd64'. The
latter is using the 32-bit executable of the 64-bit compiler.
Returns:
Nothing.
Raises:
ValueError: An error if vc_flavor is not valid.
"""
if vc_flavor not in ('x86', 'amd64', 'x86_amd64'):
raise ValueError('vc_flavor must be one of: amd64, x86, x86_amd64.')

vc_dir = os.environ.get('VCToolsInstallDir')
platform_sdk_dir = os.environ.get('OMAHA_PLATFORM_SDK_DIR')
platform_sdk_version = os.environ.get('WindowsSDKVersion')
platform_sdk_include_dir = platform_sdk_dir + 'include/' + \
platform_sdk_version
platform_sdk_lib_dir = platform_sdk_dir + 'lib/' + platform_sdk_version

env['GOOGLECLIENT'] = '$MAIN_DIR/..'
env['THIRD_PARTY'] = '$GOOGLECLIENT/third_party/'

env.Replace(
PLATFORM_SDK_DIR=platform_sdk_dir,
MSVC_FLAVOR=('amd64', 'x86')[vc_flavor == 'x86'],
VC16_0_DIR=vc_dir,
WINDOWS_SDK_10_0_DIR=platform_sdk_dir,
)

# Clear any existing paths.
env['ENV']['PATH'] = ''
env['ENV']['INCLUDE'] = ''
env['ENV']['LIB'] = ''

tools_paths = []
include_paths = []
lib_paths = []
vc_bin_dir = vc_dir + 'bin/HostX86'
if vc_flavor == 'amd64':
vc_bin_dir += '/x64'
elif vc_flavor == 'x86':
vc_bin_dir += '/x86'

tools_paths += [vc_bin_dir,]

include_paths.append(vc_dir + '/include')
if vc_flavor == 'x86':
lib_paths.append(vc_dir + '/lib/x86')
else:
lib_paths.append(vc_dir + '/lib/x64')

# Add explicit location of platform SDK to tools path
tools_paths.append(platform_sdk_dir + '/bin')
include_paths += [
platform_sdk_include_dir + 'um', # Windows SDKs
platform_sdk_include_dir + 'shared', # Windows SDKs
platform_sdk_include_dir + 'ucrt', # Windows CRT
]
if vc_flavor == 'x86':
lib_paths += [
platform_sdk_lib_dir + 'um/x86', # Windows SDK
platform_sdk_lib_dir + 'ucrt/x86', # Windows CRT
]
tools_paths.append(platform_sdk_dir + '/bin/x86') # VC 12 only
else:
lib_paths += [
platform_sdk_lib_dir + 'um/x64', # Windows SDK
platform_sdk_lib_dir + 'ucrt/x64', # Windows CRT
]

for p in tools_paths:
env.AppendENVPath('PATH', env.Dir(p).abspath)
for p in include_paths:
env.AppendENVPath('INCLUDE', env.Dir(p).abspath)
for p in lib_paths:
env.AppendENVPath('LIB', env.Dir(p).abspath)


def generate(env):
_SetMsvcCompiler(
env=env, vc_flavor='x86')
@@ -194,7 +194,7 @@ inline T get( scoped_any<T,close_policy,invalid_value,unique> const & t )
template<typename T,class close_policy,class invalid_value,int unique>
inline bool valid( scoped_any<T,close_policy,invalid_value,unique> const & t )
{
return t;
return static_cast<bool>(t);
}

// return wrapped resource and give up ownership
@@ -32,6 +32,7 @@

#include <fstream> // NOLINT(readability/streams)
#include <limits>
#include <string>
#include "omaha/base/file.h"
#include "omaha/base/path.h"
#include "omaha/base/utils.h"
@@ -81,7 +82,24 @@ int WriteMsiTag(
write_uint16(&out, static_cast<uint16>(tag_length));

// Actual tag.
std::string tag_ansi(tag, tag + tag_length);
// Formerly: std::string tag_ansi(tag, tag + tag_length);

// That code converted UTF-16 to iso-8859-1 (Latin1) via blindly
// chopping all but the lowest eight bits. This is not utf-8; it's
// Latin1, with garbage for anything outside that repertoire. Newer
// compilers rightly complain about data loss. Apparently that is
// fine though, so we do exactly as above, but more explicitly, and
// raising an assertion if we actually hit anything outside
// US-ASCII.
std::string tag_ansi;
tag_ansi.reserve(static_cast<size_t>(tag_length));
for (auto it=tag, itend=static_cast<const TCHAR*>(tag + tag_length);
it != itend;
++it) {
ASSERT1(*it < 128);
tag_ansi += static_cast<const char>(*it);
}

out.write(tag_ansi.data(), tag_length);

in.close();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.