Skip to content

Commit 3a6fceb

Browse files
authored
Fix ARM64 builds (#234)
* Fix ARM64 builds * add windows arm * include NOTICE in the zips
1 parent 52073f7 commit 3a6fceb

File tree

6 files changed

+78
-28
lines changed

6 files changed

+78
-28
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ testresults.xml
2727
# IDE files
2828
.idea
2929

30+
darwin-amd64/sqlcmd
31+
darwin-arm64/sqlcmd
32+
linux-amd64/sqlcmd
33+
linux-arm64/sqlcmd
34+
linux-s390x/sqlcmd

build/arch.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
darwin,amd64,sqlcmd
2+
darwin,arm64,sqlcmd
3+
linux,amd64,sqlcmd
4+
linux,arm64,sqlcmd
5+
linux,s390x,sqlcmd
6+
windows,arm64,sqlcmd.exe
7+
windows,amd64,sqlcmd.exe
8+
windows,arm,sqlcmd.exe

build/azure-pipelines/build-product.yml

+43-16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ stages:
3030
os:
3131
arch:
3232
binaryName: 'sqlcmd'
33+
macArm:
34+
imageName: 'macOS-latest'
35+
artifact: DarwinArm64
36+
os:
37+
arch: arm64
38+
binaryName: 'sqlcmd'
3339
windows:
3440
imageName: 'windows-latest'
3541
artifact: WindowsAmd64
@@ -42,14 +48,18 @@ stages:
4248
os:
4349
arch: arm64
4450
binaryName: 'sqlcmd'
45-
# BUG: https://github.com/microsoft/go-sqlcmd/issues/224
46-
# Windows ARM build failing in named pipes code
47-
#windowsArm:
48-
# imageName: 'windows-latest'
49-
# artifact: WindowsArm
50-
# os:
51-
# arch: arm
52-
# binaryName: 'sqlcmd.exe'
51+
windowsArm:
52+
imageName: 'windows-latest'
53+
artifact: WindowsArm
54+
os:
55+
arch: arm
56+
binaryName: 'sqlcmd.exe'
57+
windowsArm64:
58+
imageName: 'windows-latest'
59+
artifact: WindowsArm64
60+
os:
61+
arch: arm64
62+
binaryName: 'sqlcmd.exe'
5363
linuxs390x:
5464
imageName: 'ubuntu-latest'
5565
artifact: LinuxS390x
@@ -138,18 +148,26 @@ stages:
138148
- task: ArchiveFiles@2
139149
displayName: Zip Windows amd64 binary
140150
inputs:
141-
rootFolderOrFile: '$(Pipeline.Workspace)\SqlcmdWindowsAmd64\Sqlcmd.exe'
151+
rootFolderOrFile: '$(Pipeline.Workspace)\SqlcmdWindowsAmd64'
142152
includeRootFolder: false
143153
archiveType: 'zip'
144154
archiveFile: '$(Build.ArtifactStagingDirectory)/sqlcmd-$(getVersion.VERSION_TAG)-windows-x64.zip'
145155

146-
#- task: ArchiveFiles@2
147-
# displayName: Zip Windows arm binary
148-
# inputs:
149-
# rootFolderOrFile: '$(Pipeline.Workspace)\SqlcmdWindowsArm\Sqlcmd.exe'
150-
# includeRootFolder: false
151-
# archiveType: 'zip'
152-
# archiveFile: '$(Build.ArtifactStagingDirectory)/sqlcmd-$(getVersion.VERSION_TAG)-windows-arm.zip'
156+
- task: ArchiveFiles@2
157+
displayName: Zip Windows arm binary
158+
inputs:
159+
rootFolderOrFile: '$(Pipeline.Workspace)\SqlcmdWindowsArm'
160+
includeRootFolder: false
161+
archiveType: 'zip'
162+
archiveFile: '$(Build.ArtifactStagingDirectory)/sqlcmd-$(getVersion.VERSION_TAG)-windows-arm.zip'
163+
164+
- task: ArchiveFiles@2
165+
displayName: Zip Windows arm64 binary
166+
inputs:
167+
rootFolderOrFile: '$(Pipeline.Workspace)\SqlcmdWindowsArm64'
168+
includeRootFolder: false
169+
archiveType: 'zip'
170+
archiveFile: '$(Build.ArtifactStagingDirectory)/sqlcmd-$(getVersion.VERSION_TAG)-windows-arm64.zip'
153171

154172
- task: ArchiveFiles@2
155173
displayName: Tar Linux amd64 binary
@@ -169,6 +187,15 @@ stages:
169187
tarCompression: 'bz2'
170188
archiveFile: '$(Build.ArtifactStagingDirectory)/sqlcmd-$(getVersion.VERSION_TAG)-darwin-x64.tar.bz2'
171189

190+
- task: ArchiveFiles@2
191+
displayName: Tar Darwin Arm binary
192+
inputs:
193+
rootFolderOrFile: '$(Pipeline.Workspace)\SqlcmdDarwinArm64'
194+
includeRootFolder: false
195+
archiveType: 'tar'
196+
tarCompression: 'bz2'
197+
archiveFile: '$(Build.ArtifactStagingDirectory)/sqlcmd-$(getVersion.VERSION_TAG)-darwin-arm64.tar.bz2'
198+
172199
- task: ArchiveFiles@2
173200
displayName: Tar Linux arm64 binary
174201
inputs:

build/build.cmd

+5
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ go-licenses report github.com/microsoft/go-sqlcmd/cmd/modern --template build\NO
1313
copy %~dp0NOTICE.header + %~dp0notice.txt %~dp0..\NOTICE.md
1414
del %~dp0notice.txt
1515

16+
REM Generates all versions of sqlcmd in platform-specific folder
17+
setlocal
18+
19+
for /F "tokens=1-3 delims=," %%i in (%~dp0arch.txt) do set GOOS=%%i&set GOARCH=%%j&go build -o %~dp0..\%%i-%%j\%%k -ldflags="-X main.version=%sqlcmdVersion%" %~dp0..\cmd\modern
20+
1621

pkg/sqlcmd/sqlcmd.go

-12
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"github.com/golang-sql/sqlexp"
2222
mssql "github.com/microsoft/go-mssqldb"
2323
"github.com/microsoft/go-mssqldb/msdsn"
24-
_ "github.com/microsoft/go-mssqldb/namedpipe"
25-
_ "github.com/microsoft/go-mssqldb/sharedmemory"
2624
"golang.org/x/text/encoding/unicode"
2725
"golang.org/x/text/transform"
2826
)
@@ -539,13 +537,3 @@ func (s Sqlcmd) Log(_ context.Context, _ msdsn.Log, msg string) {
539537
_, _ = s.GetOutput().Write([]byte("DRIVER:" + msg))
540538
_, _ = s.GetOutput().Write([]byte(SqlcmdEol))
541539
}
542-
543-
func init() {
544-
if len(msdsn.ProtocolParsers) == 3 {
545-
// reorder the protocol parsers to lpc->np->tcp
546-
// ODBC follows this same order.
547-
var tcp = msdsn.ProtocolParsers[0]
548-
msdsn.ProtocolParsers[0] = msdsn.ProtocolParsers[2]
549-
msdsn.ProtocolParsers[2] = tcp
550-
}
551-
}

pkg/sqlcmd/sqlcmd_windows_amd64.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package sqlcmd
2+
3+
import (
4+
"github.com/microsoft/go-mssqldb/msdsn"
5+
_ "github.com/microsoft/go-mssqldb/namedpipe"
6+
_ "github.com/microsoft/go-mssqldb/sharedmemory"
7+
)
8+
9+
func init() {
10+
if len(msdsn.ProtocolParsers) == 3 {
11+
// reorder the protocol parsers to lpc->np->tcp
12+
// ODBC follows this same order.
13+
var tcp = msdsn.ProtocolParsers[0]
14+
msdsn.ProtocolParsers[0] = msdsn.ProtocolParsers[2]
15+
msdsn.ProtocolParsers[2] = tcp
16+
}
17+
}

0 commit comments

Comments
 (0)