Skip to content

Commit 78c5b4c

Browse files
committed
build: backport config for new CI infrastructure
PR-URL: #3642 Reviewed-By: Johan Bergström <[email protected]>
1 parent caa16b4 commit 78c5b4c

8 files changed

+280
-100
lines changed

Makefile

+144-35
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ DESTDIR ?=
77
SIGN ?=
88
PREFIX ?= /usr/local
99
FLAKY_TESTS ?= run
10+
STAGINGSERVER ?= node-www
1011

12+
OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]')
13+
14+
# Flags for packaging.
15+
BUILD_DOWNLOAD_FLAGS ?= --download=all
16+
BUILD_INTL_FLAGS ?= --with-intl=small-icu
17+
BUILD_RELEASE_FLAGS ?= $(BUILD_DOWNLOAD_FLAGS) $(BUILD_INTL_FLAGS)
1118
NODE ?= ./node
1219

1320
# Default to verbose builds.
@@ -251,9 +258,45 @@ run-ci:
251258

252259
RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
253260
VERSION=v$(RAWVER)
261+
262+
# For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
263+
# "custom". For the nightly and next-nightly case, you need to set DATESTRING
264+
# and COMMIT in order to properly name the build.
265+
# For the rc case you need to set CUSTOMTAG to an appropriate CUSTOMTAG number
266+
267+
ifndef DISTTYPE
268+
DISTTYPE=release
269+
endif
270+
ifeq ($(DISTTYPE),release)
271+
FULLVERSION=$(VERSION)
272+
else # ifeq ($(DISTTYPE),release)
273+
ifeq ($(DISTTYPE),custom)
274+
ifndef CUSTOMTAG
275+
$(error CUSTOMTAG is not set for DISTTYPE=custom)
276+
endif # ifndef CUSTOMTAG
277+
TAG=$(CUSTOMTAG)
278+
else # ifeq ($(DISTTYPE),custom)
279+
ifndef DATESTRING
280+
$(error DATESTRING is not set for nightly)
281+
endif # ifndef DATESTRING
282+
ifndef COMMIT
283+
$(error COMMIT is not set for nightly)
284+
endif # ifndef COMMIT
285+
ifneq ($(DISTTYPE),nightly)
286+
ifneq ($(DISTTYPE),next-nightly)
287+
$(error DISTTYPE is not release, custom, nightly or next-nightly)
288+
endif # ifneq ($(DISTTYPE),next-nightly)
289+
endif # ifneq ($(DISTTYPE),nightly)
290+
TAG=$(DISTTYPE)$(DATESTRING)$(COMMIT)
291+
endif # ifeq ($(DISTTYPE),custom)
292+
FULLVERSION=$(VERSION)-$(TAG)
293+
endif # ifeq ($(DISTTYPE),release)
294+
295+
DISTTYPEDIR ?= $(DISTTYPE)
296+
RELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
254297
NODE_DOC_VERSION=$(VERSION)
255-
RELEASE=$(shell $(PYTHON) tools/getnodeisrelease.py)
256-
PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
298+
NPMVERSION=v$(shell cat deps/npm/package.json | grep '"version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')
299+
257300
ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
258301
DESTCPU ?= x64
259302
else
@@ -268,61 +311,62 @@ else
268311
ARCH=x86
269312
endif
270313
endif
271-
TARNAME=node-$(VERSION)
272-
ifdef NIGHTLY
273-
TAG = nightly-$(NIGHTLY)
274-
TARNAME=node-$(VERSION)-$(TAG)
275-
endif
276-
TARBALL=$(TARNAME).tar.gz
277-
BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
278-
BINARYTAR=$(BINARYNAME).tar.gz
279-
PKG=out/$(TARNAME).pkg
280-
PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
281314

282-
PKGSRC=nodejs-$(DESTCPU)-$(RAWVER).tgz
283-
ifdef NIGHTLY
284-
PKGSRC=nodejs-$(DESTCPU)-$(RAWVER)-$(TAG).tgz
315+
# enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel
316+
ifeq ($(ARCH),ia32)
317+
override ARCH=x86
318+
endif
319+
ifeq ($(DESTCPU),ia32)
320+
override DESTCPU=x86
285321
endif
286322

287-
dist: doc $(TARBALL) $(PKG)
288-
323+
TARNAME=node-$(FULLVERSION)
324+
TARBALL=$(TARNAME).tar
325+
BINARYNAME=$(TARNAME)-$(OSTYPE)-$(ARCH)
326+
BINARYTAR=$(BINARYNAME).tar
327+
PKG=$(TARNAME).pkg
328+
PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
289329
PKGDIR=out/dist-osx
290330

291331
release-only:
292332
@if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
293333
exit 0 ; \
294334
else \
295-
echo "" >&2 ; \
335+
echo "" >&2 ; \
296336
echo "The git repository is not clean." >&2 ; \
297337
echo "Please commit changes before building release tarball." >&2 ; \
298338
echo "" >&2 ; \
299339
git status --porcelain | egrep -v '^\?\?' >&2 ; \
300340
echo "" >&2 ; \
301341
exit 1 ; \
302342
fi
303-
@if [ "$(NIGHTLY)" != "" -o "$(RELEASE)" = "1" ]; then \
343+
@if [ "$(DISTTYPE)" != "release" -o "$(RELEASE)" = "1" ]; then \
304344
exit 0; \
305345
else \
306-
echo "" >&2 ; \
346+
echo "" >&2 ; \
307347
echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
308-
echo "Did you remember to update src/node_version.cc?" >&2 ; \
309-
echo "" >&2 ; \
348+
echo "Did you remember to update src/node_version.h?" >&2 ; \
349+
echo "" >&2 ; \
310350
exit 1 ; \
311351
fi
312352

313-
pkg: $(PKG)
314-
315353
$(PKG): release-only
316354
rm -rf $(PKGDIR)
317355
rm -rf out/deps out/Release
318-
$(PYTHON) ./configure --download=all --with-intl=small-icu \
319-
--without-snapshot --dest-cpu=ia32 --tag=$(TAG)
356+
$(PYTHON) ./configure \
357+
--dest-cpu=ia32 \
358+
--tag=$(TAG) \
359+
--without-snapshot \
360+
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
320361
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)/32
321362
rm -rf out/deps out/Release
322-
$(PYTHON) ./configure --download=all --with-intl=small-icu \
323-
--without-snapshot --dest-cpu=x64 --tag=$(TAG)
363+
$(PYTHON) ./configure \
364+
--dest-cpu=x64 \
365+
--tag=$(TAG) \
366+
--without-snapshot \
367+
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
324368
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
325-
SIGN="$(APP_SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
369+
SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
326370
lipo $(PKGDIR)/32/usr/local/bin/node \
327371
$(PKGDIR)/usr/local/bin/node \
328372
-output $(PKGDIR)/usr/local/bin/node-universal \
@@ -333,7 +377,15 @@ $(PKG): release-only
333377
--id "org.nodejs.Node" \
334378
--doc tools/osx-pkg.pmdoc \
335379
--out $(PKG)
336-
SIGN="$(INT_SIGN)" PKG="$(PKG)" bash tools/osx-productsign.sh
380+
SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
381+
382+
pkg: $(PKG)
383+
384+
pkg-upload: pkg
385+
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
386+
chmod 664 node-$(FULLVERSION).pkg
387+
scp -p node-$(FULLVERSION).pkg $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).pkg
388+
ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).pkg.done"
337389

338390
$(TARBALL): release-only node doc
339391
git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
@@ -349,6 +401,39 @@ $(TARBALL): release-only node doc
349401

350402
tar: $(TARBALL)
351403

404+
tar-upload: tar
405+
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
406+
chmod 664 node-$(FULLVERSION).tar.gz
407+
scp -p node-$(FULLVERSION).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.gz
408+
ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.gz.done"
409+
410+
doc-upload: tar
411+
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
412+
chmod -R ug=rw-x+X,o=r+X out/doc/
413+
scp -pr out/doc/ $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/
414+
ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs.done"
415+
416+
$(TARBALL)-headers: config.gypi release-only
417+
$(PYTHON) ./configure \
418+
--prefix=/ \
419+
--dest-cpu=$(DESTCPU) \
420+
--tag=$(TAG) \
421+
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
422+
HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
423+
find $(TARNAME)/ -type l | xargs rm # annoying on windows
424+
tar -cf $(TARNAME)-headers.tar $(TARNAME)
425+
rm -rf $(TARNAME)
426+
gzip -c -f -9 $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.gz
427+
rm $(TARNAME)-headers.tar
428+
429+
tar-headers: $(TARBALL)-headers
430+
431+
tar-headers-upload: tar-headers
432+
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
433+
chmod 664 $(TARNAME)-headers.tar.gz
434+
scp -p $(TARNAME)-headers.tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz
435+
ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz.done"
436+
352437
$(BINARYTAR): release-only
353438
rm -rf $(BINARYNAME)
354439
rm -rf out/deps out/Release
@@ -364,6 +449,35 @@ $(BINARYTAR): release-only
364449

365450
binary: $(BINARYTAR)
366451

452+
binary-upload-arch: binary
453+
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
454+
chmod 664 node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz
455+
scp -p node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz
456+
ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz.done"
457+
458+
ifeq ($(OSTYPE),darwin)
459+
binary-upload:
460+
$(MAKE) binary-upload-arch \
461+
DESTCPU=ia32 \
462+
ARCH=x86 \
463+
DISTTYPE=$(DISTTYPE) \
464+
DATESTRING=$(DATESTRING) \
465+
COMMIT=$(COMMIT) \
466+
CUSTOMTAG=$(CUSTOMTAG) \
467+
CONFIG_FLAGS=$(CONFIG_FLAGS)
468+
$(MAKE) binary-upload-arch \
469+
DESTCPU=x64 \
470+
ARCH=x64 \
471+
DISTTYPE=$(DISTTYPE) \
472+
DATESTRING=$(DATESTRING) \
473+
COMMIT=$(COMMIT) \
474+
CUSTOMTAG=$(CUSTOMTAG) \
475+
CONFIG_FLAGS=$(CONFIG_FLAGS)
476+
else
477+
binary-upload: binary-upload-arch
478+
endif
479+
480+
367481
$(PKGSRC): release-only
368482
rm -rf dist out
369483
$(PYTHON) configure --prefix=/ --without-snapshot --download=all \
@@ -378,11 +492,6 @@ $(PKGSRC): release-only
378492

379493
pkgsrc: $(PKGSRC)
380494

381-
dist-upload: $(TARBALL) $(PKG)
382-
ssh [email protected] mkdir -p web/nodejs.org/dist/$(VERSION)
383-
scp $(TARBALL) [email protected]:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
384-
scp $(PKG) [email protected]:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
385-
386495
wrkclean:
387496
$(MAKE) -C tools/wrk/ clean
388497
rm tools/wrk/wrk

configure

+14-1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ parser.add_option('--with-icu-source',
267267
dest='with_icu_source',
268268
help='Intl mode: optional local path to icu/ dir, or path/URL of icu source archive.')
269269

270+
parser.add_option('--download-path',
271+
dest='download_path',
272+
default=os.path.join(root_dir, 'deps'),
273+
help='Download directory [default: %default]')
274+
270275
parser.add_option('--with-perfctr',
271276
action='store_true',
272277
dest='with_perfctr',
@@ -517,6 +522,10 @@ def configure_node(o):
517522

518523
host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
519524
target_arch = options.dest_cpu or host_arch
525+
# ia32 is preferred by the build tools (GYP) over x86 even if we prefer the latter
526+
# the Makefile resets this to x86 afterward
527+
if target_arch == 'x86':
528+
target_arch = 'ia32'
520529
o['variables']['host_arch'] = host_arch
521530
o['variables']['target_arch'] = target_arch
522531

@@ -762,11 +771,15 @@ def configure_intl(o):
762771
]
763772
def icu_download(path):
764773
# download ICU, if needed
774+
if not os.access(options.download_path, os.W_OK):
775+
print 'Error: cannot write to desired download path. ' \
776+
'Either create it or verify permissions.'
777+
sys.exit(1)
765778
for icu in icus:
766779
url = icu['url']
767780
md5 = icu['md5']
768781
local = url.split('/')[-1]
769-
targetfile = os.path.join(root_dir, 'deps', local)
782+
targetfile = os.path.join(options.download_path, local)
770783
if not os.path.isfile(targetfile):
771784
if nodedownload.candownload(auto_downloads, "icu"):
772785
nodedownload.retrievefile(url, targetfile)

src/node_version.h

+16-10
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,31 @@
2828

2929
#define NODE_VERSION_IS_RELEASE 0
3030

31-
#ifndef NODE_TAG
32-
# define NODE_TAG ""
33-
#endif
34-
3531
#ifndef NODE_STRINGIFY
3632
#define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)
3733
#define NODE_STRINGIFY_HELPER(n) #n
3834
#endif
3935

40-
#if NODE_VERSION_IS_RELEASE
41-
# define NODE_VERSION_STRING NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \
42-
NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
43-
NODE_STRINGIFY(NODE_PATCH_VERSION) \
44-
NODE_TAG
36+
#ifndef NODE_TAG
37+
# if NODE_VERSION_IS_RELEASE
38+
# define NODE_TAG ""
39+
# else
40+
# define NODE_TAG "-pre"
41+
# endif
4542
#else
43+
// NODE_TAG is passed without quotes when rc.exe is run from msbuild
44+
# define NODE_EXE_VERSION NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \
45+
NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
46+
NODE_STRINGIFY(NODE_PATCH_VERSION) \
47+
NODE_STRINGIFY(NODE_TAG)
48+
#endif
49+
4650
# define NODE_VERSION_STRING NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \
4751
NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
4852
NODE_STRINGIFY(NODE_PATCH_VERSION) \
49-
NODE_TAG "-pre"
53+
NODE_TAG
54+
#ifndef NODE_EXE_VERSION
55+
# define NODE_EXE_VERSION NODE_VERSION_STRING
5056
#endif
5157

5258
#define NODE_VERSION "v" NODE_VERSION_STRING

tools/msvs/msi/nodemsi.wixproj

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@
66
<ProductVersion>3.5</ProductVersion>
77
<ProjectGuid>{1d808ff0-b5a9-4be9-859d-b334b6f48be2}</ProjectGuid>
88
<SchemaVersion>2.0</SchemaVersion>
9-
<OutputName>node-v$(NodeVersion)-$(Platform)</OutputName>
9+
<OutputName>node-v$(FullVersion)-$(Platform)</OutputName>
1010
<OutputType>Package</OutputType>
1111
<EnableProjectHarvesting>True</EnableProjectHarvesting>
1212
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
1313
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
1414
<NodeVersion Condition=" '$(NodeVersion)' == '' ">0.0.0.0</NodeVersion>
1515
</PropertyGroup>
1616
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
17-
<OutputPath>..\..\..\$(Configuration)\</OutputPath>
17+
<OutputPath>..\..\..\</OutputPath>
1818
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
19-
<DefineConstants>Debug;ProductVersion=$(NodeVersion);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
19+
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
2020
</PropertyGroup>
2121
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
22-
<OutputPath>..\..\..\$(Configuration)\</OutputPath>
22+
<OutputPath>..\..\..\</OutputPath>
2323
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
24-
<DefineConstants>Debug;ProductVersion=$(NodeVersion);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
24+
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
2525
</PropertyGroup>
2626
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
27-
<OutputPath>..\..\..\$(Configuration)\</OutputPath>
27+
<OutputPath>..\..\..\</OutputPath>
2828
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
29-
<DefineConstants>Debug;ProductVersion=$(NodeVersion);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
29+
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
3030
<Cultures>en-US</Cultures>
3131
</PropertyGroup>
3232
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
33-
<OutputPath>..\..\..\$(Configuration)\</OutputPath>
33+
<OutputPath>..\..\..\</OutputPath>
3434
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
35-
<DefineConstants>Debug;ProductVersion=$(NodeVersion);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
35+
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NoPerfCtr=$(NoPerfCtr);NpmSourceDir=..\..\..\deps\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
3636
</PropertyGroup>
3737
<PropertyGroup>
3838
<EnableProjectHarvesting>True</EnableProjectHarvesting>

0 commit comments

Comments
 (0)