Skip to content

Commit

Permalink
Add VS Code settings (#9081)
Browse files Browse the repository at this point in the history
Summary:
This PR is on top of #9079, adding the VS Code extensions and settings so that a developer can get IDE features out-of-box.

Pull Request resolved: #9081

Test Plan:
 ---

[See this instructional video](https://www.facebook.com/yangbo.0/videos/294904826169431)

How to set up the VS Code based HHVM development environment from a fresh Ubuntu:

1. Install Nix and checkout HHVM
   ```
   sh <(curl -L https://nixos.org/nix/install) --daemon &&
   git clone git@github.com:Atry/hhvm.git --depth 1 --recurse-submodules --branch vs-code
   ```
2. Open `hhvm.code-workspace` added by this PR from VS Code
3. Install extension recommendations
4. Reload VS Code
5. Wait for the extensions to be activated. Note that it would take minutes to download dependencies, depending on your network speed.
6. Click the Build button from VS Code

You can also run `cmake` and other build tools from command line by using `nix-shell`.

Reviewed By: Wilfred

Differential Revision: D36203709

Pulled By: Atry

fbshipit-source-id: 7f1ac8ecb200c82172e9c61c142f23272e629687
  • Loading branch information
Atry authored and facebook-github-bot committed Jul 5, 2022
1 parent 00377af commit 21870f6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
9 changes: 6 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@
pkgs = nixpkgs.legacyPackages.${system};
in
rec {
packages.default = pkgs.callPackage ./hhvm.nix {
packages.hhvm = pkgs.callPackage ./hhvm.nix {
lastModifiedDate = self.lastModifiedDate;
};
packages.default = packages.hhvm;

devShells.default =
pkgs.callPackage "${nixpkgs.outPath}/pkgs/build-support/mkshell/default.nix"
{ stdenv = packages.default.stdenv; }
{ stdenv = packages.hhvm.stdenv; }
{
inputsFrom = [
packages.default
packages.hhvm
];
packages = [
pkgs.rnix-lsp
];
NIX_CFLAGS_COMPILE = packages.hhvm.NIX_CFLAGS_COMPILE;
CMAKE_INIT_CACHE = packages.hhvm.cmakeInitCache;
};

}
Expand Down
32 changes: 32 additions & 0 deletions hhvm.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
"nix.enableLanguageServer": true,
"terminal.integrated.profiles.linux": {
"Nix Shell": {
"path": "nix-shell"
}
},
"terminal.integrated.profiles.osx": {
"Nix Shell": {
"path": "nix-shell"
}
},
"cmake.configureArgs": [
"-C",
"${env:CMAKE_INIT_CACHE}"
],
},
"extensions": {
"recommendations": [
"arrterian.nix-env-selector",
"jnoortheen.nix-ide",
"ms-vscode.cpptools-extension-pack"
]
}
}
30 changes: 19 additions & 11 deletions hhvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
, unzip
, uwimap
, which
, writeTextFile
, zlib
, zstd
}:
Expand All @@ -91,7 +92,7 @@ let
makeVersion = major: minor: patch: suffix:
if suffix == "-dev" then "${major}.${minor}.${patch}-${lastModifiedDate}" else "${major}.${minor}.${patch}";
in
hhvmStdenv.mkDerivation {
hhvmStdenv.mkDerivation rec {
pname = builtins.foldl' lib.trivial.id makePName versionParts;
version = builtins.foldl' lib.trivial.id makeVersion versionParts;
src = ./.;
Expand Down Expand Up @@ -180,16 +181,23 @@ hhvmStdenv.mkDerivation {
"-Wno-error=unused-command-line-argument"
];

cmakeFlags =
[
"-DCAN_USE_SYSTEM_ZSTD:BOOL=ON"
"-DHAVE_SYSTEM_TZDATA_PREFIX=${tzdata}/share/zoneinfo"
"-DHAVE_SYSTEM_TZDATA:BOOL=ON"
"-DMYSQL_UNIX_SOCK_ADDR=/run/mysqld/mysqld.sock"
]
++ lib.optionals hostPlatform.isMacOS [
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15"
];
cmakeInitCache = writeTextFile {
name = "init-cache.cmake";
text =
''
set(CAN_USE_SYSTEM_ZSTD ON CACHE BOOL "Use system zstd" FORCE)
set(HAVE_SYSTEM_TZDATA_PREFIX "${tzdata}/share/zoneinfo" CACHE STRING "The zoneinfo directory" FORCE)
set(HAVE_SYSTEM_TZDATA ON CACHE BOOL "Use system zoneinfo" FORCE)
set(MYSQL_UNIX_SOCK_ADDR "/run/mysqld/mysqld.sock" CACHE STRING "The MySQL unix socket" FORCE)
${
lib.optionalString hostPlatform.isMacOS ''
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Targeting macOS version" FORCE)
''
}
'';
};

cmakeFlags = [ "-C" cmakeInitCache ];

prePatch = ''
patchShebangs .
Expand Down

0 comments on commit 21870f6

Please sign in to comment.