-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trying out codespaces
- Loading branch information
Showing
5 changed files
with
157 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Latest Debian | ||
FROM mcr.microsoft.com/devcontainers/cpp:debian | ||
|
||
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none" | ||
|
||
# Optionally install the cmake for vcpkg | ||
COPY ./reinstall_cmake.sh /tmp/ | ||
|
||
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ | ||
chmod +x /tmp/reinstall_cmake.sh && /tmp/reinstall_cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \ | ||
fi \ | ||
&& rm -f /tmp/reinstall_cmake.sh | ||
|
||
# [Optional] Uncomment this section to install additional vcpkg ports. | ||
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>" | ||
|
||
# [Optional] Uncomment this section to install additional packages. | ||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
# && apt-get -y install --no-install-recommends <your-package-list-here> |
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,31 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp | ||
{ | ||
"name": "C++", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
"settings": {}, | ||
"extensions": [ | ||
"streetsidesoftware.code-spell-checker" | ||
] | ||
} | ||
} | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "gcc -v", | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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,60 @@ | ||
#!/usr/bin/env bash | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
# | ||
# testing, unsure if it's needed. following steps from example: https://github.com/microsoft/vscode-remote-try-cpp/tree/main/.devcontainer | ||
|
||
set -e | ||
|
||
CMAKE_VERSION=${1:-"none"} | ||
|
||
if [ "${CMAKE_VERSION}" = "none" ]; then | ||
echo "No CMake version specified, skipping CMake reinstallation" | ||
exit 0 | ||
fi | ||
|
||
# Cleanup temporary directory and associated files when exiting the script. | ||
cleanup() { | ||
EXIT_CODE=$? | ||
set +e | ||
if [[ -n "${TMP_DIR}" ]]; then | ||
echo "Executing cleanup of tmp files" | ||
rm -Rf "${TMP_DIR}" | ||
fi | ||
exit $EXIT_CODE | ||
} | ||
trap cleanup EXIT | ||
|
||
|
||
echo "Installing CMake..." | ||
apt-get -y purge --auto-remove cmake | ||
mkdir -p /opt/cmake | ||
|
||
architecture=$(dpkg --print-architecture) | ||
case "${architecture}" in | ||
arm64) | ||
ARCH=aarch64 ;; | ||
amd64) | ||
ARCH=x86_64 ;; | ||
*) | ||
echo "Unsupported architecture ${architecture}." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" | ||
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt" | ||
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX) | ||
|
||
echo "${TMP_DIR}" | ||
cd "${TMP_DIR}" | ||
|
||
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O | ||
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O | ||
|
||
sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}" | ||
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license | ||
|
||
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake |
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,43 @@ | ||
# Codespaces | ||
|
||
You can experiment with codespaces and g3log. | ||
|
||
## Learn about Github Codespaces | ||
For an introduction to codespaces you can check out [example c++ codespace](https://github.com/microsoft/vscode-remote-try-cpp/tree/main) and [using-github-codespaces-with-github-cli](https://docs.github.com/en/codespaces/developing-in-a-codespace/using-github-codespaces-with-github-cli) | ||
|
||
|
||
# Commandline codespaces Quick Reference | ||
|
||
1. List all your codespaces `gh codespace list` | ||
2. Create a new codespace `gh codespace create -r OWNER/REPO_NAME [-b BRANCH]`. Ref [docs/github: Creating a codespace for a repository](https://docs.github.com/en/codespaces/developing-in-a-codespace/creating-a-codespace-for-a-repository) | ||
3. View codebase details `gh codespace view` | ||
4. Stop `gh codespace stop -c CODESPACE-NAME` | ||
5. Delete `gh codespace delete -c CODESPACE-NAME` | ||
6. Rebuild `gh codespace rebuild` | ||
7. Rename `gh codespace edit -c CODESPACE-NAME -d DISPLAY-NAME` | ||
8. SSH into REMOTE codespace `gh codespace ssh -c CODESPACE-NAME` | ||
9. Open a remote codespace in CVisual Studio `gh codespace code -c CODESPACE-NAME` (ref: [github:doc cs studio](https://docs.github.com/en/codespaces/developing-in-a-codespace/using-github-codespaces-in-visual-studio-code)) | ||
10. Copy local file to/from codespace `gh codespace cp [-r] SOURCE(S) DESTINATION`. Example: Copy a file from the local machine to the $HOME directory of a codespace: `gh codespace cp myfile.txt remote:`. Example Copy a file from a codespace to the current directory on the local machine: `gh codespace cp remote:myfile.txt .` (more information available [here](https://cli.github.com/manual/gh_codespace_cp)) | ||
|
||
|
||
# Try g3log in a local dev container. | ||
|
||
Please note that this will build g3log as if it's on a Debian Linux platform. | ||
|
||
1. Clone this repository to your local filesystem. | ||
2. Start Visual Studio Code. Press F1 and select the `Dev Containers: Open Folder in Container...` command. | ||
3. Select the cloned copy of this g3log folder, wait for the container to start, and try things out! You should have debian C++ environment at hand. | ||
|
||
### Example cmake configuration and build | ||
``` | ||
Open a terminal in Visual Studio Code | ||
mkdir debianbuild | ||
cd debianbuild | ||
cmake -DADD_G3LOG_UNIT_TEST=ON -DADD_G3LOG_BENCH_PERFORMANCE=ON .. | ||
make -j | ||
``` | ||
|
||
### Example runs | ||
1. performance test in the container `./g3log-performance-threaded_mean 4` | ||
2. unit tests `ctest -v` | ||
3. Try a fatal example with dumped stack trace `./g3log-FATAL-contract` |