google / mozc

Mozc - a Japanese Input Method Editor designed for multi-platform
Other
2.39k stars 348 forks source link

Add build setup in PowerShell #923

Closed tats-u closed 5 months ago

tats-u commented 5 months ago

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).

Additional context

Add any other context about the pull request here.

google-cla[bot] commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

Hi tats-u,

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

Thank you,

tats-u commented 5 months ago

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.