Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS Factory #7

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
9888811
Initialized basis for multi factory support:
Totto16 Mar 19, 2023
e5370b5
- small typo fixes
Totto16 Oct 18, 2023
fb96293
move luabins to vendor , fixes sandboy violation error
Totto16 Oct 18, 2023
4786703
fix hunspell wrap for newest meson version
Totto16 Oct 18, 2023
3b495d8
add local_wx option
Totto16 Oct 19, 2023
f36c75b
update flatpak build file
Totto16 Oct 19, 2023
5d1f6a6
small compile.sh fix
Totto16 Oct 19, 2023
c0810d0
update boost wrap file and patch dir
Totto16 Oct 19, 2023
cb22b0f
update some other wrap files
Totto16 Oct 19, 2023
632689a
update icu wrap and remove local patch dir
Totto16 Oct 19, 2023
4fa135e
remove unused uchardet patch dir
Totto16 Oct 19, 2023
602a4dd
update some minor dependencies wrap files
Totto16 Oct 19, 2023
a0c4a5c
update wxWidgets wrap file
Totto16 Oct 19, 2023
7d54d0c
update lua patches to work again
Totto16 Oct 19, 2023
72ab83d
fix errors arising from teh use of std=c++20 and newer dependencies
Totto16 Oct 19, 2023
a11221c
add better credits to the about dialog (use current year as end)
Totto16 Oct 19, 2023
f44993b
small local_wx fix
Totto16 Oct 19, 2023
d1f1959
fix dialog
Totto16 Oct 28, 2023
12425e1
fix and rewrite wakatime plugin, to use std::string instead of wxString
Totto16 Oct 28, 2023
e196493
use locally boost 1.81.0
Totto16 Oct 29, 2023
12868a6
fix boost filepath 1.81.0 errors,
Totto16 Oct 29, 2023
782d894
fix another lua error with the newer wx version
Totto16 Oct 29, 2023
ad5d7cc
fix another lua error with the newer wx version
Totto16 Oct 29, 2023
552fcdb
rename targets for assdraw and aegsiub debs
Totto16 Oct 29, 2023
a0ac57e
fix many thing sin the external scripts to build the debs
Totto16 Oct 29, 2023
75a7a82
use an archive instead of git to build wxWidgets in the flatpak maibn…
Totto16 Oct 29, 2023
4f9b2ca
use not deprecated method to setup the build dir in the compile script
Totto16 Oct 29, 2023
528bffd
use meson >= 1.2.0 and port warnings for deprecated functions
Totto16 Oct 29, 2023
ac10688
small error fix in compile script
Totto16 Oct 29, 2023
34b8197
fix ci script version of meson
Totto16 Oct 29, 2023
dd90e89
fix flatpak build files
Totto16 Oct 29, 2023
7b9033c
small bash script fixes
Totto16 Oct 29, 2023
0edd37e
add DependencyControl to flatpak build
Totto16 Oct 31, 2023
14649fe
add test disable option and use it in flatpak
Totto16 Oct 31, 2023
104c855
fix flatpak ci
Totto16 Oct 31, 2023
0634c70
fix meson file
Totto16 Oct 31, 2023
1fe524c
build boost with b2 beforehand
Totto16 Nov 3, 2023
4c7e626
fix some flatpak related things
Totto16 Nov 7, 2023
60b7ddb
fix the CI builds
Totto16 Nov 7, 2023
d5737ad
small fixes in compile.sh
Totto16 Nov 7, 2023
787d1c4
try to fix unicode conversion compile error
Totto16 Nov 7, 2023
880e0ca
fix unicode error by using normal std::string and not std::u8string!
Totto16 Nov 7, 2023
4390084
add small warning for boost meson port
Totto16 Nov 7, 2023
8b7512b
use correct name for meson targets
Totto16 Nov 7, 2023
d72d5a4
convert c++11 [=] captures to explicit [=, this] captures, meaning lo…
Totto16 Nov 7, 2023
76d65f0
update checkout action version
Totto16 Nov 7, 2023
f0e62a6
[LUA] fix - Lua Scripts that change the cwd also affect Aegisub
Totto16 Jul 23, 2022
110d1a8
solve the problem in another way, that also covers the fact, that the…
Totto16 Jul 23, 2022
0b2e41a
add flatpak option to meson options and use correct name for icons an…
Totto16 Nov 7, 2023
839f542
fix app name in .desktop
Totto16 Nov 7, 2023
655bf22
fix default value for build_flatpak_bundle
Totto16 Nov 8, 2023
b173665
add libass from official repo to flatpak build
Totto16 Nov 8, 2023
d1fe0a0
add libunibreak to libass, so that better linebreaks in unicode are p…
Totto16 Nov 8, 2023
333ed31
Initialized basis for multi factory support:
Totto16 Mar 19, 2023
725ae3b
WIP
Totto16 Oct 18, 2023
d6170b0
add inlcude in hpp file
Totto16 Nov 8, 2023
2e8e3b4
- JS factory:
Totto16 Nov 9, 2023
2d19435
add test file to test single js execution
Totto16 Nov 9, 2023
9db3a24
imrprove js code in test program
Totto16 Nov 9, 2023
71a19ae
- port test program into real aegisub c++ code
Totto16 Nov 10, 2023
2947214
add some templates to make code cleaner
Totto16 Nov 10, 2023
1166318
fix some lua related things, only allow lua5.1 to be used, since aeg…
Totto16 Nov 10, 2023
f188357
use lua 5.1 in flatpak bundle
Totto16 Nov 10, 2023
f713503
use wxversion 3.2.0 as lowest bound in ci and compile srcipt
Totto16 Nov 10, 2023
0c21da1
fix build when js is disabled
Totto16 Nov 11, 2023
5ed1baa
- add useful message to unlikely event, but it might occur on errors …
Totto16 Nov 11, 2023
d5293d5
Merge branch 'master' into js-factory
Totto16 Nov 11, 2023
7773ab9
small flatpak lua build fix
Totto16 Nov 11, 2023
a786569
-fix Ci by adding nodejs dev package
Totto16 Nov 11, 2023
98a11b8
add idl generator as submodule and a small idl file that is already n…
Totto16 Nov 11, 2023
0e357e3
updates to the js factory:
Totto16 Nov 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ jobs:
name: Ubuntu Debug,
os: ubuntu-22.04,
buildtype: debugoptimized,
args: -Dwx_version=3.2.3
args: -Dwx_version=3.2.0
}
- {
name: Ubuntu Release,
os: ubuntu-22.04,
buildtype: release,
args: -Dwx_version=3.2.3
args: -Dwx_version=3.2.0
}
#- {
# name: macOS Debug,
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
if: matrix.config.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install ninja-build build-essential libx11-dev gcc-13 g++-13 libwxgtk3.0-gtk3-dev libgtk-3-dev libfreetype6-dev pkg-config libfontconfig1-dev libass-dev libasound2-dev libffms2-dev intltool libboost-all-dev luarocks libcurl4-nss-dev lua5.1* -y
sudo apt-get install ninja-build build-essential libx11-dev gcc-13 g++-13 libwxgtk3.0-gtk3-dev libgtk-3-dev libfreetype6-dev pkg-config libfontconfig1-dev libass-dev libasound2-dev libffms2-dev intltool libboost-all-dev luarocks libcurl4-nss-dev lua5.1* libnode-dev -y
sudo luarocks install moonscript

- name: Configure
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ subprojects/zlib-*
subprojects/dirent-*
subprojects/hunspell-*
subprojects/uchardet-*
subprojects/expected-*

.vscode/*

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "idl-generator"]
path = src/automation/factories/js/idl-generator
url = https://github.com/Totto16/aegisub-idl-generator.git
13 changes: 3 additions & 10 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,19 @@ fi

# CONFIGURE

bash -c "meson setup build -Dbuildtype=$buildtype -Dwx_version=3.2.3 -Dcredit='Totto local build'"
bash -c "meson setup build -Dbuildtype=$buildtype -Dprefix=/usr -Dwx_version=3.2.0 -Dcredit='Totto local build' -Denable_js_automation=enabled"

if [ $DEBUG == "true" ]; then
nodemon --watch src/ -e .cpp,.h --exec "sudo meson compile -C build && ./build/aegisub || exit 1"
nodemon --watch src/ -e .cpp,.h,.hpp --exec "meson compile -C build && ./build/aegisub || exit 1"
exit 0
fi

# COMPILE

## maybe this has to be done: git config --global --add safe.directory $PWD

## COMPILE
meson compile -C build

## run tests
meson test -C build --verbose "gtest main"

# PACK into DEB

if [ ! -f "build/aegisub" ]; then
echo "Failed to build aegisub. Aborting"
exit 4
Expand Down Expand Up @@ -125,6 +120,4 @@ fi
#icons for .ass .ssa
#mime type,

#TODO create flatpak: https://docs.flatpak.org/en/latest/first-build.html

# TODO compile each dependency local with the newest (stable?) version and then distruibute them as deb, and their also gonna be neede for flatpak support!
1 change: 1 addition & 0 deletions libaegisub/lua/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ int exception_wrapper(lua_State *L, int (*func)(lua_State *L)) {
return lua_error(L);
}
catch (...) {
LOG_E("lua/utils/exception_wrapper") << "An Unknow type of Exception occurred: this is likely not an issue on your side, but on teh packager / maintainer!\n";
std::terminate();
}
}
Expand Down
130 changes: 122 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ project(
cmake = import('cmake')

if host_machine.system() == 'windows'
add_project_arguments('-DNOMINMAX', '-D_WIN32_WINNT=0x0601', language: 'cpp')
add_project_arguments(
'-DNOMINMAX',
'-D_WIN32_WINNT=0x0601',
language: 'cpp',
)

if not get_option('csri').disabled()
add_global_arguments('-DCSRI_NO_EXPORT', language: 'c')
Expand Down Expand Up @@ -224,7 +228,11 @@ else
wx = cmake.subproject('wxWidgets', options: opt_var)


deps += [wx.dependency('wxmono'), wx.dependency('wxregex'), wx.dependency('wxscintilla')]
deps += [
wx.dependency('wxmono'),
wx.dependency('wxregex'),
wx.dependency('wxscintilla'),
]

wx.target_list()

Expand All @@ -248,7 +256,9 @@ else
if cc.has_header('commctrl.h')
deps += cc.find_library('comctl32', required: true)
else
error('Missing Windows SDK Common Controls Library (commctrl.h / comctl32.lib)')
error(
'Missing Windows SDK Common Controls Library (commctrl.h / comctl32.lib)',
)
endif
endif
endif
Expand Down Expand Up @@ -291,7 +301,7 @@ foreach dep : [
)
endif

if not d.found() and dep[4].length() > 0 and host_machine.system() == 'darwin'
if (not d.found() and dep[4].length() > 0 and host_machine.system() == 'darwin')
d = dependency(
'appleframeworks',
modules: dep[4],
Expand All @@ -313,7 +323,7 @@ if host_machine.system() == 'windows' and get_option('avisynth').enabled()
conf.set('WITH_AVISYNTH', 1) # bundled separately with installer
endif

if host_machine.system() == 'windows' and not get_option('directsound').disabled()
if (host_machine.system() == 'windows' and not get_option('directsound').disabled())
dsound_dep = cc.find_library('dsound', required: get_option('directsound'))
winmm_dep = cc.find_library('winmm', required: get_option('directsound'))
ole32_dep = cc.find_library('ole32', required: get_option('directsound'))
Expand Down Expand Up @@ -349,7 +359,11 @@ endif
def_audio = get_option('default_audio_output')
if def_audio != 'auto'
if not dep_avail.contains(def_audio)
error('Default audio output "@0@" selected but not available'.format(def_audio))
error(
'Default audio output "@0@" selected but not available'.format(
def_audio,
),
)
endif
elif dep_avail.length() != 0
def_audio = dep_avail[0]
Expand Down Expand Up @@ -383,7 +397,9 @@ int main(void)
if get_option('system_luajit')
error('System luajit found but not compiled in 5.2 mode')
else
message('System luajit found but not compiled in 5.2 mode; using built-in luajit')
message(
'System luajit found but not compiled in 5.2 mode; using built-in luajit',
)
endif
else
deps += luajit
Expand Down Expand Up @@ -430,11 +446,105 @@ if not get_option('csri').disabled() and host_machine.system() == 'windows'
deps += csri_sp.get_variable('csri_dep')
endif

enable_js_automation = false

js_deps = []
js_include_dirs = []

if get_option('enable_js_automation').allowed()
cpp = meson.get_compiler('cpp')

all_deps_found = true

foreach dep_name : ['v8', 'v8_libbase', 'v8_libplatform', 'v8_libsampler', 'node', 'uv']
local_dep = cpp.find_library(
dep_name,
required: get_option('enable_js_automation').enabled(),
)

if not local_dep.found()
all_deps_found = false
else
js_deps += local_dep
endif

endforeach

found_include_dirs = true

fs = import('fs')

foreach def : [['node', 'node.h'], ['node', 'v8.h'], ['nodejs/deps/uv/include/', 'uv.h']]
local_found = false
foreach idir : ['/usr/include', '/usr/local/include']

subdir = def[0]
header = def[1]

dir = idir / subdir

if not local_found and fs.is_dir(dir) and cpp.has_header(header, args: '-I' + dir)
js_include_dirs += dir
local_found = true
endif
endforeach

if not local_found
found_include_dirs = false
endif
endforeach

if not found_include_dirs and get_option('enable_js_automation').enabled()
error('Not all headers could be found!')
endif

if all_deps_found and found_include_dirs
enable_js_automation = true
js_include_dirs = include_directories(js_include_dirs)
deps += js_deps
endif
endif

deps += dependency(
'tl-expected',
required: true,
fallback: ['tl-expected'],
)


if enable_js_automation
conf.set('ENABLE_JS_AUTOMATION', true)

node_js_version = 18

if (
not cpp.compiles(
'''
#include "node_version.h"

int main(void){
static_assert(NODE_MAJOR_VERSION == ''' + node_js_version.to_string() + ''', "Wrong node js version");
}
''',
dependencies: js_deps,
include_directories: js_include_dirs,
)
)
error('Required node.js version ' + node_js_version.to_string())

endif


endif


acconf = configure_file(
output: 'acconf.h',
configuration: conf,
)

general_inc = []

subdir('automation')
subdir('libaegisub')
subdir('packages')
Expand All @@ -455,10 +565,12 @@ aegisub = executable(
acconf,
link_with: [libresrc, libluabins, libaegisub],
include_directories: [
general_inc,
libaegisub_inc,
libresrc_inc,
version_inc,
deps_inc,
js_include_dirs,
include_directories('src'),
],
cpp_pch: aegisub_cpp_pch,
Expand All @@ -471,7 +583,9 @@ aegisub = executable(

if host_machine.system() == 'windows'
mt_exe = find_program('mt.exe')
apply_manifest = find_program(meson.project_source_root() / 'tools/apply-manifest.py')
apply_manifest = find_program(
meson.project_source_root() / 'tools/apply-manifest.py',
)
custom_target(
'apply-manifest',
input: aegisub,
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ option('build_osx_bundle', type: 'boolean', value: false, description: 'Package
option('build_flatpak_bundle', type: 'boolean', value: false, description: 'enable flatpak bundle build')

option('tests', type: 'feature', value: 'auto', description: 'enable tests')

option('enable_js_automation', type: 'feature', value: 'auto', description: 'Enable the js automation plugin via v8 (chromium engine)')
10 changes: 5 additions & 5 deletions org.aegisub.Aegisub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ runtime-version: "23.08"
sdk: org.freedesktop.Sdk
command: aegisub
modules:
- name: lua
- name: lua5.1
buildsystem: simple
sources:
- type: archive
url: https://www.lua.org/ftp/lua-5.4.6.tar.gz
sha256: 7d5ea1b9cb6aa0b59ca3dde1c6adcb57ef83a1ba8e5432c0ecd06bf439b3ad88
url: https://www.lua.org/ftp/lua-5.1.5.tar.gz
sha256: 2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333
build-commands:
- sed -i 's/INSTALL_TOP= \/usr\/local/INSTALL_TOP= \/app/g' Makefile
- make
- make linux
- make install

- name: glu
Expand Down Expand Up @@ -70,7 +70,7 @@ modules:
- type: git
url: https://github.com/Totto16/ffi-experiments.git
build-commands:
- luarocks install moonscript --dev ## we need the dev version for lua 5.4!
- luarocks install moonscript
- make -B lua
# - luarocks remove moonscript # remove again, to not end in the final pack
- make -B all
Expand Down
9 changes: 8 additions & 1 deletion src/auto4_base.cpp → src/automation/auto4_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ namespace Automation4 {
AutoloadScriptManager::AutoloadScriptManager(std::string path)
: path(std::move(path))
{
// Before Loading Plugins, save the current path, that could be changed by lua
// Before Loading Plugins, save the current path, that could be changed by lua or any factory
auto cwd = boost::filesystem::current_path();

Reload();
Expand Down Expand Up @@ -457,6 +457,13 @@ namespace Automation4 {
Factories().emplace_back(std::move(factory));
}

void ScriptFactory::RegisterMany(std::vector<std::unique_ptr<ScriptFactory>> factories)
{
for (auto& factory : factories) {
ScriptFactory::Register(std::move(factory));
}
}

std::unique_ptr<Script> ScriptFactory::CreateFromFile(agi::fs::path const& filename, bool complain_about_unrecognised, bool create_unknown)
{
for (auto& factory : Factories()) {
Expand Down
2 changes: 2 additions & 0 deletions src/auto4_base.h → src/automation/auto4_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ namespace Automation4 {
/// Register an automation engine.
static void Register(std::unique_ptr<ScriptFactory> factory);

static void RegisterMany(std::vector<std::unique_ptr<ScriptFactory>> factories);

/// Get the full wildcard string for all loaded engines
static std::string GetWildcardStr();

Expand Down
28 changes: 28 additions & 0 deletions src/automation/factories/auto4_factories.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


#include <memory>
#include <vector>

#include "auto4_base.h"
#include "auto4_factories.hpp"
#include "auto4_lua_factory.h"

#ifdef ENABLE_JS_AUTOMATION
#include "auto4_js_factory.h"
#endif

#include <libaegisub/make_unique.h>

namespace Automation4 {

std::vector<std::unique_ptr<ScriptFactory>> Factories::createAll() {
auto all = std::vector<std::unique_ptr<ScriptFactory>>{};
all.push_back(agi::make_unique<Automation4::LuaScriptFactory>());
#ifdef ENABLE_JS_AUTOMATION
all.push_back(agi::make_unique<Automation4::JS::JavaScriptFactory>());
#endif

return all;
}

} // namespace Automation4
Loading