From 8a4df21de88bc8cac9a48ba5c6e38c97c0af0c16 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 31 Oct 2018 12:56:48 +0100 Subject: [PATCH] here comes a helper script run python3 ./setup.py in the root directory, this will create a meson.build and a directory called subdirectry. You can now simply use the meson.build script as "main" project, all other projects will be build in this. --- meson.build.in | 10 +++++++++ setup.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 meson.build.in create mode 100755 setup.py diff --git a/meson.build.in b/meson.build.in new file mode 100644 index 00000000..48aedf3d --- /dev/null +++ b/meson.build.in @@ -0,0 +1,10 @@ +project('efl-examples', + 'c', + version: '1.0' +) + +subprojects = $subprojects + +foreach subp : subprojects + subproject(subp) +endforeach diff --git a/setup.py b/setup.py new file mode 100755 index 00000000..11b1df0b --- /dev/null +++ b/setup.py @@ -0,0 +1,59 @@ +#!/usr/bin/python3 +import os +from string import Template + +supported_languages = ["c", "csharp", "cxx"] +directories = ["apps", "reference", "tutorial"] # "examples", "legacy-examples" +goals = [] +subprojects = [] + +class SubProjectGoal: + def __init__(self, language, path): + self.language = language + self.path = path + + def verify(self): + assert os.path.isdir(self.path) + assert os.path.isfile(os.path.join(self.path, 'meson.build')) + + def flush(self): + os.symlink(os.path.join('..', self.path), os.path.realpath(os.path.join('subprojects', self.link_file_name()))) + + def link_file_name(self): + return self.language+'-'+os.path.basename(self.path) + +for directory in directories: + for lang in supported_languages: + explore_dir = os.path.join(directory, lang) + if os.path.isdir(explore_dir): + meson_build_file = os.path.join(explore_dir, "meson.build") + if os.path.isfile(meson_build_file): + goals.append(SubProjectGoal(lang, explore_dir)) + else: + for content in os.listdir(explore_dir): + sub = os.path.join(explore_dir, content) + if os.path.isdir(sub): + goals.append(SubProjectGoal(lang, sub)) + +if not os.path.isdir('./subprojects'): + os.mkdir('./subprojects') +else: + for content in os.listdir('./subprojects'): + os.unlink(os.path.join('subprojects', content)) + +for subproject in goals: + subproject.verify() + subproject.flush() + subprojects.append(subproject.link_file_name()) + +content = { 'subprojects' : '[\''+'\',\''.join(subprojects)+'\']'} + +meson_in = open('meson.build.in') +meson_temp = Template(meson_in.read()) +content = meson_temp.substitute(content) + +if os.path.isfile('meson.build'): + os.unlink('meson.build') + +meson_out = open('meson.build', 'a') +meson_out.write(content)