From 1d6ddc803ee1bddec03c1c515447094dd7541330 Mon Sep 17 00:00:00 2001 From: dpeter99 Date: Sat, 18 Jun 2022 17:03:30 +0200 Subject: [PATCH] [BUILD] Initial BAZEL setup --- .clwb/.bazelproject | 17 +++ .clwb/.idea/.gitignore | 8 ++ .github/workflows/build.yml | 25 ++-- WORKSPACE | 7 ++ projs/shadow-file-format-test/packages.config | 4 - .../shadow-file-format-test.vcxproj | 119 ------------------ .../shadow-file-format-test.vcxproj.user | 4 - projs/shadow-file-format/BUILD | 31 +++++ .../test}/pch.cpp | 0 .../test}/pch.h | 0 .../test}/sff_writer_tests.cpp | 0 .../test}/test.cpp | 24 ++-- projs/shadow-utility/BUILD | 15 +++ vendor/BUILD | 0 vendor/deps.bzl | 10 ++ vendor/glm/BUILD | 0 vendor/glm/glm-dep.bzl | 10 ++ vendor/glm/glm.BUILD | 12 ++ vendor/gtest/BUILD | 0 vendor/gtest/gtest-dep.bzl | 10 ++ vendor/gtest/gtest.BUILD | 14 +++ vendor/sdl2/BUILD | 0 vendor/sdl2/sdl2-dep.bzl | 14 +++ vendor/sdl2/sdl2.BUILD | 56 +++++++++ 24 files changed, 229 insertions(+), 151 deletions(-) create mode 100644 .clwb/.bazelproject create mode 100644 .clwb/.idea/.gitignore create mode 100644 WORKSPACE delete mode 100644 projs/shadow-file-format-test/packages.config delete mode 100644 projs/shadow-file-format-test/shadow-file-format-test.vcxproj delete mode 100644 projs/shadow-file-format-test/shadow-file-format-test.vcxproj.user create mode 100644 projs/shadow-file-format/BUILD rename projs/{shadow-file-format-test => shadow-file-format/test}/pch.cpp (100%) rename projs/{shadow-file-format-test => shadow-file-format/test}/pch.h (100%) rename projs/{shadow-file-format-test => shadow-file-format/test}/sff_writer_tests.cpp (100%) rename projs/{shadow-file-format-test => shadow-file-format/test}/test.cpp (98%) create mode 100644 projs/shadow-utility/BUILD create mode 100644 vendor/BUILD create mode 100644 vendor/deps.bzl create mode 100644 vendor/glm/BUILD create mode 100644 vendor/glm/glm-dep.bzl create mode 100644 vendor/glm/glm.BUILD create mode 100644 vendor/gtest/BUILD create mode 100644 vendor/gtest/gtest-dep.bzl create mode 100644 vendor/gtest/gtest.BUILD create mode 100644 vendor/sdl2/BUILD create mode 100644 vendor/sdl2/sdl2-dep.bzl create mode 100644 vendor/sdl2/sdl2.BUILD diff --git a/.clwb/.bazelproject b/.clwb/.bazelproject new file mode 100644 index 0000000..cb6ab22 --- /dev/null +++ b/.clwb/.bazelproject @@ -0,0 +1,17 @@ +directories: + # Add the directories you want added as source here + # By default, we've added your entire workspace ('.') + . + +# Automatically includes all relevant targets under the 'directories' above +derive_targets_from_directories: true + +targets: + # If source code isn't resolving, add additional targets that compile it here + +additional_languages: + # Uncomment any additional languages you want supported + # dart + # javascript + # python + # typescript diff --git a/.clwb/.idea/.gitignore b/.clwb/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.clwb/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91ddb87..b7964c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,29 +16,29 @@ jobs: with: submodules: recursive + + - name: Install bazelisk + run: | + choco install bazelisk + - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.1 - - name: setup nuget - uses: NuGet/setup-nuget@v1.0.6 - - - name: restore project packages - run: nuget restore umbra.sln - - - name: build - run: msbuild /m /p:Configuration=Debug umbra.sln + - name: Build + run: | + bazel build //... - name: use cache uses: actions/cache@v2 with: - path: "./bin/Debug" + path: "./bazel-bin/projs" key: ${{ runner.os }}-${{ github.run_id }} - name: Upload shadow-engine artifact uses: actions/upload-artifact@v3 with: name: ${{ needs.update.outputs.old_version_name }}-${{ needs.update.outputs.new_version_name }}-patch - path: './bin/Debug/shadow-engine/**/*' + path: './bazel-bin/projs/shadow-engine/**/*' test-sff: runs-on: windows-latest @@ -52,11 +52,11 @@ jobs: - name: use cache uses: actions/cache@v2 with: - path: "./bin/Debug" + path: "./bazel-bin/projs" key: ${{ runner.os }}-${{ github.run_id }} - name: Test shadow-file-format - run: ./bin/Debug/shadow-file-format-test/shadow-file-format-test.exe --gtest_output="xml:./test-results/shadow-file-format-test.xml" + run: ./bazel-bin/projs/shadow-file-format/test.exe --gtest_output="xml:./test-results/shadow-file-format-test.xml" - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action/composite@v1 @@ -64,4 +64,3 @@ jobs: with: files: "test-results/**/*.xml" - \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..26277c8 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,7 @@ +workspace( + name = "umbra", +) + +load("//vendor:deps.bzl", "deps") + +deps() \ No newline at end of file diff --git a/projs/shadow-file-format-test/packages.config b/projs/shadow-file-format-test/packages.config deleted file mode 100644 index 88f987c..0000000 --- a/projs/shadow-file-format-test/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/projs/shadow-file-format-test/shadow-file-format-test.vcxproj b/projs/shadow-file-format-test/shadow-file-format-test.vcxproj deleted file mode 100644 index 142a25d..0000000 --- a/projs/shadow-file-format-test/shadow-file-format-test.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - 15.0 - {3b7d6797-cc0c-43fa-8866-f438032e1c67} - Win32Proj - 10.0.19041.0 - Application - v143 - Unicode - shadow-file-format-test - - - - - - - - - - $(SolutionDir)\projs\shadow-file-format\src\; %(AdditionalIncludeDirectories) - - - - - - - - - - - Create - - - - - {b2e3515c-3fe0-44b9-9abe-8584a836230f} - - - - - - - - - - - - - Use - pch.h - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Level3 - - - true - Console - - - - - Use - pch.h - Disabled - X64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Level3 - - - true - Console - - - - - Use - pch.h - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - - - true - Console - true - true - - - - - Use - pch.h - X64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - - - true - Console - true - true - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/projs/shadow-file-format-test/shadow-file-format-test.vcxproj.user b/projs/shadow-file-format-test/shadow-file-format-test.vcxproj.user deleted file mode 100644 index 88a5509..0000000 --- a/projs/shadow-file-format-test/shadow-file-format-test.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/projs/shadow-file-format/BUILD b/projs/shadow-file-format/BUILD new file mode 100644 index 0000000..d5185cf --- /dev/null +++ b/projs/shadow-file-format/BUILD @@ -0,0 +1,31 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_library( + name = "shadow-file-format", + srcs = glob(["src/**/*.cpp", "src/**/*.h"]), + hdrs = glob(["src/**/*.h"]), + strip_include_prefix = "src/", + includes = [], + copts = [ + "/std:c++17" + ], + deps = [ + "//projs/shadow-utility" + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "test", + srcs = glob(["test/**/*.cpp", "test/**/*.h"]), + includes = [], + copts = [ + "/std:c++17" + ], + deps = [ + "//projs/shadow-file-format", + "@gtest//:gtest", + "@gtest//:gtest_main" + ], +) \ No newline at end of file diff --git a/projs/shadow-file-format-test/pch.cpp b/projs/shadow-file-format/test/pch.cpp similarity index 100% rename from projs/shadow-file-format-test/pch.cpp rename to projs/shadow-file-format/test/pch.cpp diff --git a/projs/shadow-file-format-test/pch.h b/projs/shadow-file-format/test/pch.h similarity index 100% rename from projs/shadow-file-format-test/pch.h rename to projs/shadow-file-format/test/pch.h diff --git a/projs/shadow-file-format-test/sff_writer_tests.cpp b/projs/shadow-file-format/test/sff_writer_tests.cpp similarity index 100% rename from projs/shadow-file-format-test/sff_writer_tests.cpp rename to projs/shadow-file-format/test/sff_writer_tests.cpp diff --git a/projs/shadow-file-format-test/test.cpp b/projs/shadow-file-format/test/test.cpp similarity index 98% rename from projs/shadow-file-format-test/test.cpp rename to projs/shadow-file-format/test/test.cpp index a6f6a72..fc17ede 100644 --- a/projs/shadow-file-format-test/test.cpp +++ b/projs/shadow-file-format/test/test.cpp @@ -1,5 +1,5 @@ #include "pch.h" -#include "../shadow-file-format/src/SFFParser.h" +#include "SFFParser.h" //import Shadow.FileFormat; @@ -32,16 +32,7 @@ Assets:{ \ }, \ "; -std::string example_multi_level_content = "ShadowFileFormat_1_0_0 \n\ -Assets:{ \ - a: { \ - 0: ContentContent0, \ - 1: ContentContent1, \ - 2: ContentContent2, \ - }, \ - b: ContentB, \ -}, \ -"; + std::stringstream streamFrom(std::string str) { std::stringstream ss; @@ -209,6 +200,16 @@ TEST(MultiRoot, RootsHaveCorrectName) { EXPECT_EQ(texture->name, "Texture"); } +std::string example_multi_level_content = "ShadowFileFormat_1_0_0 \n\ +Assets:{ \ + a: { \ + 0: ContentContent0, \ + 1: ContentContent1, \ + 2: ContentContent2, \ + }, \ + b: ContentB, \ +}, \ +"; TEST(MultiLevelContent, RootsHaveCorrectName) { @@ -220,6 +221,7 @@ TEST(MultiLevelContent, RootsHaveCorrectName) { EXPECT_NE(assets, nullptr); EXPECT_EQ(assets->name, "Assets"); + EXPECT_EQ(assets->isBlock, true); auto first = assets->GetChildByName("a"); diff --git a/projs/shadow-utility/BUILD b/projs/shadow-utility/BUILD new file mode 100644 index 0000000..e051055 --- /dev/null +++ b/projs/shadow-utility/BUILD @@ -0,0 +1,15 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "shadow-utility", + srcs = glob(["**/*.cpp", "**/*.h"]), + hdrs = glob(["**/*.h"]), + strip_include_prefix = "src/", + includes = [], + copts = [ + "/std:c++20" + ], + deps = [ + ], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/vendor/BUILD b/vendor/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/vendor/deps.bzl b/vendor/deps.bzl new file mode 100644 index 0000000..1dcea32 --- /dev/null +++ b/vendor/deps.bzl @@ -0,0 +1,10 @@ +load("//vendor/sdl2:sdl2-dep.bzl", "sdl2_dep") +load("//vendor/gtest:gtest-dep.bzl", "gtest_dep") +#load("//vendor/imgui:imgui_lib.bzl", "imgui_lib") +load("//vendor/glm:glm-dep.bzl", "glm_dep") + +def deps(): + sdl2_dep() + gtest_dep() +# imgui_lib() + glm_dep() \ No newline at end of file diff --git a/vendor/glm/BUILD b/vendor/glm/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/vendor/glm/glm-dep.bzl b/vendor/glm/glm-dep.bzl new file mode 100644 index 0000000..58cee7f --- /dev/null +++ b/vendor/glm/glm-dep.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") + +def glm_dep(): + if "glm_lib" not in native.existing_rules(): + new_git_repository( + name = "glm_lib", + remote = "https://github.com/g-truc/glm.git", + commit = "658d8960d081e0c9c312d49758c7ef919371b428", + build_file = Label("//vendor/glm:glm.BUILD"), + ) \ No newline at end of file diff --git a/vendor/glm/glm.BUILD b/vendor/glm/glm.BUILD new file mode 100644 index 0000000..cebac58 --- /dev/null +++ b/vendor/glm/glm.BUILD @@ -0,0 +1,12 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "glm", + hdrs = glob([ + "glm/*.hpp", + "glm/**/*.hpp", + ]), + includes = ["glm"], + textual_hdrs = glob(["glm/**/*.inl"]), + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/vendor/gtest/BUILD b/vendor/gtest/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/vendor/gtest/gtest-dep.bzl b/vendor/gtest/gtest-dep.bzl new file mode 100644 index 0000000..2b7fc3a --- /dev/null +++ b/vendor/gtest/gtest-dep.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + + +def gtest_dep(): + if "gtest" not in native.existing_rules(): + git_repository( + name = "gtest", + remote = "https://github.com/google/googletest", + branch = "v1.10.x", + ) \ No newline at end of file diff --git a/vendor/gtest/gtest.BUILD b/vendor/gtest/gtest.BUILD new file mode 100644 index 0000000..ca475f7 --- /dev/null +++ b/vendor/gtest/gtest.BUILD @@ -0,0 +1,14 @@ +cc_library( + name = "gtest_main", + srcs = glob( + ["src/*.cc"], + exclude = ["src/gtest-all.cc"] + ), + hdrs = glob([ + "include/**/*.h", + "src/*.h" + ]), + copts = ["-Iexternal/gtest/include"], + linkopts = ["-pthread"], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/vendor/sdl2/BUILD b/vendor/sdl2/BUILD new file mode 100644 index 0000000..e69de29 diff --git a/vendor/sdl2/sdl2-dep.bzl b/vendor/sdl2/sdl2-dep.bzl new file mode 100644 index 0000000..0452457 --- /dev/null +++ b/vendor/sdl2/sdl2-dep.bzl @@ -0,0 +1,14 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +VERSION = "2.0.22" +URL_TOOLCHAIN = "https://www.libsdl.org/release/SDL2-devel-2.0.22-mingw.zip" + +def sdl2_dep(): + if "sdl2" not in native.existing_rules(): + http_archive( + name = "sdl2", + build_file = Label("//vendor/sdl2:sdl2.BUILD"), + url = URL_TOOLCHAIN, + strip_prefix = "SDL2-2.0.22", + sha256 = "18b3da2b3b5f1e802e0abbe99004d7404848755bbfe5153cd9dfcfc0a9522632", + ) \ No newline at end of file diff --git a/vendor/sdl2/sdl2.BUILD b/vendor/sdl2/sdl2.BUILD new file mode 100644 index 0000000..69811ad --- /dev/null +++ b/vendor/sdl2/sdl2.BUILD @@ -0,0 +1,56 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +alias( + name = "windows", + actual = "@bazel_tools//src/conditions:windows" +) + +alias( + name = "macos", + actual = "@bazel_tools//src/conditions:darwin_x86_64" +) + +alias( + name = "linux", + actual = "@bazel_tools//src/conditions:linux_x86_64" +) + + + +cc_library( + name = "sdl2_win", + srcs= [ + "x86_64-w64-mingw32/lib/libSDL2.a", + "x86_64-w64-mingw32/lib/libSDL2main.a" + ], + hdrs = glob(["x86_64-w64-mingw32/include/**/*.h"]), + includes = ["x86_64-w64-mingw32/include"], # Optional. + linkopts = [ + "-DEFAULTLIB:user32", + "-DEFAULTLIB:gdi32", + "-DEFAULTLIB:winmm", + "-DEFAULTLIB:imm32", + "-DEFAULTLIB:ole32", + "-DEFAULTLIB:oleaut32", + "-DEFAULTLIB:version", + "-DEFAULTLIB:uuid", + "-DEFAULTLIB:shell32", + "-DEFAULTLIB:advapi32", + "-DEFAULTLIB:hid", + "-DEFAULTLIB:setupapi", + "-DEFAULTLIB:opengl32", + "-DEFAULTLIB:kernel32", + "/ENTRY:WinMainCRTStartup" + ], + visibility = ["//visibility:public"], +) + + +alias( + name = "sdl2", + actual = select({ + "//:windows": "//:sdl2_win", + "//conditions:default": "//sdl2_win", + }), + visibility = ["//visibility:public"], +) \ No newline at end of file