Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ indent_size = 4
max_line_length = 80
trim_trailing_whitespace = true

[*.{yaml,yml}]
indent_size = 2
quote_type = 'double'

[.git/COMMIT*]
max_line_length = 72

Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ on:
- 'README.md'
- 'RELEASE_NOTES'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
mingw:
runs-on: ubuntu-24.04
if: false
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
Expand Down Expand Up @@ -71,7 +76,7 @@ jobs:
- name: Install Meson Wraps
run: |
mkdir subprojects -p
meson wrap install mujs
meson wrap install quickjs-ng
meson subprojects download

- name: Build libraries
Expand Down Expand Up @@ -118,6 +123,7 @@ jobs:

win32:
runs-on: ${{ matrix.os }}
if: true
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -225,6 +231,7 @@ jobs:

macos:
runs-on: ${{ matrix.os }}
if: true
strategy:
matrix:
include:
Expand Down Expand Up @@ -269,6 +276,9 @@ jobs:
brew install -q autoconf automake pkgconf libtool python freetype fribidi little-cms2 \
luajit libass ffmpeg meson rust uchardet mujs libplacebo molten-vk vulkan-loader vulkan-headers

- run: mkdir -p subprojects
- run: git clone --depth=1 --branch=v0.11.0 https://github.com/quickjs-ng/quickjs subprojects/quickjs

- name: Build with meson
id: build
run: |
Expand Down Expand Up @@ -307,6 +317,7 @@ jobs:

linux:
runs-on: ubuntu-latest
if: true
container:
image: "registry.opensuse.org/home/mia/images/images/mpv-ci:stable-deps"
env:
Expand All @@ -327,6 +338,9 @@ jobs:
steps:
- uses: actions/checkout@v6

- run: mkdir -p subprojects
- run: git clone --depth=1 --branch=v0.11.0 https://github.com/quickjs-ng/quickjs subprojects/quickjs

- name: Build with meson
id: build
run: |
Expand All @@ -349,6 +363,7 @@ jobs:

linux-fuzz:
runs-on: ubuntu-latest
if: false
container:
image: "registry.opensuse.org/home/mia/images/images/mpv-ci:stable-deps"
env:
Expand All @@ -372,6 +387,7 @@ jobs:

linux-ffmpeg-6-1:
runs-on: ubuntu-latest
if: false
container:
# We want to test ffmpeg 6.1.2, which Alpine 3.21 includes.
# Also test compatibility with Wayland Protocols 1.38 and Wayland libs 1.23.
Expand Down Expand Up @@ -428,6 +444,7 @@ jobs:
openbsd:
runs-on: ubuntu-latest # until https://github.com/actions/runner/issues/385
timeout-minutes: 15 # avoid any weirdness with the VM
if: false
steps:
- uses: actions/checkout@v6
- name: Test in OpenBSD VM
Expand Down Expand Up @@ -474,6 +491,7 @@ jobs:
freebsd:
runs-on: ubuntu-latest # until https://github.com/actions/runner/issues/385
timeout-minutes: 15 # avoid any weirdness with the VM
if: false
steps:
- uses: actions/checkout@v6
- name: Test in FreeBSD VM
Expand Down Expand Up @@ -527,6 +545,7 @@ jobs:

msys2:
runs-on: ${{ matrix.os }}
if: false
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/subprojects/*
!/subprojects/packagefiles
!/subprojects/*.wrap
.cache/
39 changes: 24 additions & 15 deletions ci/build-win32.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# you don't need to review this file, I'll revert this changes later.
# it's for my local developing convenience.

$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
Set-StrictMode -Version Latest
Expand All @@ -7,19 +10,6 @@ if (-not (Test-Path $subprojects)) {
New-Item -Path $subprojects -ItemType Directory | Out-Null
}

$amfVersion = "1.5.0"
$amfUrl = "https://github.com/GPUOpen-LibrariesAndSDKs/AMF/releases/download/v$amfVersion/AMF-headers-v$amfVersion.tar.gz"
$amfArchive = "AMF-headers-v$amfVersion.tar.gz"
$amfExtractPath = "$subprojects/amf-headers"
if (-not (Test-Path $amfArchive)) {
Invoke-WebRequest -Uri $amfUrl -OutFile $amfArchive
}
if (-not (Test-Path "$amfExtractPath/AMF")) {
New-Item -Path $amfExtractPath -ItemType Directory -Force | Out-Null
tar -xzf $amfArchive --strip-components=1 -C $amfExtractPath
}
$amfExtractPath = Resolve-Path $amfExtractPath

# Wrap shaderc to run git-sync-deps and patch unsupported generator expression
if (-not (Test-Path "$subprojects/shaderc_cmake")) {
git clone https://github.com/google/shaderc --depth 1 $subprojects/shaderc_cmake
Expand Down Expand Up @@ -187,6 +177,14 @@ $projects = @(
URL = "https://code.videolan.org/videolan/libplacebo.git"
Revision = "master"
},
@{
Path = "$subprojects/quickjs.wrap"
URL = "https://github.com/quickjs-ng/quickjs"
Revision = "v0.11.0"
Provides = @(
"quickjs = quickjs_dep"
)
},
@{
Path = "$subprojects/dav1d.wrap"
URL = "https://code.videolan.org/videolan/dav1d"
Expand Down Expand Up @@ -237,10 +235,21 @@ clone-recursive = true
Set-Content -Path $project.Path -Value $content
}

# $env:VS="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise"
$env:CC="clang"
$env:CXX="clang++"
$env:CC_LD="lld-link"
$env:CXX_LD="lld-link"
$env:WINDRES="llvm-rc"
$env:RUST_LD="lld-link"
# $env:RUSTC="rustc --target ${{ matrix.target }}"
# $env:CCACHE_BASEDIR=${{ github.workspace }}
# $env:CCACHE_DIR="${{ github.workspace }}\\.ccache"
# $env:CCACHE_MAXSIZE=500M

meson setup build `
--wrap-mode=forcefallback `
-Ddefault_library=static `
-Dc_args="-I$amfExtractPath" `
-Dlibmpv=true `
-Dtests=true `
-Dgpl=true `
Expand Down Expand Up @@ -268,7 +277,7 @@ meson setup build `
-Dxxhash:inline-all=true `
-Dxxhash:cli=false `
-Dluajit:amalgam=true `
-Damf=enabled `
-Damf=disabled `
-Dd3d11=enabled `
-Dvulkan=enabled `
-Djavascript=enabled `
Expand Down
56 changes: 50 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,51 @@ if features['iconv']
add_project_arguments('-DWINICONV_CONST=', language: ['c', 'objc'])
endif

javascript = dependency('mujs', version: '>= 1.0.0', required: get_option('javascript'))
features += {'javascript': javascript.found()}
javascript_opt = get_option('javascript')
javascript_dep = disabler()
javascript_sources = []
javascript_runtime = ''

if javascript_opt != 'disabled'
if javascript_opt in ['auto', 'enabled', 'quickjs']
quickjs_dep = dependency('quickjs-ng', version: '>= 0.10.0',
fallback: ['quickjs', 'qjs_dep'],
default_options: ['libc=true'],
required: javascript_opt in ['quickjs', 'enabled'])
if quickjs_dep.found()
javascript_dep = quickjs_dep
javascript_runtime = 'quickjs'
add_project_arguments('-DJAVASCRIPT_RUNTIME=2', language : 'c')
endif
endif

if not javascript_dep.found() and javascript_opt in ['auto', 'enabled', 'mujs']
mujs_dep = dependency('mujs', version: '>= 1.0.0',
required: javascript_opt == 'mujs')
if mujs_dep.found()
javascript_dep = mujs_dep
javascript_runtime = 'mujs'
add_project_arguments('-DJAVASCRIPT_RUNTIME=1', language : 'c')
endif
endif

if javascript_opt == 'enabled' and not javascript_dep.found()
error('Javascript enabled but no supported runtime (mujs or quickjs-ng) was found!')
endif

if javascript_runtime == 'mujs'
javascript_sources += files('player/javascript_mujs.c',
'sub/filter_jsre_mujs.c')
elif javascript_runtime == 'quickjs'
javascript_sources += files('player/javascript_quickjs.c',
'sub/filter_jsre_quickjs.c')
endif
endif

features += {'javascript': javascript_dep.found()}
if features['javascript']
dependencies += javascript
sources += files('player/javascript.c',
'sub/filter_jsre.c')
dependencies += javascript_dep
sources += javascript_sources
endif

lcms2 = dependency('lcms2', version: '>= 2.6', required: get_option('lcms2'))
Expand Down Expand Up @@ -1904,10 +1943,15 @@ if features['sdl2-audio'] or features['sdl2-gamepad'] or features['sdl2-video']
warning('You are building with optional SDL2 support. If you encounter build issues, try disabling it.')
endif

javascript_summary = javascript_opt
if features['javascript']
javascript_summary = javascript_runtime
endif

summary({'cocoa': features['cocoa'] and features['swift'],
'd3d11': features['d3d11'],
'drm': features['drm'],
'javascript': features['javascript'],
'javascript': javascript_summary,
'libmpv': get_option('libmpv'),
'lua': features['lua'],
'opengl': features['gl'],
Expand Down
2 changes: 1 addition & 1 deletion meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ option('cplugins', type: 'feature', value: 'auto', description: 'C plugins')
option('dvbin', type: 'feature', value: 'auto', description: 'DVB input module')
option('dvdnav', type: 'feature', value: 'auto', description: 'dvdnav support')
option('iconv', type: 'feature', value: 'auto', description: 'iconv')
option('javascript', type: 'feature', value: 'auto', description: 'Javascript (MuJS backend)')
option('javascript', type: 'combo', choices: ['auto', 'mujs', 'quickjs', 'enabled', 'disabled'], value: 'quickjs', description: 'Javascript')
option('jpeg', type: 'feature', value: 'auto', description: 'libjpeg image writer')
option('lcms2', type: 'feature', value: 'auto', description: 'LCMS2 support')
option('libarchive', type: 'feature', value: 'auto', description: 'libarchive wrapper for reading zip files and more')
Expand Down
11 changes: 11 additions & 0 deletions player/javascript/defaults.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
"use strict";

console.log('running', 'defaults.js');

console.log(1);
console.log(2);
console.log(3);

console.log(mp.script_name);
console.log(Object.keys(mp).length, JSON.stringify(Object.keys(mp)));

(function main_default_js(g) {
// - g is the global object.
// - User callbacks called without 'this', global only if callee is non-strict.
// - The names of function expressions are not required, but are used in stack
// traces. We name them where useful to show up (fname:#line always shows).


mp.msg = { log: mp.log };
mp.msg.verbose = mp.log.bind(null, "v");
var levels = ["fatal", "error", "warn", "info", "debug", "trace"];
Expand Down
File renamed without changes.
Loading