summaryrefslogtreecommitdiff
path: root/system/packager/packager.mk
blob: bf968e3dc1d26df0a3e49b9b34c57c2a0bd54879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# == | Makefile Targets | =============================================================================================

libs:: stage-package

install::
	$(error "make install" is no longer supported on any target operating system. Use "make package" instead)

ifeq ($(OS_ARCH),WINNT)
ifndef MAKENSISU
installer::
	$(error "make installer" requires NSIS)
endif # MAKENSISU
else
installer::
	$(error "make installer" only supports Windows at this time)
endif

# ---------------------------------------------------------------------------------------------------------------------

# Handle the package manifest(s) if it is used
ifdef MOZ_PKG_MANIFEST_P
MOZ_PKG_MANIFEST = package-manifest

$(MOZ_PKG_MANIFEST): $(MOZ_PKG_MANIFEST_P) $(GLOBAL_DEPS)
	$(call py_action,preprocessor,$(DEFINES) $(ACDEFINES) $< -o $@)

GARBAGE += $(MOZ_PKG_MANIFEST)
endif

# ---------------------------------------------------------------------------------------------------------------------

# Create the mozbuildinfo json file
.PHONY: json-metadata
json-metadata:
	@$(RM) -f $(DIST)/$(PKG_JSON_FILENAME)
	$(PYTHON) $(MOZINST_PATH)/informulate.py \
		$(DIST)/$(PKG_JSON_FILENAME) \
		BUILDID=$(BUILDID) \
		MOZ_PKG_PLATFORM=$(PKG_BUILD_TARGET)

# ---------------------------------------------------------------------------------------------------------------------

# Stage and strip the package
stage-package: $(MOZ_PKG_MANIFEST) json-metadata
	@echo 'Staging application files...'
	OMNIJAR_NAME=$(OMNIJAR_NAME) \
	NO_PKG_FILES="$(NO_PKG_FILES)" \
	$(PYTHON) $(MOZINST_PATH)/packager.py $(DEFINES) $(ACDEFINES) \
		--format $(MOZ_PACKAGER_FORMAT) \
		$(if $(MOZ_PKG_REMOVALS),$(addprefix --removals ,$(MOZ_PKG_REMOVALS))) \
		$(if $(filter-out 0,$(MOZ_PKG_FATAL_WARNINGS)),,--ignore-errors) \
		$(if $(OPTIMIZEJARS),--optimizejars) \
		$(addprefix --compress ,$(JAR_COMPRESSION)) \
		$(MOZ_PKG_MANIFEST) '$(DIST)' '$(DIST)'/$(PKG_STAGE_DIR)$(if $(MOZ_PKG_MANIFEST),,$(_BINPATH)) \
		$(if $(filter omni,$(MOZ_PACKAGER_FORMAT)),$(if $(NON_OMNIJAR_FILES),--non-resource $(NON_OMNIJAR_FILES)))
	$(PYTHON) $(MOZINST_PATH)/find-dupes.py $(DIST)/$(PKG_STAGE_DIR)
	@(cd $(DIST)/$(PKG_STAGE_DIR) && $(CREATE_PRECOMPLETE_CMD))

# ---------------------------------------------------------------------------------------------------------------------

# Package the application as an archive
archive: stage-package
	@echo 'Compressing application archive...'
ifeq ($(OS_ARCH),WINNT)
	cd $(DIST); $(CYGWIN_WRAPPER) $(PKG_ARCHIVER_CMD) $(PKG_ARCHIVE_FILENAME) $(PKG_STAGE_DIR)
else
	cd $(DIST); XZ_OPT=-9e $(PKG_ARCHIVER_CMD) $(PKG_ARCHIVE_FILENAME) $(PKG_STAGE_DIR)
endif

# ---------------------------------------------------------------------------------------------------------------------

update: $(call mkdir_deps,$(ABS_DIST)/$(PKG_STAGE_DIR))
	@echo 'Creating update mar (xz compressed)...'
	MAR=$(DIST)/host/bin/mar$(HOST_BIN_SUFFIX) \
	  $(MOZILLA_DIR)/system/packager/make-update.sh \
	  '$(DIST)/$(PKG_UPDATE_FILENAME)' '$(DIST)/$(PKG_STAGE_DIR)'

# ---------------------------------------------------------------------------------------------------------------------

update-bz2: $(call mkdir_deps,$(ABS_DIST)/$(PKG_STAGE_DIR))
	@echo 'Creating update mar (bz2 compressed)...'
	MAR_OLD_FORMAT=1 MAR=$(DIST)/host/bin/mar$(HOST_BIN_SUFFIX) \
	  $(MOZILLA_DIR)/system/packager/make-update.sh \
	  '$(DIST)/$(PKG_BASENAME).complete.mar' '$(DIST)/$(PKG_STAGE_DIR)'

# ---------------------------------------------------------------------------------------------------------------------

# Package debugging symbols
.PHONY: symbols
symbols:
ifeq ($(OS_ARCH),WINNT)
	@echo 'Staging debugging symbols...'
	@$(RM) -rf $(DIST)/$(PKG_SYMBOLS_STAGE_DIR) $(DIST)/$(PKG_SYMBOLS_FILENAME)
	cd $(topobjdir); find . -type f -name "*.pdb" \
		-not -path "./dist/*" \
		-not -name "generated.pdb" \
		-not -name "vc*.pdb" \
		-exec install -Dv {} ./dist/$(PKG_SYMBOLS_STAGE_DIR)/{} \;
	@echo 'Compressing debugging symbols...'
	cd $(DIST); $(CYGWIN_WRAPPER) $(PKG_ARCHIVER_CMD) $(PKG_SYMBOLS_FILENAME) $(PKG_SYMBOLS_STAGE_DIR) 
else
	$(error "make symbols" only supports Windows at this time)
endif

# ---------------------------------------------------------------------------------------------------------------------

# For some reason when manually regenerating the chrome files with a fully built dist/bin it fucks up compiling
# the startupcache.
# So we only invoke this phony-target purging and regenerating when the application is NOT fully built.
# Otherwise one should treat the locale and skin targets like any other packaging target, namely, issuing a build
# command to regenerate.
# tl;dr hacks are hack-y.
.PHONY: regenerate-chrome
regenerate-chrome:
	@echo '(Re)generating chrome files...'
	@test -f $(topobjdir)/source-repo.h || $(MAKE) -C $(DEPTH) export
	@$(RM) -rf $(DIST)/bin/chrome.manifest $(DIST)/bin/chrome;
	@$(MAKE) -C $(DEPTH) chrome

# ---------------------------------------------------------------------------------------------------------------------

# Create an en-US language pack without needing a whole custom build system codepath
.PHONY: locale
locale:
	@$(RM) -rf $(DIST)/$(PKG_XPI_L10N_STAGE_DIR) $(DIST)/$(PKG_XPI_L10N_FILENAME)
	@test -f $(DIST)/bin/$(MOZ_APP_NAME)$(BIN_SUFFIX) || $(MAKE) regenerate-chrome
	@echo 'Staging l10n files...'
	@$(NSINSTALL) -D $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/chrome
	@$(TOOLCHAIN_PREFIX)cp -rv $(DIST)/bin/chrome/en-US.manifest $(DIST)/bin/chrome/en-US $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/chrome
	@echo manifest chrome/en-US.manifest > $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/chrome.manifest
	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
		$(GREPKGR_PATH)/locale-install.rdf.in -o $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/install.rdf)
	@echo 'Compressing l10n files...'
	cd $(DIST)/$(PKG_XPI_L10N_STAGE_DIR); $(ZIP) -Dr9X ../../$(PKG_XPI_L10N_FILENAME) *

# ---------------------------------------------------------------------------------------------------------------------

# Create an os-dependent skin without needing a whole custom build system codepath
.PHONY: skin
skin:
	@$(RM) -rf $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR) $(DIST)/$(PKG_XPI_SKIN_FILENAME)
	@test -f $(DIST)/bin/$(MOZ_APP_NAME)$(BIN_SUFFIX) || $(MAKE) regenerate-chrome
	@echo 'Staging theme files...'
	@$(NSINSTALL) -D $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/chrome
	@$(TOOLCHAIN_PREFIX)cp -rv $(DIST)/bin/chrome/classic.manifest $(DIST)/bin/chrome/classic $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/chrome
	@$(TOOLCHAIN_PREFIX)cp -rv $(DIST)/bin/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.manifest $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)
	@echo manifest chrome/classic.manifest >> $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/chrome.manifest
	$(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \
		$(GREPKGR_PATH)/skin-install.rdf.in -o $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/install.rdf)
	@echo 'Compressing theme files...'
	cd $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR); $(ZIP) -Dr9X ../../$(PKG_XPI_SKIN_FILENAME) *

# =====================================================================================================================