build-local.sh 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. #!/usr/bin/env bash
  2. # Builds and tests the core (without JUCE) with any C++20 compiler.
  3. # Uses $CXX if set; otherwise tries Zig in ~/opt, then g++/clang++.
  4. set -euo pipefail
  5. cd "$(dirname "$0")/.."
  6. # tests/tests.cpp is one big translation unit: at -O2 clang (zig 0.13's 18.1) needs more than the default 8 MB stack
  7. # for it (a segfault, exit 139 / abort 134, with no message). Raise the soft limit (no root needed) to 1 GiB: a FINITE
  8. # value, because with "unlimited" glibc gives new threads only the default 8 MB and zig compiles on worker threads.
  9. ulimit -s 1048576 2>/dev/null || ulimit -s "$(ulimit -H -s)" 2>/dev/null || true
  10. if [[ -z "${CXX:-}" ]]; then
  11. if [[ -x "$HOME/opt/zig-linux-x86_64-0.13.0/zig" ]]; then
  12. CXX="$HOME/opt/zig-linux-x86_64-0.13.0/zig c++"
  13. else
  14. CXX="$(command -v clang++ || command -v g++)"
  15. fi
  16. fi
  17. # LYNX_OPT_FLAGS (round toolchain190gt): the optimisation flags, -O2 by default; e.g. "-O3" runs the test suite (and its
  18. # bit-exact hash tests) with the release builds' optimisation of the core
  19. FLAGS="-std=c++20 ${LYNX_OPT_FLAGS:--O2} -g -ffp-contract=off -Wall -Wextra -Wpedantic -Isrc -Ithird_party/wavpack/include -Ithird_party/vorbis/include -Ithird_party/lame/include -Ithird_party/sse2neon -Ithird_party/pocketpy -Ithird_party/monocypher"
  20. CORE="src/flp/Flp.cpp src/core/Song.cpp src/core/MarkerPlan.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/TakeRecording.cpp src/core/Comping.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/OverloadGuard.cpp src/core/TimeStretch.cpp src/core/WarpEngines.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/AudioToMidi.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/VintagePhaser.cpp src/core/EmphasizerFx.cpp src/core/EmphasisFx.cpp src/core/TransporterFl.cpp src/core/EmphasisEngine.cpp src/core/FreqShifterFl.cpp src/core/LowLifterFl.cpp src/core/FlLegacyFx.cpp src/core/PocketFx.cpp src/core/PocketMultiFx.cpp src/core/VisualFx.cpp src/core/FlExtraFx.cpp src/core/Scratcher.cpp src/core/Dvs.cpp src/core/Transmitter.cpp src/core/VideoPlayer.cpp src/core/FruityDance.cpp src/core/Reeverb2.cpp src/core/LuxeVerb.cpp src/core/IldspMath.cpp src/core/ConvolverFx.cpp src/core/EquoFx.cpp src/core/PitchShifterFl.cpp src/core/SimSynth.cpp src/core/Wasp.cpp src/core/Granulizer.cpp src/core/Drumaxx.cpp src/core/FruityFilters.cpp src/core/NewtoneFx.cpp src/core/EdisonFx.cpp src/core/VocalPitch.cpp src/core/LynxTune.cpp src/core/LynxVerbs.cpp src/core/NebulaCloud.cpp src/core/MixSuite.cpp src/core/VoiceMatch.cpp src/core/EchoSuite.cpp src/core/LovePhilter.cpp src/core/DistructorFx.cpp src/core/MultibandDelayFx.cpp src/core/FrequencySplitter.cpp src/core/Slayer.cpp src/core/FlangusFastDist.cpp src/core/FruityPhaser.cpp src/core/FruityDelayBank.cpp src/core/FruityMultiband.cpp src/core/Vocodex.cpp src/core/FruityVocoder.cpp src/core/DelphiMath.cpp src/core/MaximusFx.cpp src/core/ParametricEqFl.cpp src/core/ParametricEqLinear.cpp src/core/FruityBasicFx.cpp src/core/TransistorBass.cpp src/core/GrossBeat.cpp src/core/StereoFx.cpp src/core/FruityDelay.cpp src/core/FruityShapers.cpp src/core/ChorusFx.cpp src/core/FruityDynamics.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/DrumSynthLive.cpp src/core/SytrusEngine.cpp src/core/Harmless.cpp src/core/HarmlessFx.cpp src/core/Harmor.cpp src/core/Gms.cpp src/core/Morphine.cpp src/core/Ogun.cpp src/core/Toxic.cpp src/core/ToxicFx.cpp src/core/FruitKick.cpp src/core/BassDrum.cpp src/core/MiniSynth.cpp src/core/Dx10.cpp src/core/Kepler.cpp src/core/PoiZone.cpp src/core/FlPatcher.cpp src/core/Patcher.cpp src/core/Vfx.cpp src/core/VfxSequencer.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/core/Scheduler.cpp src/core/Performance.cpp src/core/ClipLauncher.cpp src/core/Patcherize.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp src/core/LoadTrace.cpp src/core/ModuleWarmup.cpp src/core/FlpImport.cpp src/core/FlpExport.cpp src/core/XmlLite.cpp src/core/Gzip.cpp src/core/AlsImport.cpp src/core/AlsExport.cpp src/flp/FlpWrite.cpp src/core/Effects.cpp src/core/EmberClassic.cpp src/core/RhythmPan.cpp src/core/VoxStrip.cpp src/core/WaveTraveller.cpp src/core/FruitySlicer.cpp src/core/Slicex.cpp src/core/SlicexEngine.cpp src/core/VideoTime.cpp src/core/VideoTrack.cpp src/core/Adr.cpp src/core/DialogueAlign.cpp src/core/FlmFormat.cpp src/core/FlmImport.cpp src/core/FlmExport.cpp src/core/ModulatorExport.cpp src/core/BandFormat.cpp src/core/BandImport.cpp src/core/FlmEffects.cpp src/core/PocketFxC.cpp src/core/PocketFxD.cpp src/core/PocketFxE.cpp src/core/PocketReverb.cpp src/core/PocketFxB.cpp src/core/PocketFxA.cpp src/core/Fpc.cpp src/core/FpcInstrument.cpp src/core/FpcEnvelope.cpp src/core/Rack.cpp src/core/AlsDevices.cpp src/core/FlmNoteFx.cpp src/core/FlmDwSampler.cpp src/core/FlmSlicer.cpp src/core/SessionOps.cpp src/core/DrawMode.cpp src/core/AutoPointEdit.cpp src/core/Groove.cpp src/core/AlsDevicesLot2.cpp src/core/AlsDevicesLot3.cpp src/core/AlsDevicesLot4.cpp src/core/RemoteMap.cpp src/core/BlxImport.cpp src/core/RegionLoop.cpp src/core/SmartControls.cpp src/core/FactoryContent.cpp src/core/LoopKeywords.cpp src/core/SampleProps.cpp src/core/EdisonView.cpp src/core/HarmorResynth.cpp src/core/RenderAhead.cpp src/core/AlsDevicesLot5.cpp"
  21. # (the generated test chunks include tests/*.inc; the same flags everywhere keep one cached object per core file)
  22. FLAGS="$FLAGS -iquote tests"
  23. # Linux arm64 (a native build or a cross one, CXX=aarch64-linux-gnu-g++): a signed plain char, as on x86 and Apple
  24. # arm64 (CMakeLists.txt does the same; round 190oy)
  25. if $CXX -dM -E -x c++ /dev/null 2> /dev/null | grep -q '__aarch64__' && ! $CXX -dM -E -x c++ /dev/null 2> /dev/null | grep -q '__APPLE__'; then
  26. FLAGS="$FLAGS -fsigned-char"
  27. fi
  28. mkdir -p build-local build-local/wavpack
  29. # workflow shell (key map, workspace layout, rack operations)
  30. CORE="$CORE src/core/KeyMap.cpp src/core/PresetCycle.cpp src/core/Sfz.cpp src/core/Workspace.cpp src/core/RackOps.cpp src/core/PlaylistTrackOps.cpp src/core/ChannelMiscFx.cpp src/core/MidiImport.cpp"
  31. CORE="$CORE src/core/DawProject.cpp src/core/ZipLite.cpp" # DAWproject import / export (round 190jf, B22)
  32. # workflow P2 (note tools, mixer operations, history labels, browser search)
  33. CORE="$CORE src/core/RollingAudioLog.cpp src/core/ChordReadout.cpp src/core/NoteTools.cpp src/core/MidiTools.cpp src/core/MidiGenerate.cpp src/core/PianoRollTools.cpp src/core/EventEdit.cpp src/core/AudioEdit.cpp src/core/AudioEditTools.cpp src/core/FlAutoSlicer.cpp src/core/MixerOps.cpp src/core/History.cpp src/core/SearchQuery.cpp src/core/SearchIndex.cpp src/core/SearchService.cpp src/core/BrowserView.cpp src/core/EffectPresets.cpp src/core/PluginPresets.cpp src/core/GeneratorPresets.cpp src/core/ParamHelp.cpp"
  34. # Slicex as a channel (round 190l)
  35. CORE="$CORE src/core/SlicexInstrument.cpp"
  36. CORE="$CORE src/core/Jsfx.cpp" # JSFX scripts' identity, file policy and state (round 190pj)
  37. # Loop Starter, local (round 168b)
  38. CORE="$CORE src/core/LoopStarter.cpp"
  39. # Simple workflow: adding a track (round 184a)
  40. CORE="$CORE src/core/SimpleTracks.cpp src/core/SimplePads.cpp src/core/SimpleSteps.cpp src/core/KeyFollow.cpp src/core/LoopAnalysis.cpp src/core/GamepadMap.cpp src/core/ExportBundle.cpp"
  41. # Simple workflow: one-knob effects, chain presets, the sound picker (round 190bu)
  42. CORE="$CORE src/core/GoalKnobs.cpp src/core/ChainPresets.cpp src/core/SoundLibrary.cpp"
  43. # MIDI controller profiles and the controller layer (round 190aw)
  44. CORE="$CORE src/core/ControllerProfile.cpp src/core/ControllerSession.cpp"
  45. # start-up sound (procedural)
  46. CORE="$CORE src/core/StartupSound.cpp"
  47. # speech synthesizer: .speech files, LYNX voice (round 168b)
  48. CORE="$CORE src/core/Speech.cpp src/core/SpeechRules.cpp"
  49. # FL's 3x Osc engine (REA round 47)
  50. CORE="$CORE src/core/ThreeOsc.cpp"
  51. # FL Studio Mobile's GMSynth (round 190ab)
  52. CORE="$CORE src/core/GmsMobile.cpp"
  53. # Pocket SuperSaw: FL Studio Mobile's SuperSaw (round 190by)
  54. CORE="$CORE src/core/PocketSuperSaw.cpp"
  55. # Tetra: LYNX's own FM synth and the import of Live's Operator onto it (round 190hs)
  56. CORE="$CORE src/core/FmSynth.cpp src/core/AlsDevicesFm.cpp"
  57. # LYNX Model: LYNX's own physical-modelling instrument, mallets on a modal core (round 190ni)
  58. CORE="$CORE src/core/physmod/ModalBank.cpp src/core/physmod/LynxModel.cpp src/core/LynxModelBank.cpp"
  59. # Track clips: "Clips own their notes" on FL's instrument tracks (round 190ne)
  60. CORE="$CORE src/core/TrackClips.cpp"
  61. # The tracker editor's model and the module import (round 190nw)
  62. CORE="$CORE src/core/TrackerGrid.cpp src/core/ModuleImport.cpp"
  63. # Copy and paste between LYNX SHARE windows: what a pasted clip brings along (round 190nz, #232 stage 2)
  64. CORE="$CORE src/core/CrossPaste.cpp"
  65. # Track versions and the import of tracks from another project (round 190pe, research190oe P20 / P11)
  66. CORE="$CORE src/core/TrackVersions.cpp src/core/TrackImport.cpp"
  67. # Helix: LYNX's own wavetable synth and the import of Live's Wavetable onto it (round 190ja)
  68. CORE="$CORE src/core/WavetableSynth.cpp src/core/WavetableTables.cpp src/core/WavetableUser.cpp src/core/AlsDevicesWt.cpp"
  69. # Braid (Live's Meld) and the spectral effects' import, round 190ko
  70. CORE="$CORE src/core/Braid.cpp src/core/BraidParams.cpp src/core/AlsDevicesLot6.cpp"
  71. # FL Studio integration: plugin database and sample relocation (read-only)
  72. CORE="$CORE src/core/FlPluginDb.cpp"
  73. # missing files of an opened project: search and relocation (round 81)
  74. CORE="$CORE src/core/MissingFiles.cpp"
  75. # polyphonic note editor on PitchNet's engine (round 190lk, third_party/pitchnet-poly)
  76. CORE="$CORE src/core/PolyEdit.cpp third_party/pitchnet-poly/PolyEngine.cpp third_party/pitchnet-poly/PolyExtraction.cpp third_party/pitchnet-poly/PolyPurifier.cpp third_party/pitchnet-poly/PolyRenderer.cpp third_party/pitchnet-poly/PolySoundModel.cpp third_party/pitchnet-poly/PolySpectral.cpp third_party/pitchnet-poly/PolyLazy.cpp"
  77. # the plugin picker's catalog (round 151)
  78. CORE="$CORE src/core/PluginCatalog.cpp"
  79. CORE="$CORE src/core/PluginDbFolder.cpp"
  80. CORE="$CORE src/core/FolderWatcher.cpp"
  81. # project safety: backups, versions, packages (REA round 118)
  82. CORE="$CORE src/core/ProjectSafety.cpp"
  83. # Online Sessions P1: stable ids, parts, stand-ins (round 168a)
  84. CORE="$CORE src/core/SessionIds.cpp src/core/SessionParts.cpp src/core/StandIns.cpp"
  85. # Online Sessions P2: live sessions — entity replication, authority, replicas, invite code + encryption (round 169b)
  86. CORE="$CORE src/core/LiveSession.cpp src/core/LiveCrypto.cpp"
  87. # Online Sessions P5-A1: remote plugins (round 190ai)
  88. CORE="$CORE src/core/RemotePlugins.cpp"
  89. # LYNX substitutes for missing third-party plugins (round 98)
  90. CORE="$CORE src/core/PluginSubstitutes.cpp"
  91. # settings pages, plugin manager and shortcut manager logic (round 82)
  92. CORE="$CORE src/core/Preferences.cpp src/core/MidiSync.cpp"
  93. # user themes: the palette derived from an accent and a background (round 162d)
  94. CORE="$CORE src/core/ThemePalette.cpp"
  95. # layouts of the native plugin editors (round 93)
  96. CORE="$CORE src/core/PluginLayout.cpp src/core/StateParams.cpp"
  97. # the drum / physical-model generators' controls and LYNX bank states (round 168p)
  98. CORE="$CORE src/core/DrumControls.cpp src/core/BankStates.cpp src/core/DrumBanks.cpp"
  99. # spectral waveforms (band analysis, multi-resolution peak cache)
  100. CORE="$CORE src/core/WaveAnalysis.cpp src/core/Spectrogram.cpp"
  101. # FL's Plucked!, Sawer and BeepMap engines (REA round 65)
  102. CORE="$CORE src/core/Plucked.cpp src/core/BeepMap.cpp src/core/Sawer.cpp"
  103. # FL's sampler interpolation and FL Keys (REA round 69)
  104. CORE="$CORE src/core/FlResampler.cpp src/core/FlKeys.cpp"
  105. # FL's Hardcore (REA round 71)
  106. CORE="$CORE src/core/HardcoreFx.cpp"
  107. # FL's DirectWave (REA round 72)
  108. CORE="$CORE src/core/DirectWave.cpp"
  109. CORE="$CORE src/core/DirectWaveState.cpp"
  110. # LYNX Soundfont: SF2 / SF3 player (round 158; TinySoundFont + stb_vorbis in third_party)
  111. CORE="$CORE src/core/SoundFont.cpp src/core/SoundFontLoad.cpp src/core/SoundFontIndex.cpp"
  112. # other samplers' instruments as DirectWave channels: .dwp / .dwb, .gig, NCW, Kontakt detection (round 190ii, issue #149)
  113. CORE="$CORE src/core/SamplerImport.cpp src/core/GigFile.cpp src/core/Ncw.cpp src/core/KontaktFile.cpp"
  114. # Ogg Vorbis decoding as FL does (REA round 77)
  115. CORE="$CORE src/core/OggVorbis.cpp"
  116. # export options, MP3 encoding, plugin performance monitor, clip properties / arrangements (round 84)
  117. CORE="$CORE src/core/ExportOptions.cpp src/core/Mp3Encoder.cpp src/core/Mp3Decoder.cpp src/core/PluginMonitor.cpp src/core/PlaylistOps.cpp src/core/QuickRender.cpp src/core/ProjectContents.cpp src/core/TempoDetect.cpp src/core/AutoWarp.cpp src/core/ScoreLog.cpp src/core/ChannelLoops.cpp src/core/PatternBlocks.cpp src/core/ChannelBurn.cpp src/core/AutoSampler.cpp"
  118. # LYNX's Facet EQ and Apex Limiter (round 99)
  119. CORE="$CORE src/core/FacetEq.cpp src/core/ApexLimiter.cpp src/core/Mastering.cpp src/core/MasterLooks.cpp"
  120. # LYNX's dynamics suite and FabFilter state translation (round 108)
  121. CORE="$CORE src/core/DynamicsSuite.cpp src/core/FabFilterStates.cpp"
  122. # LYNX's voice tools: Quell Denoiser, Gemini Doubler (round 119)
  123. CORE="$CORE src/core/VoiceTools.cpp"
  124. # MIDI CC automation of hosted plugins, Formula Controller (round 133, issue #3)
  125. CORE="$CORE src/core/MidiControls.cpp src/core/MidiOut.cpp src/core/FormulaController.cpp"
  126. # controller links: FL's mapping formula and smoothing (round 190bt)
  127. CORE="$CORE src/core/LinkFormula.cpp"
  128. CORE="$CORE src/core/VoiceShift.cpp"
  129. # FL engines usable in native projects (round 142, issue #5)
  130. CORE="$CORE src/core/NativeEngines.cpp src/core/LynxBanks.cpp src/core/ModelParams.cpp src/core/ToxicBank.cpp src/core/PoiZoneBank.cpp src/core/ModelParamsSynths.cpp src/core/PluginLayoutSynths.cpp src/core/HarmlessBank.cpp src/core/Dx10Bank.cpp src/core/SimSynthBank.cpp src/core/BeepMapBank.cpp src/core/GranulizerBank.cpp src/core/HelixBank.cpp src/core/EngineLayouts.cpp"
  131. # FL's Layer channel and the round 164 controllers
  132. CORE="$CORE src/core/Layer.cpp src/core/XyController.cpp src/core/FlCurve.cpp src/core/ControlSurface.cpp src/core/VoltageController.cpp"
  133. # crash / freeze reports: consent, anonymiser, report JSON, GitHub issue URL (round 159)
  134. CORE="$CORE src/core/CrashReport.cpp"
  135. # in-app update check: versions, release list, flavours, checksums, release notes (round 166b)
  136. CORE="$CORE src/core/UpdateCheck.cpp"
  137. # the first-start audio check: verdict and the devices to try (round 190gh, B23)
  138. CORE="$CORE src/core/AudioCheck.cpp"
  139. # the Browser's "Find similar samples" (round 190as)
  140. CORE="$CORE src/core/SampleSimilarity.cpp"
  141. # the embedded Python (pocketpy) and FL's VFX Script (round 165d)
  142. CORE="$CORE src/core/Python.cpp src/core/VfxScript.cpp src/core/EdisonScript.cpp src/core/ScriptDialog.cpp src/core/PianoRollScript.cpp"
  143. # WavPack decoder (C)
  144. if [[ -z "${CC:-}" ]]; then
  145. case "$CXX" in
  146. *zig*) CC="${CXX/c++/cc}" ;;
  147. *clang++*) CC="${CXX/clang++/clang}" ;;
  148. *g++*) CC="${CXX/g++/gcc}" ;;
  149. *) CC=cc ;;
  150. esac
  151. fi
  152. for f in third_party/wavpack/src/*.c; do
  153. obj="build-local/wavpack/$(basename "$f" .c).o"
  154. [[ -f "$obj" && "$obj" -nt "$f" ]] || $CC -c -O2 -w -DHAVE___BUILTIN_CLZ=1 -Ithird_party/wavpack/include -Ithird_party/wavpack/src "$f" -o "$obj"
  155. done
  156. WAVPACK="$(ls build-local/wavpack/*.o | tr '\n' ' ')"
  157. # libogg + libvorbis decoder (C, BSD; third_party/vorbis): no FMA contraction, so the float order stays libvorbis'
  158. mkdir -p build-local/vorbis
  159. for f in third_party/vorbis/src/*.c; do
  160. [[ "$(basename "$f")" == lookup.c ]] && continue # (included by lsp.c)
  161. obj="build-local/vorbis/$(basename "$f" .c).o"
  162. [[ -f "$obj" && "$obj" -nt "$f" ]] || $CC -c -O2 -w -ffp-contract=off -include third_party/vorbis/include/lynx_vorbis_prefix.h -Ithird_party/vorbis/include -Ithird_party/vorbis/src "$f" -o "$obj"
  163. done
  164. WAVPACK="$WAVPACK $(ls build-local/vorbis/*.o | tr '\n' ' ')"
  165. # LAME's libmp3lame (MP3 encoder, LGPL; third_party/lame, configured by its src/config.h)
  166. mkdir -p build-local/lame
  167. for f in third_party/lame/src/*.c; do
  168. obj="build-local/lame/$(basename "$f" .c).o"
  169. [[ -f "$obj" && "$obj" -nt "$f" ]] || $CC -c -O2 -w -DHAVE_CONFIG_H -Ithird_party/lame/include -Ithird_party/lame/src "$f" -o "$obj"
  170. done
  171. WAVPACK="$WAVPACK $(ls build-local/lame/*.o | tr '\n' ' ')"
  172. # pocketpy (C11, MIT; third_party/pocketpy, LYNX's changes marked "LYNX"): sandboxed (no os / files), interruptible
  173. mkdir -p build-local/pocketpy
  174. obj=build-local/pocketpy/pocketpy.o
  175. [[ -f "$obj" && "$obj" -nt third_party/pocketpy/pocketpy.c && "$obj" -nt third_party/pocketpy/pocketpy.h ]] || $CC -c -O2 -w -std=c11 -DPK_ENABLE_OS=0 -DPK_ENABLE_WATCHDOG=1 -Ithird_party/pocketpy third_party/pocketpy/pocketpy.c -o "$obj"
  176. WAVPACK="$WAVPACK $obj"
  177. # libxmp-lite 4.7.4 (MIT; third_party/libxmp-lite): the module import's reader (round 190nw)
  178. mkdir -p build-local/libxmp
  179. for f in third_party/libxmp-lite/src/*.c third_party/libxmp-lite/src/loaders/*.c; do
  180. obj="build-local/libxmp/$(basename "$f" .c).o"
  181. [[ -f "$obj" && "$obj" -nt "$f" ]] || $CC -c -O2 -w -std=c99 -DLIBXMP_CORE_PLAYER -DLIBXMP_STATIC -D_REENTRANT -Ithird_party/libxmp-lite/include/libxmp-lite -Ithird_party/libxmp-lite/src "$f" -o "$obj"
  182. done
  183. WAVPACK="$WAVPACK $(ls build-local/libxmp/*.o | tr '\n' ' ')"
  184. # Monocypher (BSD-2 / CC0; third_party/monocypher): the live sessions' encryption (round 169b)
  185. mkdir -p build-local/monocypher
  186. obj=build-local/monocypher/monocypher.o
  187. [[ -f "$obj" && "$obj" -nt third_party/monocypher/monocypher.c ]] || $CC -c -O2 -w -Ithird_party/monocypher third_party/monocypher/monocypher.c -o "$obj"
  188. WAVPACK="$WAVPACK $obj"
  189. # ysfx + WDL's EEL2 (Apache-2.0 / zlib-style; third_party/ysfx): the JSFX runtime the tests check against upstream's
  190. # reference render (round 190pj; flags as CMakeLists.txt's lynx_ysfx: no @gfx, the GAS x86-64 code generator, empty on
  191. # other CPUs) (rollup 0.1.31 step 7: the Core jobs build with this script)
  192. mkdir -p build-local/ysfx
  193. YSFX_WDL=third_party/ysfx/thirdparty/WDL/source/WDL
  194. YSFX_DEFS="-DYSFX_API= -DYSFX_NO_GFX -DWDL_FFT_REALSIZE=8 -DWDL_LINEPARSE_ATOF=ysfx_wdl_atof -DNSEEL_ATOF=ysfx_wdl_atof -D_FILE_OFFSET_BITS=64 -Ithird_party/ysfx/include -Ithird_party/ysfx/sources -Ithird_party/ysfx/thirdparty/WDL/source -Ithird_party/ysfx/thirdparty/dr_libs"
  195. for f in third_party/ysfx/sources/ysfx*.cpp "$YSFX_WDL"/fft.c "$YSFX_WDL"/eel2/nseel-caltab.c "$YSFX_WDL"/eel2/nseel-cfunc.c \
  196. "$YSFX_WDL"/eel2/nseel-compiler.c "$YSFX_WDL"/eel2/nseel-eval.c "$YSFX_WDL"/eel2/nseel-lextab.c "$YSFX_WDL"/eel2/nseel-ram.c \
  197. "$YSFX_WDL"/eel2/nseel-yylex.c third_party/ysfx/sources/eel2-gas/sources/asm-nseel-x64-sse.S; do
  198. name="$(basename "$f")"; obj="build-local/ysfx/${name%.*}.o"
  199. if [[ ! -f "$obj" || "$f" -nt "$obj" ]]; then
  200. case "$f" in
  201. *.cpp) $CXX -c -O2 -w -std=gnu++17 -fsigned-char $YSFX_DEFS "$f" -o "$obj" ;;
  202. *.S) $CC -c -O2 -w $YSFX_DEFS "$f" -o "$obj" ;;
  203. *) $CC -c -O2 -w -std=gnu11 -fsigned-char $YSFX_DEFS "$f" -o "$obj" ;;
  204. esac
  205. fi
  206. WAVPACK="$WAVPACK $obj"
  207. done
  208. [[ "$(uname -s)" == Linux ]] && WAVPACK="$WAVPACK -ldl -lpthread"
  209. FLAGS="$FLAGS -Ithird_party/ysfx/include -DYSFX_API="
  210. # zig links its compiler_rt, whose archive member also defines WEAK cos/sin/exp/log (double and x87 long double). When a
  211. # link needs any builtin of that member (128-bit division...), those copies replace glibc's libm, whose last bits the
  212. # x87 bit-exact goldens hold: the "no-LTO failures" of multiband_delay_exact and the Kepler tests (round speed185a; the
  213. # LTO links resolve to glibc). So a zig -fno-lto link on Linux puts GCC's libgcc.a ahead of compiler_rt: the builtins
  214. # come from libgcc and the math from glibc. LYNX_ZIG_LIBGCC=0 turns it off.
  215. case "$CXX" in
  216. *zig*-fno-lto*)
  217. if [[ "$(uname -s)" == Linux && "${LYNX_ZIG_LIBGCC:-1}" != 0 ]]; then
  218. libgcc="$(gcc -print-libgcc-file-name 2> /dev/null || true)"
  219. if [[ -f "$libgcc" ]]; then WAVPACK="$WAVPACK $libgcc"; else echo "note: no libgcc.a: zig's compiler_rt math replaces glibc's libm (x87 goldens may fail)" >&2; fi
  220. fi ;;
  221. esac
  222. # g++ / clang++ (not zig, which caches each object itself): every source is compiled once per build, in parallel, and
  223. # the tests and tools link the objects (scripts/cxx-once.sh; it saves ~90 % of a CI "Core" job). LYNX_COMPILE_ONCE=0: off.
  224. case "$CXX" in
  225. *zig*) ;;
  226. *)
  227. if [[ "${LYNX_COMPILE_ONCE:-1}" != 0 ]]; then
  228. export LYNX_CXX_ONCE_REAL="$CXX" LYNX_CXX_ONCE_RUN="$$-$(date +%s)"
  229. mkdir -p build-local/obj
  230. rm -f build-local/obj/*/.done-*
  231. CXX=scripts/cxx-once.sh
  232. fi ;;
  233. esac
  234. # The tests: tests/tests.cpp with its .inc files is split at build time into N translation units compiled in parallel
  235. # (scripts/split-tests.py; same tests, same order, same checks). LYNX_TESTS_SPLIT=0 builds the single TU as before,
  236. # LYNX_TESTS_SPLIT=<n> sets the number of chunks (default: the CPUs this build may use, 2 to 12).
  237. split="${LYNX_TESTS_SPLIT:-auto}"
  238. if [[ "$split" == auto ]]; then
  239. split="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)"
  240. (( split < 2 )) && split=2
  241. (( split > 12 )) && split=12
  242. fi
  243. tests_single() { $CXX $FLAGS $CORE $WAVPACK tests/tests.cpp -o build-local/lynx_tests 2> >(grep -v 'glibc version' >&2); }
  244. if [[ "$split" -ge 2 ]] && command -v python3 > /dev/null && python3 scripts/split-tests.py tests/tests.cpp build-local/split "$split"; then
  245. CHUNKS="build-local/split/lynx_split_main.cpp $(ls build-local/split/chunk*.cpp | tr '\n' ' ')"
  246. rc=0
  247. case "$CXX" in
  248. *zig*) # zig compiles every source of one command in parallel (and caches each object)
  249. $CXX $FLAGS $CORE $WAVPACK $CHUNKS -o build-local/lynx_tests 2> build-local/split/errors.log || rc=$? ;;
  250. *)
  251. # g++ -O2 -g needs ~5.5 GB for one chunk of four (rollup 0.1.28: four at once ran GitHub's 16 GB runner out of
  252. # memory and the runner was lost): with g++ at most as many chunks compile at once as the free memory holds
  253. # (6 GB each; LYNX_TESTS_CHUNK_JOBS=<n> sets it). clang++ and zig need far less: all at once, as before.
  254. chunkJobs="${LYNX_TESTS_CHUNK_JOBS:-0}"
  255. if [[ "$chunkJobs" == 0 ]]; then
  256. chunkJobs=$split
  257. case "${LYNX_CXX_ONCE_REAL:-$CXX}" in
  258. *g++*)
  259. availKb="$(awk '/^MemAvailable:/ { print $2 }' /proc/meminfo 2> /dev/null || true)"
  260. if [[ -n "$availKb" ]]; then
  261. chunkJobs=$(( availKb / (6 * 1024 * 1024) ))
  262. (( chunkJobs < 1 )) && chunkJobs=1
  263. echo "note: g++ test chunks: $chunkJobs at a time ($(( availKb / 1024 / 1024 )) GB free)" >&2
  264. fi ;;
  265. esac
  266. fi
  267. pids=""
  268. for f in $CHUNKS; do
  269. while (( $(jobs -rp | wc -l) >= chunkJobs )); do sleep 1; done
  270. $CXX $FLAGS -c "$f" -o "${f%.cpp}.o" 2> "${f%.cpp}.log" &
  271. pids="$pids $!"
  272. done
  273. for p in $pids; do wait "$p" || rc=$?; done
  274. # (not errors.log itself: a second run in the same build-local would otherwise cat it into itself)
  275. find build-local/split -maxdepth 1 -name '*.log' ! -name 'errors.log' -exec cat {} + > build-local/split/errors.log
  276. [[ $rc == 0 ]] && { $CXX $FLAGS $CORE $WAVPACK $(echo "$CHUNKS" | sed 's/\.cpp/.o/g') -o build-local/lynx_tests 2>> build-local/split/errors.log || rc=$?; } ;;
  277. esac
  278. grep -v 'glibc version' build-local/split/errors.log >&2 || true
  279. if [[ $rc != 0 ]]; then
  280. # a failure only the split can cause (a definition the splitter did not make inline...): build the single TU
  281. if grep -qE 'multiple definition|duplicate symbol|redefinition of|lynxSplit|LYNX_TEST_|LYNX_SPLIT' build-local/split/errors.log; then
  282. echo "note: the split test build failed (see above), building tests/tests.cpp as one unit (LYNX_TESTS_SPLIT=0)" >&2
  283. tests_single
  284. else
  285. exit $rc
  286. fi
  287. fi
  288. else
  289. [[ "$split" -ge 2 ]] && echo "note: the test split is not available, building tests/tests.cpp as one unit" >&2
  290. tests_single
  291. fi
  292. # The tools: zig keys its per-file object cache on the output file name, so every tool that links the core recompiled
  293. # all of it (7 times per cold build), and each one ran its own single-threaded LTO link, one after the other. With zig
  294. # the lines below only queue the tools (build-local/.bin/cxx): each is linked as build-local/.bin/<tool>/lynx_tests
  295. # (the tests' name, so the cached core objects are reused) and they are built in parallel before the tests run.
  296. TOOLS_QUEUE=
  297. case "$CXX" in
  298. *zig*)
  299. mkdir -p build-local/.bin
  300. TOOLS_QUEUE=build-local/.bin/queue
  301. rm -f "$TOOLS_QUEUE"
  302. cat > build-local/.bin/cxx << EOF
  303. #!/usr/bin/env bash
  304. args=(); out=
  305. while [[ \$# -gt 0 ]]; do [[ "\$1" == -o ]] && { out="\$2"; shift 2; continue; }; args+=("\$1"); shift; done
  306. [[ -n "\$out" ]] || exec $CXX "\${args[@]}"
  307. d="build-local/.bin/\$(basename "\$out")"; mkdir -p "\$d"
  308. { printf '%q ' $CXX "\${args[@]}" -o "\$d/lynx_tests"; printf '2> >(grep -v "glibc version" >&2) && mv -f %q %q\n' "\$d/lynx_tests" "\$out"; } >> $TOOLS_QUEUE
  309. EOF
  310. chmod +x build-local/.bin/cxx
  311. CXX=build-local/.bin/cxx ;;
  312. esac
  313. # The JUCE-free Remote Control suites (they also run through the upstream core CI path). After the zig queue above,
  314. # so with zig they link the cached core objects instead of compiling the whole core once more each (round 190ha).
  315. $CXX $FLAGS $CORE $WAVPACK tests/RemotePlaylistEditsTests.cpp -o build-local/lynx_remote_playlist_tests
  316. $CXX $FLAGS $CORE $WAVPACK tests/RemoteInstrumentEditsTests.cpp -o build-local/lynx_remote_instrument_tests
  317. $CXX $FLAGS $CORE $WAVPACK tests/RemotePatternEditsTests.cpp -o build-local/lynx_remote_pattern_tests
  318. $CXX $FLAGS src/flp/Flp.cpp tools/flpdump.cpp -o build-local/flpdump 2> >(grep -v 'glibc version' >&2)
  319. $CXX $FLAGS $CORE $WAVPACK tools/renderwav.cpp -o build-local/renderwav 2> >(grep -v 'glibc version' >&2)
  320. # a Live set, one WAV per MIDI track (round 190hs: the LYNX side of the Operator / Tetra quality gate)
  321. $CXX $FLAGS $CORE $WAVPACK tools/alsrender.cpp -o build-local/alsrender 2> >(grep -v 'glibc version' >&2)
  322. # LYNX Model's renderer / cost per voice (round 190ni: the timbre score's and the calibration's renders)
  323. $CXX $FLAGS $CORE $WAVPACK tools/physmodrender.cpp -o build-local/physmodrender 2> >(grep -v 'glibc version' >&2)
  324. # a tracker module rendered by libxmp-lite's own player (round 190nw): the module import's reference renders
  325. $CXX $FLAGS -DLIBXMP_STATIC -Ithird_party/libxmp-lite/include/libxmp-lite tools/modrender.cpp $(ls build-local/libxmp/*.o | tr '\n' ' ') -lm -o build-local/modrender 2> >(grep -v 'glibc version' >&2)
  326. $CXX $FLAGS src/core/OggVorbis.cpp $(ls build-local/vorbis/*.o | tr '\n' ' ') tools/oggdecode.cpp -o build-local/oggdecode 2> >(grep -v 'glibc version' >&2)
  327. $CXX $FLAGS $CORE $WAVPACK tools/comparewav.cpp -o build-local/comparewav 2> >(grep -v 'glibc version' >&2)
  328. # LYNX effects offline, the LYNX side of the third-party parity harness (round tp172b)
  329. $CXX $FLAGS $CORE $WAVPACK tools/fxrender.cpp -o build-local/fxrender 2> >(grep -v 'glibc version' >&2)
  330. $CXX $FLAGS $CORE $WAVPACK tools/vocodexrender.cpp -o build-local/vocodexrender 2> >(grep -v 'glibc version' >&2)
  331. # Newtone offline (round 190li): the LYNX side of the vocal lab (tools/vocallab)
  332. $CXX $FLAGS $CORE $WAVPACK tools/newtonelab.cpp -o build-local/newtonelab 2> >(grep -v 'glibc version' >&2)
  333. # (rollup 0.1.30 step 6: Harmor's resynthesis (natives190kj) reads samples through the core: the whole core, as the other renderers)
  334. $CXX $FLAGS $CORE $WAVPACK tools/harmorrender.cpp -o build-local/harmorrender 2> >(grep -v 'glibc version' >&2)
  335. $CXX $FLAGS $CORE $WAVPACK tools/gmsrender.cpp -o build-local/gmsrender 2> >(grep -v 'glibc version' >&2)
  336. $CXX $FLAGS src/core/Morphine.cpp tools/morphinerender.cpp -o build-local/morphinerender 2> >(grep -v 'glibc version' >&2)
  337. $CXX $FLAGS src/core/FruitKick.cpp src/core/FlangusFastDist.cpp tools/fruitkickrender.cpp -o build-local/fruitkickrender 2> >(grep -v 'glibc version' >&2)
  338. $CXX $FLAGS src/core/BassDrum.cpp tools/bassdrumrender.cpp -o build-local/bassdrumrender 2> >(grep -v 'glibc version' >&2)
  339. $CXX $FLAGS src/core/Toxic.cpp src/core/ToxicFx.cpp tools/toxicrender.cpp -o build-local/toxicrender 2> >(grep -v 'glibc version' >&2)
  340. $CXX $FLAGS $CORE $WAVPACK tools/ogunrender.cpp -o build-local/ogunrender 2> >(grep -v 'glibc version' >&2)
  341. $CXX $FLAGS src/core/MiniSynth.cpp tools/minisynthrender.cpp -o build-local/minisynthrender 2> >(grep -v 'glibc version' >&2)
  342. $CXX $FLAGS src/core/SimSynth.cpp tools/simsynthrender.cpp -o build-local/simsynthrender 2> >(grep -v 'glibc version' >&2)
  343. $CXX $FLAGS src/core/Dx10.cpp tools/dx10render.cpp -o build-local/dx10render 2> >(grep -v 'glibc version' >&2)
  344. $CXX $FLAGS src/core/Kepler.cpp src/core/IldspMath.cpp tools/keplerrender.cpp -o build-local/keplerrender 2> >(grep -v 'glibc version' >&2)
  345. $CXX $FLAGS src/core/TransistorBass.cpp tools/tbassrender.cpp -o build-local/tbassrender 2> >(grep -v 'glibc version' >&2)
  346. $CXX $FLAGS src/core/PoiZone.cpp tools/poizonerender.cpp -o build-local/poizonerender 2> >(grep -v 'glibc version' >&2)
  347. $CXX $FLAGS $CORE $WAVPACK tools/bankrender.cpp -o build-local/bankrender 2> >(grep -v 'glibc version' >&2)
  348. $CXX $FLAGS src/core/FruityDelay.cpp tools/fdelayrender.cpp -o build-local/fdelayrender 2> >(grep -v 'glibc version' >&2)
  349. $CXX $FLAGS $CORE $WAVPACK tools/distructorrender.cpp -o build-local/distructorrender 2> >(grep -v 'glibc version' >&2)
  350. $CXX $FLAGS src/core/ThreeOsc.cpp tools/threeoscrender.cpp -o build-local/threeoscrender 2> >(grep -v 'glibc version' >&2)
  351. $CXX $FLAGS src/core/Slayer.cpp tools/slayerrender.cpp -o build-local/slayerrender 2> >(grep -v 'glibc version' >&2)
  352. $CXX $FLAGS $CORE $WAVPACK tools/wavetravellerrender.cpp -o build-local/wavetravellerrender 2> >(grep -v 'glibc version' >&2)
  353. # (the tools queued above: build them in parallel, at most half the cores at once, an LTO link takes ~4 GB)
  354. if [[ -n "$TOOLS_QUEUE" && -f "$TOOLS_QUEUE" ]]; then
  355. # 2026-11-04: in parallel the tools deadlocked inside zig's shared object cache (every zig process waiting on a
  356. # manifest lock another one held, 0 % CPU for hours). One at a time by default; LYNX_TOOLS_JOBS=n to try more.
  357. tools_jobs=${LYNX_TOOLS_JOBS:-1}
  358. if [[ "${LYNX_TOOLS_WITH_TESTS:-0}" == 1 ]]; then
  359. # (round speed185a) the tests don't use the tools: link them (single-threaded LTO links, ~8 min) while the tests run
  360. rm -f build-local/tools.rc
  361. ( xargs -P "$tools_jobs" -d '\n' -I{} bash -c '{}' < "$TOOLS_QUEUE" > build-local/tools.log 2>&1; echo $? > build-local/tools.rc; rm -f "$TOOLS_QUEUE" ) &
  362. tools_pid=$!
  363. else
  364. xargs -P "$tools_jobs" -d '\n' -I{} bash -c '{}' < "$TOOLS_QUEUE"
  365. rm -f "$TOOLS_QUEUE"
  366. fi
  367. fi
  368. # LYNX_TESTS_RUN=0: build only, run nothing (a cross build, e.g. CXX=aarch64-linux-gnu-g++, whose tests then run under
  369. # qemu-user or on an arm64 machine: docs/BUILDING.md "Linux arm64")
  370. if [[ "${LYNX_TESTS_RUN:-1}" == 0 ]]; then
  371. if [[ -n "${tools_pid:-}" ]]; then
  372. wait "$tools_pid" || true
  373. [[ "$(cat build-local/tools.rc 2> /dev/null)" == 0 ]] || { echo "build-local: the tools did not build (build-local/tools.log)" >&2; exit 1; }
  374. fi
  375. echo "build-local: built (LYNX_TESTS_RUN=0: no tests run)"
  376. exit 0
  377. fi
  378. # LYNX_TEST_JOBS=<n> (or "auto": the CPUs) runs the tests in parallel shards, then the timing-sensitive ones alone
  379. # (scripts/run-tests.sh: same tests, same checks, the same "N checks, M failures" line). Unset or 1: one process, as before.
  380. tests_rc=0
  381. case "${LYNX_TEST_JOBS:-1}" in
  382. 1) ./build-local/lynx_tests "$@" || tests_rc=$? ;;
  383. auto) scripts/run-tests.sh build-local/lynx_tests "$@" || tests_rc=$? ;;
  384. *) scripts/run-tests.sh -j "$LYNX_TEST_JOBS" build-local/lynx_tests "$@" || tests_rc=$? ;;
  385. esac
  386. if [[ -n "${tools_pid:-}" ]]; then
  387. wait "$tools_pid" || true
  388. if [[ "$(cat build-local/tools.rc 2> /dev/null)" != 0 ]]; then
  389. grep -v 'glibc version' build-local/tools.log >&2 || true
  390. echo "build-local: the tools did not build (build-local/tools.log)" >&2
  391. exit 1
  392. fi
  393. fi
  394. ./build-local/lynx_remote_playlist_tests || tests_rc=$?
  395. ./build-local/lynx_remote_instrument_tests || tests_rc=$?
  396. ./build-local/lynx_remote_pattern_tests || tests_rc=$?
  397. exit $tests_rc