The Meson Build System http://mesonbuild.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
3.3 KiB

# Copyright 2019 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
meson_executable_template = '''project('{project_name}', '{language}',
version : '{version}',
default_options : [{default_options}])
executable('{executable}',
{sourcespec},{depspec}
install : true)
'''
meson_jar_template = '''project('{project_name}', '{language}',
version : '{version}',
default_options : [{default_options}])
jar('{executable}',
Fix meson_jar_template It was generating an extra comma. The Meson build system Version: 0.54.0 Source dir: /tmp/tmp34halxhe Build dir: /tmp/tmp34halxhe/build Build type: native build meson.build:6:15: ERROR: Expecting rparen got comma. 'Foo.java',, ^ For a block that started at 5,3 jar('tmp34halxhe', ^ A full log can be found at /tmp/tmp34halxhe/build/meson-logs/meson-log.txt Using "tmp34halxhe" (name of current directory) as project name. Using "tmp34halxhe" (project name) as name of executable to build. Detected source files: Foo.java Detected language: java Generated meson.build file: project('tmp34halxhe', 'java', version : '0.1', default_options : ['warning_level=3']) jar('tmp34halxhe', 'Foo.java',, main_class: tmp34halxhe, install : true) It was also missing quotes around the main class name. The Meson build system Version: 0.54.0 Source dir: /tmp/tmpjm5cg44a Build dir: /tmp/tmpjm5cg44a/build Build type: native build Project name: tmpjm5cg44a Project version: 0.1 Java compiler for the host machine: javac (unknown 1.8.0) Host machine cpu family: x86_64 Host machine cpu: x86_64 meson.build:5:0: ERROR: Unknown variable "tmpjm5cg44a". A full log can be found at /tmp/tmpjm5cg44a/build/meson-logs/meson-log.txt Using "tmpjm5cg44a" (name of current directory) as project name. Using "tmpjm5cg44a" (project name) as name of executable to build. Detected source files: Foo.java Detected language: java Generated meson.build file: project('tmpjm5cg44a', 'java', version : '0.1', default_options : ['warning_level=3']) jar('tmpjm5cg44a', 'Foo.java', main_class: tmpjm5cg44a, install : true)
5 years ago
{sourcespec},{depspec}
main_class: '{main_class}',
install : true)
'''
def create_meson_build(options):
if options.type != 'executable':
raise SystemExit('\nGenerating a meson.build file from existing sources is\n'
'supported only for project type "executable".\n'
'Run meson init in an empty directory to create a sample project.')
default_options = ['warning_level=3']
if options.language == 'cpp':
# This shows how to set this very common option.
default_options += ['cpp_std=c++14']
# If we get a meson.build autoformatter one day, this code could
# be simplified quite a bit.
formatted_default_options = ', '.join("'{}'".format(x) for x in default_options)
sourcespec = ',\n '.join("'{}'".format(x) for x in options.srcfiles)
depspec = ''
if options.deps:
depspec = '\n dependencies : [\n '
depspec += ',\n '.join("dependency('{}')".format(x)
for x in options.deps.split(','))
depspec += '],'
if options.language != 'java':
content = meson_executable_template.format(project_name=options.name,
language=options.language,
version=options.version,
executable=options.executable,
sourcespec=sourcespec,
depspec=depspec,
default_options=formatted_default_options)
else:
content = meson_jar_template.format(project_name=options.name,
language=options.language,
version=options.version,
executable=options.executable,
main_class=options.name,
sourcespec=sourcespec,
depspec=depspec,
default_options=formatted_default_options)
open('meson.build', 'w').write(content)
print('Generated meson.build file:\n\n' + content)