Skip to content

Commit

Permalink
Bug 1656141 - Create res and rc files based on the name of the binary…
Browse files Browse the repository at this point in the history
… they are linked into. r=firefox-build-system-reviewers,rstewart

This will allow creating separate res files for e.g. SIMPLE_PROGRAMS.

Differential Revision: https://phabricator.services.mozilla.com/D86155
  • Loading branch information
glandium committed Aug 7, 2020
1 parent 5a5a1ed commit 5919ab8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 59 deletions.
2 changes: 1 addition & 1 deletion config/create_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def generate_module_rc(binary='', rcinclude=None):
productname=overrides.get('WIN32_MODULE_PRODUCTNAME', display_name),
buildid=buildid,
)
with io.open('module.rc', 'w', encoding='latin1') as fh:
with io.open('{}.rc'.format(binary or 'module'), 'w', encoding='latin1') as fh:
fh.write(data)


Expand Down
4 changes: 2 additions & 2 deletions config/makefiles/rust.mk
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ ifdef RUST_PROGRAMS

GARBAGE_DIRS += $(RUST_TARGET)

force-cargo-program-build: $(RESFILE)
force-cargo-program-build: $(call resfile,module)
$(REPORT_BUILD)
$(call CARGO_BUILD) $(addprefix --bin ,$(RUST_CARGO_PROGRAMS)) $(cargo_target_flag) -- $(if $(RESFILE),-C link-arg=$(CURDIR)/$(RESFILE))
$(call CARGO_BUILD) $(addprefix --bin ,$(RUST_CARGO_PROGRAMS)) $(cargo_target_flag) -- $(addprefix -C link-arg=$(CURDIR)/,$(call resfile,module))

$(RUST_PROGRAMS): force-cargo-program-build ;

Expand Down
25 changes: 15 additions & 10 deletions config/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ ifndef INCLUDED_CONFIG_MK
include $(topsrcdir)/config/config.mk
endif

ifndef INCLUDED_VERSION_MK
include $(MOZILLA_DIR)/config/version.mk
endif

USE_AUTOTARGETS_MK = 1
include $(MOZILLA_DIR)/config/makefiles/makeutils.mk

Expand Down Expand Up @@ -403,6 +399,12 @@ everything::
# Dependencies which, if modified, should cause everything to rebuild
GLOBAL_DEPS += Makefile $(addprefix $(DEPTH)/config/,$(INCLUDED_AUTOCONF_MK)) $(MOZILLA_DIR)/config/config.mk

ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
resfile = $(notdir $1).res
else
resfile =
endif

##############################################
ifdef COMPILE_ENVIRONMENT
compile:: host target
Expand Down Expand Up @@ -452,11 +454,11 @@ endef
# PROGRAM = Foo
# creates OBJS, links with LIBS to create Foo
#
$(PROGRAM): $(PROGOBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(RESFILE) $(GLOBAL_DEPS) $(call mkdir_deps,$(FINAL_TARGET))
$(PROGRAM): $(PROGOBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(call resfile,$(PROGRAM)) $(GLOBAL_DEPS) $(call mkdir_deps,$(FINAL_TARGET))
$(REPORT_BUILD)
@$(RM) $@.manifest
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
$(LINKER) -OUT:$@ -PDB:$(LINK_PDBFILE) -IMPLIB:$(basename $(@F)).lib $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $($(notdir $@)_OBJS) $(RESFILE) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
$(LINKER) -OUT:$@ -PDB:$(LINK_PDBFILE) -IMPLIB:$(basename $(@F)).lib $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $($(notdir $@)_OBJS) $(filter %.res,$^) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
ifdef MSMANIFEST_TOOL
@if test -f [email protected]; then \
echo "Manifest in objdir is not supported"; \
Expand All @@ -467,7 +469,7 @@ ifdef MSMANIFEST_TOOL
fi
endif # MSVC with manifest tool
else # !WINNT || GNU_CC
$(call EXPAND_CC_OR_CXX,$@) -o $@ $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) $($(notdir $@)_OBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS)
$(call EXPAND_CC_OR_CXX,$@) -o $@ $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) $($(notdir $@)_OBJS) $(filter %.res,$^) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS)
$(call py_action,check_binary,--target $@)
endif # WINNT && !GNU_CC

Expand Down Expand Up @@ -598,12 +600,12 @@ endif
# symlinks back to the originals. The symlinks are a no-op for stabs debugging,
# so no need to conditionalize on OS version or debugging format.

$(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
$(SHARED_LIBRARY): $(OBJS) $(call resfile,$(SHARED_LIBRARY)) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
$(REPORT_BUILD)
ifndef INCREMENTAL_LINKER
$(RM) $@
endif
$(MKSHLIB) $($@_OBJS) $(RESFILE) $(LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS)
$(MKSHLIB) $($@_OBJS) $(filter %.res,$^) $(LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS)
$(call py_action,check_binary,--target $@)

ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
Expand Down Expand Up @@ -859,7 +861,7 @@ endif

endif

$(RESFILE): %.res: $(RCFILE)
%.res: $(or $(RCFILE),%.rc)
$(REPORT_BUILD)
@echo Creating Resource file: $@
ifdef GNU_CC
Expand All @@ -868,6 +870,9 @@ else
$(call WINEWRAP,$(RC)) $(RCFLAGS) -r $(DEFINES) $(INCLUDES:-I%=-I$(call relativize,%)) $(OUTOPTION)$@ $(call relativize,$<)
endif

$(notdir $(addsuffix .rc,$(PROGRAM) $(SHARED_LIBRARY) module)): %.rc: $(RCINCLUDE) $(MOZILLA_DIR)/config/create_rc.py
$(PYTHON3) $(MOZILLA_DIR)/config/create_rc.py '$(if $(filter module,$*),,$*)' '$(RCINCLUDE)'

# Cancel GNU make built-in implicit rules
MAKEFLAGS += -r

Expand Down
46 changes: 0 additions & 46 deletions config/version.mk

This file was deleted.

0 comments on commit 5919ab8

Please sign in to comment.