Skip to content
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

Add Mac OS build setup steps #287

Merged
merged 12 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ProjFS.Mac/Scripts/Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ fi
SCRIPTDIR=$(dirname ${BASH_SOURCE[0]})
SRCDIR=$SCRIPTDIR/../..
ROOTDIR=$SRCDIR/..
PACKAGES=$ROOTDIR/packages
PACKAGES=$ROOTDIR/packages

PROJFS=$SRCDIR/ProjFS.Mac

xcodebuild -sdk macosx10.13 -configuration $CONFIGURATION -workspace $PROJFS/PrjFS.xcworkspace build -scheme PrjFS -derivedDataPath $ROOTDIR/BuildOutput/ProjFS.Mac/Native || exit 1
kyle-rader marked this conversation as resolved.
Show resolved Hide resolved
xcodebuild -configuration $CONFIGURATION -workspace $PROJFS/PrjFS.xcworkspace build -scheme PrjFS -derivedDataPath $ROOTDIR/BuildOutput/ProjFS.Mac/Native || exit 1

dotnet restore $PROJFS/PrjFSLib.Mac.Managed/PrjFSLib.Mac.Managed.csproj /p:Configuration=$CONFIGURATION /p:Platform=x64 --packages $PACKAGES || exit 1
dotnet build $PROJFS/PrjFSLib.Mac.Managed/PrjFSLib.Mac.Managed.csproj /p:Configuration=$CONFIGURATION /p:Platform=x64 || exit 1
105 changes: 101 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ built executables, and releases may still refer to the old GVFS name. See https:
* VFS for Git requires Windows 10 Anniversary Update (Windows 10 version 1607) or later
* Run the latest GVFS and Git for Windows installers from https://github.com/Microsoft/VFSForGit/releases

## Building VFS for Git
## Building VFS for Git on Windows

If you'd like to build your own VFS for Git Windows installer:
* Install Visual Studio 2017 Community Edition or higher (https://www.visualstudio.com/downloads/).
* Install Visual Studio 2017 Community Edition or higher (https://www.visualstudio.com/downloads/).
* Include the following workloads:
* .NET desktop development
* Desktop development with C++
Expand All @@ -46,15 +46,111 @@ If you'd like to build your own VFS for Git Windows installer:
* Create a folder to clone into, e.g. `C:\Repos\VFSForGit`
* Clone this repo into the `src` subfolder, e.g. `C:\Repos\VFSForGit\src`
* Run `\src\Scripts\BuildGVFSForWindows.bat`
* You can also build in Visual Studio by opening `src\GVFS.sln` (do not upgrade any projects) and building. However, the very first
* You can also build in Visual Studio by opening `src\GVFS.sln` (do not upgrade any projects) and building. However, the very first
build will fail, and the second and subsequent builds will succeed. This is because the build requires a prebuild code generation step.
For details, see the build script in the previous step.

The installer can now be found at `C:\Repos\VFSForGit\BuildOutput\GVFS.Installer\bin\x64\[Debug|Release]\SetupGVFS.<version>.exe`

## Building VFS for Git on Mac

Note that VFS for Git on Mac is under active development.

* Ensure you have Xcode installed, have accepted the terms of use, and have launched Xcode at least once.

* Install [Visual Studio for Mac ](https://visualstudio.microsoft.com/vs/mac). (This will also install the `dotnet` CLI).

kyle-rader marked this conversation as resolved.
Show resolved Hide resolved
* If you still do not have the `dotnet` cli `>= v2.1.300` installed [manually install it]. You can check what version you have with `dotnet --version`.(https://www.microsoft.com/net/download/dotnet-core/2.1)

* You will need to manage and sign your own certificate.
kyle-rader marked this conversation as resolved.
Show resolved Hide resolved

If you're using Xcode for the first time, you may have to login to Xcode with your Apple ID to generate a codesigning certificate. You can do this by launching Xcode.app, opening the PrjFS.xcworkspace and trying to build. You can find the signing options in the General tab of the project's settings.

* Create a `VFSForGit` directory and Clone VFSForGit into a directory called `src` inside it:
```
mkdir VFSForGit
cd VFSForGit
git clone https://github.com/Microsoft/VFSForGit.git src
cd src
```

* Prep your machine to use VFS for Git. The following are all done by the script below.
* install Homebrew
* install and setup the Git Credential Manager (with `brew`)
* install/update Java (with `brew`)
* install a VFS for Git aware version of Git

```
Scripts/Mac/PrepFunctionalTests.sh
```

* From the src directory run

```
Scripts/Mac/BuildGVFSForMac.sh [Debug|Release]
```

_Troubleshooting if this fails_

If you get
```
xcodebuild: error: SDK "macosx10.13" cannot be located.
```
You may have the "XCode Command Line Tools" installed (helpfully by Mac OS) instead of full XCode.
Make sure
```
xcode-select -p
```

shows `/Applications/Xcode.app/Contents/Developer`. If it does not, install Xcode and then launch it (you can close it afterwards.)

* For the time being, only for active development, you will have to disable the SIP (System Integrity Protection) in order to load the kext).
kyle-rader marked this conversation as resolved.
Show resolved Hide resolved

**This is dangerous and very bad for the security of your machine. Do not do this on any production machine! If you no longer need to developer VFS for Git on Mac we recommend re-enabling SIP ASAP.**
kyle-rader marked this conversation as resolved.
Show resolved Hide resolved

To disable SIP boot into recovery mode (`[Win/⌘] + R` while booting your Mac).
Once booted into recovery mode open Utilities -> Terminal to launch a terminal. Enter:

```
csrutil disable
# use "csrutil enable" to re-enable when you no longer need to build VFS for Git on Mac
```
Then click the Apple logo in the top left and restart.

* Now you have to load the ProjFS Kext.

```
kyle-rader marked this conversation as resolved.
Show resolved Hide resolved
ProjFS.Mac/Scripts/LoadPrjFSKext.sh [Debug|Release]
```

* Add your built VFS for Git executable (`gvfs`) program to your path. A simple way to do that is by adding

```
<Path to>/VFSForGit/Publish
```

to your `PATH`.

Confirm you have it by running

```
command -v gvfs
```

You should see a path to the gvfs executable.

* Try cloning a VFS for Git enabled repository!

```
gvfs clone URL_TO_REPOSITORY --local-cache-path ~/.gvfsCache
```

Note the current use of `--local-cache-path`. Without this argument VFS for Git will encounter a permissions error when it attempts to create its cache at the root of your hard-drive. Automatic picking of the cache path has not yet been ported to VFS for Git on Mac.


## Trying out VFS for Git

* VFS for Git will work with any git service that supports the GVFS [protocol](Protocol.md). For example, you can create a repo in
* VFS for Git will work with any git service that supports the GVFS [protocol](Protocol.md). For example, you can create a repo in
Visual Studio Team Services (https://www.visualstudio.com/team-services/), and push some contents to it. There are two constraints:
* Your repo must not enable any clean/smudge filters
* Your repo must have a `.gitattributes` file in the root that includes the line `* -text`
Expand All @@ -63,6 +159,7 @@ Visual Studio Team Services (https://www.visualstudio.com/team-services/), and p
* Run git commands as you normally would
* `gvfs unmount` when done


# Licenses

The VFS for Git source code in this repo is available under the MIT license. See [License.md](License.md).
Expand Down
8 changes: 4 additions & 4 deletions Scripts/Mac/BuildGVFSForMac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ popd

SRCDIR=$SCRIPTDIR/../..
ROOTDIR=$SRCDIR/..
BUILDOUTPUT=$ROOTDIR/BuildOutput
BUILDOUTPUT=$ROOTDIR/BuildOutput
PUBLISHDIR=$ROOTDIR/Publish

if [ ! -d $BUILDOUTPUT ]; then
mkdir $BUILDOUTPUT
fi

PACKAGES=$ROOTDIR/packages
PACKAGES=$ROOTDIR/packages

# Build the ProjFS kext and libraries
$SRCDIR/ProjFS.Mac/Scripts/Build.sh $CONFIGURATION || exit 1

# Create the directory where we'll do pre build tasks
BUILDDIR=$BUILDOUTPUT/GVFS.Build
BUILDDIR=$BUILDOUTPUT/GVFS.Build
if [ ! -d $BUILDDIR ]; then
mkdir $BUILDDIR || exit 1
fi
Expand All @@ -44,7 +44,7 @@ dotnet build $SRCDIR/GVFS.sln --runtime osx-x64 --framework netcoreapp2.1 --conf
dotnet publish $SRCDIR/GVFS.sln /p:Configuration=$DOTNETCONFIGURATION /p:Platform=x64 --runtime osx-x64 --framework netcoreapp2.1 --self-contained --output $PUBLISHDIR /maxcpucount:1 || exit 1

NATIVEDIR=$SRCDIR/GVFS/GVFS.Native.Mac
xcodebuild -sdk macosx10.13 -configuration $CONFIGURATION -workspace $NATIVEDIR/GVFS.Native.Mac.xcworkspace build -scheme GVFS.Native.Mac -derivedDataPath $ROOTDIR/BuildOutput/GVFS.Native.Mac || exit 1
xcodebuild -configuration $CONFIGURATION -workspace $NATIVEDIR/GVFS.Native.Mac.xcworkspace build -scheme GVFS.Native.Mac -derivedDataPath $ROOTDIR/BuildOutput/GVFS.Native.Mac || exit 1

echo 'Copying native binaries to Publish directory'
cp $BUILDOUTPUT/GVFS.Native.Mac/Build/Products/$CONFIGURATION/GVFS.ReadObjectHook $PUBLISHDIR || exit 1
Expand Down
7 changes: 0 additions & 7 deletions Scripts/Mac/PrepFunctionalTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ fi

git-credential-manager install

# If our Java version is 9+ (the formatting of 'java -version' changed in Java 9), work around
kyle-rader marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/Microsoft/Git-Credential-Manager-for-Mac-and-Linux/issues/71
JAVAVERSION="$(java -version 2>&1 | egrep -o '"[[:digit:]]+.[[:digit:]]+.[[:digit:]]+"' | xargs)"
if [[ ! -z $JAVAVERSION ]]; then
git config --global credential.helper "!/usr/bin/java -Ddebug=false --add-modules java.xml.bind -Djava.net.useSystemProxies=true -jar /usr/local/Cellar/git-credential-manager/2.0.3/libexec/git-credential-manager-2.0.3.jar" || exit 1
fi

# If we're running on an agent where the PAT environment variable is set and a URL is passed into the script, add it to the keychain.
PATURL=$1
PAT=$2
Expand Down