Merge branch 'prepare_mac_os_x_builds' into 'master'

Prepare macOS Build

See merge request libreweb/browser!25
master
Melroy van den Berg 2022-02-08 23:26:01 +00:00
commit 38e94c1618
15 changed files with 118 additions and 127 deletions

51
.github/workflows/macOS-build.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: MacOS build
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install dependencies
run: |
brew install \
cmake \
curl \
gtkmm3 \
ninja
# Workaround for now, we create our own features.h file (macos image either is missing this file, or some include folder is missing during the build)
- name: Add `features.h`
run: |
cat >> src/features.h << EOF
#pragma once
/*** @file features.h*
* @brief Synonym for `<sys/cdefs.h>` for source compatibility with glibc.
* */
#include <sys/cdefs.h>
EOF
- name: Build
run: |
mkdir build && cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DDOXYGEN:BOOL=FALSE ..
ninja
- uses: actions/upload-artifact@v2
with:
name: macOS-binary
path: build/src/libreweb-browser
# TODO: Packaging using CPack and PackageMaker
#xcodebuild \
# -project "libreweb-browser.xcodeproj" \
# -scheme libreweb-browser \
# -configuration Debug

View File

@ -8,7 +8,8 @@ With all the knowledge and new technologies available today. I was inspired by D
[![Matrix](https://img.shields.io/badge/chat-on%20matrix-brightgreen)](https://matrix.to/#/#libreweb:melroy.org)
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-brightgreen)](https://gitter.im/LibreWeb/Browser)
[![Roadmap](https://img.shields.io/badge/Roadmap-yellow)](https://gitlab.melroy.org/libreweb/browser/-/milestones)
[![Release](https://img.shields.io/badge/Release-latest-orange)](https://gitlab.melroy.org/libreweb/browser/-/releases)
[![Docs](https://img.shields.io/badge/Documentation-orange)](https://docs.libreweb.org/)
[![Release](https://img.shields.io/badge/release-latest-orange)](https://gitlab.melroy.org/libreweb/browser/-/releases)
*Note:* This project is still work in progress. However, we have a working [alpha version available](https://gitlab.melroy.org/libreweb/browser/-/releases).
@ -54,7 +55,9 @@ The current success criteria:
---
The sections below are mainly relevant for software developers, who want to contribute or help LibreWeb Browser.
The sections below are mainly relevant for software developers, who want to contribute or help the LibreWeb Browser project.
---
## For Developers
@ -65,29 +68,26 @@ LibreWeb Browser is also using [Gnome GTK3](https://developer.gnome.org/gtk3/sta
### Development Environment
Personally, I'm using VSCodium editor, with the following extensions installed: `C/C++`, `CMake`, `CMake Tools`, `PlantUML`, `Markdown All in One`, `vscode-icons` and `GitLab Workflow`.
Personally, I'm using VSCodium editor, with the following extensions installed: `C/C++`, `CMake`, `CMake Tools`, `PlantUML`, `Markdown All in One`, `vscode-icons` and `GitLab Workflow`. But your local development setup is completely up to you.
But that is up to you.
### Linux Build Dependencies
### Build Dependencies
For the **GNU/Linux build** you need at least:
For the GNU/Linux build you need at least:
* GCC 9 or higher (`build-essential`, `g++-9`)
* GCC 9 or higher (Packages: `build-essential g++-9`)
* CMake (Package: `cmake`)
* Ninja build system (Package: `ninja-build`)
* Libcurl (Package: `libcurl4-openssl-dev`)
* GTK & Pango (including C++ bindings):
* Package: `libgtkmm-3.0-dev` under Debian based distros
* GTK3/Gtkmm3 (Package: `libgtkmm-3.0-dev`)
Depedencies for tests:
**Dependencies for testing:**
* X virtual framebuffer (Package: `xvfb`)
* Clang-format (Package: `clang-format`)
*Note:* For cross-compiling towards Windows, see the cross-compile section down below.
*Note:* For cross-compiling towards Windows and building on macOS see "[Other platforms](#Other%20platforms)" section below.
### Build
### Linux Build
Clone the source-code with SSH (do not forget `--recurse-submodules`):
@ -105,13 +105,13 @@ Optionally, use the VSCode `CMake Tools` extension to start the build or build w
#### Linux Packaging
*Note:* (Linux) Packages are already [available under releases](https://gitlab.melroy.org/libreweb/browser/-/releases).
*Note:* Linux packages are already [available under releases](https://gitlab.melroy.org/libreweb/browser/-/releases).
To build a release target yourself including packaging under GNU/Linux, use: `./scripts/build-lnx-prod.sh`
Root access is required when building Linux packages; add `/opt/mxe/usr/bin` to the secure_path using: `sudo visudo`.
### Unit testing
### Unit testing (Linux)
To execute the **unit tests** you can configure with `cmake -DUNITTEST:BOOL=TRUE` and build. Execute: `ctest` command in the `tst` target directory.
@ -123,7 +123,7 @@ Or just use script:
### C++ Coding Style Guidelines
#### Automated Clang-format
#### Automated Clang Format
We use our [own Clang LLVM C++ Programming Style Format](.clang-format), using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) command.
@ -137,17 +137,17 @@ Check only for errors, run: `./scripts/check-format.sh`
#### Core Guidelines
We also tend to follow the [C++ Core Guidelines](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) as much as possible.
We also tend to follow the popular [C++ Core Guidelines](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) as much as possible.
### Doxygen
See latest [Developer Documentation](https://gitlab.melroy.org/libreweb/browser/-/jobs/artifacts/master/file/build/docs/html/index.html?job=doxygen).
See latest [Developer Documentation](https://gitlab.melroy.org/libreweb/browser/-/jobs/artifacts/master/file/build_docs/docs/html/index.html?job=doxygen).
Doxygen is build by default. You can disable the doxygen build, if you want, using: `cmake -DDOXYGEN:BOOL=FALSE ..`
### Memory Leaks
First **build** the (GNU/Linux) target with *debug symbols*. Build target file should be present: `./build/bin/libreweb-browser`.
First **build** the (Linux) target including *debug symbols*. Binary should be present in the `build/src` folder.
Next, check for memory leaks using `valgrind` by executing:
@ -155,9 +155,13 @@ Next, check for memory leaks using `valgrind` by executing:
./scripts/valgrind.sh
```
### Cross-compiling Build Dependencies
## Other platforms
For the [cross-compiling](https://en.wikipedia.org/wiki/Cross_compiler) towards **Windows** (while under GNU/Linux), you need at least:
### Microsoft Windows
We are [**cross-compiling**](https://en.wikipedia.org/wiki/Cross_compiler) towards **Windows** using GNU/Linux.
#### Windows Build Dependencies
* [MXE Gtkmm3 / Curl Binary packages](mxe.cc) (static build using Meson build with GCC11, see below for more info)
* CMake (Package: `cmake`)
@ -182,7 +186,7 @@ Add the following line to the end of the `~/.bashrc` file:
export PATH="/opt/mxe/usr/bin:$PATH"
```
#### Cross-compile Build
#### Windows Cross-compile Build
Please, be sure you meet all the requirements above. So your MXE environment should be ready in: `/opt/mxe/usr`.
@ -194,15 +198,36 @@ Build a Windows development release:
./scripts/build-win.sh
```
Build a production release + packaging with [NSIS](https://sourceforge.net/projects/nsis/), execute the following:
#### Windows Packaging
*Note:* Windows Installer is already [available under releases](https://gitlab.melroy.org/libreweb/browser/-/releases).
Build a production release + packaging with [NSIS Installer](https://sourceforge.net/projects/nsis/), execute the following:
```sh
./scripts/build-win-prod.sh
```
See also: [Windows readme](Windows.md) file.
For more info, see also: [Windows readme file](windows.md).
### Research
### Apple MacOS / Darwin
#### MacOS Build Dependencies
* Xcode (`xcode-select --install`)
* Brew (`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"`)
* CMake (brew: `cmake`)
* Libcurl (brew: `curl`)
* Gtk3/Gtkmm3 (brew: `gtkmm3`)
* Ninja (brew: `ninja`)
#### MacOS Build
We're currently using [GitHub Actions](https://github.com/LibreWeb/Browser/blob/master/.github/workflows/macOS-build.yml) for the [macOS build](https://github.com/LibreWeb/Browser/actions/workflows/macOS-build.yml). You could already download the artifact if you want, but do not expect the runtime to work.
*Note:* **Packaging towards MacOS is still in progress**.
## LibreWeb Research
For [research document](https://gitlab.melroy.org/libreweb/research_lab/-/blob/master/research.md) plus findings including explanation (like [diagrams](https://gitlab.melroy.org/libreweb/research_lab/-/blob/master/diagrams.md)) see the:

View File

@ -1,8 +0,0 @@
This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license.
Unless otherwise noted, all code contributed prior to 2019-05-06 and not contributed by
a user listed in [this signoff issue](https://github.com/ipfs/go-ipfs/issues/6302) is
licensed under MIT-only. All new contributions (and past contributions since 2019-05-06)
are licensed under a dual MIT/Apache-2.0 license.
MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0

View File

@ -1,5 +0,0 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

View File

@ -1,19 +0,0 @@
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,28 +0,0 @@
# ipfs commandline tool
This is the [ipfs](http://ipfs.io) commandline tool. It contains a full ipfs node.
## Install
To install it, move the binary somewhere in your `$PATH`:
```sh
sudo mv ipfs /usr/local/bin/ipfs
```
Or run `sudo ./install.sh` which does this for you.
## Usage
First, you must initialize your local ipfs node:
```sh
ipfs init
```
This will give you directions to get started with ipfs.
You can always get help with:
```sh
ipfs --help
```

View File

@ -1,36 +0,0 @@
#!/bin/sh
#
# Installation script for ipfs. It tries to move $bin in one of the
# directories stored in $binpaths.
INSTALL_DIR=$(dirname $0)
bin="$INSTALL_DIR/ipfs"
binpaths="/usr/local/bin /usr/bin"
# This variable contains a nonzero length string in case the script fails
# because of missing write permissions.
is_write_perm_missing=""
for binpath in $binpaths; do
if mv "$bin" "$binpath/ipfs" ; then
echo "Moved $bin to $binpath"
exit 0
else
if [ -d "$binpath" ] && [ ! -w "$binpath" ]; then
is_write_perm_missing=1
fi
fi
done
echo "We cannot install $bin in one of the directories $binpaths"
if [ -n "$is_write_perm_missing" ]; then
echo "It seems that we do not have the necessary write permissions."
echo "Perhaps try running this script as a privileged user:"
echo
echo " sudo $0"
echo
fi
exit 1

BIN
go-ipfs/ipfs-darwin Executable file

Binary file not shown.

View File

@ -8,6 +8,11 @@ add_library(${LIBARY_NAME} STATIC whereami.c whereami.h)
# Add X/Open definition for realpath
target_compile_definitions(${LIBARY_NAME} PUBLIC _XOPEN_SOURCE=500)
# MacOS specific compile flag
if(APPLE)
target_compile_definitions(${LIBARY_NAME} PUBLIC _DARWIN_C_SOURCE)
endif()
# Use PUBLIC iso INTERFACE, so the library itself also finds it's own header file
target_include_directories(
${LIBARY_NAME}

View File

@ -12,15 +12,20 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Download & untar/zip Go-IPFS
echo "INFO: Start downloading IPFS (version ${IPFS_VERSION})..."
wget --quiet "https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSION}_darwin-amd64.tar.gz" -O "$CURRENT_DIR/go-ipfs_darwin.tar.gz"
wget --quiet "https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSION}_linux-amd64.tar.gz" -O "$CURRENT_DIR/go-ipfs_linux.tar.gz"
wget --quiet "https://dist.ipfs.io/go-ipfs/v${IPFS_VERSION}/go-ipfs_v${IPFS_VERSION}_windows-amd64.zip" -O "$CURRENT_DIR/go-ipfs_windows.zip"
# Extract on root level of the git repo
echo "INFO: Extracting Go IPFS..."
tar -xzf "$CURRENT_DIR/go-ipfs_linux.tar.gz" -C "$CURRENT_DIR/../"
unzip -q -o "$CURRENT_DIR/go-ipfs_windows.zip" -d "$CURRENT_DIR/../"
tar -xzf "$CURRENT_DIR/go-ipfs_darwin.tar.gz" go-ipfs/ipfs -C "$CURRENT_DIR/../"
# rename darwin binary
mv "$CURRENT_DIR/../go-ipfs/ipfs" "$CURRENT_DIR/../go-ipfs/ipfs-darwin"
tar -xzf "$CURRENT_DIR/go-ipfs_linux.tar.gz" go-ipfs/ipfs -C "$CURRENT_DIR/../"
unzip -q -o "$CURRENT_DIR/go-ipfs_windows.zip" go-ipfs/ipfs.exe -d "$CURRENT_DIR/../"
# Clean-up
echo "INFO: Clean up"
rm -rf "$CURRENT_DIR/go-ipfs_darwin.tar.gz"
rm -rf "$CURRENT_DIR/go-ipfs_linux.tar.gz"
rm -rf "$CURRENT_DIR/go-ipfs_windows.zip"

View File

@ -3,4 +3,4 @@
# Description: Used for memory leak analysis,
# be-aware that you will get a lot of false positives messages due to GTK
valgrind --leak-check=full --track-origins=yes ./libreweb-browser
valgrind --leak-check=full --track-origins=yes ./build/src/libreweb-browser

View File

@ -370,7 +370,7 @@ void Draw::clear()
{
auto buffer = get_buffer();
buffer->erase(buffer->begin(), buffer->end());
for (const Glib::RefPtr<Gtk::TextMark> mark : headingsToc)
for (const Glib::RefPtr<Gtk::TextMark>& mark : headingsToc)
{
buffer->delete_mark(mark);
}

View File

@ -1,5 +1,6 @@
#include "file.h"
#include <fstream>
#include <sstream>
#include <stdexcept>
#ifdef LEGACY_CXX

View File

@ -1709,7 +1709,7 @@ void MainWindow::setTableofContents(std::vector<Glib::RefPtr<Gtk::TextMark>> hea
{
Gtk::TreeRow heading1Row, heading2Row, heading3Row, heading4Row, heading5Row;
int previousLevel = 1; // Default heading 1
for (const Glib::RefPtr<Gtk::TextMark> headerMark : headings)
for (const Glib::RefPtr<Gtk::TextMark>& headerMark : headings)
{
Glib::ustring heading = static_cast<char*>(headerMark->get_data("name"));
auto level = reinterpret_cast<std::intptr_t>(headerMark->get_data("level"));

View File

@ -1,6 +1,6 @@
# Windows Packaging
The additional files in `packaging_win` are required for packaging to the Windows platform.
The additional files in `packaging_win` are required for packaging to the Windows platform (after the cross-compile went successfully).
## GTK Windows 10 Theme