Commit graph

685 commits

Author SHA1 Message Date
Olivier Goffart
7106e354a3 Fix C++ compilation
The generated cbindgen would otherwise not compile
2020-06-10 13:45:01 +02:00
Simon Hausmann
1baab9823a Another small typo fix :) 2020-06-10 12:05:44 +02:00
Simon Hausmann
ea52c7c9c9 Fix typo 2020-06-10 12:03:46 +02:00
Olivier Goffart
bd4bcdfeb3 Even better way to use enums from C++ 2020-06-10 10:18:27 +02:00
Simon Hausmann
0674c4f544 Ignore generated files 2020-06-10 10:10:00 +02:00
Olivier Goffart
4c6205d09b Use the generated internal::types::Resource from the C++ resource header 2020-06-10 10:06:41 +02:00
Simon Hausmann
983c8571e3 Minor cleanup in function naming 2020-06-10 09:27:54 +02:00
Olivier Goffart
58618c0683 Documentation for the interpreter 2020-06-10 09:26:11 +02:00
Olivier Goffart
300cb26208 Rename the interpreter crate to sixtyfps_interpreter 2020-06-10 08:41:49 +02:00
Simon Hausmann
f95b31bca4 Fix build 2020-06-09 23:24:38 +02:00
Simon Hausmann
1404cb73ae Add support for embedding resources in the rust generator
This is relatively straight-forward via a pass in the compiler to
collect the resources to embed and then use include_bytes! (once per
resource).

What's really annoying is that the rust resource enum can't store a
&'static [u8] because cbindgen doesn't represent that, probably because
the slice representation isn't guaranteed to stay as it is. So instead
this, for now, uses raw pointers.
2020-06-09 22:54:29 +02:00
Simon Hausmann
82a7c3e070 Change rust-wasm example to use the separate file compilation
This makes it easier to switch on resource embedding then :-)
2020-06-09 22:54:29 +02:00
Simon Hausmann
5bae6e01a5 Prepare for the ability to embed image data
The Image's source property used to be a string. Now it is a Resource
enum, which can either be None or an absolute file path to the image on
disk. This also replaces the internal Image type.

The compiler internally resolves the img bang expression to a resource
reference, which shall remain just an absolute path. For now the target
generator passes that through, but in the future the target generator
may choose a target specific way of embedding the data and thus
generating a different Resource type in the final code (through
compile_expression in the cpp and rust generator).

The C++ binding is a bit messy as cbindgen doesn't really support
exporting enums that can be constructed on the C++ side. So instead we
use cbindgen to merely export the type internally and only use the tag
from it then. The public API is then a custom Resource type that is
meant to be binary compatible.
2020-06-09 22:54:29 +02:00
Olivier Goffart
a756b7fa0e Keep a reference to the AST node in the Element structure
So we can give error for elements
2020-06-09 18:20:32 +02:00
Simon Hausmann
aa61a9d2b2 Reduce the #[cfg] usage a little in the GL renderer
Collect configuration specific fields in one PlatformData structure.
2020-06-09 14:04:39 +02:00
Simon Hausmann
afd7319ae5 Rename corelib to sixtyfps_corelib
This is consistent with the other packages and since corelib is now also
a cdylib, libsixtyfps_corelib.so looks much better than libcorelib.so
:-)
2020-06-09 13:27:18 +02:00
Simon Hausmann
547a732e33 Fix rebuild issues, part 10523
By setting RUSTFLAGS in the Cargo config we run into the situation that
when doing a host build, all rust files are compiled with the flags,
including build.rs. When cross-compiling, build.rs is not build with the
RUSTFLAGS specified. That makes kind of sense, but it also means that
all the build scripts are always recompiled when switching between a
target and a host build - and that applies to *all* packages, including
dependencies.

So short of a better solution, this patch removes the need to set
RUSTFLAGS. It was used to extract the system library dependencies for
the static library we'd create. Instead we're now building two shared
libraries and are linking against them. They contain the rust library
twice, so that's not really a desirable final state either, but
productivity wins right now :-)

It might make sense to go back to creating *one* shared library through
a dedicated crate and -- since 'pub extern "C"' functions are not
transitively exported, it may require re-exporting them by hand or using
some clever build trick perhaps.
2020-06-09 13:08:59 +02:00
Olivier Goffart
c05da294a1 Add GridLayout and Row
The compiler currently lowers them to nothing
2020-06-09 12:46:16 +02:00
Olivier Goffart
b7bc884447 Run the JS test without using npm install 2020-06-09 10:25:38 +02:00
Olivier Goffart
34931e58c0 Polishing of the documentation 2020-06-08 17:57:18 +02:00
Olivier Goffart
89b77937bb Put some sensible value into the LayoutInfo struct 2020-06-08 17:55:10 +02:00
Simon Hausmann
bf58647ad1 Fix wasm build, part 2
Build only the example for now, explicitly. There are other crates that
don't compile to wasm (notably proc-macro related ones).
2020-06-08 17:48:34 +02:00
Simon Hausmann
a176f08b13 Change rustwasm example to plus-minus, minus the image.
Next step though is to convert to the external .60 file build.
2020-06-08 17:06:53 +02:00
Simon Hausmann
e10cecef14 Re-enable the WASM build
This reverts commit f9cafcdbea.
2020-06-08 17:01:45 +02:00
Simon Hausmann
fb2b12c28a Implement basic text rendering on the wasm port
Based on Olivier's suggestion, the text rendering primitive is created
by painting the text onto a temporary HTML canvas
element and binding that to a texture.
2020-06-08 17:00:59 +02:00
Simon Hausmann
aea81f5202 Upgrade glow to a patched version
The GL bindings were missing one feature on the web side, the ability to
set texture image data from an HTML canvas element.
We're going to need that soon.

The bump to a newer version also came with some odd (but sensible)
source incompatibilities.
2020-06-08 16:57:58 +02:00
Simon Hausmann
2c1ecc7478 Revert attempts to make emscripten build work
This reverts commit aef96cb7d8, commit
1b2d0a309f, and commit
82214dc2d7.

The wasm32-unknown-emscripten target is not very well supported right
now, from build issues in instant/winit to toolchain issues
(https://github.com/rust-lang/rust/issues/66916).

So let's not go down that route for now.
2020-06-08 14:54:24 +02:00
Simon Hausmann
aef96cb7d8 Refine winit stdweb feature selection
Amend commit 1b2d0a309f by restricting the
stdweb choice only when targeting emscripten.
2020-06-08 13:14:32 +02:00
Simon Hausmann
1b2d0a309f Fix wasm32-unknown-emscripten build of corelib
Depend on a version of winit that enables the use within emscripten.
2020-06-08 13:04:48 +02:00
Simon Hausmann
82214dc2d7 Fix wasm32-unknown-emscripten build of corelib
There's an implicit dependency to instant, which in turn requires a patch
to work around https://github.com/rust-lang/rust/issues/67782
2020-06-08 13:03:29 +02:00
Simon Hausmann
5e7c6372fd Fix cross-compilation of vtable
syn/quote/proc-macro are not needed at run-time for the vtable use.
2020-06-08 13:00:55 +02:00
Olivier Goffart
11ac0cfad0 Test for nodejs 2020-06-08 12:24:39 +02:00
Olivier Goffart
11a0e89827 Test framework: extract the cpp and rust snippets 2020-06-08 10:54:17 +02:00
Olivier Goffart
0e67a0ecbc Block comments 2020-06-08 10:40:02 +02:00
Olivier Goffart
d1febde6c7 Fix warning in the generated code 2020-06-08 10:07:17 +02:00
Olivier Goffart
4b7f8e2d04 Fix building of corelib for wasm
Wasm does not have the run_return function, so use the trick with
scoped_tls to have non-static functions
2020-06-08 09:22:38 +02:00
Olivier Goffart
772f77b700 Rust test: generate a different file for each test
So that the file name show which test it cames from in case of error
2020-06-05 19:51:41 +02:00
Olivier Goffart
e18689af5c Test the rist frontend 2020-06-05 19:29:40 +02:00
Olivier Goffart
d0332fafbf Revert "Not-working Tests for the Rust frontend"
This reverts commit 87bce9c106688516ab66de3f81cc907bee0a8b9b.

Because it is not working
2020-06-05 19:04:07 +02:00
Olivier Goffart
9f6639631c Not-working Tests for the Rust frontend
This is not working because spawning cargo for each tests is too slow,
and cannot even re-use the same target directory because it would block
on the cargo lock file. and rebuild all the dependences because of
different flags
2020-06-05 19:04:07 +02:00
Simon Hausmann
d574a088a6 Remove unnecessary CARGO environment variable forwarding
In contrast to the others, this one seems to be universally set :)
2020-06-05 18:01:40 +02:00
Simon Hausmann
318e65b1d4 Fix typo 2020-06-05 17:41:59 +02:00
Simon Hausmann
8b475440c6 Reduce build ping-pong due to system library extraction 2020-06-05 17:22:42 +02:00
Olivier Goffart
6adbf1a077 Test: Slightly better error output when the C++ code does not compile 2020-06-05 17:03:42 +02:00
Simon Hausmann
975d0603e6 Fix scopeguard API usage
This is more idiomatic and nicer :)
2020-06-05 16:53:31 +02:00
Simon Hausmann
2579d4e84c Don't exit the process if there's an issue with the C++ generator 2020-06-05 16:15:32 +02:00
Simon Hausmann
3aa0c94f83 Run tests through the interpreter as well, at least for instantiation. 2020-06-05 16:02:59 +02:00
Simon Hausmann
d20eec1b4e Pick up newly added test cases
Add all the directories of the tests to the watch list of cargo. Adding
a new file will change the mtime of the directory and trigger a rebuild
then.
2020-06-05 15:18:14 +02:00
Simon Hausmann
5a5ab27f70 Minor cleanups
* Remove the dependency to the rust frontend and library from the test
  driver. Tests are compiled and run as standalone programs.
* Add diagnostics for the initial cargo run for the dependencies.
2020-06-05 15:11:26 +02:00
Simon Hausmann
54b02d2b0d Change the test driver to use the rust test framework
Collect all tests are build time in build.rs and generate Rust code that
uses #[test] annotated functions. This gives nice reporting and the
ability to run individual tests.
2020-06-05 14:47:05 +02:00