summaryrefslogtreecommitdiffstats
path: root/third_party/yasm/yasm_compile.gypi
blob: 52760cc04cced1098b8b22b4d383160a88e5de0e (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
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This is an gyp include to use YASM for compiling assembly files.
#
# Files to be compiled with YASM should have an extension of .asm.
#
# There are two variables for this include:
# yasm_flags : Pass additional flags into YASM.
# yasm_output_path : Output directory for the compiled object files.
#
# Sample usage:
# 'sources': [
#   'ultra_optimized_awesome.asm',
# ],
# 'variables': {
#   'yasm_flags': [
#     '-I', 'assembly_include',
#   ],
#   'yasm_output_path': '<(SHARED_INTERMEDIATE_DIR)/project',
# },
# 'includes': [
#   'third_party/yasm/yasm_compile.gypi'
# ],

{
  'variables': {
    'yasm_flags': [],

    'conditions': [
      [ 'use_system_yasm==0', {
        'yasm_path': '<(PRODUCT_DIR)/yasm<(EXECUTABLE_SUFFIX)',
      }, {
        'yasm_path': '<!(which yasm)',
      }],

      # Define yasm_flags that pass into YASM.
      [ 'os_posix==1 and OS!="mac" and target_arch=="ia32"', {
        'yasm_flags': [
          '-felf32',
          '-m', 'x86',
        ],
      }],
      [ 'os_posix==1 and OS!="mac" and target_arch=="x64"', {
        'yasm_flags': [
          '-DPIC',
          '-felf64',
          '-m', 'amd64',
        ],
      }],
      [ 'OS=="mac" and target_arch=="ia32"', {
        'yasm_flags': [
          '-fmacho32',
          '-m', 'x86',
        ],
      }],
      [ 'OS=="win" and target_arch=="ia32"', {
        'yasm_flags': [
          '-DPREFIX',
          '-fwin32',
          '-m', 'x86',
        ],
      }],

      # Define output extension.
      ['OS=="win"', {
        'asm_obj_extension': 'obj',
      }, {
        'asm_obj_extension': 'o',
      }],
    ],
  },  # variables

  'conditions': [
    # Only depend on YASM on x86 systems, do this so that compiling
    # .asm files for ARM will fail.
    ['use_system_yasm==0 and ( target_arch=="ia32" or target_arch=="x64" )', {
      'dependencies': [
        '<(DEPTH)/third_party/yasm/yasm.gyp:yasm#host',
      ],
    }],
  ],  # conditions

  'rules': [
    {
      'rule_name': 'assemble',
      'extension': 'asm',
      'inputs': [ '<(yasm_path)', ],
      'outputs': [
        '<(yasm_output_path)/<(RULE_INPUT_ROOT).<(asm_obj_extension)',
      ],
      'action': [
        '<(yasm_path)',
        '<@(yasm_flags)',
        '-o', '<(yasm_output_path)/<(RULE_INPUT_ROOT).<(asm_obj_extension)',
        '<(RULE_INPUT_PATH)',
      ],
      'process_outputs_as_sources': 1,
      'message': 'Compile assembly <(RULE_INPUT_PATH).',
    },
  ],  # rules
}