diff --git a/.bazelignore b/.bazelignore index 5446323..d2c27ed 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1 +1,2 @@ external +dist diff --git a/.bazelrc b/.bazelrc index b1a5004..76045ba 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,11 +4,14 @@ build --incompatible_enable_cc_toolchain_resolution build --incompatible_strict_action_env build:windows --platforms=//bazel/platforms:windows +build:windows --host_platform=//bazel/platforms:windows build:linux --platforms=//bazel/platforms:linux +build:linux --host_platform=//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 +build:ci -c opt try-import %workspace%/user.bazelrc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..640ca1e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,117 @@ +name: Release + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" + +jobs: + release-draft: + runs-on: ubuntu-latest + steps: + - uses: softprops/action-gh-release@v1 + + windows-x64-binaries: + runs-on: windows-latest + steps: + - name: Get Home Directory + id: get_home_dir + run: echo "::set-output name=dir::$HOME" + - uses: actions/cache@v3 + with: + path: | + /Users/runneradmin/AppData/Local/bazelisk + /Users/runneradmin/.cache/bazel-disk-cache + key: ${{runner.os}}-bazel-cache + - uses: actions/checkout@v3 + - run: bazel run --config=ci //:copy_dist_bin + - run: bazel run --config=ci //:copy_dist_codegen_plugins + - uses: actions/upload-artifact@v3 + with: + name: windows-x64-binaries + path: dist + linux-x64-binaries: + runs-on: ubuntu-latest + steps: + - uses: actions/cache@v3 + with: + path: | + ~/.cache/bazelisk + ~/.cache/bazel-disk-cache + key: ${{runner.os}}-bazel-cache + - uses: actions/checkout@v3 + - run: bazel run --config=ci //:copy_dist_bin + - run: bazel run --config=ci //:copy_dist_codegen_plugins + - uses: actions/upload-artifact@v3 + with: + name: linux-x64-binaries + path: dist + + linux-x64-archive: + runs-on: ubuntu-latest + needs: + - linux-x64-binaries + steps: + - uses: actions/download-artifact@v3 + with: + name: linux-x64-binaries + - run: tar -czf ecsact_sdk_${{github.ref_name}}_linux_x64.tar.gz bin include + - uses: actions/upload-artifact@v3 + with: + name: linux-x64-archive + path: ecsact_sdk_${{github.ref_name}}_linux_x64.tar.gz + + windows-x64-archive: + runs-on: ubuntu-latest + needs: + - windows-x64-binaries + steps: + - uses: actions/download-artifact@v3 + with: + name: windows-x64-binaries + - run: > + zip -r ecsact_sdk_${{github.ref_name}}_windows_x64.zip bin include + - uses: actions/upload-artifact@v3 + with: + name: windows-x64-archive + path: ecsact_sdk_${{github.ref_name}}_windows_x64.zip + + release-upload-linux-x64-archive: + runs-on: ubuntu-latest + needs: + - release-draft + - linux-x64-archive + steps: + - uses: actions/download-artifact@v3 + with: + name: linux-x64-archive + - uses: softprops/action-gh-release@v1 + with: + fail_on_unmatched_files: true + files: ecsact_sdk_${{github.ref_name}}_linux_x64.tar.gz + + release-upload-windows-x64-archive: + runs-on: ubuntu-latest + needs: + - release-draft + - windows-x64-archive + steps: + - uses: actions/download-artifact@v3 + with: + name: windows-x64-archive + - uses: softprops/action-gh-release@v1 + with: + fail_on_unmatched_files: true + files: ecsact_sdk_${{github.ref_name}}_windows_x64.zip + + release-finish: + runs-on: ubuntu-latest + needs: + - release-upload-windows-x64-archive + - release-upload-linux-x64-archive + steps: + - uses: softprops/action-gh-release@v1 + with: + name: ${{github.ref_name}} + generate_release_notes: true diff --git a/.gitignore b/.gitignore index 7b0d298..e3340df 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,10 @@ # ecsact codegen *.ecsact.* + +# MSIX distribution folder +/dist/* +!/dist/AppxManifest.xml +!/dist/images +*.msix +*.zip diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..6d20dfa --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,31 @@ +load("@bzlws//:index.bzl", "bzlws_copy") + +bzlws_copy( + name = "copy_dist_bin", + srcs = [ + "//cli:ecsact", + ], + out = "dist/bin/{FILENAME}", + force = True, +) + +bzlws_copy( + name = "copy_dist_include", + srcs = [ + "@ecsact_runtime//:headers", + ], + out = "dist/include/{FILEPATH}", + force = True, +) + +bzlws_copy( + name = "copy_dist_codegen_plugins", + srcs = [ + "@ecsact_lang_cpp//cpp_header_codegen", + "@ecsact_lang_cpp//cpp_systems_header_codegen", + "@ecsact_lang_cpp//systems_header_codegen", + "@ecsact_lang_csharp//csharp_codegen", + ], + out = "dist/share/ecsact/plugins/{FILENAME}", + force = True, +) diff --git a/CreateMsix.bat b/CreateMsix.bat new file mode 100644 index 0000000..c0bfd47 --- /dev/null +++ b/CreateMsix.bat @@ -0,0 +1,6 @@ +@echo off + +set /p "PASSWORD=Password: " + +MSIXHeroCLI pack -d dist -p EcsactSdk.msix +MSIXHeroCLI sign --file %USERPROFILE%\Documents\Certificates\Seaube.pfx -p %PASSWORD% EcsactSdk.msix diff --git a/UploadMsix.ps1 b/UploadMsix.ps1 new file mode 100644 index 0000000..94f3e89 --- /dev/null +++ b/UploadMsix.ps1 @@ -0,0 +1,31 @@ +#!/usr/bin/env pwsh + +$ErrorActionPreference = 'Stop' + +# GitHub requires TLS 1.2 +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +$LatestTag = (gh release list -L 1).split()[0] +Write-Host "Latest Tag: $LatestTag" + +$ArchiveUrl = "https://github.com/ecsact-dev/ecsact_sdk/releases/download/$($LatestTag)/ecsact_sdk_$($LatestTag)_windows_x64.zip" +$ArchivePath = "ecsact_sdk_$($LatestTag)_windows_x64.zip" + +Write-Host "Downloading $ArchiveUrl to $ArchivePath..." +Invoke-WebRequest $ArchiveUrl -OutFile $ArchivePath -UseBasicParsing + +git clean dist -dfx +Write-Host "Extracting $ArchivePath to dist..." +Expand-Archive -Path $ArchivePath -DestinationPath dist + +((Get-Content -path .\dist\AppxManifest.xml -Raw) -replace '0.0.0.0-placeholder',"$($LatestTag).0") | Set-Content -Path .\dist\AppxManifest.xml + +try { + $MsixPath = "ecsact_sdk_$($LatestTag)_windows_x64.msix" + $CertPassword = Read-Host "Cert Password" + MSIXHeroCLI pack -d dist -p $MsixPath + MSIXHeroCLI sign --file $env:USERPROFILE\Documents\Certificates\Seaube.pfx -p $CertPassword $MsixPath + gh release upload $LatestTag $MsixPath +} finally { + git checkout .\dist\AppxManifest.xml +} diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index e8c186a..4c35dc8 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -20,6 +20,41 @@ load("@boost//:index.bzl", "boost_http_archives") boost_http_archives() +http_archive( + name = "ecsact_parse", + sha256 = "", + strip_prefix = "ecsact_parse-41e73763ecf19b675efb9a23f9b3fe8cac10d7b4", + url = "https://github.com/ecsact-dev/ecsact_parse/archive/41e73763ecf19b675efb9a23f9b3fe8cac10d7b4.zip", +) + +http_archive( + name = "ecsact_runtime", + sha256 = "edf15d37e509163d0d1d8edad71536d125674f1757dacb338e7a665961788262", + strip_prefix = "ecsact_runtime-6c5afb2032b9ec343bd17e1da4d658d1a5c3429b", + url = "https://github.com/ecsact-dev/ecsact_runtime/archive/6c5afb2032b9ec343bd17e1da4d658d1a5c3429b.zip", +) + +http_archive( + name = "ecsact_parse_runtime_interop", + sha256 = "d87bdae35c2d3d3d0588835adcb9137a9de123feebc95fad903b3277903ffa60", + strip_prefix = "ecsact_parse_runtime_interop-f3ff60a7d13bacd139b01073fb7feb68496860dc", + url = "https://github.com/ecsact-dev/ecsact_parse_runtime_interop/archive/f3ff60a7d13bacd139b01073fb7feb68496860dc.zip", +) + +http_archive( + name = "ecsact_lang_cpp", + sha256 = "8a430ca8c92937403c0f879eca2a29da97662abd03901d11d8b419d97fa029b8", + strip_prefix = "ecsact_lang_cpp-bb88f875b3300f795ce72feab1b30109af9bbc64", + url = "https://github.com/ecsact-dev/ecsact_lang_cpp/archive/bb88f875b3300f795ce72feab1b30109af9bbc64.zip", +) + +http_archive( + name = "ecsact_lang_csharp", + sha256 = "abaec7f347a4bb02017df4e85a9a2f74f54c2397fbc1f2277622d9517ff8c371", + strip_prefix = "ecsact_lang_csharp-8dc906f95836e1ea90b3644dae6e2890c10237b8", + url = "https://github.com/ecsact-dev/ecsact_lang_csharp/archive/8dc906f95836e1ea90b3644dae6e2890c10237b8.zip", +) + load("@ecsact_parse//:repositories.bzl", "ecsact_parse_dependencies") ecsact_parse_dependencies() @@ -31,6 +66,28 @@ http_archive( url = "https://github.com/google/googletest/archive/25cc5777a17820a6339204a3552aa1dd5e428669.zip", ) +http_archive( + name = "bzlws", + sha256 = "9f52b3f339fb42e5a663b379eda56723fafb27c0fb3113152ee3a9229b059080", + strip_prefix = "bzlws-4042efa29a0359cf13f1b64e0bcd560c2d1dc4c2", + url = "https://github.com/zaucy/bzlws/archive/4042efa29a0359cf13f1b64e0bcd560c2d1dc4c2.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"], +) + +load("@rules_7zip//:setup.bzl", "setup_7zip") + +setup_7zip() + http_archive( name = "hedron_compile_commands", sha256 = "c192482fc1d76eeec2c92d1dced179122b6bd2895ca0e7239aa4866ece7e096c", diff --git a/dist/AppxManifest.xml b/dist/AppxManifest.xml new file mode 100644 index 0000000..5956bdf --- /dev/null +++ b/dist/AppxManifest.xml @@ -0,0 +1,31 @@ + + + + + Ecsact SDK + Seaube + images\logo.png + Ecsact development tools and runtime headers. https://ecsact.dev + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dist/images/logo.png b/dist/images/logo.png new file mode 100644 index 0000000..c2922af Binary files /dev/null and b/dist/images/logo.png differ diff --git a/dist/images/logo150.png b/dist/images/logo150.png new file mode 100644 index 0000000..a8bcdc8 Binary files /dev/null and b/dist/images/logo150.png differ diff --git a/dist/images/logo44.png b/dist/images/logo44.png new file mode 100644 index 0000000..7b1df12 Binary files /dev/null and b/dist/images/logo44.png differ diff --git a/pkg.bzl b/pkg.bzl new file mode 100644 index 0000000..b9acf53 --- /dev/null +++ b/pkg.bzl @@ -0,0 +1,100 @@ +load("@rules_pkg//:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo") + +def _runfile_path(workspace_name, file): + path = file.short_path + return path[len("../"):] if path.startswith("../") else "%s/%s" % (workspace_name, path) + +def _runfiles_pkg_files(workspace_name, runfiles): + files = {} + for file in runfiles.files.to_list(): + files[_runfile_path(workspace_name, file)] = file + for file in runfiles.symlinks.to_list(): + files[file.path] = "%s/%s" % (workspace_name, files.target_file) + for file in runfiles.root_symlinks.to_list(): + files[file.path] = files.target_file + + return PackageFilesInfo( + dest_src_map = files, + attributes = {"mode": "0755"}, + ) + +def _pkg_runfiles_impl(ctx): + runfiles = ctx.attr.runfiles[DefaultInfo] + label = ctx.label + workspace_name = ctx.workspace_name + + runfiles_files = _runfiles_pkg_files(workspace_name, runfiles.default_runfiles) + + pkg_filegroup_info = PackageFilegroupInfo( + pkg_dirs = [], + pkg_files = [(runfiles_files, label)], + pkg_symlinks = [], + ) + + default_info = DefaultInfo(files = depset(runfiles_files.dest_src_map.values())) + + return [default_info, pkg_filegroup_info] + +pkg_runfiles = rule( + implementation = _pkg_runfiles_impl, + attrs = { + "runfiles": attr.label( + doc = "Runfiles.", + mandatory = True, + ), + }, + provides = [PackageFilegroupInfo], +) + +def _pkg_executable_impl(ctx): + bin = ctx.attr.bin[DefaultInfo] + bin_executable = ctx.executable.bin + bin_executable_ext = bin_executable.extension + if bin_executable_ext: + bin_executable_ext = "." + bin_executable_ext + + path = ctx.attr.path + bin_executable_ext + label = ctx.label + workspace_name = ctx.workspace_name + + runfiles_files = _runfiles_pkg_files(workspace_name, bin.default_runfiles) + + dest_src_map = {"%s.runfiles/%s" % (path, p): file for p, file in runfiles_files.dest_src_map.items()} + + runfiles_files = PackageFilesInfo( + dest_src_map = dest_src_map, + attributes = runfiles_files.attributes, + ) + + executable_symlink = PackageSymlinkInfo( + attributes = {"mode": "0755"}, + destination = path, + target = "%s.runfiles/%s" % (path, _runfile_path(workspace_name, bin_executable)), + ) + + pkg_filegroup_info = PackageFilegroupInfo( + pkg_dirs = [], + pkg_files = [(runfiles_files, label)], + pkg_symlinks = [(executable_symlink, label)], + ) + + default_info = DefaultInfo(files = depset(runfiles_files.dest_src_map.values())) + + return [default_info, pkg_filegroup_info] + +pkg_executable = rule( + implementation = _pkg_executable_impl, + attrs = { + "bin": attr.label( + doc = "Executable.", + executable = True, + cfg = "target", + mandatory = True, + ), + "path": attr.string( + doc = "Packaged path of executable. (Runfiles tree will be at .runfiles.)", + mandatory = True, + ), + }, + provides = [PackageFilegroupInfo], +)