Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"BazelBuild.vscode-bazel",
"ms-dotnettools.csharp"
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.insertSpaces": false,
"files.insertFinalNewline": true,
"[starlark]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "BazelBuild.vscode-bazel"
}
}
51 changes: 33 additions & 18 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "ecsact",
remote = "git@github.com:seaube/ecsact.git",
commit = "6bce75438e812fd887dbe24e757d2a523993fa26",
shallow_since = "1651763515 -0400",
name = "ecsact_rtb",
commit = "4d4856d697300a1e3c8b2e49b25acb72e9328b9d",
remote = "git@github.com:seaube/ecsact-rtb.git",
# shallow_since = "1657554031 -0700",
)

http_archive(
name = "boost",
strip_prefix = "boost-563e8e0de4eac4b48a02d296581dc2454127608e",
urls = ["https://github.com/bazelboost/boost/archive/563e8e0de4eac4b48a02d296581dc2454127608e.zip"],
sha256 = "c41441a6e9f8038ad626e9f937ddc3675ab896b6c3512eefc6840037b3816d03",
)
load("@ecsact_rtb//:repositories.bzl", "ecsact_rtb_repositories")

ecsact_rtb_repositories()

load("@boost//:index.bzl", "boost_http_archives")
boost_http_archives()
load("@ecsact_rtb//:workspace.bzl", "ecsact_rtb_workspace")

ecsact_rtb_workspace()

http_archive(
name = "bzlws",
strip_prefix = "bzlws-f929e5380f441f50a77776d34a7df8cacdbdf986",
url = "https://github.com/zaucy/bzlws/archive/f929e5380f441f50a77776d34a7df8cacdbdf986.zip",
sha256 = "5bebb821b158b11d81dd25cf031b5b26bae97dbb02025df7d0e41a262b3a030b",
sha256 = "9bc9d6bf1d885992d58a4ad9dc7476a8cd48d672b497707b0ae2c0899c6d369b",
strip_prefix = "bzlws-344801b9b3105bd13e4b51ec9776f04bd5e01972",
url = "https://github.com/zaucy/bzlws/archive/344801b9b3105bd13e4b51ec9776f04bd5e01972.zip",
)

load("@bzlws//:repo.bzl", "bzlws_deps")

bzlws_deps()

http_archive(
name = "rules_7zip",
sha256 = "29ba984e2a7d48540faa839efaf09be4b880d211a93575e7ac87abffc12dbdea",
strip_prefix = "rules_7zip-25d3b858a37580dbc1f1ced002e210be15012e2f",
urls = ["https://github.com/zaucy/rules_7zip/archive/25d3b858a37580dbc1f1ced002e210be15012e2f.zip"],
sha256 = "29ba984e2a7d48540faa839efaf09be4b880d211a93575e7ac87abffc12dbdea",
)

load("@rules_7zip//:setup.bzl", "setup_7zip")

setup_7zip()

_nlohmann_json_build_file = """
Expand All @@ -54,9 +54,9 @@ cc_library(

http_archive(
name = "nlohmann_json",
url = "https://github.com/nlohmann/json/releases/download/v3.10.4/include.zip",
sha256 = "62c585468054e2d8e7c2759c0d990fd339d13be988577699366fe195162d16cb",
build_file_content = _nlohmann_json_build_file,
sha256 = "62c585468054e2d8e7c2759c0d990fd339d13be988577699366fe195162d16cb",
url = "https://github.com/nlohmann/json/releases/download/v3.10.4/include.zip",
)

http_archive(
Expand All @@ -66,6 +66,7 @@ http_archive(
)

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")

node_repositories()

http_archive(
Expand All @@ -76,4 +77,18 @@ http_archive(
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")

aspect_bazel_lib_dependencies()

http_archive(
name = "rules_pkg",
sha256 = "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
],
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()
23 changes: 15 additions & 8 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
load("@bzlws//:index.bzl", "bzlws_copy")
load("@bzlws//:index.bzl", "bzlws_copy", "bzlws_extract")

package(default_visibility = ["//visibility:public"])

bzlws_copy(
# bzlws_copy(
# name = "copy_for_dev",
# testonly = True,
# srcs = ["//packages/com.seaube.ecsact:generators"],
# out = "packages/com.seaube.ecsact/generators~.tar",
# force = True,
# metafile_path = "generators~/.copy_for_dev.yml",
# visibility = ["//visibility:private"],
# )

bzlws_extract(
name = "copy_for_dev",
visibility = ["//visibility:private"],
testonly = True,
srcs = ["//packages/com.seaube.ecsact:generators"],
out = "packages/com.seaube.ecsact/generators~",
force = True,
out = "packages/com.seaube.ecsact/generators~/{FILENAME}",
metafile_path = "generators~/.copy_for_dev.yml",
srcs = [
"@ecsact//generator/csharp:cli",
"@ecsact//generator/parser_info:cli",
],
visibility = ["//visibility:private"],
)
2 changes: 1 addition & 1 deletion packages/com.seaube.ecsact/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa/*

# Folder that stores codegen executables
# /generators~
/generators~
47 changes: 25 additions & 22 deletions packages/com.seaube.ecsact/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load(":pkg.bzl", "pkg_executable")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

copy_to_directory(
name = "generators~",
replace_prefixes = {
"generator/csharp/": "",
"generator/parser_info/": "",
},
include_external_repositories = [
"ecsact",
],
srcs = [
"@ecsact//generator/csharp:cli",
"@ecsact//generator/parser_info:cli",
],
pkg_executable(
name = "ecsact_csharp_codegen_with_runfiles",
bin = "@ecsact//generator/csharp:cli",
path = "ecsact_csharp_codegen",
)

pkg_executable(
name = "ecsact_parser_info_codegen_with_runfiles",
bin = "@ecsact//generator/parser_info:cli",
path = "ecsact_parser_info_codegen",
)

pkg_npm(
name = "com.seaube.ecsact",
package_name = "com.seaube.ecsact",
deps = [":generators~"],
srcs = glob(["**/*"]),
pkg_executable(
name = "ecsact_rtb_with_runfiles",
bin = "@ecsact_rtb//cli:ecsact-rtb",
path = "ecsact-rtb",
)

alias(name = "pack", actual = "com.seaube.ecsact.pack")
alias(name = "publish", actual = "com.seaube.ecsact.publish")
pkg_tar(
name = "generators",
srcs = [
":ecsact_csharp_codegen_with_runfiles",
":ecsact_parser_info_codegen_with_runfiles",
":ecsact_rtb_with_runfiles",
],
visibility = ["//visibility:public"],
)
41 changes: 41 additions & 0 deletions packages/com.seaube.ecsact/Editor/DefaultRunnerEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEditor;
using UnityEngine;

namespace Ecsact.Editor {
[CustomEditor(typeof(Ecsact.DefaultRunner))]
public class DefaultRunnerEditor : UnityEditor.Editor {
public override bool RequiresConstantRepaint() {
return Application.isPlaying;
}

public override void OnInspectorGUI() {
var runner = target as DefaultRunner;
var executionHeatStyle = new GUIStyle(EditorStyles.label);
executionHeatStyle.normal.textColor = Color.green;

float deltaTimePc = 0f;
if(runner.debugExecutionTimeMs > 0) {
// 0.0 - 1.0 how much the execution time takes up from the delta time
deltaTimePc =
Time.deltaTime / ((float)runner.debugExecutionTimeMs) / 1000f;

if(deltaTimePc > 0.5) {
executionHeatStyle.normal.textColor = Color.red;
} else if(deltaTimePc > 0.2) {
executionHeatStyle.normal.textColor = Color.yellow;
}
}

EditorGUILayout.LabelField(
"Execution Count",
$"{runner.debugExecutionCountTotal}"
);
EditorGUILayout.LabelField(
"Execution Time",
$"{runner.debugExecutionTimeMs}ms " +
$"({deltaTimePc*100:0.0}% of delta time)",
executionHeatStyle
);
}
}
}
11 changes: 11 additions & 0 deletions packages/com.seaube.ecsact/Editor/DefaultRunnerEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 24 additions & 18 deletions packages/com.seaube.ecsact/Editor/Ecsact.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
{
"name": "Ecsact.Editor",
"rootNamespace": "",
"references": [
"Ecsact",
"Unity.EditorCoroutines.Editor"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
"name": "Ecsact.Editor",
"rootNamespace": "",
"references": [
"GUID:6e7029456009ab94da19a8f93d5e3523",
"GUID:478a2357cc57436488a56e564b08d223",
"GUID:21b0c8d1703a94250bfac916590cea4f",
"GUID:54cb1906aeb4e4264bc1d2aa3818a43f",
"GUID:ea715009a4efd4c6cbc85be3ae097dd3",
"GUID:23f3c6063e13e4fd9addce3606ff4e42",
"GUID:7faa839a710e565409361b9f0c62a4da",
"GUID:2cd956959600cec4a97cd312e2adbdbb"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
43 changes: 32 additions & 11 deletions packages/com.seaube.ecsact/Editor/EcsactPackagesPostprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

public class EcsactPackagesPostprocessor : AssetPostprocessor {

Expand Down Expand Up @@ -59,6 +60,26 @@ static void OnPostprocessAllAssets
}
}

static void TryImportAssets
( List<string> assets
)
{
EditorApplication.delayCall += () => {
if(!Progress.running) {
try {
AssetDatabase.StartAssetEditing();
foreach(var asset in assets) {
AssetDatabase.ImportAsset(asset);
}
} finally {
AssetDatabase.StopAssetEditing();
}
} else {
TryImportAssets(assets);
}
};
}

static void RefreshEcsactCodegen
( List<string> importedPkgs
, List<string> deletedPkgs
Expand All @@ -70,7 +91,7 @@ static void RefreshEcsactCodegen
);

var progressId = Progress.Start(
"ECSACT Codegen",
"Ecsact Codegen",
"Generating C# files..."
);

Expand All @@ -97,19 +118,15 @@ static void RefreshEcsactCodegen
UnityEngine.Debug.LogError(codegen.StandardError.ReadToEnd());
Progress.Remove(progressId);
} else {
Progress.Report(progressId, 0.9f);

EditorApplication.delayCall += () => {
foreach(var importedPkg in importedPkgs) {
// Import newly created scripts
AssetDatabase.ImportAsset(importedPkg + ".cs");
}
Progress.Remove(progressId);
};
Progress.Finish(progressId, Progress.Status.Succeeded);
// Import newly created scripts
// TryImportAssets(importedPkgs.Select(pkg => pkg + ".cs").ToList());
}
};

foreach(var (pkg, pkgPath) in FindEcsactPackages()) {
var packages = FindEcsactPackages().ToList();

foreach(var (pkg, pkgPath) in packages) {
codegen.StartInfo.Arguments += pkgPath + " ";
}

Expand All @@ -119,6 +136,10 @@ static void RefreshEcsactCodegen
foreach(var plugin in GetCodegenPlugins()) {
// TODO: Custom codegen plugins
}

EcsactRuntimeBuilder.Build(new EcsactRuntimeBuilder.Options{
ecsactFiles = packages.Select(item => item.Item2).ToList(),
});
}

static IEnumerable<EcsactCodegenPlugin> GetCodegenPlugins() {
Expand Down
Loading