Integrate OCaml in Qt project
This commit is contained in:
parent
3c0c2cff6f
commit
dbc17bb003
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@ all:
|
|||
dune build src/lib/oboy.exe
|
||||
|
||||
core:
|
||||
dune build src/retroarch
|
||||
dune build src/core/oboy.a
|
||||
|
||||
check:
|
||||
ocamlbuild -use-ocamlfind -I src -lflag -g test/test_bit.byte --
|
||||
|
|
|
@ -60,7 +60,7 @@ let power_up cartridge =
|
|||
run cpu mem screen
|
||||
|
||||
|
||||
let () =
|
||||
let main =
|
||||
if Array.length Sys.argv < 2 then begin
|
||||
prerr_endline "Please specify a ROM.";
|
||||
eprintf "Usage: %s path/to/rom\n" Sys.argv.(0);
|
||||
|
@ -71,3 +71,6 @@ let () =
|
|||
match cartridge with
|
||||
| None -> print_endline "Invalid ROM file."
|
||||
| Some c -> power_up c
|
||||
|
||||
(** let () =
|
||||
main *)
|
||||
|
|
6
src/core/version.ml
Normal file
6
src/core/version.ml
Normal file
|
@ -0,0 +1,6 @@
|
|||
let name () = "oboy"
|
||||
let version () = "1.0a"
|
||||
|
||||
let () =
|
||||
Callback.register "name" name;
|
||||
Callback.register "version" version;
|
19
src/qt/About.qml
Normal file
19
src/qt/About.qml
Normal file
|
@ -0,0 +1,19 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Window 2.0
|
||||
|
||||
Window {
|
||||
title: "About"
|
||||
// A background map is 32 x 32 tiles.
|
||||
// Each tile is 8 x 8 pixels.
|
||||
width: 128
|
||||
height: 128
|
||||
maximumWidth: width
|
||||
minimumWidth: width
|
||||
maximumHeight: height
|
||||
minimumHeight: height
|
||||
|
||||
Text {
|
||||
id: name
|
||||
text: qsTr("About name")
|
||||
}
|
||||
}
|
|
@ -1,6 +1,14 @@
|
|||
#include <QApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include <caml/mlvalues.h>
|
||||
#include <caml/callback.h>
|
||||
|
||||
void load_caml(char *argv[])
|
||||
{
|
||||
caml_main(argv);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
@ -8,5 +16,7 @@ int main(int argc, char *argv[])
|
|||
QQmlApplicationEngine engine;
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
|
||||
load_caml(argv);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,18 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
title: qsTr("Help")
|
||||
MenuItem {
|
||||
text: qsTr("About")
|
||||
onTriggered: {
|
||||
var component = Qt.createComponent("About.qml")
|
||||
var about = component.createObject(root)
|
||||
about.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MainForm {
|
||||
|
|
|
@ -6,6 +6,12 @@ CONFIG += c++11
|
|||
|
||||
SOURCES += main.cpp
|
||||
|
||||
# `ocamlc -where` = /usr/lib/ocaml
|
||||
INCLUDEPATH += /usr/lib/ocaml
|
||||
|
||||
LIBS += -L/home/fabs/Code/oboy/_build/default/src/core -loboy # TODO: fix path to OCaml library
|
||||
LIBS += -L/usr/lib/ocaml -lm -ldl -lasmrun # /usr/lib/ocaml/Makefile.config | grep NATIVECCLIBS
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
<file>MainForm.ui.qml</file>
|
||||
<file>BackgroundMap.qml</file>
|
||||
<file>BackgroundMapForm.ui.qml</file>
|
||||
<file>About.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in a new issue