27
27
ETAGFILE = os .path .join (DESTDIR , "etags" )
28
28
ETAGS = {}
29
29
30
- VERSION = {}
30
+ VERSION = ""
31
31
32
32
33
33
def run (cmd , ** kwargs ):
@@ -113,37 +113,23 @@ def build():
113
113
"""
114
114
Build binaries.
115
115
"""
116
- platforms = [ "linux/amd64 " , "windows/386" , "windows/amd64" , "darwin/amd64" ]
117
- print ( f"--> Building binary for { ', ' . join ( platforms ) } " )
116
+ run ([ "make " , "clean" ]) # clean before build
117
+ cmd = [ "make" , "allplatforms" ]
118
118
verfilename = "version"
119
119
with open (verfilename ) as verfile :
120
120
verinfo = verfile .read ()
121
121
122
- VERSION ["version" ] = re .search (r"version=(.*)" , verinfo ).group (1 )
123
- cmd = ["git" , "rev-list" , "--count" , "HEAD" ]
124
- VERSION ["build" ] = int (check_output (cmd ).strip ().decode ())
125
- cmd = ["git" , "rev-parse" , "HEAD" ]
126
- VERSION ["commit" ] = check_output (cmd ).strip ().decode ()
127
- print (("Version: {version} "
128
- "Build: {build:06d} "
129
- "Commit: {commit}" ).format (** VERSION ))
130
- ldflags = ("-X main.gincliversion={version} "
131
- "-X main.build={build:06d} "
132
- "-X main.commit={commit}" ).format (** VERSION )
133
- output = os .path .join (DESTDIR , "{{.OS}}-{{.Arch}}" , "gin" )
134
- cmd = [
135
- "gox" , f"-output={ output } " ,
136
- f"-osarch={ ' ' .join (platforms )} " , f"-ldflags={ ldflags } "
137
- ]
122
+ global VERSION
123
+ VERSION = re .search (r"version=(.*)" , verinfo ).group (1 )
138
124
print (f"Running { ' ' .join (cmd )} " )
139
125
if run (cmd ) > 0 :
140
126
die ("Build failed" )
141
127
142
128
print ()
143
129
print ("--> Build succeeded" )
144
130
print ("--> The following files were built:" )
145
- ginfiles = glob (os .path .join (DESTDIR , "*" , "gin" ))
146
- ginfiles .extend (glob (os .path .join (DESTDIR , "*" , "gin.exe" )))
131
+ ginfiles = glob (os .path .join ("build" , "*" , "gin" ))
132
+ ginfiles .extend (glob (os .path .join ("build" , "*" , "gin.exe" )))
147
133
print ("\n " .join (ginfiles ), end = "\n \n " )
148
134
149
135
plat = sys .platform
@@ -216,7 +202,7 @@ def package_linux_plain(binfile):
216
202
_ , osarch = os .path .split (dirname )
217
203
# simple binary archive
218
204
shutil .copy ("README.md" , dirname )
219
- arc = f"gin-cli-{ VERSION [ 'version' ] } -{ osarch } .tar.gz"
205
+ arc = f"gin-cli-{ VERSION } -{ osarch } .tar.gz"
220
206
archive = os .path .join (PKGDIR , arc )
221
207
cmd = ["tar" , "-czf" , archive , "-C" , dirname , fname , "README.md" ]
222
208
print (f"Running { ' ' .join (cmd )} " )
@@ -265,7 +251,7 @@ def docker_cleanup():
265
251
266
252
# create directory structure
267
253
pkgname = "gin-cli"
268
- pkgnamever = f"{ pkgname } -{ VERSION [ 'version' ] } "
254
+ pkgnamever = f"{ pkgname } -{ VERSION } "
269
255
debmdsrc = os .path .join ("debdock" , "debian" )
270
256
pkgdir = os .path .join (tmpdir , pkgname )
271
257
debcapdir = os .path .join (pkgdir , "DEBIAN" )
@@ -301,7 +287,7 @@ def docker_cleanup():
301
287
# Adding version number to debian control file
302
288
controlpath = os .path .join (debcapdir , "control" )
303
289
with open (controlpath ) as controlfile :
304
- controllines = controlfile .read ().format (** VERSION )
290
+ controllines = controlfile .read ().format (version = VERSION )
305
291
306
292
with open (controlpath , "w" ) as controlfile :
307
293
controlfile .write (controllines )
@@ -361,7 +347,7 @@ def package_mac_plain(binfile):
361
347
osarch = osarch .replace ("darwin" , "macos" )
362
348
# simple binary archive
363
349
shutil .copy ("README.md" , dirname )
364
- archive = f"gin-cli-{ VERSION [ 'version' ] } -{ osarch } .tar.gz"
350
+ archive = f"gin-cli-{ VERSION } -{ osarch } .tar.gz"
365
351
archive = os .path .join (PKGDIR , archive )
366
352
cmd = ["tar" , "-czf" , archive , "-C" , dirname , fname , "README.md" ]
367
353
print (f"Running { ' ' .join (cmd )} " )
@@ -407,8 +393,8 @@ def package_mac_bundle(binfile, annex_tar):
407
393
408
394
with open ("./macapp/gin-Info.plist" , "rb" ) as plistfile :
409
395
info = plistlib .load (plistfile , fmt = plistlib .FMT_XML )
410
- info ["CFBundleVersion" ] = VERSION [ "version" ]
411
- info ["CFBundleShortVersionString" ] = VERSION [ "version" ]
396
+ info ["CFBundleVersion" ] = VERSION
397
+ info ["CFBundleShortVersionString" ] = VERSION
412
398
# info["CFBundleExecutable"] = "runshell"
413
399
with open (os .path .join (ginapproot , "Contents" , "Info.plist" ),
414
400
"wb" ) as plistfile :
@@ -418,7 +404,7 @@ def package_mac_bundle(binfile, annex_tar):
418
404
_ , osarch = os .path .split (dirname )
419
405
osarch = osarch .replace ("darwin" , "macos" )
420
406
421
- archive = f"gin-cli-{ VERSION [ 'version' ] } -{ osarch } -bundle.tar.gz"
407
+ archive = f"gin-cli-{ VERSION } -{ osarch } -bundle.tar.gz"
422
408
archive = os .path .join (PKGDIR , archive )
423
409
print ("Creating macOS bundle" )
424
410
if os .path .exists (archive ):
@@ -481,7 +467,7 @@ def winbundle(binfile, git_pkg, annex_pkg):
481
467
dirname , _ = os .path .split (binfile )
482
468
_ , osarch = os .path .split (dirname )
483
469
484
- arc = f"gin-cli-{ VERSION [ 'version' ] } -{ osarch } .zip"
470
+ arc = f"gin-cli-{ VERSION } -{ osarch } .zip"
485
471
arc = os .path .join (PKGDIR , arc )
486
472
print ("Creating Windows zip file" )
487
473
# need to change paths before making zip file
@@ -536,6 +522,7 @@ def main():
536
522
print (f"Linux: { len (linux_bins )} " )
537
523
print (f"Windows: { len (win_bins )} " )
538
524
print (f"macOS: { len (darwin_bins )} " )
525
+ sys .exit (1 )
539
526
540
527
# package stuff
541
528
linux_pkg = package_linux_plain (linux_bins [0 ])
@@ -546,8 +533,8 @@ def main():
546
533
mac_pkg = package_mac_plain (darwin_bins [0 ])
547
534
mac_bundle = package_mac_bundle (darwin_bins [0 ], mac_annex_tar )
548
535
549
- win_bin_32 = [wb for wb in win_bins if "386 " in wb ][0 ]
550
- win_bin_64 = [wb for wb in win_bins if "amd64 " in wb ][0 ]
536
+ win_bin_32 = [wb for wb in win_bins if "windows32 " in wb ][0 ]
537
+ win_bin_64 = [wb for wb in win_bins if "windows64 " in wb ][0 ]
551
538
win_git_32 = [wg for wg in win_git_files if "32-bit" in wg ][0 ]
552
539
win_git_64 = [wg for wg in win_git_files if "64-bit" in wg ][0 ]
553
540
@@ -559,7 +546,7 @@ def link_latest(fname):
559
546
Create symlinks with the version part replaced by 'latest' for the
560
547
newly built package.
561
548
"""
562
- latestname = fname .replace (VERSION [ "version" ] , "latest" )
549
+ latestname = fname .replace (VERSION , "latest" )
563
550
print (f"Linking { fname } to { latestname } " )
564
551
if os .path .lexists (latestname ):
565
552
os .unlink (latestname )
0 commit comments