Introduced Makefile for compilation from CLI

This commit is contained in:
Andrea Alberti 2025-10-01 05:58:19 +02:00
parent 39e614d1da
commit 2f839c6deb
6 changed files with 119 additions and 31 deletions

95
Makefile Normal file
View File

@ -0,0 +1,95 @@
# Makefile: Volume Control build rules
UID := $(shell id -u)
BUILD_DIR := /tmp/VolumeControl-$(UID)/build
CONFIGURATION_BUILD_DIR := $(BUILD_DIR)/target
DESTINATION_X86_64 := "platform=macOS,arch=x86_64"
DESTINATION_ARM64 := "platform=macOS,arch=arm64"
PROJECT := Volume Control.xcodeproj
SCHEME := Volume Control
.PHONY: debug-arm64 debug-x86_64 release \
clean-arm64 clean-x86_64 run generate-db
Q ?= @ # quiet by default; override with `make Q=`
# Debug build for ARM64
debug-arm64:
$(Q)xcrun xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration Debug \
-destination "${DESTINATION_ARM64}" \
BUILD_DIR="$(BUILD_DIR)/debug" \
CONFIGURATION_BUILD_DIR="$(CONFIGURATION_BUILD_DIR)/debug" \
build | xcpretty
# Debug build for x86_64
debug-x86_64:
$(Q)xcrun xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration Debug \
-destination "${DESTINATION_X86_64}" \
BUILD_DIR="$(BUILD_DIR)/debug" \
CONFIGURATION_BUILD_DIR="$(CONFIGURATION_BUILD_DIR)/debug" \
build | xcpretty
# Release build for distribution (both archs)
release:
$(Q)xcrun xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration Release \
ARCHS="arm64 x86_64" \
ONLY_ACTIVE_ARCH=NO \
BUILD_DIR="$(BUILD_DIR)/release" \
CONFIGURATION_BUILD_DIR="$(CONFIGURATION_BUILD_DIR)/release" \
build | xcpretty
# Clean targets
clean-arm64:
$(Q)xcrun xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration Debug \
-destination "${DESTINATION_ARM64}" \
BUILD_DIR="$(BUILD_DIR)/debug" \
CONFIGURATION_BUILD_DIR="$(CONFIGURATION_BUILD_DIR)/debug" \
clean | xcpretty
clean-x86_64:
$(Q)xcrun xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration Debug \
-destination "${DESTINATION_ARM64}" \
BUILD_DIR="$(BUILD_DIR)/debug" \
CONFIGURATION_BUILD_DIR="$(CONFIGURATION_BUILD_DIR)/debug" \
clean | xcpretty
# Run the app (after debug build)
run:
$(Q)open "$(CONFIGURATION_BUILD_DIR)/debug/Volume Control.app"
# Generate compile_commands.json for LSP-clangd server
generate-db-x86_64:
$(Q)xcrun xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration Debug \
-destination "${DESTINATION_X86_64}" \
BUILD_DIR="$(BUILD_DIR)" \
CONFIGURATION_BUILD_DIR="$(CONFIGURATION_BUILD_DIR)/debug" \
clean build | xcpretty -r json-compilation-database -o compile_commands_x86_64.json
generate-db-arm64:
$(Q)xcrun xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration Debug \
-destination "${DESTINATION_ARM64}" \
BUILD_DIR="$(BUILD_DIR)" \
CONFIGURATION_BUILD_DIR="$(CONFIGURATION_BUILD_DIR)/debug" \
clean build | xcpretty -r json-compilation-database -o compile_commands_arm64.json

View File

@ -14,42 +14,47 @@
},
],
"variables": {
"build_dir": "${project_path}/build.nosync/target/debug"
"build_dir": "${project_path}/build.nosync/target/debug",
},
"build_systems": [
{
"name": "Build with xcodebuild for debug+arm64",
"shell_cmd": "source ./build_config.env && xcrun xcodebuild -project 'Volume Control.xcodeproj' -scheme 'Volume Control' -configuration Debug -destination 'platform=macOS,arch=arm64' BUILD_DIR=\"\\${BUILD_DIR}/debug\" CONFIGURATION_BUILD_DIR=\"\\${CONFIGURATION_BUILD_DIR}/debug\" build | xcpretty",
"name": "Build Debug (arm64)",
"shell_cmd": "make debug-arm64",
"working_dir": "${project_path}",
},
{
"name": "Build with xcodebuild for debug+x86_64",
"shell_cmd": "source ./build_config.env && xcrun xcodebuild -project 'Volume Control.xcodeproj' -scheme 'Volume Control' -configuration Debug -destination 'platform=macOS,arch=x86_64' BUILD_DIR=\"\\${BUILD_DIR}/debug\" CONFIGURATION_BUILD_DIR=\"\\${CONFIGURATION_BUILD_DIR}/debug\" build | xcpretty",
"name": "Build Debug (x86_64)",
"shell_cmd": "make debug-x86_64",
"working_dir": "${project_path}",
},
{
"name": "Distribute",
"shell_cmd": "source ./build_config.env && xcrun xcodebuild -project 'Volume Control.xcodeproj' -scheme 'Volume Control' -configuration Release ARCHS=\"arm64 x86_64\" ONLY_ACTIVE_ARCH=NO BUILD_DIR=\"\\${BUILD_DIR}/release\" CONFIGURATION_BUILD_DIR=\"\\${CONFIGURATION_BUILD_DIR}/release\" build | xcpretty",
"shell_cmd": "make release",
"working_dir": "${project_path}",
},
{
"name": "Clean with xcodebuild for debug+arm64",
"shell_cmd": "source ./build_config.env && xcrun xcodebuild -project 'Volume Control.xcodeproj' -scheme 'Volume Control' -configuration Debug BUILD_DIR=\"\\${BUILD_DIR}/debug\" CONFIGURATION_BUILD_DIR=\"\\${CONFIGURATION_BUILD_DIR}/debug\" clean | xcpretty",
"name": "Clean Debug (arm64)",
"shell_cmd": "make clean-arm64",
"working_dir": "${project_path}",
},
{
"name": "Clean with xcodebuild for debug+x86_64",
"shell_cmd": "source ./build_config.env && xcrun xcodebuild -project 'Volume Control.xcodeproj' -scheme 'Volume Control' -configuration Debug BUILD_DIR=\"\\${BUILD_DIR}/debug\" CONFIGURATION_BUILD_DIR=\"\\${CONFIGURATION_BUILD_DIR}/debug\" clean | xcpretty",
"name": "Clean Debug (x86_64)",
"shell_cmd": "make clean-x86_64",
"working_dir": "${project_path}",
},
{
"name": "Run App for debug",
"shell_cmd": "source ./build_config.env && open \"\\${CONFIGURATION_BUILD_DIR}/debug/Volume Control.app\"",
"working_dir": "${project_path}"
"name": "Run App",
"shell_cmd": "make run",
"working_dir": "${project_path}",
},
{
"name": "Generate compile_commands.json for debug",
"shell_cmd": "source ./build_config.env && xcrun xcodebuild -project 'Volume Control.xcodeproj' -scheme 'Volume Control' -configuration Debug -destination 'platform=macOS,arch=arm64' BUILD_DIR=\"\\${BUILD_DIR}\" CONFIGURATION_BUILD_DIR=\"\\${CONFIGURATION_BUILD_DIR}/debug\" clean build | xcpretty -r json-compilation-database -o compile_commands.json",
"name": "Generate Compilation DB (arm64)",
"shell_cmd": "make generate-db-arm64",
"working_dir": "${project_path}",
},
{
"name": "Generate Compilation DB (x86_64)",
"shell_cmd": "make generate-db-x86_64",
"working_dir": "${project_path}",
},
],
@ -61,17 +66,7 @@
"LSP": {
/*
To regenerate compile_commands.json, you should run:
> gem install xcpretty
> xcrun xcodebuild \
-project "Volume Control.xcodeproj" \
-scheme "Volume Control" \
-configuration Debug \
-destination 'platform=macOS,arch=x86_64' \
clean \
build \
-UseNewBuildSystem=YES \
| xcpretty -r json-compilation-database -o compile_commands.json
It requires compile_commands.json generated with `make generate-db-${YOUR_PLATFORM}`
*/
"LSP-SourceKit": {
"enabled": true,

View File

@ -1,4 +0,0 @@
# build_config.env: define build variables once
export BUILD_DIR="/tmp/VolumeControl-${UID}/build"
export CONFIGURATION_BUILD_DIR="${BUILD_DIR}/target"

File diff suppressed because one or more lines are too long

1
compile_commands.json Symbolic link
View File

@ -0,0 +1 @@
compile_commands_x86_64.json

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long