Skip to content

Commit

Permalink
Merge the work I'm doing on multiple computers :|.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Nov 9, 2024
2 parents a4c2f5c + 2077a2c commit 67b7e43
Show file tree
Hide file tree
Showing 95 changed files with 1,122 additions and 596 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ jobs:
needs: [cache-submodule]
runs-on: ubuntu-24.04

if: ${{ false }} # XXX: Flutter 3.24 --windows
steps:
- uses: actions/checkout@v4
- run: env/setup.sh
Expand Down Expand Up @@ -370,7 +371,7 @@ jobs:

build-lnx-bad:
needs: [cache-submodule]
runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Orchid is a decentralized marketplace "for bandwidth"; providers run a server (i

Many users would like to compile Orchid. Thankfully, Orchid is extremely easy to build... so easy, in fact, that a lot of people seem confused by a lack of complex instructions :(. Every single library dependency of Orchid is included as a git submodule (so don't forget to run "git submodule update --init --recursive") and is compiled by the Orchid build system, so there is no need for a lengthy DEPS list: there are no "external" steps (as you often see with many other C/C++ projects).

Of course, you do need to have the requisite build tooling installed... in addition to the standard set of C/C++ development tools (autotools, bison/flex, make, etc.) we specifically require clang (for which I'm truly sorry: maybe one day we'll support gcc) and ldd (neither binutils ld nor gold are sufficient). Some of the build scripts for our dependencies use Python (I think only 3.x), one insists on being built using meson/ninja, and we use a couple libraries that are written in Rust.
Of course, you do need to have the requisite build tooling installed... in addition to the standard set of C/C++ development tools (autotools, bison/flex, make, etc.) we specifically require clang 16+ (for which I'm truly sorry: maybe one day we'll support gcc) and ldd (neither binutils ld nor gold are sufficient). Some of the build scripts for our dependencies use Python (I think only 3.x), one insists on being built using meson/ninja, and we use a couple libraries that are written in Rust.

(At this point I will note, as this has come up multiple times: it is neither practical nor appropriate for Orchid's documentation to detail how to install any of these toolchains. The instructions are different for every operating system, are different for every single distribution of Linux, and are often even different for specific versions of a distribution. FWIW, developers already have most of this software installed; and, if you don't, these projects have their own documentation.)

Expand Down
14 changes: 8 additions & 6 deletions app-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand All @@ -30,12 +30,12 @@ apply plugin: 'kotlin-android'
def flutter = files(orcFlutter)

android {
compileSdkVersion 33
compileSdkVersion 34

defaultConfig {
applicationId orcUnique
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode orcMonotonic.toInteger() - 946684800
versionName orcVersion
manifestPlaceholders = [orcUnique: orcUnique, orcName: orcName]
Expand Down Expand Up @@ -102,6 +102,8 @@ plugins.plugins.android.each { dependency ->
}

plugin.afterEvaluate {
plugin.android { compileSdkVersion 34 }

plugin.android.buildTypes {
profile {
initWith debug
Expand Down
11 changes: 8 additions & 3 deletions app-flutter.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ $(call include,shared/target-all.mk)

$(foreach fork,$(forks),$(shell ln -sf $(patsubst %/pubspec.yaml,%,$(fork)) >/dev/null))

sed := $(shell which gsed sed | head -n1)

.PHONY: create
create: $(pwd/flutter)/packages/flutter/pubspec.lock
$(flutter) create -i objc -a java --no-pub --project-name orchid .
$(flutter) pub get
sed -ie 's/flutter\.compileSdkVersion/33/g;s/flutter.minSdkVersion/21/g' android/app/build.gradle
sed -ie "/^platform :osx/{s/,.*/, '10.15'/g;}" macos/Podfile
sed -ie "/MACOSX_DEPLOYMENT_TARGET =/{s/=.*/= 10.15;/g;}" macos/Runner.xcodeproj/project.pbxproj
$(sed) -ie 's/flutter\.compileSdkVersion/34/g;s/flutter.minSdkVersion/21/g' android/app/build.gradle
$(sed) -ie '0,/subprojects {/s//\0 afterEvaluate { android { compileSdkVersion 34 } }/' android/build.gradle
$(sed) -ie '/org\.jetbrains\.kotlin\.android/s/\(version "\)[^"]*/\11.8.0/' android/settings.gradle
$(sed) -ie "/^# platform :ios/{s/^# //;}" ios/Podfile
$(sed) -ie "/^platform :osx/{s/,.*/, '10.15'/;}" macos/Podfile
$(sed) -ie "/MACOSX_DEPLOYMENT_TARGET =/{s/=.*/= 10.15;/g;}" macos/Runner.xcodeproj/project.pbxproj

builds :=
builds += apk
Expand Down
8 changes: 6 additions & 2 deletions app-ios/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ $(call include,shared/target-ios.mk)
local :=
local += app.mm.o

local += $(subst %,.,$(word 1,$(generated))).o
temp := $(subst %,.,$(word 1,$(generated)))
local += $(temp).o

$(call depend,$(temp).o,$(output)/XCBuildData/build.db)
cflags/$(temp) += -fmodules $(patsubst %,-fmodule-map-file=%,$(wildcard $(output)/Release-$(sdk)/*/*.modulemap)) -Wno-ignored-attributes

include env/output.mk

Expand Down Expand Up @@ -139,7 +143,7 @@ $(bundle)/Assets.car: $(wildcard Assets.xcassets/*/*)
@mkdir -p $(output)/info
# XXX: --launch-image LaunchImage
actool --output-format human-readable-text --errors --warnings --notices \
--target-device iphone --target-device ipad --minimum-deployment-target 11.0 \
--target-device iphone --target-device ipad --minimum-deployment-target 12.0 \
--platform iphoneos \
--app-icon AppIcon \
--compress-pngs \
Expand Down
2 changes: 1 addition & 1 deletion app-linux/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct _MyApplication {
char **dart_entrypoint_arguments;
};

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,performance-no-int-to-ptr)
// NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange,cppcoreguidelines-avoid-non-const-global-variables,performance-no-int-to-ptr)
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)

static void my_application_activate(GApplication *application) {
Expand Down
2 changes: 1 addition & 1 deletion app-shared/engine
Submodule engine updated 4025 files
2 changes: 1 addition & 1 deletion app-shared/flutter
Submodule flutter updated 4500 files
2 changes: 1 addition & 1 deletion app-shared/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ install! 'cocoapods',
:integrate_targets => false

# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
8 changes: 6 additions & 2 deletions app-shared/target-all.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ flutter := $(CURDIR)/$(pwd/flutter)/bin/flutter --suppress-analytics --verbose -

# -a is needed as flutter (incorrectly) only installs files for windows *target* on windows *host*
# https://github.com/flutter/flutter/issues/58379
precache := --android --ios --linux --macos --windows -a

# XXX: ugh. now I had to disable all the windows support due to Failed to download https://storage.googleapis.com/flutter_infra_release/flutter/b8800d88be4866db1b15f8b954ab2573bba9960f/windows-arm64/artifacts.zip. Ensure you have network connectivity and then try again. Exception: 404
# I actually think I can get them to fix this, as this breaks precache -a even without --windows and even without --enable-windows-desktop

precache := --android --ios --linux --macos #--windows

$(pwd/flutter)/packages/flutter/pubspec.lock: $(pwd/flutter)/packages/flutter/pubspec.yaml $(call head,$(pwd/flutter))
cd $(pwd/flutter) && git clean -fxd
cd $(pwd/flutter) && bin/flutter config --enable-linux-desktop
cd $(pwd/flutter) && bin/flutter config --enable-macos-desktop
cd $(pwd/flutter) && bin/flutter config --enable-windows-desktop
#cd $(pwd/flutter) && bin/flutter config --enable-windows-desktop
cd $(pwd/flutter) && bin/flutter precache $(precache)
cd $(pwd/flutter) && bin/flutter update-packages

Expand Down
3 changes: 2 additions & 1 deletion app-shared/target-and.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

assemble := android
platform := android
capped := Android

generated := $(pwd/gui)/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant%java

include $(pwd)/target-all.mk

jni := armeabi-v7a arm64-v8a
#jnis := $(subst $(space),$(comma),$(foreach arch,$(jni),android-$(flutter/$(arch))))

assembled := $(output)/flutter/flutter_assets/AssetManifest%json $(if $(filter noaot,$(debug)),,$(foreach arch,$(jni),$(output)/flutter/$(arch)/app%so))
$(assembled): $(dart)
Expand All @@ -35,6 +35,7 @@ $(assembled): $(dart)
-dTargetPlatform="$(platform)" \
-dTargetFile="lib/main.dart" \
-dBuildMode="$(mode)" \
-d$(capped)Archs="$(foreach arch,$(jni),$(flutter/$(arch)))" \
-dTreeShakeIcons="true" \
-dTrackWidgetCreation="true" \
--output="$(CURDIR)/$(output)/flutter" \
Expand Down
5 changes: 0 additions & 5 deletions app-shared/target-apl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ endif

codesign += && touch $(3)

ifeq ($(target),mac)
cflags += -F$(engine)
lflags += -F$(engine)
else
cflags += -F$(engine)/$(framework).xcframework/$(xcframework)
lflags += -F$(engine)/$(framework).xcframework/$(xcframework)
endif

app := $(bundle)$(contents)/Frameworks/App.framework
embed := $(bundle)$(contents)/Frameworks/$(framework).framework
Expand Down
26 changes: 21 additions & 5 deletions env/checks.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ checks += bugprone-*
checks/bugprone-argument-comment.StrictMode := true
checks += -bugprone-branch-clone
checks += -bugprone-easily-swappable-parameters
# XXX: I should enable this check and do a comprehensive audit
checks += -bugprone-empty-catch
# XXX: this is higher priority but I'm not ready for this yet
checks += -bugprone-exception-escape
checks/bugprone-exception-escape.IgnoredExceptions := "broken_promise"
Expand All @@ -34,9 +36,12 @@ checks += -cert-env33-c
checks += -cert-err58-cpp

checks += clang-analyzer-*
# XXX: this flags something in boost multiprecision (of course)
checks += -clang-analyzer-core.BitwiseShift

checks += cppcoreguidelines-*
checks += -cppcoreguidelines-avoid-c-arrays
checks += -cppcoreguidelines-avoid-capturing-lambda-coroutines
# this check is the exact opposite of a good guideline :/
checks += -cppcoreguidelines-avoid-const-or-ref-data-members
checks += -cppcoreguidelines-avoid-do-while
Expand All @@ -49,6 +54,10 @@ checks += -cppcoreguidelines-avoid-reference-coroutine-parameters
checks += -cppcoreguidelines-init-variables
# XXX: I didn't pay any attention to whether this check was interesting or not
checks += -cppcoreguidelines-macro-usage
# this was accidentally helpful, actually, but isn't an acceptable decision :/
checks += -cppcoreguidelines-misleading-capture-default-by-value
# this check doesn't handle unused parameters; am I doing this wrong?!
checks += -cppcoreguidelines-missing-std-forward
checks += -cppcoreguidelines-non-private-member-variables-in-classes
# XXX: the code which most hates this apparently does allow for memory leaks :(
checks += -cppcoreguidelines-prefer-member-initializer
Expand All @@ -57,8 +66,13 @@ checks += -cppcoreguidelines-pro-bounds-array-to-pointer-decay
checks += -cppcoreguidelines-pro-bounds-pointer-arithmetic
checks += -cppcoreguidelines-pro-type-reinterpret-cast
checks += -cppcoreguidelines-pro-type-union-access
# XXX: this check is interesting, but I'm unsure about move/forward confusion
checks += -cppcoreguidelines-rvalue-reference-param-not-moved
checks/cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams := true
# this check makes utility classes super frustrating :/
checks += -cppcoreguidelines-special-member-functions
# this check makes separates definitions of related variables
checks += -cppcoreguidelines-use-default-member-init

# XXX: I'm using a lot of statically constructed objects
#checks += fuchsia-statically-constructed-objects
Expand All @@ -67,6 +81,9 @@ checks += fuchsia-virtual-inheritance
checks += google-build-*

checks += misc-*
# I love the idea of this check, but boost does this a lot
checks += -misc-header-include-cycle
checks += -misc-include-cleaner
checks += -misc-misplaced-const
checks += -misc-no-recursion
# this check doesn't allow for any protected members :/
Expand All @@ -76,6 +93,8 @@ checks += -misc-unused-parameters

checks += modernize-*
checks += -modernize-avoid-c-arrays
# XXX: I don't want this, but it also crashes on boost::multiprecision::abs
checks += -modernize-use-constraints
checks += -modernize-use-default-member-init
checks += -modernize-use-nodiscard
checks += -modernize-use-trailing-return-type
Expand All @@ -84,6 +103,8 @@ checks += -modernize-use-using

checks += performance-*
checks/performance-move-const-arg.CheckTriviallyCopyableMove := 0
# XXX: I am pretty sure I just disagree with this optimization
checks += -performance-avoid-endl

checks += readability-const-return-type
checks += readability-container-size-empty
Expand All @@ -98,11 +119,6 @@ checks += readability-redundant-string-init
checks += readability-static-definition-in-anonymous-namespace
checks += readability-uniqueptr-delete-release

ifeq ($(target),and)
# XXX: boost multiprecision on android
#checks += -clang-analyzer-core.UndefinedBinaryOperatorResult
endif

ifeq ($(target),win)
# XXX: boost::asio::detail::do_throw_error should be [[noreturn]]
# (though, marking it [[noreturn]] didn't actually make it work)
Expand Down
2 changes: 1 addition & 1 deletion env/lnx-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

pacman -Sy \
ubuntu-keyring \
bc tcl vim \
bc sed tcl vim \
curl git rsync wget \
fakeroot talloc \
cpio rpm-tools unzip zstd \
Expand Down
2 changes: 1 addition & 1 deletion env/lnx-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apt-get update

apt-get -y install \
ubuntu-keyring \
bc tcl xxd \
bc sed tcl xxd \
curl git-core rsync wget \
fakeroot libtalloc-dev \
cpio rpm unzip zstd \
Expand Down
2 changes: 1 addition & 1 deletion env/output.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ code = $(patsubst @/%,$(output)/$(arch)/%,$(header)) $(sysroot)
# in this model, cflags would be something controlled only by the user
flags_ = $(if $(filter ./,$(1)),,$(call flags_,$(dir $(patsubst %/,%,$(1)))) $(cflags/$(1)))
flags- = $(call flags_,$(patsubst ./$(output)/%,%,$(patsubst ./$(output)/$(arch)/%,./$(output)/%,./$(dir $<))))
flags = $(qflags) $(patsubst -I@/%,-I$(output)/$(arch)/%,$(filter -I%,$(cflags/./$<) $(flags-) $(cflags)) $(filter-out -I%,$(cflags) $(flags-) $(cflags/./$<)))
flags = $(filter-out $(dflags/./$<),$(qflags)) $(patsubst -I@/%,-I$(output)/$(arch)/%,$(filter -I%,$(cflags/./$<) $(flags-) $(cflags)) $(filter-out -I%,$(cflags) $(flags-) $(cflags/./$<)))
flags += $(if $(filter $(output)/%,$<),-D__FILE__='"$(patsubst $(output)/%,%,$<)"' -Wno-builtin-macro-redefined)

define compile
Expand Down
4 changes: 3 additions & 1 deletion env/revision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ echo
if [[ $# -eq 0 ]]; then
echo; echo
else
"$@" --version | head -n 1
# Android NDK annotates version with their clang build-time flags
# (as in, the strategy used to optimize clang, not configuration)
"$@" --version | sed -e '1!d;s/, [+-][a-z]*//g'
# ld64 doesn't support --version and prints its version to stderr
# Android NDK uses inconsistent directories / urls for repository
"$@" -Wl,-v 2>&1 | sed -e '1!d;s/([^ ]* /(/' || true
Expand Down
1 change: 1 addition & 0 deletions env/setup-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ which brew &>/dev/null || /bin/bash -c "$(curl -fsSL https://raw.githubuserconte

# XXX: duplicate linux setup as much as possible
brew install \
gnu-sed \
fakeroot \
rpm2cpio zstd \
binutils \
Expand Down
11 changes: 10 additions & 1 deletion env/setup-ndk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/bash
set -e
set -o pipefail
echo y | "${ANDROID_HOME}"/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.2" "ndk;26.3.11579264" "platforms;android-33" >/dev/null

ndk=27.0.12077973

echo y | "${ANDROID_HOME}"/cmdline-tools/latest/bin/sdkmanager "ndk;${ndk}" "build-tools;30.0.3" "platforms;android-34" >/dev/null

export ANDROID_NDK_ROOT="${ANDROID_HOME}/ndk/${ndk}"

if [[ -n ${GITHUB_ENV} ]]; then
echo "ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT}" >>"${GITHUB_ENV}"
fi
2 changes: 2 additions & 0 deletions env/target-any.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ cflags += -Wno-tautological-overlap-compare
cflags += -fmessage-length=0
cflags += -ferror-limit=0
cflags += -ftemplate-backtrace-limit=0
cflags += -fmacro-backtrace-limit=0
cflags += -fdiagnostics-show-note-include-stack

beta := false

Expand Down
3 changes: 0 additions & 3 deletions env/target-apl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ signature := /_CodeSignature/CodeResources

isysroot := $(shell xcrun --sdk $(sdk) --show-sdk-path)
more += -isysroot $(isysroot)
ifneq ($(sdk),macosx)
more += -idirafter $(shell xcrun --sdk macosx --show-sdk-path)/usr/include
endif

define _
more/$(1) := -arch $(1)
Expand Down
2 changes: 2 additions & 0 deletions env/target-mac.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ runtime := osx
more := -mmacosx-version-min=10.15
include $(pwd)/target-apl.mk

xcframework := macos-arm64_x86_64

contents := /Contents
resources := /Resources
versions := /Versions/A
2 changes: 1 addition & 1 deletion env/target-win.mk
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ sysroot += $$(temp)

$(output)/$(1)/%.msys2:
@mkdir -p $$(dir $$@)
curl https://repo.msys2.org/mingw/$(1)/mingw-w64-$(1)-$$*-any.pkg.tar.zst | zstd -d | tar -C $(output)/$(1) -xvf-
curl -L https://repo.msys2.org/mingw/$(1)/mingw-w64-$(1)-$$*-any.pkg.tar.zst | zstd -d | tar -C $(output)/$(1) -xvf-
@touch $$@
sysroot += $(patsubst %,$(output)/$(1)/%.msys2,$(msys2))
endef
Expand Down
Loading

0 comments on commit 67b7e43

Please sign in to comment.