-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
300 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
build --enable_platform_specific_config | ||
build --incompatible_use_platforms_repo_for_constraints | ||
build --incompatible_enable_cc_toolchain_resolution | ||
build --incompatible_strict_action_env | ||
build --enable_runfiles | ||
|
||
build:windows --platforms=//bazel/platforms:windows | ||
|
||
build:linux --platforms=//bazel/platforms:linux | ||
build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux | ||
|
||
common:ci --announce_rc | ||
common:ci --disk_cache=~/.cache/bazel-disk-cache | ||
test:ci --test_output=errors | ||
import %workspace%/bazel/common.bazelrc | ||
|
||
try-import %workspace%/user.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
# bazel | ||
/bazel-* | ||
/user.bazelrc | ||
|
||
# https://github.com/hedronvision/bazel-compile-commands-extractor | ||
/compile_commands.json | ||
/external | ||
|
||
# clangd | ||
/.cache/ | ||
bazel-* | ||
user.bazelrc | ||
compile_commands.json | ||
external | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module( | ||
name = "ecsact_lang_cpp", | ||
version = "0.1.0", | ||
compatibility_level = 1, | ||
) | ||
|
||
bazel_dep(name = "rules_cc", version = "0.0.8") | ||
bazel_dep(name = "ecsact_runtime", version = "0.5.0") | ||
bazel_dep(name = "rules_ecsact", version = "0.4.0") | ||
bazel_dep(name = "ecsact_codegen", version = "0.1.2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
load("@rules_ecsact//ecsact:defs.bzl", "ecsact_codegen_plugin") | ||
load("@rules_ecsact//ecsact/private:ecsact_codegen_plugin.bzl", "EcsactCodegenPluginInfo") | ||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test") | ||
|
||
def _cc_ecsact_codegen_plugin_impl(ctx): | ||
plugin = None | ||
files = ctx.attr.cc_binary[DefaultInfo].files | ||
|
||
for file in files.to_list(): | ||
if file.extension == "so": | ||
plugin = file | ||
if file.extension == "dll": | ||
plugin = file | ||
|
||
return [ | ||
EcsactCodegenPluginInfo( | ||
output_extension = ctx.attr.output_extension, | ||
plugin = plugin, | ||
data = [plugin], | ||
), | ||
] | ||
|
||
_cc_ecsact_codegen_plugin = rule( | ||
implementation = _cc_ecsact_codegen_plugin_impl, | ||
attrs = { | ||
"cc_binary": attr.label(mandatory = True), | ||
"output_extension": attr.string(mandatory = True), | ||
}, | ||
) | ||
|
||
_generated_src = """ | ||
#include "ecsact/codegen/plugin.h" | ||
const char* ecsact_codegen_plugin_name() {{ | ||
return "{output_extension}"; | ||
}} | ||
""" | ||
|
||
def _cc_ecsact_codegen_plugin_src_impl(ctx): | ||
output_cc_src = ctx.actions.declare_file("{}.plugin_name.cc".format(ctx.attr.name)) | ||
ctx.actions.write( | ||
output = output_cc_src, | ||
content = _generated_src.format(output_extension = ctx.attr.output_extension), | ||
) | ||
|
||
return [ | ||
DefaultInfo(files = depset([output_cc_src])), | ||
] | ||
|
||
_cc_ecsact_codegen_plugin_src = rule( | ||
implementation = _cc_ecsact_codegen_plugin_src_impl, | ||
attrs = { | ||
"output_extension": attr.string(mandatory = True), | ||
}, | ||
) | ||
|
||
def cc_ecsact_codegen_plugin(name = None, srcs = [], deps = [], defines = [], no_validate_test = False, output_extension = None, **kwargs): | ||
"""Create ecsact codegen plugin with C++ | ||
NOTE: ecsact_codegen_plugin_name() is automatically generated for you based | ||
on the `output_extension` attribute. | ||
Args: | ||
name: Passed to underling cc_binary | ||
srcs: Passed to underling cc_binary | ||
deps: Passed to underling cc_binary | ||
defines: Passed to underling cc_binary | ||
output_extension: File extension the plugin writes to | ||
no_validate_test: Don't create plugin validation test (not recommended) | ||
**kwargs: Passed to underling cc_binary | ||
""" | ||
cc_binary( | ||
name = "{}_bin".format(name), | ||
srcs = srcs + [ | ||
"@ecsact_runtime//dylib:dylib.cc", | ||
":{}__pn".format(name), | ||
], | ||
deps = deps + [ | ||
"@ecsact_runtime//:dylib", | ||
"@ecsact_runtime//dylib:meta", | ||
"@ecsact_codegen//:plugin", | ||
], | ||
defines = defines + ["ECSACT_META_API_LOAD_AT_RUNTIME"], | ||
linkshared = True, | ||
**kwargs | ||
) | ||
|
||
_cc_ecsact_codegen_plugin_src( | ||
name = "{}__pn".format(name), | ||
output_extension = output_extension, | ||
) | ||
|
||
_cc_ecsact_codegen_plugin( | ||
name = name, | ||
cc_binary = ":{}_bin".format(name), | ||
output_extension = output_extension, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,3 @@ | ||
common --enable_bzlmod | ||
build --enable_platform_specific_config | ||
build --incompatible_use_platforms_repo_for_constraints | ||
build --incompatible_enable_cc_toolchain_resolution | ||
build --incompatible_strict_action_env | ||
build --enable_runfiles | ||
|
||
build:windows --platforms=@ecsact_lang_cpp//bazel/platforms:windows | ||
build:windows --host_platform=@ecsact_lang_cpp//bazel/platforms:windows | ||
|
||
build:linux --platforms=@ecsact_lang_cpp//bazel/platforms:linux | ||
build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux | ||
|
||
common:ci --announce_rc | ||
common:ci --disk_cache=~/.cache/bazel-disk-cache | ||
test:ci --test_output=errors | ||
import %workspace%/../bazel/common.bazelrc | ||
|
||
try-import %workspace%/user.bazelrc |
Oops, something went wrong.