bug 1257689 - move YASM check to moz.configure. r=mshal
authorTed Mielczarek <ted@mielczarek.org>
Thu, 17 Mar 2016 19:15:01 -0400
changeset 289634 d5efe76a40b3e7d22a85e738b11cd1e567c1de16
parent 289633 c4ed371b3a335b4cffc43c370d2b3988ed03800b
child 289635 4af78cb017495e521731f0c60895289d051bc536
push id30108
push usercbook@mozilla.com
push dateTue, 22 Mar 2016 11:14:31 +0000
treeherdermozilla-central@ea6298e1b4f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1257689
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1257689 - move YASM check to moz.configure. r=mshal MozReview-Commit-ID: KU3eSCsykPl
build/moz.configure/init.configure
config/config.mk
moz.configure
old-configure.in
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -271,16 +271,17 @@ def wanted_mozconfig_variables(help):
          'MOZTTDIR',
          'PERL',
          'RPMBUILD',
          'TAR',
          'UNZIP',
          'USE_FC_FREETYPE',
          'WITHOUT_X',
          'XARGS',
+         'YASM',
          'ZIP',
      ])
 
 
 @depends(mozconfig, wanted_mozconfig_variables, '--help')
 def mozconfig_options(mozconfig, wanted_mozconfig_variables, help):
     if mozconfig['path']:
         helper = command_line_helper()
--- a/config/config.mk
+++ b/config/config.mk
@@ -133,17 +133,17 @@ TOUCH ?= touch
 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
 
 # determine debug-related options
 _DEBUG_ASFLAGS :=
 _DEBUG_CFLAGS :=
 _DEBUG_LDFLAGS :=
 
 ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS))
-  ifeq ($(AS),yasm)
+  ifeq ($(AS),$(YASM))
     ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
       _DEBUG_ASFLAGS += -g cv8
     else
       ifneq ($(OS_ARCH),Darwin)
         _DEBUG_ASFLAGS += -g dwarf2
       endif
     endif
   else
--- a/moz.configure
+++ b/moz.configure
@@ -115,16 +115,62 @@ def perl_version_check(min_version):
     def require_full_perl_installation(has_full_perl_installation):
         if not has_full_perl_installation:
             error('Cannot find Config.pm or $Config{archlib}. '
                   'A full perl installation is required.')
 
 perl_version_check('5.006')
 
 
+# yasm detection
+# ==============================================================
+yasm = check_prog('YASM', ['yasm'], allow_missing=True)
+
+@depends(yasm)
+@checking('yasm version')
+@advanced
+def yasm_version(yasm):
+    if yasm:
+        import subprocess
+        try:
+            version = Version(subprocess.check_output(
+                [yasm, '--version']
+            ).splitlines()[0].split()[1])
+            # Until we move all the yasm consumers out of old-configure.
+            # bug 1257904
+            add_old_configure_assignment('_YASM_MAJOR_VERSION', version.major)
+            add_old_configure_assignment('_YASM_MINOR_VERSION', version.minor)
+            return version
+        except subprocess.CalledProcessError as e:
+            error('Failed to get yasm version: %s' % e.message)
+
+@depends(yasm, target)
+def yasm_asflags(yasm, target):
+    if yasm:
+        asflags = {
+            ('OSX', 'x86'): '-f macho32',
+            ('OSX', 'x86_64'): '-f macho64',
+            ('WINNT', 'x86'): '-f win32',
+            ('WINNT', 'x86_64'): '-f x64',
+        }.get((target.os, target.cpu), None)
+        if asflags is None:
+            # We're assuming every x86 platform we support that's
+            # not Windows or Mac is ELF.
+            if target.cpu == 'x86':
+                asflags = '-f elf32'
+            elif target.cpu == 'x86_64':
+                asflags = '-f elf64'
+        if asflags:
+            asflags += ' -rnasm -pnasm'
+            set_config('YASM_ASFLAGS', asflags)
+            set_config('HAVE_YASM', '1')
+            # Until the YASM variable is not necessary in old-configure.
+            add_old_configure_assignment('YASM', '1')
+        return asflags
+
 # Miscellaneous programs
 # ==============================================================
 check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
 check_prog('TAR', ('gnutar', 'gtar', 'tar'))
 check_prog('UNZIP', ('unzip',))
 check_prog('XARGS', ('xargs',))
 check_prog('ZIP', ('zip',))
 
--- a/old-configure.in
+++ b/old-configure.in
@@ -2601,69 +2601,16 @@ if test -n "$_USE_SYSTEM_NSS"; then
 fi
 
 if test -n "$MOZ_SYSTEM_NSS"; then
    NSS_LIBS="$NSS_LIBS -lcrmf"
 else
    NSS_CFLAGS="-I${DIST}/include/nss"
 fi
 
-dnl ======================
-dnl Detect yasm
-dnl ======================
-
-AC_MSG_CHECKING([for YASM assembler])
-AC_CHECK_PROGS(YASM, yasm, "")
-
-if test -n "$YASM"; then
-  AC_MSG_CHECKING([yasm version])
-  dnl Pull out yasm's version string
-  YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
-  _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
-  _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
-  _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
-  _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
-  AC_MSG_RESULT([$_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.$_YASM_RELEASE ($YASM_VERSION)])
-
-  # Determine proper yasm arguments.
-  YASM_ASFLAGS=
-  case "$OS_ARCH:$CPU_ARCH" in
-    Darwin:x86)
-      YASM_ASFLAGS="-f macho32 -rnasm -pnasm"
-    ;;
-    Darwin:x86_64)
-      YASM_ASFLAGS="-f macho64 -rnasm -pnasm"
-    ;;
-    WINNT:x86_64)
-      YASM_ASFLAGS="-f x64 -rnasm -pnasm"
-    ;;
-    WINNT:x86)
-      YASM_ASFLAGS="-f win32 -rnasm -pnasm"
-    ;;
-    *:x86)
-      if $CC -E -dM -</dev/null | grep -q __ELF__; then
-        YASM_ASFLAGS="-f elf32 -rnasm -pnasm"
-      fi
-    ;;
-    *:x86_64)
-      if $CC -E -dM -</dev/null | grep -q __ELF__; then
-        YASM_ASFLAGS="-f elf64 -rnasm -pnasm"
-      fi
-    ;;
-    *)
-      # yasm doesn't support other architectures, so just disable it.
-      YASM=
-  esac
-  if test -z "$YASM_ASFLAGS"; then
-    # If we didn't get YASM_ASFLAGS, we shouldn't be using yasm.
-    YASM=
-  fi
-fi
-AC_SUBST(YASM_ASFLAGS)
-
 if test -z "$SKIP_LIBRARY_CHECKS"; then
 dnl system JPEG support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-jpeg,
 [  --with-system-jpeg[=PFX]
                           Use system libjpeg [installed at prefix PFX]],
     JPEG_DIR=$withval)