@@ -20,6 +20,7 @@ class PrologCompilationBox extends CompilationBox
2020 public static $ BOX_TYPE = "prolog-compilation " ;
2121 public static $ PROLOG_BINARY = "/usr/bin/swipl " ;
2222 public static $ DEFAULT_NAME = "SWI-Prolog Compilation " ;
23+ public static $ INIT_FILE_PORT_KEY = "init-file " ;
2324 public static $ WRAPPER_FILE_PORT_KEY = "compilation-wrapper " ;
2425
2526 private static $ initialized = false ;
@@ -34,6 +35,7 @@ public static function init() {
3435 if (!self ::$ initialized ) {
3536 self ::$ initialized = true ;
3637 self ::$ defaultInputPorts = array (
38+ new Port ((new PortMeta ())->setName (self ::$ INIT_FILE_PORT_KEY )->setType (VariableTypes::$ FILE_TYPE )),
3739 new Port ((new PortMeta ())->setName (self ::$ WRAPPER_FILE_PORT_KEY )->setType (VariableTypes::$ FILE_TYPE )),
3840 new Port ((new PortMeta ())->setName (self ::$ RUNNER_FILE_PORT_KEY )->setType (VariableTypes::$ FILE_TYPE )),
3941 new Port ((new PortMeta ())->setName (self ::$ ARGS_PORT_KEY )->setType (VariableTypes::$ STRING_ARRAY_TYPE )),
@@ -111,20 +113,22 @@ public function compile(CompilationParams $params): array {
111113 $ this ->getInputPortValue (self ::$ ARGS_PORT_KEY )->getValue ());
112114 }
113115
116+ $ initFile = $ this ->getInputPortValue (self ::$ INIT_FILE_PORT_KEY )->getValue ();
117+ $ sourceFiles = $ this ->getInputPortValue (self ::$ SOURCE_FILES_PORT_KEY )->getValue (ConfigParams::$ EVAL_DIR );
118+ $ extraFiles = $ this ->getInputPortValue (self ::$ EXTRA_FILES_PORT_KEY )->getValue (ConfigParams::$ EVAL_DIR );
119+ $ runnerFile = $ this ->getInputPortValue (self ::$ RUNNER_FILE_PORT_KEY )->getValue (ConfigParams::$ EVAL_DIR );
120+
114121 array_push ($ args ,
115122 "-o " ,
116123 $ this ->getOutputPortValue (self ::$ BINARY_FILE_PORT_KEY )->getValue (ConfigParams::$ EVAL_DIR ),
117- "-c "
124+ "-c " ,
125+ $ initFile ,
126+ ...$ sourceFiles
118127 );
128+ array_push ($ args , ...$ extraFiles );
129+ array_push ($ args , $ runnerFile );
119130
120- $ task ->setCommandArguments (
121- array_merge (
122- $ args ,
123- $ this ->getInputPortValue (self ::$ SOURCE_FILES_PORT_KEY )->getValue (ConfigParams::$ EVAL_DIR ),
124- $ this ->getInputPortValue (self ::$ EXTRA_FILES_PORT_KEY )->getValue (ConfigParams::$ EVAL_DIR ),
125- [ $ this ->getInputPortValue (self ::$ RUNNER_FILE_PORT_KEY )->getValue (ConfigParams::$ EVAL_DIR ) ]
126- )
127- );
131+ $ task ->setCommandArguments ($ args );
128132
129133 // check if file produced by compilation was successfully created
130134 $ binary = $ this ->getOutputPortValue (self ::$ BINARY_FILE_PORT_KEY )->getDirPrefixedValue (ConfigParams::$ SOURCE_DIR );
0 commit comments