data_compiler.vala 929 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2012-2020 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/dbartolini/crown/blob/master/LICENSE
  4. */
  5. namespace Crown
  6. {
  7. public class DataCompiler
  8. {
  9. private ConsoleClient _compiler;
  10. private Guid _id;
  11. private bool _success;
  12. private SourceFunc _callback;
  13. public DataCompiler(ConsoleClient client)
  14. {
  15. _compiler = client;
  16. _id = GUID_ZERO;
  17. _success = false;
  18. _callback = null;
  19. }
  20. // Returns true if success, false otherwise.
  21. public async bool compile(string data_dir, string platform)
  22. {
  23. if (_callback != null)
  24. return false;
  25. _id = Guid.new_guid();
  26. _success = false;
  27. _compiler.send(DataCompilerApi.compile(_id, data_dir, platform));
  28. _callback = compile.callback;
  29. yield;
  30. return _success;
  31. }
  32. public void finished(bool success)
  33. {
  34. _success = success;
  35. if (_callback != null)
  36. _callback();
  37. _callback = null;
  38. }
  39. }
  40. }