Skip to content

Commit

Permalink
initial work on docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Oct 12, 2024
1 parent 44fd5e1 commit 435e5b2
Show file tree
Hide file tree
Showing 20 changed files with 622 additions and 83 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build documentation

on: [push]

env:
# Name of module and id separated by a slash
INSTANCE: docs/Writerside/in
# Replace HI with the ID of the instance in capital letters
ARTIFACT: webHelpIN2-all.zip
# Docker image version
DOCKER_VERSION: 242.21870

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '^1.23.2'
- uses: hecrj/setup-rust-action@v2
with:
rust-version: stable
- name: Update image
run: cd docs && ./update_screenshot.sh
- name: Build Writerside docs using Docker
uses: JetBrains/writerside-github-action@v4
with:
instance: ${{ env.INSTANCE }}
artifact: ${{ env.ARTIFACT }}
docker-version: ${{ env.DOCKER_VERSION }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: artifact
path: artifacts/${{ env.ARTIFACT }}

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: release/gh/*
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
87 changes: 4 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,15 @@

> Wrapper around wallet2_api.h that can be called using C api.
[![status-badge](https://ci.mrcyjanek.net/api/badges/5/status.svg?branch=rewrite-wip)](https://ci.mrcyjanek.net/repos/5/branches/rewrite-wip)

## Building

to "clean" everything:
TL;DR:

```bash
$ rm -rf monero wownero release
$ git submodule update --init --recursive --force
$ for coin in monero wownero; do ./apply_patches $coin; done
$ ./build_single monero $(gcc -dumpmachine) -j$(nproc)
```

fix ownership (if you build in docker but clone as a local user)

```bash
$ sudo chown $(whoami) . -R
```

patch codebase

```bash
$ ./apply_patches.sh monero
$ ./apply_patches.sh wownero
```

build monero_c

```bash
$ ./build_single.sh monero x86_64-linux-gnu -j$(nproc)
wownero i686-linux-gnu
aarch64-linux-gnu
x86_64-linux-android
i686-linux-android
aarch64-linux-android
arm-linux-androideabi
i686-w64-mingw32
x86_64-w64-mingw32
host-apple-darwin
host-apple-ios
```

While building I aim to compile the code at oldest supported release of debian, using default toolchain to ensure that all linux distributions are able to run monero_c libraries, below I present a supported builders for given targets

| x | builder | notes |
| ---------------------- | -------------------- | ----- |
| x86_64-linux-gnu | debian:buster | |
| i686-linux-gnu | debian:buster | |
| aarch64-linux-gnu | debian:buster | |
| x86_64-linux-android | debian:buster | |
| i686-linux-android | debian:buster | |
| aarch64-linux-android | debian:buster | |
| arm-linux-androideabi | debian:buster | |
| i686-w64-mingw32 | debian:buster | hardcoded DLL paths in build_single.sh |
| x86_64-w64-mingw32 | debian:buster | -"- |
| x86_64-apple-darwin11 | debian:bookworm | extra build step: `${HOST_ABI}-ranlib $PWD/$repo/contrib/depends/${HOST_ABI}/lib/libpolyseed.a` |
| aarch64-apple-darwin11 | debian:bookworm | -"- |
| host-apple-darwin | arm64-apple-darwin23 | dependencies: `brew install unbound [email protected] zmq cmake ccache autoconf automake libtool && brew link [email protected]` |
| host-apple-ios | arm64-apple-darwin23 | |

## Design

Functions are as simple as reasonably possible as few steps should be performed to get from the exposed C api to actual wallet2 (or wallet3 in future) api calls.

The only things passed in and out are:

- void
- bool
- int
- uint64_t
- void*
- const char*

All more complex structures are serialized into `const char*`, take look at MONERO_Wallet_createTransaction which uses `splitString(std::string(preferredInputs), std::string(separator));` to convert string into a std::set, so no implementation will need to worry about that.

Is there more effective way to do that? Probably. Is there more universal way to pass that (JSON, or others?)? Most likely. That being said, I'm against doing that. You can easily join a string in any language, and I like to keep dependency count as low as possible.

As for function naming `${COIN}_namespaceOrClass_functionName` is being used, currently these cryptocurrencies are supported

- monero
- wownero

both using wallet2 api, and both being patched with our secret ingredient(tm) (check patches directory).

Since monero_c aims to be one-fits-all solution for monero wallets, there are some special things inside, like functions prefixed with `DEBUG_*`, these are not quarenteed to stay in the code, and can be changed, the only reason they are in is because I needed some testing early in the development when bringing support for variety of platforms.

If you are a wallet developer and you **really** need this one function that doesn't exist, feel free to let me know I'll be happy to implement that.

Currently there are enterprise resitents in our library: `${COIN}_cw_*` these functions are not guaranteed to stay stable, and are made for cake wallet to implement features that are not used in xmruw nor in stack_wallet (which I need to double-check later?).

## Contributing

To contribute you can visit git.mrcyjanek.net/mrcyjanek/monero_c and open a PR, alternatively use any other code mirror or send patches directly.
Broken? Not working? Need help? https://moneroc.mrcyjanek.net/
3 changes: 3 additions & 0 deletions docs/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/.idea/docs.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added docs/Writerside/assets/onefetch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/Writerside/c.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE categories
SYSTEM "https://resources.jetbrains.com/writerside/1.0/categories.dtd">
<categories>
<category id="wrs" name="Writerside documentation" order="1"/>
</categories>
13 changes: 13 additions & 0 deletions docs/Writerside/cfg/buildprofiles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE buildprofiles SYSTEM "https://resources.jetbrains.com/writerside/1.0/build-profiles.dtd">
<buildprofiles xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<variables></variables>
<build-profile instance="in">
<variables>
<noindex-content>true</noindex-content>
</variables>
</build-profile>

</buildprofiles>
7 changes: 7 additions & 0 deletions docs/Writerside/cfg/glossary.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE terms SYSTEM "https://resources.jetbrains.com/writerside/1.0/glossary.dtd">
<terms>
<term name="foo">
Description of what "foo" is.
</term>
</terms>
17 changes: 17 additions & 0 deletions docs/Writerside/in.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE instance-profile
SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd">

<instance-profile id="in"
name="monero_c docs"
start-page="about.md">

<toc-element topic="about.md"/>
<toc-element topic="Building.md">
<toc-element topic="Using-prebuilds.md"/>
<toc-element topic="Linux.md"/>
<toc-element topic="Android.md"/>
<toc-element topic="Windows.md"/>
<toc-element topic="macOS.md"/>
</toc-element>
</instance-profile>
52 changes: 52 additions & 0 deletions docs/Writerside/topics/Android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Android

Building on linux has been tested on
- `ubuntu:22.04` (docker tag)

## Install dependencies

```bash
$ apt update
$ apt install -y build-essential pkg-config autoconf libtool \
ccache make cmake gcc g++ git curl lbzip2 libtinfo5 gperf \
unzip python-is-python3
```

## Prepare source

> If you are running in docker or have not configured git you may need to do the following:
> ```bash
> git config --global --add safe.directory '*'
> git config --global user.email "[email protected]"
> git config --global user.name "CI mrcyjanek.net"
> ```
```bash
$ git clone https://github.com/mrcyjanek/monero_c --recursive
$ cd monero_c
$ ./apply_patches.sh monero
```
## Building

<tabs>
<tab title="x86_64">
<code-block>
$ ./build_single.sh monero x86_64-linux-android -j$(nproc)
</code-block>
</tab>
<tab title="aarch64">
<code-block>
$ ./build_single.sh monero aarch64-linux-android -j$(nproc)
</code-block>
</tab>
<tab title="armv7a">
<code-block>
$ ./build_single.sh monero armv7a-linux-androideabi -j$(nproc)
</code-block>
</tab>
</tabs>

## Known issues

None. Open an issue if you find something not working.
99 changes: 99 additions & 0 deletions docs/Writerside/topics/Building.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Building

Building monero_c comes down to these simple steps:
```bash
$ git clone https://github.com/mrcyjanek/monero_c --recursive
$ ./apply_patches.sh monero # patch the libraries
$ ./build_single x86_64-linux-gnu -j$(nproc)
```

To get detailed information about building please select your host platform (the one that you will use to build the
monero wallet)

- [I'm scared. How can I use prebuilds?](Using-prebuilds.md)
- [Linux](#linux)
- [macOS](#macos)
- [Windows](#windows)

## Supported systems

| Target | Builder | Notes |
|------------------|-----------------------------|----------------------------------------------------------------------------------|
| Windows | Linux, Docker, WSL2 | msys2 builds are not supported, there are hardcoded DLL paths in build_single.sh |
| macOS | Native, Linux, Docker, WSL2 | Native builds are being widely used, but are not endorsed by me personally. |
| iOS | macOS | |
| Android | Linux, Docker, WSL2 | |
| Linux | Native, Docker, WSL2 | |
| Linux/SailfishOS | Native, Docker | Required meego toolchain. |

All supported systems are built on CI, so for the most up-to-date list of all supported systems, together with proper
dependencies please take a look at [full_check.yml](https://github.com/MrCyjaneK/monero_c/blob/master/.github/workflows/full_check.yaml)
file.

### Linux

Linux builds should be built on as old of a distro as possible - targeting `debian:oldoldstable`, main reason for that
is GLIBC compatibility (or lack of it). For some reason software compiled with newer GLIBC won't work on devices with
older GLIBC, so the solution is to simply build on the oldest possible os (or abandon GLIBC and use musl).

- x86-64-linux-gnu
- i686-linux-gnu - deprecated by monero
- aarch64-linux-gnu

[More details](Linux.md)

#### SailfishOS

Fully supported (except for armv7l devices).

- i686-meego-linux-gnu
- aarch64-meego-linux-gnu

More details: TBD

#### Alpine Linux

Requires dependency removed by upstream - it is preserved in `external/alpine/libexecinfo`. It could easily
be brought back - but since nobody uses it and nobody complained about it missing it kind of never landed in monero_c
after rewrite fully. That being said it should mostly work.

- ~~x86_64-alpine-linux-musl~~
- ~~aarch64-alpine-linux-musl~~

More details: TBD

### Android

Includes bumped NDK version

- x86_64-linux-android
- ~~i686-linux-android~~ - unsupported, fails to build
- aarch64-linux-android
- armv7a-linux-androideabi

[More details](Android.md)

### Windows

Msys2 shell is not supported, docker or WSL2 is requried to build

- i686-w64-mingw32 - deprecated by monero
- x86_64-w64-mingw32
- aarch64-w64-unknown - unsupported.
Though - if somebody can grab and send me a decent CopilotPC I'll be happy to work on that. As for now using x86_64
build should be fine (but slower in runtime) solution.

[More details](Windows.md)

### macOS

- x86_64-apple-darwin11
- aarch64-apple-darwin11
- host-apple-darwin
- x86_64-host-apple-darwin - alias for host-apple-darwin
- aarch64-host-apple-darwin alias for host-apple-darwin

[More details](macOS.md)

### iOS
- host-apple-ios - probably will be renamed to `aarch64-apple-ios`
Loading

0 comments on commit 435e5b2

Please sign in to comment.