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

Add build setup in PowerShell #923

Closed
wants to merge 1 commit into from
Closed

Add build setup in PowerShell #923

wants to merge 1 commit into from

Conversation

tats-u
Copy link
Contributor

@tats-u tats-u commented Apr 28, 2024

Description

A clear and concise description of this pull request.

vcvarsamd64_x86.bat is only for CMD.
If you are using PowerShell, you should use Launch-VsDevShell.ps1 instead.
This PR adds how to use Launch-VsDevShell.ps1 instead of vcvarsamd64_x86.bat to docs\build_mozc_in_windows.md.

Issue IDs

Issue and/or discussion IDs related to this pull request.

Steps to test new behaviors (if any)

A clear and concise description about how to verify new behaviors (if any).

  • OS: Windows
  • Steps:
    1. See docs\build_mozc_in_windows.md
    2. Build (or check VS build environment at least)
    • (gcm cl).path (PowerShell) / where cl (CMD)

Additional context

Add any other context about the pull request here.

Copy link

google-cla bot commented Apr 28, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@yukawa
Copy link
Collaborator

yukawa commented Apr 29, 2024

Thank you for the pull request, but I guess what we should double check is to see if we still need to run the following batch file or not in our build instruction, rather than mechanically copying the command to PowerShell.

"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat"

I'll check to see it and remove the above line if I can confirm that it's no longer necessary. Thanks!

@tats-u
Copy link
Contributor Author

tats-u commented Apr 30, 2024

It doesn't have any effect in PS:

PowerShell 7.4.2
PS C:\Users\tatsu> (gcm cl).path
Get-Command: The term 'cl' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Users\tatsu> & "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.9.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_x86'
PS C:\Users\tatsu> (gcm cl).path
Get-Command: The term 'cl' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Users\tatsu> & 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1'  -HostArch amd64 -Arch x86 -SkipAutomaticLocation
**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.9.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
PS C:\Users\tatsu> (gcm cl).path
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x86\cl.exe
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

新機能と改善のために最新の PowerShell をインストールしてください!https://aka.ms/PSWindows

PS C:\Users\tatsu> (gcm cl).path
gcm : 用語 'cl' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名
前が正しく記述されていることを確認し、パスが含まれている場合はそのパスが正しいことを確認してから、再試行してください。
発生場所 行:1 文字:2
+ (gcm cl).path
+  ~~~~~~
    + CategoryInfo          : ObjectNotFound: (cl:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

PS C:\Users\tatsu> & "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.9.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_x86'
PS C:\Users\tatsu> (gcm cl).path
gcm : 用語 'cl' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名
前が正しく記述されていることを確認し、パスが含まれている場合はそのパスが正しいことを確認してから、再試行してください。
発生場所 行:1 文字:2
+ (gcm cl).path
+  ~~~~~~
    + CategoryInfo          : ObjectNotFound: (cl:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

PS C:\Users\tatsu> & 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1'  -HostArch amd64 -Arch x86 -SkipAutomaticLocation
& : このシステムではスクリプトの実行が無効になっているため、ファイル C:\Program Files\Microsoft Visual Studio\2022\Comm
unity\Common7\Tools\Launch-VsDevShell.ps1 を読み込むことができません。詳細については、「about_Execution_Policies」(http
s://go.microsoft.com/fwlink/?LinkID=135170) を参照してください。
発生場所 行:1 文字:3
+ & 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\To ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : セキュリティ エラー: (: ) []、PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\tatsu> Set-ExecutionPolicy Bypass -Scope Process
PS C:\Users\tatsu> & 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1'  -HostArch amd64 -Arch x86 -SkipAutomaticLocation
**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.9.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
PS C:\Users\tatsu> (gcm cl).path
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x86\cl.exe

CMD:

Microsoft Windows [Version 10.0.22631.3447]
(c) Microsoft Corporation. All rights reserved.

C:\Users\tatsu>where cl
情報: 与えられたパターンのファイルが見つかりませんでした。

C:\Users\tatsu>"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.9.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64_x86'

C:\Users\tatsu>where cl
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x86\cl.exe
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64\cl.exe

In the first place, a quoted string in PS is evaluated as an expression without command execution:

PS C:\Users\tatsu> "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat"
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_x86.bat

hiroyuki-komatsu pushed a commit that referenced this pull request Apr 30, 2024
This is a follow up to my previous commits [1][2], which aimed to
automate and encapsulate vcvarsall.bat handling in build_qt.py rather
than asking each developer to call it before running build_qt.py.

As seen in #923, however, build_mozc.py still requires us to run
vcvarsall.bat (or its variant) before running any sub-command in
build_qt.py. In order to let build_mozc.py take care of vcvarsall.bat
handling internally, this commit extracts out 'get_vs_env_vars' from
build_qt.py into a newly introduced vs_util.py so that build_mozc.py
can reuse it in a subsequent commit.

This is just a mechanical refactoring commit.
There must be no developer-observable difference in this commit.

#codehealth

 [1]: c777896
 [2]: f88dd04

PiperOrigin-RevId: 629244129
@hiroyuki-komatsu
Copy link
Collaborator

Hi tats-u,

We appreciate your PR.
Your identification of the problem introduced 1d82d68 that reduced the extra step.

Thank you,

@tats-u tats-u deleted the pwsh branch May 1, 2024 11:10
@tats-u
Copy link
Contributor Author

tats-u commented May 1, 2024

It’s unfortunate that the PR was not merged, but it’s good that as a result, you can now build by typing the commands as described even in PowerShell.

hiroyuki-komatsu added a commit that referenced this pull request Jun 6, 2024
Features
* Added more symbol characters (#933)
* Added words of 対象内 / 対象外 by fixing the format error (#928)

Bug fix
* Fixed the crash issue on saving the user dictionary. (42cbb3f)
* Fixed the crash issue on the debug build caused by converting negative numbers (#878)
* macOS: Replaced "Google Japanese Input" with Mozc in UI messages. (caeb9ce)
* macOS: Fixed the crash issue of mozc_emacs_helper (#900)
* macOS (Apple Silicon): Fixed the crash issue of GUI tools (#791)

Build
* Set proper release/debug build options for GitHub Actions (07c5f89)
* Updated the Protobuf version: v26.1 → v27.0 (#937)
* Updated the Qt version: 6.7.0 → 6.7.1 (#934)
* Linux: Added Dockerfile for Ubuntu 24.04 (#924)
* Windows: Simplified the build process by reducing manual execution of the vcvars .bat file. (#923)

Code
* Applied Clang's build cleaner
* Completed the migration from base/logging.h to Abseil log.
* macOS: Applied suggestions from code scanning alerts (b955086)

PiperOrigin-RevId: 639975159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants