Commit 01879b59 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1618766 - Properly find and use MT on Windows cross-builds. r=froydnj

- Remove the separate option() for MT, because it dates back from when
  we needed `MT` not being an absolute path, but that hasn't been true
  since bug 1290040.

- Extend what was done in bug 1617794 to MT, although the long term move
  is to not rely on MT at all.

- Patch leftovers from bug 1613799.

Differential Revision: https://phabricator.services.mozilla.com/D64712

--HG--
extra : moz-landing-system : lando
parent f9285c19
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -433,13 +433,6 @@ set_config('HOST_LINKER_LIBPATHS', host_linker_libpaths)
set_config('HOST_LINKER_LIBPATHS_BAT', host_linker_libpaths_bat)


# The when is technically wrong and should be removed and the code that
# @depends on the option will need to be adapted when actual support for
# clang-cl cross-builds emerge.
option(env='MT', nargs=1, help='Path to the Microsoft Manifest Tool',
       when=host_is_windows)


@depends(valid_windows_sdk_dir, valid_ucrt_sdk_dir, host)
@imports(_from='os', _import='environ')
def sdk_bin_path(valid_windows_sdk_dir, valid_ucrt_sdk_dir, host):
@@ -464,15 +457,20 @@ def sdk_bin_path(valid_windows_sdk_dir, valid_ucrt_sdk_dir, host):
    return result


mt = check_prog('MT', ('mt.exe',), input='MT',
                paths=sdk_bin_path, when=host_is_windows)
# allow_missing=True for mingw builds, until bug 1617793
mt = check_prog('MT', ('mt.exe',), allow_missing=True, paths=sdk_bin_path)


# Check that MT is not something unexpected like "magnetic tape manipulation
# utility".
@depends_if(mt)
@depends(mt, wine)
@checking('whether MT is really Microsoft Manifest Tool', lambda x: bool(x))
def valid_mt(path):
def valid_mt(path, wine):
    if not path:
        return None
    if wine and path.lower().endswith('.exe'):
        out = check_cmd_output(wine, path, onerror=lambda: '').splitlines()
    else:
        out = check_cmd_output(path, onerror=lambda: '').splitlines()
    out = '\n'.join(l for l in out
                    if 'Microsoft (R) Manifest Tool' in l)
+6 −6
Original line number Diff line number Diff line
@@ -469,7 +469,7 @@ ifdef MSMANIFEST_TOOL
		exit 1; \
	elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
		echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
		$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
		$(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
	fi
endif	# MSVC with manifest tool
else # !WINNT || GNU_CC
@@ -494,7 +494,7 @@ ifdef MSMANIFEST_TOOL
		exit 1; \
	elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
		echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
		$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
		$(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
	fi
endif	# MSVC with manifest tool
else
@@ -522,10 +522,10 @@ ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
	$(LINKER) -out:$@ -pdb:$(LINK_PDBFILE) $($@_OBJS) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
ifdef MSMANIFEST_TOOL
	@if test -f $@.manifest; then \
		$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
		rm -f $@.manifest; \
		echo "Manifest in objdir is not supported"; \
		exit 1; \
	elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
		$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
		$(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
	fi
endif	# MSVC with manifest tool
else
@@ -620,7 +620,7 @@ ifdef EMBED_MANIFEST_AT
		exit 1; \
	elif test -f '$(srcdir)/$@.manifest'; then \
		echo 'Embedding manifest from $(srcdir_rel)/$@.manifest'; \
		$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$@.manifest' -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
		$(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$@.manifest' -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
	fi
endif   # EMBED_MANIFEST_AT
endif	# MSVC with manifest tool
+7 −5
Original line number Diff line number Diff line
@@ -133,6 +133,13 @@ js_option(env='MOZ_PGO', help='Build with profile guided optimizations')

set_config('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))


wine = check_prog(
    'WINE', ['wine'], allow_missing=True,
    when=depends(target, host, compile_environment)(
        lambda t, h, c: c and t.kernel == 'WINNT' and h.kernel == 'Linux'))


include('build/moz.configure/toolchain.configure',
        when='--enable-compile-environment')

@@ -536,11 +543,6 @@ check_prog('HFS_TOOL', extra_programs.HFS_TOOL,
check_prog('RPMBUILD', extra_programs.RPMBUILD,
           allow_missing=True)

wine = check_prog(
    'WINE', ['wine'], allow_missing=True,
    when=depends(target, host, compile_environment)(
        lambda t, h, c: c and t.kernel == 'WINNT' and h.kernel == 'Linux'))


@depends(target)
@imports('os')