Commit graph

41 commits

Author SHA1 Message Date
Simon Hausmann
893b5132c8 Further encapsulate Diagnostics
Use has_error() and a new convenience function to get the diagnostics as a string vector.
2020-07-17 11:52:29 +02:00
Simon Hausmann
732a56259f Simplify compilation call sites further
Move run_passes into the library compilation function. That way the
FileDiagnostics are created by the parser, can be passed on to the library
compilation function and after that we don't need them anymore and can
replace them with future BuildDiagnostics for example.
2020-07-16 18:53:59 +02:00
Simon Hausmann
4c1e4c4da4 Reduce direct access to CompilerDiagnostic::message
Instead use to_string(), to make it easier to change in the future.
2020-07-16 18:22:23 +02:00
Olivier Goffart
96cfd8a620 Fix property named "value" in C++, and fix comparison of lenght in rust 2020-07-16 17:22:29 +02:00
Simon Hausmann
4721dbfd53 Fix build with clang
Include cmath to get the overload of std::abs that takes a float.
2020-07-16 13:58:18 +02:00
Simon Hausmann
c3aae7648a Further simplify compilation call sites
Remove the need to construct the type registry at all the call sites by
offering a compile_syntax_node function in the compiler library.
2020-07-16 09:25:26 +02:00
Simon Hausmann
64a4e749b7 Simplify path setup in the Diagnostics
Pass the path to the parse function, as that's easier at most call sites.
Also offer a convenience parse_file function.
2020-07-15 19:21:25 +02:00
Simon Hausmann
8e047d3761 Simplify compiler diagnostics API
Don't require the callers to hold on to the source code string until an
eventual diagnostics code path is hit. Instead it turns out it's
simpler to let the parser consume the source code as string, where
internally after tokenizing it can be moved into the diagnostics and
from there into the code map if needed.

There are a few places where we now clone the source code, but that's
only in cases where we also extract stuff separately (test code) or the
syntax updater.
2020-07-15 17:34:11 +02:00
Simon Hausmann
5b43962bb2 Split up TypeRegistry
For a .60 files the locally defined components are now stored in a separate
per-document TypeRegistry instance that falls back to the global registry
for lookups.
2020-07-15 13:09:43 +02:00
Olivier Goffart
89ad110fc2 Test nodejs driver: print compile error on the console if there are some 2020-06-29 10:52:48 +02:00
Olivier Goffart
f35c12aef1 Fix building of the nodejs frontend for the tests 2020-06-29 10:35:18 +02:00
Simon Hausmann
ba15a768d6 Add the ability to output rust code to the compiler cli 2020-06-29 09:00:35 +02:00
Simon Hausmann
778c6c8cca Fix the C++ tests
Don't link against the corelib shared library anymore
2020-06-17 19:14:56 +02:00
Olivier Goffart
e8c825b434 Add a test for embedded conditionals
Also fix the initialization of properties in C++, make them zero-initialized like in rust
2020-06-16 17:47:10 +02:00
Olivier Goffart
e95d7da888 Parser: typed syntax node accessor 2020-06-11 17:50:28 +02:00
Simon Hausmann
be3d0ab369 Provide convenience accessors for public properties in C++
While properties declared in the root component are named as-is and
exposed as Property<T>, their get() function in particular is hard to
use because it requires an EvaluationContext as a parameter.

This patch adds get_foo() and set_foo() accessors for each public
property and hides the evaluation context business for the getter.

The added test uses this right away and adds missing test coverage for
the conditional expression.
2020-06-11 15:45:16 +02:00
Olivier Goffart
0d4f370e95 Fix linking error in the tests
We also need to link against corelib
2020-06-10 19:53:06 +02:00
Olivier Goffart
300cb26208 Rename the interpreter crate to sixtyfps_interpreter 2020-06-10 08:41:49 +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
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
b7bc884447 Run the JS test without using npm install 2020-06-09 10:25:38 +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
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
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
Simon Hausmann
46d7aaa2cb WIP 2020-06-05 14:11:29 +02:00
Simon Hausmann
31da762245 Complete compilation and running of .60 to mapped c++ tests
* Fix text-file-busy error when running the binary by replacing the use
  of named temp file with simply using the input source file and the
  extension replaced. A scope guard make sure to also delete the binary.
* Fix hard-coded library dependencies by sharing code with the cmake
  xtask that needs the same list.
2020-06-05 13:30:13 +02:00
Simon Hausmann
a69594530f First step towards compiling the generated C++ in the test driver
This extracts a compiler command line from the cc crate, runs the
compiler and tries to run the resulting binary. Unfortunately the latter
fails still.
2020-06-05 11:08:05 +02:00
Simon Hausmann
19a2777aec Fix build 2020-06-05 09:28:09 +02:00
Olivier Goffart
3651885d87 Move the compiler binary in tools/
And rename sixtyfps_compiler to sixtyfps_compilerlib
2020-06-05 09:23:38 +02:00
Simon Hausmann
3d1064f2e8 Separate the C++ bits into a separate module 2020-06-05 09:00:49 +02:00
Simon Hausmann
8624566e5c Add boilerplate for new testing harness
The objective is to have a bunch of .60 files with annotations inside
and the test harness picks them up and runs them through the Rust and
C++ frontend.
2020-06-05 08:56:16 +02:00