1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-23 19:21:53 +03:00

update build requirements

This commit is contained in:
George Harker 2023-10-30 13:25:04 -07:00
parent ba32d88eaf
commit acc9328082
21 changed files with 488 additions and 11 deletions

3
NvimServer/NvimServer/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.deps
third-party

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,7 @@
{
"deploymentTarget": "10.15",
"gettext": {
"arm64BottleTag": "arm64_ventura",
"x86_64BottleTag": "ventura"
}
}

View File

@ -0,0 +1 @@
../../NvimServerTypes/Sources/include/NvimServerTypes.h

View File

@ -0,0 +1 @@
../../../Neovim/src/nvim/main.c

1
NvimServer/NvimServer/bin/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea

View File

@ -0,0 +1,86 @@
## How to develop
First, clean everything
```
$ ./bin/clean_all.sh
```
Then, build `libnvim` once with dependencies
```
$ target=x86_64 build_deps=true ./bin/build_libnvim.sh
```
After editing the code of neovim or NvimServer, you build NvimServer in Xcode or by executing
the following:
```
$ target="${ARCH}" build_deps=false build_dir="${PROJECT_ROOT}/NvimServer/build" \
./bin/build_nvimserver.sh
```
where `${ARCH}` is either `arm64` or `x86_64`.
We use `${PROJECT_ROOT}/NvimServer/build` as the NvimServer target assumes that location.
## How to release
```
$ ./bin/build_release.sh
```
The resulting package will be in `${PROJECT_ROOT}/NvimServer/build/NvimServer.tar.bz2`.
## Individual steps
In the following the `target` variable can be either `x86_64` or `arm64`.
### How to build `libintl`
```
$ ./bin/build_deps.sh
```
which will result in
```
${PROJECT_ROOT}
NvimServer
third-party
lib
liba
libb
...
include
a.h
b.h
...
x86_64
lib
liba
libb
include
a.h
b.h
```
Files, e.g. `lib` and `include`, in `${PROJECT_ROOT}/NvimServer/third-party` are used to build
`libnvim` and NvimServer.
### How to build `libnvim`
```
$ build_deps=true ./bin/build_libnvim.sh
```
When `build_deps` is `true`, then the `build_deps.sh` is executed. The resuling library will be
located in `/build/lib/libnvim.a`.
### how to build NvimServer
```
$ build_dir="${some_dir}" build_libnvim=true build_deps=true ./bin/build_nvimserver.sh
```
The `build_libnvim.sh` script is executed automatically with the given parameters. The resulting
binary will be located in `${some_dir}`.

View File

@ -0,0 +1,54 @@
#!/bin/bash
set -Eeuo pipefail
readonly clean=${clean:?"true or false"}
build_libnvim() {
local -r deployment_target=$1
# Brew's gettext does not get sym-linked to PATH
export PATH="/opt/homebrew/opt/gettext/bin:/usr/local/opt/gettext/bin:${PATH}"
macos_flags="-DCMAKE_OSX_DEPLOYMENT_TARGET=${deployment_target} -DCMAKE_OSX_ARCHITECTURES=arm64\;x86_64"
pushd ../Neovim
# W/o setting MACOSX_DEPLOYMENT_TARGET, the dependencies have min. macOS set to the macOS you're on.
make \
CMAKE_BUILD_TYPE=Release \
SDKROOT="$(xcrun --show-sdk-path)" \
MACOSX_DEPLOYMENT_TARGET="${deployment_target}" \
CMAKE_EXTRA_FLAGS="" \
DEPS_CMAKE_FLAGS="${macos_flags}" \
libnvim nvim
popd
}
main() {
# This script is located in /NvimServer/bin and we have to go to /
echo "$(dirname "${BASH_SOURCE[0]}")/../../"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
echo "### Building libnvim"
local deployment_target
deployment_target=$(jq -r .deploymentTarget ./NvimServer/Resources/buildInfo.json)
readonly deployment_target
if [[ "${clean}" == true ]]; then
pushd ../Neovim
make distclean
popd
./NvimServer/bin/prepare_libintl.sh
fi
build_libnvim "${deployment_target}"
popd >/dev/null
echo "### Built libnvim"
}
main

View File

@ -0,0 +1,26 @@
#!/bin/bash
set -Eeuo pipefail
declare -r -x clean=${clean:?"if true, will clean libnvim and nvimserver"}
readonly build_libnvim=${build_libnvim:?"true or false"}
readonly build_dir=${build_dir:-"./.build"}
main() {
echo "### Building NvimServer"
# This script is located in /NvimServer/bin and we have to go to /
pushd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null
if [[ "${clean}" == true ]]; then
rm -rf "${build_dir}"
fi
if [[ "${build_libnvim}" == true ]]; then
./NvimServer/bin/build_libnvim.sh
fi
swift build --arch arm64 --arch x86_64 -c release --product NvimServer
popd >/dev/null
echo "### Built NvimServer"
}
main

View File

@ -0,0 +1,38 @@
#!/bin/bash
set -Eeuo pipefail
readonly nvim_install_path=${nvim_install_path:?"where to install temp nvim"}
build_runtime() {
local -r deployment_target=$1
echo "#### runtime in ${nvim_install_path}"
echo "### Building nvim to get the complete runtime"
make \
SDKROOT="$(xcrun --show-sdk-path)" \
MACOSX_DEPLOYMENT_TARGET="${deployment_target}" \
CMAKE_EXTRA_FLAGS="-DCMAKE_OSX_DEPLOYMENT_TARGET=${deployment_target} -DCUSTOM_UI=0 -DCMAKE_INSTALL_PREFIX=${nvim_install_path}" \
DEPS_CMAKE_FLAGS="-DCMAKE_OSX_DEPLOYMENT_TARGET=${deployment_target}" \
CMAKE_BUILD_TYPE="Release" \
install
echo "#### runtime is installed at ${nvim_install_path}/share/nvim/runtime"
}
main() {
# This script is located in /NvimServer/bin and we have to go to /
pushd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null
echo "### Building runtime"
local deployment_target
deployment_target=$(jq -r .deploymentTarget ./NvimServer/Resources/buildInfo.json)
readonly deployment_target
build_runtime "${deployment_target}"
popd >/dev/null
echo "### Built runtime"
}
main

View File

@ -0,0 +1,18 @@
#!/bin/bash
set -Eeuo pipefail
readonly clean_deps=${clean_deps:-true}
pushd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null
pushd ../Neovim
rm -rf ./build
rm -rf ./.deps
make distclean
popd
if [[ "${clean_deps}" == true ]]; then
rm -rf ./NvimServer/build
fi
popd >/dev/null

View File

@ -0,0 +1,67 @@
#!/bin/bash
set -Eeuo pipefail
shopt -s extglob
main() {
# This script is located in /NvimServer/bin and we have to go to /
pushd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null
rm -rf ./NvimServer/third-party
mkdir -p NvimServer/third-party
local arm64_bottle
arm64_bottle=$(jq -r .gettext.arm64BottleTag ./NvimServer/Resources/buildInfo.json)
readonly arm64_bottle
local x86_64_bottle
x86_64_bottle=$(jq -r .gettext.x86_64BottleTag ./NvimServer/Resources/buildInfo.json)
readonly x86_64_bottle
pushd ./NvimServer/third-party >/dev/null
brew fetch --bottle-tag="${arm64_bottle}" gettext
brew fetch --bottle-tag="${x86_64_bottle}" gettext
brew fetch --bottle-tag="${x86_64_bottle}" lua
local version; version=$(brew info gettext --json | jq -r ".[0].versions.stable"); readonly version
echo "### gettext version ${version}"
local lua_version; lua_version=$(brew info lua --json | jq -r ".[0].versions.stable"); readonly version
echo "### gettext lua_version ${lua_version}"
local temp_dir; temp_dir="$(mktemp -d)"; readonly temp_dir
echo "${temp_dir}"
pushd "${temp_dir}" >/dev/null
mkdir "${arm64_bottle}"
pushd "${arm64_bottle}" >/dev/null
tar xf "$(brew --cache)"/**/*--gettext--+([0-9.])${arm64_bottle}*.tar.gz
tar xf "$(brew --cache)"/**/*--lua--+([0-9.])${arm64_bottle}*.tar.gz
popd >/dev/null
mkdir "${x86_64_bottle}"
pushd "${x86_64_bottle}" >/dev/null
tar xf "$(brew --cache)"/**/*--gettext--+([0-9.])${x86_64_bottle}*.tar.gz
tar xf "$(brew --cache)"/**/*--lua--+([0-9.])${x86_64_bottle}*.tar.gz
popd >/dev/null
mkdir universal
cp -r "${arm64_bottle}/gettext/${version}/include" ./universal/
mkdir universal/lib
lipo "${arm64_bottle}/gettext/${version}/lib/libintl.a" "${x86_64_bottle}/gettext/${version}/lib/libintl.a" -create -output ./universal/lib/libintl.a
mkdir universal_lua
cp -r "${arm64_bottle}/lua/${lua_version}/include" ./universal_lua/
mkdir universal_lua/lib
lipo "${arm64_bottle}/lua/${lua_version}/lib/liblua.a" "${x86_64_bottle}/lua/${lua_version}/lib/liblua.a" -create -output ./universal_lua/lib/liblua.a
popd >/dev/null
mv "${temp_dir}/universal" gettext
mv "${temp_dir}/universal_lua" lua
rm -rf "${temp_dir}"
popd >/dev/null
popd >/dev/null
}
main

View File

@ -0,0 +1 @@
../../Neovim

View File

@ -0,0 +1,76 @@
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
#ifndef NVIMSERVER_SHARED_TYPES_H
#define NVIMSERVER_SHARED_TYPES_H
#include <CoreFoundation/CoreFoundation.h>
#define NSInteger long
#define NSUInteger unsigned long
typedef CF_OPTIONS(NSUInteger, FontTrait) {
FontTraitNone = 0,
FontTraitItalic = (1 << 0),
FontTraitBold = (1 << 1),
FontTraitUnderline = (1 << 2),
FontTraitUndercurl = (1 << 3)
};
typedef CF_ENUM(NSInteger, RenderDataType) {
RenderDataTypeRawLine,
RenderDataTypeGoto,
RenderDataTypeScroll,
};
typedef CF_ENUM(NSInteger, NvimServerMsgId) {
NvimServerMsgIdServerReady = 0,
NvimServerMsgIdNvimReady,
NvimServerMsgIdResize,
NvimServerMsgIdClear,
NvimServerMsgIdSetMenu,
NvimServerMsgIdBusyStart,
NvimServerMsgIdBusyStop,
NvimServerMsgIdModeChange,
NvimServerMsgIdModeInfoSet,
NvimServerMsgIdBell,
NvimServerMsgIdVisualBell,
NvimServerMsgIdFlush,
NvimServerMsgIdHighlightAttrs,
NvimServerMsgIdSetTitle,
NvimServerMsgIdStop,
NvimServerMsgIdOptionSet,
NvimServerMsgIdEvent,
NvimServerMsgIdDirtyStatusChanged,
NvimServerMsgIdCwdChanged,
NvimServerMsgIdColorSchemeChanged,
NvimServerMsgIdDefaultColorsChanged,
NvimServerMsgIdAutoCommandEvent,
NvimServerMsgIdRpcEventSubscribed,
NvimServerMsgIdFatalError,
NvimServerMsgIdDebug1,
};
typedef CF_ENUM(NSInteger, NvimServerFatalErrorCode) {
NvimServerFatalErrorCodeLocalPort = 1,
NvimServerFatalErrorCodeRemotePort,
};
typedef CF_ENUM(NSInteger, NvimBridgeMsgId) {
NvimBridgeMsgIdAgentReady = 0,
NvimBridgeMsgIdReadyForRpcEvents,
NvimBridgeMsgIdDeleteInput,
NvimBridgeMsgIdResize,
NvimBridgeMsgIdScroll,
NvimBridgeMsgIdFocusGained,
NvimBridgeMsgIdDebug1,
};
#endif // NVIMSERVER_SHARED_TYPES_H

View File

@ -0,0 +1,6 @@
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
// SwiftPM requires at least one c source file, which can be empty.

58
NvimServer/Package.swift Normal file
View File

@ -0,0 +1,58 @@
// swift-tools-version:5.6
import PackageDescription
let package = Package(
name: "NvimServer",
platforms: [.macOS(.v10_15)],
products: [
.library(name: "NvimServerTypes", targets: ["NvimServerTypes"]),
],
dependencies: [],
targets: [
.target(name: "NvimServerTypes", dependencies: [], path: "NvimServerTypes"),
.executableTarget(
name: "NvimServer",
dependencies: [],
path: "NvimServer/Sources",
cSettings: [
// Otherwise we get typedef redefinition error due to double definition of Boolean
.unsafeFlags(["-fno-modules"]),
.define("INCLUDE_GENERATED_DECLARATIONS", to: "1"),
// The target folder is the working directory.
.headerSearchPath("../../NvimServer/neovim/src"),
.headerSearchPath("../../NvimServer/neovim/build/include"),
.headerSearchPath("../../NvimServer/neovim/.deps/usr/include"),
.headerSearchPath("../../NvimServer/neovim/build/cmake.config"),
.headerSearchPath("../../NvimServer/neovim/build/src/nvim/auto/"),
.headerSearchPath("../../NvimServer/third-party/gettext/include"),
.headerSearchPath("../../NvimServer/third-party/lua/include/lua"),
],
linkerSettings: [
.linkedFramework("CoreServices"),
.linkedFramework("CoreFoundation"),
.linkedLibrary("util"),
.linkedLibrary("m"),
.linkedLibrary("dl"),
.linkedLibrary("pthread"),
.linkedLibrary("iconv"),
.unsafeFlags([
// These paths seem to depend on where swift build is executed. Xcode does it in the
// folder where Package.swift is located.
"../neovim/build/lib/libnvim.a",
"../neovim/.deps/usr/lib/libmsgpack-c.a",
"../neovim/.deps/usr/lib/libluv.a",
"../neovim/.deps/usr/lib/liblpeg.a",
"../neovim/.deps/usr/lib/libtermkey.a",
"../neovim/.deps/usr/lib/libuv.a",
"../neovim/.deps/usr/lib/libunibilium.a",
"../neovim/.deps/usr/lib/libvterm.a",
"../neovim/.deps/usr/lib/libluajit-5.1.a",
"../neovim/.deps/usr/lib/libtree-sitter.a",
"NvimServer/third-party/gettext/lib/libintl.a",
]),
]
),
],
cLanguageStandard: .gnu99
)

4
NvimServer/README.md Normal file
View File

@ -0,0 +1,4 @@
# NvimServerTypes
This is a package to provider some types of NvimServer that are used in NvimView.
It consists of just one header file. Since SwiftPM requires at least a C file, we included an empty C file.

View File

@ -6,7 +6,6 @@
import Commons
import Foundation
import MessagePack
import NvimServerTypes
import os
import RxPack
import RxSwift

View File

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 60;
objects = {
/* Begin PBXBuildFile section */
@ -339,6 +339,7 @@
packageReferences = (
4BD67C9524ECF4AB00147C51 /* XCRemoteSwiftPackageReference "MessagePack" */,
4BD67CCF24ED08CB00147C51 /* XCRemoteSwiftPackageReference "PureLayout" */,
1FF017012AF02F64003D62BB /* XCLocalSwiftPackageReference "../../NvimServer" */,
);
productRefGroup = 4B90F0051FD2AF59008A39E0 /* Products */;
projectDirPath = "";
@ -754,6 +755,13 @@
};
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
1FF017012AF02F64003D62BB /* XCLocalSwiftPackageReference "../../NvimServer" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../../NvimServer;
};
/* End XCLocalSwiftPackageReference section */
/* Begin XCRemoteSwiftPackageReference section */
4BD67C9524ECF4AB00147C51 /* XCRemoteSwiftPackageReference "MessagePack" */ = {
isa = XCRemoteSwiftPackageReference;

View File

@ -124,8 +124,9 @@
4B02263B224AB11A0052362B /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1020;
LastUpgradeCheck = 1340;
LastUpgradeCheck = 1500;
ORGANIZATIONNAME = "Tae Won Ha";
TargetAttributes = {
4B02265B224AB1490052362B = {
@ -224,9 +225,11 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
@ -287,9 +290,11 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = fast;
@ -314,11 +319,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = RxMessagePortDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
PRODUCT_BUNDLE_IDENTIFIER = com.qvacua.RxMessagePortDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@ -330,11 +337,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = RxMessagePortDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
PRODUCT_BUNDLE_IDENTIFIER = com.qvacua.RxMessagePortDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;

View File

@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlCatchException.git",
"state" : {
"revision" : "35f9e770f54ce62dd8526470f14c6e137cef3eea",
"version" : "2.1.1"
"revision" : "3b123999de19bf04905bc1dfdb76f817b0f2cc00",
"version" : "2.1.2"
}
},
{
@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state" : {
"revision" : "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688",
"version" : "2.1.0"
"revision" : "a23ded2c91df9156628a6996ab4f347526f17b6b",
"version" : "2.1.2"
}
},
{
@ -86,8 +86,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble",
"state" : {
"revision" : "b7f6c49acdb247e3158198c5448b38c3cc595533",
"version" : "11.2.1"
"revision" : "eb5e3d717224fa0d1f6aff3fc2c5e8e81fa1f728",
"version" : "11.2.2"
}
},
{
@ -131,8 +131,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
"revision" : "a902f1823a7ff3c9ab2fba0f992396b948eda307",
"version" : "1.0.5"
}
},
{