Skip to content

Commit

Permalink
add config param for command-line options for LilyPond
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Prete committed Jun 1, 2024
1 parent ef0d9b5 commit ba71331
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions documentation/miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ along with Spontini-Editor. If not, see <http://www.gnu.org/licenses/>.

# Miscellaneous

### ADDITIONAL COMPILE OPTIONS/FLAGS

You can add them by setting "compile-additional-opts" configuration parameter:
click on "TOOLS--->Set configuration parameter", then insert "compile-additional-opts" as parameter, then insert all the additional options you need in the same entry. For example: "-I /my/include/directory -l WARN".
Don't forget to restart the SpontiniServer after the parameter is set.

### AXES

Once a score is loaded and rendered, four draggable axes, useful for graphically aligning objects, can be activated by selecting "TOOLS--->Toggle axes"
Expand Down
17 changes: 16 additions & 1 deletion lib/python/spontini_server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
inkscapeVersion = ""
defaultMode = "svg"
defaultMidiInputChannel = "-1"
compileAdditionalOpts="compile-additional-opts"
WORKSPACE_PARAM = "workspace"
VERSION_PARAM = "version"
CAN_CONFIG_FROM_NON_LOCALHOST_PARAM = "can-config-from-non-localhost"
Expand All @@ -93,8 +94,9 @@
MIDI_ENABLED_PARAM = "midi-enabled"
SOUNDFONT_URL_PARAM = "soundfont-url"
DEFAULT_MODE_PARAM = "default-mode"
COMPILE_ADDITIONAL_OPTS_PARAM = "compile-additional-opts"
DEFAULT_MIDI_INPUT_CHANNEL_PARAM = "default-midi-input-channel"
configurableParams = [WORKSPACE_PARAM, VERSION_PARAM, CAN_CONFIG_FROM_NON_LOCALHOST_PARAM, FORK_ACCESS_ONLY_PARAM, DEBUG_PARAM, LILYPOND_EXEC_PARAM, INKSCAPE_EXEC_PARAM, MIDI_ENABLED_PARAM, DEFAULT_MIDI_INPUT_CHANNEL_PARAM, SOUNDFONT_URL_PARAM, DEFAULT_MODE_PARAM]
configurableParams = [WORKSPACE_PARAM, VERSION_PARAM, CAN_CONFIG_FROM_NON_LOCALHOST_PARAM, FORK_ACCESS_ONLY_PARAM, DEBUG_PARAM, LILYPOND_EXEC_PARAM, INKSCAPE_EXEC_PARAM, MIDI_ENABLED_PARAM, DEFAULT_MIDI_INPUT_CHANNEL_PARAM, SOUNDFONT_URL_PARAM, DEFAULT_MODE_PARAM, COMPILE_ADDITIONAL_OPTS_PARAM]

debug = True
savedConFilename = "saved-config.txt"
Expand Down Expand Up @@ -186,6 +188,7 @@ def readConfigParams():
global spontiniVersion
global forkAccessOnly
global defaultMode
global compileAdditionalOpts
global WORKSPACE_PARAM
global VERSION_PARAM
global CAN_CONFIG_FROM_NON_LOCALHOST_PARAM
Expand All @@ -197,6 +200,7 @@ def readConfigParams():
global DEFAULT_MIDI_INPUT_CHANNEL_PARAM
global DEFAULT_MODE_PARAM
global SOUNDFONT_URL_PARAM
global COMPILE_ADDITIONAL_OPTS_PARAM
global configurableParams

try:
Expand All @@ -211,6 +215,7 @@ def readConfigParams():
setConfigParam(DEBUG_PARAM, "no")
setConfigParam(MIDI_ENABLED_PARAM, "yes")
setConfigParam(SOUNDFONT_URL_PARAM, "")
setConfigParam(COMPILE_ADDITIONAL_OPTS_PARAM, "")
setConfigParam(CAN_CONFIG_FROM_NON_LOCALHOST_PARAM, "no")
setConfigParam(FORK_ACCESS_ONLY_PARAM, "no")
setConfigParam(WORKSPACE_PARAM, "")
Expand Down Expand Up @@ -265,6 +270,9 @@ def readConfigParams():
if parm == LILYPOND_EXEC_PARAM:
lilyExecutableCmd = val

if parm == COMPILE_ADDITIONAL_OPTS_PARAM:
compileAdditionalOpts = val

if parm == DEFAULT_MIDI_INPUT_CHANNEL_PARAM:
defaultMidiInputChannel = val

Expand Down Expand Up @@ -442,6 +450,7 @@ def doPostSync(message, request):
global lilyExecutableCmd
global sepTkn
global inkscapeVersion
global compileAdditionalOpts

clientInfo = "["+host+":"+clPort+"] "

Expand Down Expand Up @@ -615,6 +624,12 @@ def doPostSync(message, request):
cliArr.insert(2, "-dbackend="+param3)
if param3.strip() == "null":
cliArr.insert(2, "-dno-print-pages")
if compileAdditionalOpts:
for opt in reversed(compileAdditionalOpts.split()):
cliArr.insert(2, opt)

log(clientInfo + "Executing: " + ' '.join(cliArr), "I")

try:
p = subprocess.run(cliArr, encoding='utf-8', stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
if p.returncode == 0:
Expand Down

0 comments on commit ba71331

Please sign in to comment.