mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
LV2: Add generated resources
This commit is contained in:
parent
e4b3eda5ef
commit
6fffbdae92
2 changed files with 10295 additions and 0 deletions
|
|
@ -0,0 +1,93 @@
|
|||
import argparse
|
||||
import os
|
||||
|
||||
BUNDLE_TEMPLATE = """juce::lv2::Bundle
|
||||
{{
|
||||
"{}",
|
||||
{{
|
||||
{}
|
||||
}}
|
||||
}}
|
||||
"""
|
||||
|
||||
BUNDLE_RESOURCE_TEMPLATE = """juce::lv2::BundleResource
|
||||
{{
|
||||
"{}",
|
||||
{}
|
||||
}}
|
||||
"""
|
||||
|
||||
FUNCTION_TEMPLATE = """#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace juce
|
||||
{{
|
||||
namespace lv2
|
||||
{{
|
||||
|
||||
struct BundleResource
|
||||
{{
|
||||
const char* name;
|
||||
const char* contents;
|
||||
}};
|
||||
|
||||
struct Bundle
|
||||
{{
|
||||
const char* name;
|
||||
std::vector<BundleResource> contents;
|
||||
|
||||
static std::vector<Bundle> getAllBundles();
|
||||
}};
|
||||
|
||||
}}
|
||||
}}
|
||||
|
||||
std::vector<juce::lv2::Bundle> juce::lv2::Bundle::getAllBundles()
|
||||
{{
|
||||
return {{
|
||||
{}
|
||||
}};
|
||||
}}
|
||||
"""
|
||||
|
||||
|
||||
def chunks(lst, n):
|
||||
for i in range(0, len(lst), n):
|
||||
yield lst[i:i + n]
|
||||
|
||||
|
||||
def get_chunked_string_literal(s):
|
||||
return ' '.join(map(lambda x: 'R"lv2ttl({})lv2ttl"'.format(''.join(x)), chunks(s, 8000)))
|
||||
|
||||
|
||||
def get_file_source_string(ttl):
|
||||
with open(ttl) as f:
|
||||
return BUNDLE_RESOURCE_TEMPLATE.format(os.path.basename(ttl),
|
||||
get_chunked_string_literal(f.read()))
|
||||
|
||||
|
||||
def generate_bundle_source(root, files):
|
||||
if len(files) == 0:
|
||||
return ""
|
||||
|
||||
return BUNDLE_TEMPLATE.format(os.path.basename(root),
|
||||
", ".join(get_file_source_string(os.path.join(root, ttl)) for ttl in files))
|
||||
|
||||
def filter_turtle(files):
|
||||
return [f for f in files if f.endswith(".ttl")]
|
||||
|
||||
|
||||
def filter_ttl_files(lv2_dir):
|
||||
for root, _, files in os.walk(args.lv2_dir):
|
||||
yield root, filter_turtle(files)
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("lv2_dir")
|
||||
args = parser.parse_args()
|
||||
|
||||
print(FUNCTION_TEMPLATE.format(", ".join(generate_bundle_source(root, files)
|
||||
for root, files in filter_ttl_files(args.lv2_dir)
|
||||
if len(files) != 0)),
|
||||
end = "\r\n")
|
||||
10202
modules/juce_audio_processors/format_types/lv2/juce_LV2Resources.h
Normal file
10202
modules/juce_audio_processors/format_types/lv2/juce_LV2Resources.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue