-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools for Integrating Gamer with VS Code #382
base: main
Are you sure you want to change the base?
Conversation
And creating .vscode directory if not exists
Update copy_to_vscode.sh exclusions to not copy README.md.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I've tested the setup on both my MacBook Air (M1) and spock
. The run on spock
works without any issues when OpenMP is disabled. However, on the Mac with the new architecture, they only support LLVM instead of GDB, leading to differences in implementation.
To make it work on the Mac, here's what I did:
Install llvm
for lldm-mi
:
brew install llvm
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc
echo 'export LDFLAGS="-L/usr/local/opt/llvm/lib"' >> ~/.zshrc
echo 'export CPPFLAGS="-I/usr/local/opt/llvm/include"' >> ~/.zshrc
Install lldb-mi
:
git clone https://github.com/lldb-tools/lldb-mi.git
cmake -DCMAKE_CXX_FLAGS="-I/usr/local/opt/llvm/include" -DCMAKE_CXX_COMPILER="/usr/local/opt/llvm/bin/clang++" ..
cmake --build .
Lastly, I updated the launch.json
file with the following configuration:
"MIMode": "lldb",
"miDebuggerPath": "/Users/vivi/develop/lldb-mi/build/src/lldb-mi",
"miDebuggerArgs": "-Q",
Here, the miDebuggerPath
is set to the directory where lldb-mi
is installed.
With these changes, I was able to get the application running on my Mac.
I haven't tried it on Windows yet. If cross-platform compatibility is required, additional adjustments may be necessary. Let me know if you have any thought.
tool/vscode/copy_to_vscode.sh
Outdated
if [ ! -d "$(realpath "$TARGET_DIR")" ]; then | ||
echo "Target directory $(realpath "$TARGET_DIR") does not exist." | ||
mkdir -p "$(realpath "$TARGET_DIR")" | ||
echo "Target directory $(realpath "$TARGET_DIR") created." | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The realpath
has different usage at mac os. Is it necessary to avoid the problem of not absolute path? If not, maybe can switch to
if [ ! -d "$TARGET_DIR" ]; then
echo "Target directory $TARGET_DIR does not exist."
mkdir -p "$TARGET_DIR"
echo "Target directory $TARGET_DIR created."
fi
so it can run at both os.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed all of the realpath
. I would like to make the message to be more informative before.
Please help me to test it again. Thanks!
tool/vscode/copy_to_vscode.sh
Outdated
echo "$filename copied." | ||
fi | ||
|
||
sed -i "s/Gamer_Working_SubDir/$WORKING_DIR/g" "$TARGET_DIR/$filename" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage of sed
is different between linux and mac os.
sed "s/Gamer_Working_SubDir/$WORKING_DIR/g" "$TARGET_DIR/$filename" > "$TARGET_DIR/$filename.tmp" && mv "$TARGET_DIR/$filename.tmp" "$TARGET_DIR/$filename"
This might can run on both os.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change the way to setup the working directory. So sed
is not needed anymore.
tool/vscode/tasks.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be more convenient if it can automatically copy the new build gamer into the work directory. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe run sh generate_make.sh
automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have integrated copying the new executable into the building task.
And added a new task for configuring.
doc/wiki/Developing-with-VS-Code.md
Outdated
|
||
### Run build task | ||
|
||
After configuring Gamer with [configure.py](https://github.com/gamer-project/gamer/wiki/Installation%3A-Configure.py), select `Terminal` > `Run Build Task...` or press `Ctrl + Shift + B` to start the build task. This will update the macros, providing IntelliSense highlighting support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that debugging with parallel at vscode
is difficult (not only mpi
, but also openmp
). Should we remind to disable mpi
and openmp
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a note for the macOS users. But have not provide an explicit solusion yet.
- Add new tasks for configuring GAMER - Copy the executable after building - Update wiki for the new tasks - Remove `realpath` from the copy script - Add a note for macOS users And some other minor improvements - Make build-GAMER as a sequence of tasks - Fix typos: `Gamer` -> `GAMER` - Remove unnecessary information from `tool/vscode/README`.
- Make tasks as a `.sh` script - Avoid the use of `sed` in the bash script - Update wiki accordingly - Update `tool/vscode/README` accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thansk for the review and the comments.
The main change in this update is to add a new task for setup the working directory under bin/
. And the copy script will only be executed once.
As the commit messages, the minor updates are:
Improvements as the code review comments
- Add new tasks for configuring GAMER and update wiki accordingly
- Copy the executable after building
- Remove
realpath
from the copy script - Add a note for macOS users
And some other minor improvements
- Fix typos: Gamer -> GAMER
- Remove unnecessary information from
tool/vscode/README
. - Make tasks as
.sh
scripts - Avoid the use of
sed
in the bash script - Update wiki accordingly
- Update
tool/vscode/README
accordingly
Please help me to review these updates, thanks!
tool/vscode/copy_to_vscode.sh
Outdated
if [ ! -d "$(realpath "$TARGET_DIR")" ]; then | ||
echo "Target directory $(realpath "$TARGET_DIR") does not exist." | ||
mkdir -p "$(realpath "$TARGET_DIR")" | ||
echo "Target directory $(realpath "$TARGET_DIR") created." | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed all of the realpath
. I would like to make the message to be more informative before.
Please help me to test it again. Thanks!
tool/vscode/tasks.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have integrated copying the new executable into the building task.
And added a new task for configuring.
tool/vscode/copy_to_vscode.sh
Outdated
echo "$filename copied." | ||
fi | ||
|
||
sed -i "s/Gamer_Working_SubDir/$WORKING_DIR/g" "$TARGET_DIR/$filename" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change the way to setup the working directory. So sed
is not needed anymore.
doc/wiki/Developing-with-VS-Code.md
Outdated
|
||
### Run build task | ||
|
||
After configuring Gamer with [configure.py](https://github.com/gamer-project/gamer/wiki/Installation%3A-Configure.py), select `Terminal` > `Run Build Task...` or press `Ctrl + Shift + B` to start the build task. This will update the macros, providing IntelliSense highlighting support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a note for the macOS users. But have not provide an explicit solusion yet.
@technic960183 Please resolve the conflicts |
These files help user to setup an environment to work on Gamer in Visual Studio Code.
README.md
: Contains instructions of setup and usages.c_cpp_properties.json
: Contains the IntelliSense configuration.gamercpp.natvis
: Contains the visualization configuration for debugger.launch.json
: Contains the debug configuration.tasks.json
: Contains the build configuration.extract_macros.py
: Script to extract the macros from theMakefile.log
toc_cpp_properties.json
.copy_to_vscode.sh
: Script to copy the files to.vscode/
directory and set up the working path.Note:
Now
gamercpp.natvis
containTimer_t
only. This can let us check that the NATVIS works correctly. We could add more type of structures and classes in the future.