diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0c71d95..9f6d6db 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -67,7 +67,7 @@ jobs: - uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: latest - + - name: Import application certificates uses: apple-actions/import-codesign-certs@v3 with: diff --git a/.gitmodules b/.gitmodules index 635e41f..9c651bf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,10 +7,11 @@ [submodule "modules/osci_render_core"] path = modules/osci_render_core url = ../../jameshball/osci_render_core.git -[submodule "Source/lua/lua"] - path = Source/lua/lua - url = ../../lua/lua.git [submodule "modules/melatonin_inspector"] path = modules/melatonin_inspector url = https://github.com/sudara/melatonin_inspector.git branch = main +[submodule "LuaJIT"] + path = modules/LuaJIT + url = https://luajit.org/git/luajit.git + ignore = untracked diff --git a/Source/components/SosciMainMenuBarModel.cpp b/Source/components/SosciMainMenuBarModel.cpp index 324f8dd..4a52642 100644 --- a/Source/components/SosciMainMenuBarModel.cpp +++ b/Source/components/SosciMainMenuBarModel.cpp @@ -8,10 +8,13 @@ SosciMainMenuBarModel::SosciMainMenuBarModel(SosciPluginEditor& e, SosciAudioPro } void SosciMainMenuBarModel::resetMenuItems() { + MainMenuBarModel::resetMenuItems(); + addTopLevelMenu("File"); addTopLevelMenu("About"); addTopLevelMenu("Video"); addTopLevelMenu("Audio"); + addTopLevelMenu("Interface"); std::vector> examples = { {"default.sosci", BinaryData::default_sosci, BinaryData::default_sosciSize}, @@ -111,8 +114,7 @@ void SosciMainMenuBarModel::resetMenuItems() { } // Interface menu index depends on whether Audio menu exists - int interfaceMenuIndex = (editor.processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone) ? 4 : 3; - addToggleMenuItem(interfaceMenuIndex, "Listen for Special Keys", [this] { + addToggleMenuItem(4, "Listen for Special Keys", [this] { processor.setAcceptsKeys(! processor.getAcceptsKeys()); resetMenuItems(); }, [this] { return processor.getAcceptsKeys(); }); diff --git a/Source/lua/LuaParser.cpp b/Source/lua/LuaParser.cpp index d4c366f..98a4840 100644 --- a/Source/lua/LuaParser.cpp +++ b/Source/lua/LuaParser.cpp @@ -1,5 +1,9 @@ #include "LuaParser.h" -#include "luaimport.h" + +// If you haven't compiled LuaJIT yet, this will fail, and you'll get a ton of syntax errors in a few Lua-related files! +// On all platforms, this should be done automatically when you run the export. +// If not, use the luajit_win.bat or luajit_linux_macos.sh scripts in the git root from the dev environment. +#include std::function LuaParser::onPrint; std::function LuaParser::onClear; @@ -322,7 +326,7 @@ static int luaPrint(lua_State* L) { int nargs = lua_gettop(L); for (int i = 1; i <= nargs; ++i) { - LuaParser::onPrint(luaL_tolstring(L, i, nullptr)); + LuaParser::onPrint(lua_tolstring(L, i, nullptr)); lua_pop(L, 1); } @@ -468,7 +472,7 @@ void LuaParser::revertToFallback(lua_State*& L) { } void LuaParser::readTable(lua_State*& L, std::vector& values) { - auto length = lua_rawlen(L, -1); + auto length = lua_objlen(L, -1); for (int i = 1; i <= length; i++) { lua_pushinteger(L, i); @@ -493,7 +497,7 @@ std::vector LuaParser::run(lua_State*& L, LuaVariables& vars) { setGlobalVariables(L, vars); // Get the function from the registry - lua_geti(L, LUA_REGISTRYINDEX, functionRef); + lua_rawgeti(L, LUA_REGISTRYINDEX, functionRef); setMaximumInstructions(L, 5000000); diff --git a/Source/lua/lua b/Source/lua/lua deleted file mode 160000 index 3dbb1a4..0000000 --- a/Source/lua/lua +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3dbb1a4b894c0744a331d4319d8d1704dc4ad943 diff --git a/Source/lua/luaimport.cpp b/Source/lua/luaimport.cpp deleted file mode 100644 index 0a804bb..0000000 --- a/Source/lua/luaimport.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "luaimport.h" \ No newline at end of file diff --git a/Source/lua/luaimport.h b/Source/lua/luaimport.h deleted file mode 100644 index 673f56a..0000000 --- a/Source/lua/luaimport.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef LUAIMPORT_H -#define LUAIMPORT_H - -extern "C" { - #include "lua/lapi.c" - #include "lua/lauxlib.c" - #include "lua/lbaselib.c" - #include "lua/lcode.c" - #include "lua/lcorolib.c" - #include "lua/lctype.c" - #include "lua/ldblib.c" - #include "lua/ldebug.c" - #include "lua/ldo.c" - #include "lua/ldump.c" - #include "lua/lfunc.c" - #include "lua/lgc.c" - #include "lua/linit.c" - #include "lua/liolib.c" - #include "lua/llex.c" - #include "lua/lmathlib.c" - #include "lua/lmem.c" - #include "lua/loadlib.c" - #include "lua/lobject.c" - #include "lua/lopcodes.c" - #include "lua/loslib.c" - #include "lua/lparser.c" - #include "lua/lstate.c" - #include "lua/lstring.c" - #include "lua/lstrlib.c" - #include "lua/ltable.c" - #include "lua/ltablib.c" - #include "lua/ltests.c" - #include "lua/ltm.c" - #include "lua/lundump.c" - #include "lua/lutf8lib.c" - #include "lua/lvm.c" - #include "lua/lzio.c" -} - -#endif \ No newline at end of file diff --git a/ci/build.sh b/ci/build.sh index bbcb66e..ac10525 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -22,13 +22,13 @@ eval "$RESAVE_COMMAND" # Build mac version if [ "$OS" = "mac" ]; then cd "$ROOT/Builds/$PLUGIN/MacOSX" - xcodebuild -configuration Release || exit 1 + xcodebuild -configuration Release -parallelizeTargets -jobs $(sysctl -n hw.logicalcpu) || exit 1 fi # Build linux version if [ "$OS" = "linux" ]; then cd "$ROOT/Builds/$PLUGIN/LinuxMakefile" - make CONFIG=Release + make -j$(nproc) CONFIG=Release cp -r ./build/$PLUGIN.vst3 "$ROOT/ci/bin/$PLUGIN.vst3" cp -r ./build/$PLUGIN "$ROOT/ci/bin/$PLUGIN" @@ -44,11 +44,10 @@ fi if [ "$OS" = "win" ]; then VS_WHERE="C:/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" - MSBUILD_EXE=$("$VS_WHERE" -latest -requires Microsoft.Component.MSBuild -find "MSBuild\**\Bin\MSBuild.exe") - echo $MSBUILD_EXE + eval "$($(cygpath "$COMSPEC") /c$(cygpath -w "$ROOT/ci/vcvars_export.bat"))" cd "$ROOT/Builds/$PLUGIN/VisualStudio2022" - "$MSBUILD_EXE" "$PLUGIN.sln" "//p:VisualStudioVersion=16.0" "//m" "//t:Build" "//p:Configuration=Release" "//p:Platform=x64" "//p:PreferredToolArchitecture=x64" "//restore" "//p:RestorePackagesConfig=true" + msbuild.exe "//m" "$PLUGIN.sln" "//p:VisualStudioVersion=16.0" "//p:MultiProcessorCompilation=true" "//p:CL_MPCount=16" "//p:BuildInParallel=true" "//t:Build" "//p:Configuration=Release" "//p:Platform=x64" "//p:PreferredToolArchitecture=x64" "//restore" "//p:RestorePackagesConfig=true" cp "$ROOT/Builds/$PLUGIN/VisualStudio2022/x64/Release/Standalone Plugin/$PLUGIN.pdb" "$ROOT/bin/$OUTPUT_NAME.pdb" fi diff --git a/ci/setup-env.sh b/ci/setup-env.sh index da97dda..5f54f55 100755 --- a/ci/setup-env.sh +++ b/ci/setup-env.sh @@ -31,7 +31,7 @@ fi curl -s -S -L "https://api.juce.com/api/v1/download/juce/latest/$PROJUCER_OS" -o Projucer.zip # curl -s -S -L "https://github.com/juce-framework/JUCE/releases/download/8.0.4/juce-8.0.4-$PROJUCER_OS.zip" -o Projucer.zip -unzip Projucer.zip +unzip -q Projucer.zip # Set Projucer path based on OS if [ "$OS" = "mac" ]; then diff --git a/ci/test.sh b/ci/test.sh index c59ce08..8efdb1d 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -9,7 +9,7 @@ eval "$RESAVE_COMMAND" # Build mac version if [ "$OS" = "mac" ]; then cd "$ROOT/Builds/Test/MacOSX" - xcodebuild -configuration Release || exit 1 + xcodebuild -configuration Release -parallelizeTargets -jobs $(sysctl -n hw.logicalcpu) || exit 1 cd "build/Release" find . echo "Running the test" @@ -20,7 +20,7 @@ fi # Build linux version if [ "$OS" = "linux" ]; then cd "$ROOT/Builds/Test/LinuxMakefile" - make CONFIG=Release + make -j$(nproc) CONFIG=Release cd build echo "Running the test" @@ -36,7 +36,7 @@ if [ "$OS" = "win" ]; then echo $MSBUILD_EXE cd "$ROOT/Builds/Test/VisualStudio2022" - "$MSBUILD_EXE" "$PLUGIN.sln" "//p:VisualStudioVersion=16.0" "//m" "//t:Build" "//p:Configuration=Release" "//p:Platform=x64" "//p:PreferredToolArchitecture=x64" + "$MSBUILD_EXE" "//m" "$PLUGIN.sln" "//p:MultiProcessorCompilation=true" "//p:CL_MPCount=32" "//p:VisualStudioVersion=16.0" "//t:Build" "//p:Configuration=Release" "//p:Platform=x64" "//p:PreferredToolArchitecture=x64" cd "x64/Release/ConsoleApp" echo "Running the test" diff --git a/ci/vcvars_export.bat b/ci/vcvars_export.bat new file mode 100644 index 0000000..bec2fe5 --- /dev/null +++ b/ci/vcvars_export.bat @@ -0,0 +1,7 @@ +@echo off + +set VSWHERE="C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere" +for /f "tokens=*" %%i in ('%VSWHERE% -latest -property installationPath') do set VSWHERE2=%%i + +call "%VSWHERE2%\VC\Auxiliary\Build\vcvars64.bat" > nul +bash -c "export -p" \ No newline at end of file diff --git a/luajit_linux_macos.sh b/luajit_linux_macos.sh new file mode 100755 index 0000000..9e709de --- /dev/null +++ b/luajit_linux_macos.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Build LuaJIT for Linux or macOS (produces universal static lib on macOS). +# Safe to run multiple times; always re-build cleanly for each architecture. + +set -euo pipefail + +# Resolve DIR (allow user override). Prefer script directory so you can invoke from anywhere. +: "${DIR:=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}" + +LUAJIT_SRC="$DIR/modules/LuaJIT/src" +if [[ ! -d "$LUAJIT_SRC" ]]; then + echo "Error: LuaJIT source directory not found: $LUAJIT_SRC" >&2 + echo "(Did you forget to init submodules or place LuaJIT under modules/LuaJIT?)" >&2 + exit 1 +fi + +cd "$LUAJIT_SRC" + +if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Building LuaJIT universal binary (x86_64 + arm64)..." + + # Allow caller to override; default minimum version. + export MACOSX_DEPLOYMENT_TARGET="${MACOSX_DEPLOYMENT_TARGET:-10.13}" + CPUs=$(sysctl -n hw.logicalcpu) + + # Remove any previous fat/intermediate libs to avoid accidental reuse. + rm -f libluajit_x86_64.a libluajit_arm64.a libluajit.a + + # Function to build one architecture. + build_arch() { + local ARCH="$1" TARGET_NAME="$2" + echo "-- Building $ARCH ..." + make clean || true # ignore if already clean + MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \ + make -j"$CPUs" \ + LUAJIT_T="$TARGET_NAME" \ + BUILDMODE=static \ + CC="clang -arch $ARCH -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" \ + XCFLAGS="-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" \ + || { echo "Build failed for $ARCH" >&2; exit 2; } + mv libluajit.a "libluajit_${ARCH}.a" + echo "-- Built $ARCH OK" + } + + build_arch x86_64 luajit-x86_64 + build_arch arm64 luajit-arm64 + + echo "-- Creating universal libluajit.a" + lipo -create -output libluajit.a libluajit_x86_64.a libluajit_arm64.a + lipo -info libluajit.a || true + echo "Universal libluajit.a created." +else + # Linux path + CPUs="${NPROC:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || nproc 2>/dev/null || echo 1)}" + echo "Building LuaJIT static library for Linux with $CPUs threads..." + make clean || true + make -j"$CPUs" BUILDMODE=static XCFLAGS="-fPIC" + echo "Linux libluajit.a built." +fi + +echo "Done." diff --git a/luajit_win.bat b/luajit_win.bat new file mode 100644 index 0000000..2d3f553 --- /dev/null +++ b/luajit_win.bat @@ -0,0 +1,22 @@ +@echo off +if "%VisualStudioVersion%"=="" ( + ECHO Visual Studio command line variables not detected! + ECHO This script will only work if you run it from a Visual Studio command line! + goto error_luajit +) + +if /I "%VSTEL_MSBuildProjectFullPath:~-18%" neq "SharedCode.vcxproj" ( + goto finish_luajit +) + +cd ..\..\..\modules\LuaJIT\src +call .\msvcbuild.bat static +copy /b lua51.lib luajit51.lib +goto finish_luajit + +:error_luajit + +timeout 10 + +:finish_luajit +@echo on \ No newline at end of file diff --git a/modules/LuaJIT b/modules/LuaJIT new file mode 160000 index 0000000..871db2c --- /dev/null +++ b/modules/LuaJIT @@ -0,0 +1 @@ +Subproject commit 871db2c84ecefd70a850e03a6c340214a81739f0 diff --git a/modules/chowdsp_utils b/modules/chowdsp_utils index 17edebc..ffc70ba 160000 --- a/modules/chowdsp_utils +++ b/modules/chowdsp_utils @@ -1 +1 @@ -Subproject commit 17edebcc64d9dc96a9c0b0c7e9b9bd1673a585f9 +Subproject commit ffc70ba399f9afaeefb996eb14e55a1d487270b8 diff --git a/osci-render.jucer b/osci-render.jucer index 984520f..92053e2 100644 --- a/osci-render.jucer +++ b/osci-render.jucer @@ -4,9 +4,9 @@ addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1" pluginCharacteristicsValue="pluginWantsMidiIn" pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender" cppLanguageStandard="20" projectLineFeed=" " headerPath="./include" - version="2.5.1.1" companyName="James H Ball" companyWebsite="https://osci-render.com" + version="2.6.0.0" companyName="James H Ball" companyWebsite="https://osci-render.com" companyEmail="james@ball.sh" defines="NOMINMAX=1 INTERNET_FLAG_NO_AUTO_REDIRECT=0 OSCI_PREMIUM=1 JUCE_USE_CUSTOM_PLUGIN_STANDALONE_APP=1 JUCE_MODAL_LOOPS_PERMITTED=1" - pluginAUMainType="'aumf'"> + pluginAUMainType="'aumf'" postExportShellCommandPosix="echo "Building LuaJIT for $OSTYPE..." && DIR=%%1%% %%1%%/luajit_linux_macos.sh "> @@ -422,73 +422,6 @@ file="Source/ixwebsocket/IXWebSocketVersion.h"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -749,10 +682,12 @@ JUCE_WEB_BROWSER="0"/> + bigIcon="pSc1mq" externalLibraries="luajit"> - - + + @@ -786,11 +721,15 @@ + extraLinkerFlags="/IGNORE:4006" externalLibraries="luajit51.lib"> - + + debugInformationFormat="ProgramDatabase" winWarningLevel="2" + libraryPath="..\..\..\modules\LuaJIT\src" headerPath="..\..\..\modules\LuaJIT\src" + prebuildCommand="call ..\..\..\luajit_win.bat" enablePluginBinaryCopyStep="0"/> @@ -827,15 +766,18 @@ bigIcon="aZXbCi" applicationCategory="public.app-category.music" microphonePermissionNeeded="1" frameworkSearchPaths="/Library/Frameworks" extraCustomFrameworks="/Library/Frameworks/Syphon.framework" - hardenedRuntime="1" hardenedRuntimeOptions="com.apple.security.cs.disable-library-validation,com.apple.security.device.audio-input" - userNotes="D86A3M3H2L"> + hardenedRuntime="1" hardenedRuntimeOptions="com.apple.security.cs.allow-jit,com.apple.security.cs.allow-unsigned-executable-memory,com.apple.security.cs.disable-library-validation,com.apple.security.device.audio-input" + externalLibraries="luajit" iosDevelopmentTeamID="D86A3M3H2L"> + headerPath="../../../modules/LuaJIt/src" libraryPath="../../../modules/LuaJIt/src" + codeSigningIdentity="Developer ID Application: James Ball (D86A3M3H2L)"/> + headerPath="../../../modules/LuaJIt/src" libraryPath="../../../modules/LuaJIt/src" + codeSigningIdentity="Developer ID Application: James Ball (D86A3M3H2L)"/> diff --git a/sosci.jucer b/sosci.jucer index 87bab75..da847e8 100644 --- a/sosci.jucer +++ b/sosci.jucer @@ -3,7 +3,7 @@