Skip to content

Commit 2f62464

Browse files
committed
New MetadataAudioFile class (which FLACFile now derives from). Makefile update to build libraries. New workflow file for GitHub.
1 parent dc5e1f3 commit 2f62464

6 files changed

Lines changed: 539 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-test:
11+
name: Build and Test (${{ matrix.os }})
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest]
16+
17+
steps:
18+
- name: Check out code
19+
uses: actions/checkout@v4
20+
21+
- name: Install dependencies (Linux)
22+
if: runner.os == 'Linux'
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y g++ make libflac-dev
26+
27+
- name: Install dependencies (macOS)
28+
if: runner.os == 'macOS'
29+
run: |
30+
brew install flac
31+
32+
- name: Build
33+
working-directory: code
34+
run: make

code/Makefile

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
# This is a makefile that will build a command-line application for Linux
2-
# (and hopefully similar operating systems).
1+
# This is a makefile that will build a command-line application and library
2+
# files for Linux, macOS, BSD, and similar operating systems.
33
# Requires libflac-dev (or equivalent) to be installed.
44

5+
# Detect the operating system
6+
OS := $(shell uname)
7+
58
CXX := g++
6-
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra -fno-aggressive-loop-optimizations
79
LDFLAGS := -lFLAC
10+
11+
# Platform-specific settings
12+
# macOS (Darwin): g++ is actually clang, so avoid GCC-specific flags.
13+
# Dynamic library is .dylib on macOS, .so on Linux/BSD/etc.
14+
ifeq ($(OS),Darwin)
15+
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra -fPIC
16+
DYNAMIC_LIB := libaudiomixer.dylib
17+
DYNAMIC_LDFLAGS := -dynamiclib -install_name $(DYNAMIC_LIB)
18+
else
19+
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra -fPIC -fno-aggressive-loop-optimizations
20+
DYNAMIC_LIB := libaudiomixer.so
21+
DYNAMIC_LDFLAGS := -shared -Wl,-soname,$(DYNAMIC_LIB)
22+
endif
23+
24+
STATIC_LIB := libaudiomixer.a
825
AUDIO_MIXER_CMDLINE_APP := audioMixer
926

1027
SRC_DIR := ./common
@@ -16,21 +33,33 @@ SOURCES := \
1633
$(SRC_DIR)/EOUtils.cpp \
1734
$(SRC_DIR)/FLACFile.cpp \
1835
$(SRC_DIR)/FLACFileInfo.cpp \
36+
$(SRC_DIR)/MetadataAudioFile.cpp \
1937
$(SRC_DIR)/utilFunctions.cpp \
2038
$(SRC_DIR)/WAVFile.cpp \
2139
$(SRC_DIR)/WAVFileInfo.cpp
2240

2341
OBJECTS := $(SOURCES:.cpp=.o)
2442

25-
.PHONY: all clean
43+
.PHONY: all libs clean
2644

27-
all: $(AUDIO_MIXER_CMDLINE_APP)
45+
all: $(AUDIO_MIXER_CMDLINE_APP) libs
46+
47+
libs: $(STATIC_LIB) $(DYNAMIC_LIB)
2848

2949
$(AUDIO_MIXER_CMDLINE_APP): $(OBJECTS) $(SRC_DIR)/cmdLineApp.cpp
3050
$(CXX) $(CXXFLAGS) -o $@ $(OBJECTS) $(SRC_DIR)/cmdLineApp.cpp $(LDFLAGS)
3151

52+
# Static library
53+
$(STATIC_LIB): $(OBJECTS)
54+
ar rvu $(STATIC_LIB) $(OBJECTS)
55+
ranlib $(STATIC_LIB)
56+
57+
# Dynamic/shared library
58+
$(DYNAMIC_LIB): $(OBJECTS)
59+
$(CXX) $(DYNAMIC_LDFLAGS) -o $(DYNAMIC_LIB) $(OBJECTS) $(LDFLAGS)
60+
3261
%.o: %.cpp %.h
3362
$(CXX) $(CXXFLAGS) -c $< -o $@
3463

3564
clean:
36-
rm -f $(AUDIO_MIXER_CMDLINE_APP) $(OBJECTS)
65+
rm -f $(AUDIO_MIXER_CMDLINE_APP) $(OBJECTS) $(STATIC_LIB) $(DYNAMIC_LIB)

0 commit comments

Comments
 (0)