aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml4
-rw-r--r--mesonbuild/backend/ninjabackend.py16
-rw-r--r--mesonbuild/backend/vs2010backend.py8
-rw-r--r--mesonbuild/mesonlib.py1
-rwxr-xr-x[-rw-r--r--]msi/createmsi.py233
-rwxr-xr-xrun_unittests.py4
-rw-r--r--test cases/common/138 include order/ctsub/copyfile.py6
-rw-r--r--test cases/common/138 include order/ctsub/emptyfile.c0
-rw-r--r--test cases/common/138 include order/ctsub/main.h1
-rw-r--r--test cases/common/138 include order/ctsub/meson.build9
-rw-r--r--test cases/common/138 include order/meson.build2
-rw-r--r--test cases/common/138 include order/sub4/meson.build2
-rw-r--r--test cases/common/87 declare dep/entity/meson.build2
13 files changed, 187 insertions, 101 deletions
diff --git a/.travis.yml b/.travis.yml
index 3a4ef5d..5b6e022 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -45,6 +45,6 @@ script:
ci_env=`bash <(curl -s https://codecov.io/env)`
docker run $ci_env -v ${PWD}/.coverage:/root/.coverage \
withgit \
- /bin/sh -c "cd /root && CC=$CC CXX=$CXX OBJC=$CC OBJCXX=$CXX ./run_tests.py --cov -- $MESON_ARGS && chmod -R a+rwX .coverage"
+ /bin/sh -c "cd /root && CC=$CC CXX=$CXX OBJC=$CC OBJCXX=$CXX ./run_tests.py -- $MESON_ARGS && chmod -R a+rwX .coverage"
fi
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then SDKROOT=$(xcodebuild -version -sdk macosx Path) OBJC=$CC OBJCXX=$CXX ./run_tests.py --cov --backend=ninja -- $MESON_ARGS ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then SDKROOT=$(xcodebuild -version -sdk macosx Path) OBJC=$CC OBJCXX=$CXX ./run_tests.py --backend=ninja -- $MESON_ARGS ; fi
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index dce3b80..bff173a 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2038,6 +2038,12 @@ rule FORTRAN_DEP_HACK
# Add compiler args and include paths from several sources; defaults,
# build options, external dependencies, etc.
commands += self.generate_basic_compiler_args(target, compiler, no_warn_args)
+ # Add custom target dirs as includes automatically, but before
+ # target-specific include directories.
+ # XXX: Not sure if anyone actually uses this? It can cause problems in
+ # situations which increase the likelihood for a header name collision,
+ # such as in subprojects.
+ commands += self.get_custom_target_dir_include_args(target, compiler)
# Add include dirs from the `include_directories:` kwarg on the target
# and from `include_directories:` of internal deps of the target.
#
@@ -2081,14 +2087,12 @@ rule FORTRAN_DEP_HACK
# from external dependencies, internal dependencies, and from
# per-target `include_directories:`
#
- # We prefer headers in the build dir and the custom target dir over the
- # source dir since, for instance, the user might have an
- # srcdir == builddir Autotools build in their source tree. Many
- # projects that are moving to Meson have both Meson and Autotools in
- # parallel as part of the transition.
+ # We prefer headers in the build dir over the source dir since, for
+ # instance, the user might have an srcdir == builddir Autotools build
+ # in their source tree. Many projects that are moving to Meson have
+ # both Meson and Autotools in parallel as part of the transition.
if target.implicit_include_directories:
commands += self.get_source_dir_include_args(target, compiler)
- commands += self.get_custom_target_dir_include_args(target, compiler)
if target.implicit_include_directories:
commands += self.get_build_dir_include_args(target, compiler)
# Finally add the private dir for the target to the include path. This
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 00ee34a..ec5ad7d 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -763,6 +763,10 @@ class Vs2010Backend(backends.Backend):
# This is where Visual Studio will insert target_args, target_defines,
# etc, which are added later from external deps (see below).
args += ['%(AdditionalOptions)', '%(PreprocessorDefinitions)', '%(AdditionalIncludeDirectories)']
+ # Add custom target dirs as includes automatically, but before
+ # target-specific include dirs. See _generate_single_compile() in
+ # the ninja backend for caveats.
+ args += ['-I' + arg for arg in generated_files_include_dirs]
# Add include dirs from the `include_directories:` kwarg on the target
# and from `include_directories:` of internal deps of the target.
#
@@ -789,14 +793,12 @@ class Vs2010Backend(backends.Backend):
if l in file_args:
file_args[l] += args
# The highest priority includes. In order of directory search:
- # target private dir, target build dir, generated sources include dirs,
- # target source dir
+ # target private dir, target build dir, target source dir
for args in file_args.values():
t_inc_dirs = [self.relpath(self.get_target_private_dir(target),
self.get_target_dir(target))]
if target.implicit_include_directories:
t_inc_dirs += ['.']
- t_inc_dirs += generated_files_include_dirs
if target.implicit_include_directories:
t_inc_dirs += [proj_to_src_dir]
args += ['-I' + arg for arg in t_inc_dirs]
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 305f600..4862e23 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -707,6 +707,7 @@ def windows_proof_rmtree(f):
def unholder_array(entries):
result = []
+ entries = flatten(entries)
for e in entries:
if hasattr(e, 'held_object'):
e = e.held_object
diff --git a/msi/createmsi.py b/msi/createmsi.py
index 7b7ba68..921e2ac 100644..100755
--- a/msi/createmsi.py
+++ b/msi/createmsi.py
@@ -17,54 +17,11 @@
import sys, os, subprocess, shutil, uuid
from glob import glob
import platform
+import xml.etree.ElementTree as ET
sys.path.append(os.getcwd())
from mesonbuild import coredata
-xml_templ = '''<?xml version='1.0' encoding='windows-1252'?>
-<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
- <Product Name='Meson Build System' Manufacturer='The Meson Development Team'
- Id='%s'
- UpgradeCode='%s'
- Language='1033' Codepage='1252' Version='%s'>
- <Package Id='*' Keywords='Installer' Description="Meson %s installer"
- Comments='Meson is a high performance build system' Manufacturer='Meson development team'
- InstallerVersion='200' Languages='1033' Compressed='yes' SummaryCodepage='1252'
- %s />
-
- <Media Id="1" Cabinet="meson.cab" EmbedCab="yes" />
-
- <Directory Id='TARGETDIR' Name='SourceDir'>
- <Directory Id="%s">
- <Directory Id="INSTALLDIR" Name="Meson">
-'''
-
-xml_footer_templ = '''
- </Directory>
- </Directory>
- </Directory>
-
- <Feature Id="DefaultFeature" Level="1">
-%s
- </Feature>
-
- <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
- <UIRef Id="WixUI_InstallDir" />
-
- </Product>
-</Wix>
-'''
-
-file_templ = '''<File Id='%s' Name='%s' DiskId='1' Source='%s' />
-'''
-
-comp_ref_templ = '''<ComponentRef Id="%s" />
-'''
-
-path_addition_xml = '''<Environment Id="Environment" Name="PATH" Part="last" System="yes" Action="set" Value="[INSTALLDIR]"/>
-'''
-
-
def gen_guid():
return str(uuid.uuid4()).upper()
@@ -78,78 +35,180 @@ class Node:
class PackageGenerator:
def __init__(self):
+ self.product_name = 'Meson Build System'
+ self.manufacturer = 'The Meson Development Team'
self.version = coredata.version.replace('dev', '')
self.guid = 'DF5B3ECA-4A31-43E3-8CE4-97FC8A97212E'
self.update_guid = '141527EE-E28A-4D14-97A4-92E6075D28B2'
- self.main_xml = 'Meson.wxs'
- self.main_o = 'Meson.wixobj'
- self.bytesize = '32' if '32' in platform.architecture()[0] else '64'
- self.final_output = 'meson-%s-%s.msi' % (self.version, self.bytesize)
- self.staging_dir = 'dist'
- if self.bytesize == '64':
- self.platform_str = 'Platform="x64"'
+ self.main_xml = 'meson.wxs'
+ self.main_o = 'meson.wixobj'
+ self.bytesize = 32 if '32' in platform.architecture()[0] else 64
+ self.final_output = 'meson-%s-%d.msi' % (self.version, self.bytesize)
+ self.staging_dirs = ['dist', 'dist2']
+ if self.bytesize == 64:
self.progfile_dir = 'ProgramFiles64Folder'
- self.component_platform = 'Win64="yes"'
else:
- self.platform_sr = ''
self.progfile_dir = 'ProgramFilesFolder'
- self.component_platform = ''
+ self.component_num = 0
+ self.feature_properties = {
+ self.staging_dirs[0]: {
+ 'Id': 'MainProgram',
+ 'Title': 'Meson',
+ 'Description': 'Meson executables',
+ 'Level': '1',
+ 'Absent': 'disallow',
+ },
+ self.staging_dirs[1]: {
+ 'Id': 'NinjaProgram',
+ 'Title': 'Ninja',
+ 'Description': 'Ninja build tool',
+ 'Level': '1',
+ }
+ }
+ self.feature_components = {}
+ for sd in self.staging_dirs:
+ self.feature_components[sd] = []
def build_dist(self):
- if os.path.exists(self.staging_dir):
- shutil.rmtree(self.staging_dir)
+ for sdir in self.staging_dirs:
+ if os.path.exists(sdir):
+ shutil.rmtree(sdir)
+ main_stage, ninja_stage = self.staging_dirs
modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join('mesonbuild/modules/*'))]
modules = ['mesonbuild.modules.' + x for x in modules if not x.startswith('_')]
modulestr = ','.join(modules)
subprocess.check_call(['c:\\Python\python.exe',
'c:\\Python\Scripts\\cxfreeze',
'--target-dir',
- self.staging_dir,
+ main_stage,
'--include-modules',
modulestr,
'meson.py'])
- shutil.copy(shutil.which('ninja'), self.staging_dir)
- if not os.path.exists(os.path.join(self.staging_dir, 'meson.exe')):
+ if not os.path.exists(os.path.join(main_stage, 'meson.exe')):
sys.exit('Meson exe missing from staging dir.')
- if not os.path.exists(os.path.join(self.staging_dir, 'ninja.exe')):
+ os.mkdir(ninja_stage)
+ shutil.copy(shutil.which('ninja'), ninja_stage)
+ if not os.path.exists(os.path.join(ninja_stage, 'ninja.exe')):
sys.exit('Ninja exe missing from staging dir.')
-
def generate_files(self):
- assert(os.path.isdir(self.staging_dir))
- comp_ref_xml = ''
- nodes = {}
- with open(self.main_xml, 'w') as ofile:
- for root, dirs, files in os.walk(self.staging_dir):
+ self.root = ET.Element('Wix', {'xmlns': 'http://schemas.microsoft.com/wix/2006/wi'})
+ product = ET.SubElement(self.root, 'Product', {
+ 'Name': self.product_name,
+ 'Manufacturer': 'The Meson Development Team',
+ 'Id': self.guid,
+ 'UpgradeCode': self.update_guid,
+ 'Language': '1033',
+ 'Codepage': '1252',
+ 'Version': self.version,
+ })
+
+ package = ET.SubElement(product, 'Package', {
+ 'Id': '*',
+ 'Keywords': 'Installer',
+ 'Description': 'Meson %s installer' % self.version,
+ 'Comments': 'Meson is a high performance build system',
+ 'Manufacturer': 'The Meson Development Team',
+ 'InstallerVersion': '500',
+ 'Languages': '1033',
+ 'Compressed': 'yes',
+ 'SummaryCodepage': '1252',
+ })
+
+ if self.bytesize == 64:
+ package.set('Platform', 'x64')
+ ET.SubElement(product, 'Media', {
+ 'Id': '1',
+ 'Cabinet': 'meson.cab',
+ 'EmbedCab': 'yes',
+ })
+ targetdir = ET.SubElement(product, 'Directory', {
+ 'Id': 'TARGETDIR',
+ 'Name': 'SourceDir',
+ })
+ progfiledir = ET.SubElement(targetdir, 'Directory', {
+ 'Id' : self.progfile_dir,
+ })
+ installdir = ET.SubElement(progfiledir, 'Directory', {
+ 'Id': 'INSTALLDIR',
+ 'Name': 'Meson'})
+
+ ET.SubElement(product, 'Property', {
+ 'Id': 'WIXUI_INSTALLDIR',
+ 'Value': 'INSTALLDIR',
+ })
+ ET.SubElement(product, 'UIRef', {
+ 'Id': 'WixUI_FeatureTree',
+ })
+ for sd in self.staging_dirs:
+ assert(os.path.isdir(sd))
+ top_feature = ET.SubElement(product, 'Feature', {
+ 'Id': 'Complete',
+ 'Title': 'Meson ' + self.version,
+ 'Description': 'The complete package',
+ 'Display': 'expand',
+ 'Level': '1',
+ 'ConfigurableDirectory': 'INSTALLDIR',
+ })
+ for sd in self.staging_dirs:
+ nodes = {}
+ for root, dirs, files in os.walk(sd):
cur_node = Node(dirs, files)
nodes[root] = cur_node
- ofile.write(xml_templ % (self.guid, self.update_guid, self.version, self.version,
- self.platform_str, self.progfile_dir))
- self.component_num = 0
- self.create_xml(nodes, ofile, self.staging_dir)
- for i in range(self.component_num):
- comp_ref_xml += comp_ref_templ % ('ApplicationFiles%d' % i)
- ofile.write(xml_footer_templ % comp_ref_xml)
-
- def create_xml(self, nodes, ofile, root):
- cur_node = nodes[root]
+ self.create_xml(nodes, sd, installdir, sd)
+ self.build_features(nodes, top_feature, sd)
+ ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8',xml_declaration=True)
+ # ElementTree can not do prettyprinting so do it manually
+ import xml.dom.minidom
+ doc = xml.dom.minidom.parse(self.main_xml)
+ with open(self.main_xml, 'w') as of:
+ of.write(doc.toprettyxml())
+
+ def build_features(self, nodes, top_feature, staging_dir):
+ feature = ET.SubElement(top_feature, 'Feature', self.feature_properties[staging_dir])
+ for component_id in self.feature_components[staging_dir]:
+ ET.SubElement(feature, 'ComponentRef', {
+ 'Id': component_id,
+ })
+
+
+ def create_xml(self, nodes, current_dir, parent_xml_node, staging_dir):
+ cur_node = nodes[current_dir]
if cur_node.files:
- ofile.write("<Component Id='ApplicationFiles%d' Guid='%s' %s>\n" % (self.component_num, gen_guid(), self.component_platform))
+ component_id = 'ApplicationFiles%d' % self.component_num
+ comp_xml_node = ET.SubElement(parent_xml_node, 'Component', {
+ 'Id': component_id,
+ 'Guid': gen_guid(),
+ })
+ self.feature_components[staging_dir].append(component_id)
+ if self.bytesize == 64:
+ comp_xml_node.set('Win64', 'yes')
if self.component_num == 0:
- ofile.write(path_addition_xml)
+ ET.SubElement(comp_xml_node, 'Environment', {
+ 'Id': 'Environment',
+ 'Name': 'PATH',
+ 'Part': 'last',
+ 'System': 'yes',
+ 'Action': 'set',
+ 'Value': '[INSTALLDIR]',
+ })
self.component_num += 1
for f in cur_node.files:
- file_source = os.path.join(root, f).replace('\\', '\\\\')
- file_id = os.path.join(root, f).replace('\\', '_').replace('#', '_').replace('-', '_')
- ofile.write(file_templ % (file_id, f, file_source))
- ofile.write('</Component>\n')
+ file_source = os.path.join(current_dir, f).replace('\\', '\\\\')
+ file_id = os.path.join(current_dir, f).replace('\\', '_').replace('#', '_').replace('-', '_')
+ ET.SubElement(comp_xml_node, 'File', {
+ 'Id': file_id,
+ 'Name': f,
+ 'Source': os.path.join(current_dir, f),
+ })
for dirname in cur_node.dirs:
- dir_id = os.path.join(root, dirname).replace('\\', '_').replace('/', '_')
- ofile.write('''<Directory Id="%s" Name="%s">\n''' % (dir_id, dirname))
- self.create_xml(nodes, ofile, os.path.join(root, dirname))
- ofile.write('</Directory>\n')
-
+ dir_id = os.path.join(current_dir, dirname).replace('\\', '_').replace('/', '_')
+ dir_node = ET.SubElement(parent_xml_node, 'Directory', {
+ 'Id': dir_id,
+ 'Name': dirname,
+ })
+ self.create_xml(nodes, os.path.join(current_dir, dirname), dir_node, staging_dir)
def build_package(self):
wixdir = 'c:\\Program Files\\Wix Toolset v3.11\\bin'
diff --git a/run_unittests.py b/run_unittests.py
index 08ec774..6487496 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -899,7 +899,7 @@ class AllPlatformTests(BasePlatformTests):
raise Exception('Could not find someexe and somfxe commands')
# Check include order for 'someexe'
incs = [a for a in shlex.split(execmd) if a.startswith("-I")]
- self.assertEqual(len(incs), 8)
+ self.assertEqual(len(incs), 9)
# target private dir
self.assertPathEqual(incs[0], "-Isub4/someexe@exe")
# target build subdir
@@ -916,6 +916,8 @@ class AllPlatformTests(BasePlatformTests):
self.assertPathEqual(incs[6], "-Isub1")
# target internal dependency include_directories: source dir
self.assertPathBasenameEqual(incs[7], 'sub1')
+ # custom target include dir
+ self.assertPathEqual(incs[8], '-Ictsub')
# Check include order for 'somefxe'
incs = [a for a in shlex.split(fxecmd) if a.startswith('-I')]
self.assertEqual(len(incs), 9)
diff --git a/test cases/common/138 include order/ctsub/copyfile.py b/test cases/common/138 include order/ctsub/copyfile.py
new file mode 100644
index 0000000..ff42ac3
--- /dev/null
+++ b/test cases/common/138 include order/ctsub/copyfile.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import sys
+import shutil
+
+shutil.copyfile(sys.argv[1], sys.argv[2])
diff --git a/test cases/common/138 include order/ctsub/emptyfile.c b/test cases/common/138 include order/ctsub/emptyfile.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/common/138 include order/ctsub/emptyfile.c
diff --git a/test cases/common/138 include order/ctsub/main.h b/test cases/common/138 include order/ctsub/main.h
new file mode 100644
index 0000000..9d9acf3
--- /dev/null
+++ b/test cases/common/138 include order/ctsub/main.h
@@ -0,0 +1 @@
+#error "ctsub/main.h included"
diff --git a/test cases/common/138 include order/ctsub/meson.build b/test cases/common/138 include order/ctsub/meson.build
new file mode 100644
index 0000000..a242e07
--- /dev/null
+++ b/test cases/common/138 include order/ctsub/meson.build
@@ -0,0 +1,9 @@
+# https://github.com/mesonbuild/meson/pull/2291
+copy = find_program('copyfile.py')
+configure_file(input : 'main.h',
+ output : 'main.h',
+ command : [copy, '@INPUT@', '@OUTPUT@'])
+ctfile = custom_target('emptyfile',
+ input : 'emptyfile.c',
+ output : 'emptyfile.c',
+ command : [copy, '@INPUT@', '@OUTPUT@'])
diff --git a/test cases/common/138 include order/meson.build b/test cases/common/138 include order/meson.build
index c79cb0a..c370bb1 100644
--- a/test cases/common/138 include order/meson.build
+++ b/test cases/common/138 include order/meson.build
@@ -10,6 +10,8 @@ project('include order', 'c')
# 5. Include paths added via `include_directories:` of internal deps
# Within this, the build dir takes precedence over the source dir
+# Custom target dir with a built header
+subdir('ctsub')
# Defines an internal dep
subdir('sub1')
# Defines a per-target include path
diff --git a/test cases/common/138 include order/sub4/meson.build b/test cases/common/138 include order/sub4/meson.build
index ab4c455..c01edaa 100644
--- a/test cases/common/138 include order/sub4/meson.build
+++ b/test cases/common/138 include order/sub4/meson.build
@@ -1,4 +1,4 @@
-e = executable('someexe', 'main.c',
+e = executable('someexe', 'main.c', ctfile,
c_args : ['-I' + sub3],
include_directories : j,
dependencies : dep)
diff --git a/test cases/common/87 declare dep/entity/meson.build b/test cases/common/87 declare dep/entity/meson.build
index 80bbf36..3bfe13c 100644
--- a/test cases/common/87 declare dep/entity/meson.build
+++ b/test cases/common/87 declare dep/entity/meson.build
@@ -1,6 +1,6 @@
entity_lib = static_library('entity', 'entity1.c')
-entity_dep = declare_dependency(link_with : entity_lib,
+entity_dep = declare_dependency(link_with : [[entity_lib]],
include_directories : include_directories('.'),
sources : 'entity2.c',
compile_args : ['-DUSING_ENT=1'],