Skip to content

Commit

Permalink
Build on linux fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed May 13, 2019
1 parent 2acc9d5 commit 3eca1fa
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 89 deletions.
127 changes: 127 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Commented out parameters are those with the same value as base LLVM style
# We can uncomment them if we want to change their value, or enforce the
# chosen value in case the base style changes (last sync: Clang 6.0.1).
---
### General config, applies to all languages ###
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# AlignConsecutiveAssignments: false
# AlignConsecutiveDeclarations: false
# AlignEscapedNewlines: Right
# AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: false
# AlwaysBreakTemplateDeclarations: false
# BinPackArguments: true
# BinPackParameters: true
# BraceWrapping:
# AfterClass: false
# AfterControlStatement: false
# AfterEnum: false
# AfterFunction: false
# AfterNamespace: false
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# AfterExternBlock: false
# BeforeCatch: false
# BeforeElse: false
# IndentBraces: false
# SplitEmptyFunction: true
# SplitEmptyRecord: true
# SplitEmptyNamespace: true
# BreakBeforeBinaryOperators: None
# BreakBeforeBraces: Attach
# BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
# BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
# BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
# CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
# DerivePointerAlignment: false
# DisableFormat: false
# ExperimentalAutoDetectBinPacking: false
# FixNamespaceComments: true
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IncludeBlocks: Preserve
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
# IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
# IndentPPDirectives: None
IndentWidth: 4
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: true
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
# PenaltyBreakAssignment: 2
# PenaltyBreakBeforeFirstCallParameter: 19
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakString: 1000
# PenaltyExcessCharacter: 1000000
# PenaltyReturnTypeOnItsOwnLine: 60
# PointerAlignment: Right
# RawStringFormats:
# - Delimiter: pb
# Language: TextProto
# BasedOnStyle: google
# ReflowComments: true
# SortIncludes: true
# SortUsingDeclarations: true
# SpaceAfterCStyleCast: false
# SpaceAfterTemplateKeyword: true
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeParens: ControlStatements
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Always
---
### C++ specific config ###
Language: Cpp
Standard: Cpp03
---
### ObjC specific config ###
Language: ObjC
Standard: Cpp03
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
---
### Java specific config ###
Language: Java
# BreakAfterJavaFieldAnnotations: false
...
26 changes: 21 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
import os
import sys
EnsureSConsVersion(0,14);

env = Environment(CPPPATH=['#/globals','#gui','#.'],ENV=os.environ)



env.ParseConfig("pkg-config gtkmm-3.0 --libs --cflags")
#env.ParseConfig("pkg-config lilv-0 --libs --cflags")
#env.ParseConfig("pkg-config suil-0 --libs --cflags")
env.Append(CXXFLAGS=["-g3"])
env.Append(CXXFLAGS=["-DWINDOWS_ENABLED"])

opts = Variables(ARGUMENTS)

detected_platform = "windows"
if (os.getenv("XDG_CURRENT_DESKTOP")!=None):
detected_platform="freedesktop"
elif (os.getenv("APPDATA")!=None):
detected_platform = "windows"
else:
detected_platform = ""

opts.Add(EnumVariable("platform","Platform to build",detected_platform,("windows","osx","x11")))
opts.Add(EnumVariable("platform","Platform to build",detected_platform,("windows","osx","freedesktop")))
opts.Add(BoolVariable("enable_rtaudio","Use RtAudio as Sound Driver",True))
opts.Add(BoolVariable("enable_vst2","Enable VST2",True))

opts.Update(env) # update environment
Help(opts.GenerateHelpText(env)) # generate help

if (detected_platform==""):
print("No build platform detected, available platforms: windows, freedesktop,osx")
sys.exit()

if (env["enable_rtaudio"]):

env.Append(CXXFLAGS=["-DRTAUDIO_ENABLED"])
Expand All @@ -30,7 +38,15 @@ if (env["enable_rtaudio"]):
#env.Append(CXXFLAGS=["-D__WINDOWS_ASIO__"])
env.Append(LIBS=["dsound","mfplat","mfuuid","wmcodecdspuuid","ksuser"])

if (env["platform"]=="windows"):
env.Append(CXXFLAGS=["-DWINDOWS_ENABLED"])
if (env["enable_vst2"]):
env.Append(CXXFLAGS=["-DVST2_ENABLED"])


if (env["platform"]=="freedesktop"):
env["enable_vst2"]=False # not supported
env.Append(CXXFLAGS=["-DFREEDESKTOP_ENABLED"])

def add_sources(self, sources, filetype, lib_env = None, shared = False):
import glob;
Expand Down
20 changes: 9 additions & 11 deletions bin/zytrax.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <gtkmm.h>

#include "drivers/lv2/audio_effect_factory_lv2.h"
#ifdef VST2_ENABLED
#include "drivers/vst2/factory_wrapper_vst2.h"
#endif

#include "engine/song.h"
#include "globals/json_file.h"
#include "gui/interface.h"
Expand All @@ -13,21 +15,15 @@
int main(int argc, char *argv[]) {

AudioEffectFactory effect_factory;

#ifdef VST2_ENABLED
AudioEffectProvider *provider_vst2 = create_vst2_provider();
effect_factory.add_provider(provider_vst2);
#endif

#ifdef RTAUDIO_ENABLED
register_rtaudio_driver();
#endif

#ifdef UNIX_ENABLED

AudioEffectProviderLV2 provider_lv2(&argc, &argv); //lv2 madness
provider_lv2.scan_effects(&effect_factory);
effect_factory.add_provider(&provider_lv2);
#endif

auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");

Theme theme;
Expand Down Expand Up @@ -190,12 +186,14 @@ int main(int argc, char *argv[]) {

Interface window(app.operator->(), &effect_factory, &theme, &key_bindings);
window.set_default_size(800, 600);

#ifdef VST2_ENABLED
window.add_editor_plugin_function(get_vst2_editor_function());

#endif
int ret = app->run(window);

#ifdef VST2_ENABLED
delete provider_vst2;
#endif

#ifdef RTAUDIO_ENABLED
cleanup_rtaudio_driver();
Expand Down
3 changes: 2 additions & 1 deletion drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Export('env');

targets=[]

env.add_sources(targets,"vst2/*.cpp")
if (env["enable_vst2"]):
env.add_sources(targets,"vst2/*.cpp")
if (env["enable_rtaudio"]):
env.add_sources(targets,"rtaudio/*.cpp")
env.add_sources(targets,"rtaudio/rtaudio/*.cpp")
Expand Down
1 change: 1 addition & 0 deletions drivers/rtaudio/sound_driver_rtaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SoundDriverRTAudio : public SoundDriver {
unsigned int nFrames,
double streamTime,
RtAudioStreamStatus status) {
return 0;
}

virtual void lock() {
Expand Down
9 changes: 6 additions & 3 deletions engine/song_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class AudioEffectDummy : public AudioEffect {
/* Load/Save */

virtual JSON::Node to_json() const { return json; }
virtual Error from_json(const JSON::Node &node) { json = node; }
virtual Error from_json(const JSON::Node &node) {
json = node;
return OK;
}

AudioEffectDummy() {}
};
Expand Down Expand Up @@ -181,7 +184,7 @@ Error SongFile::save(const String &p_path) {
JSON::Node note = JSON::object();
Track::Pos p = t->get_note_pos_by_index(i, k);

note.add("tick", p.tick);
note.add("tick", (int)p.tick);
note.add("column", p.column);

Track::Note n = t->get_note_by_index(i, k);
Expand Down Expand Up @@ -217,7 +220,7 @@ Error SongFile::save(const String &p_path) {

Tick t = a->get_point_tick_by_index(i, l);

point.add("tick", t);
point.add("tick", (int)t);

int value = a->get_point_by_index(i, l);

Expand Down
3 changes: 1 addition & 2 deletions globals/json_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ Error load_json(const String &p_path, JSON::Node &p_node) {
std::string str;

fseek(f, 0, SEEK_END);
fpos_t pos;
fgetpos(f, &pos);
size_t pos = ftell(f);
str.resize(pos);
fseek(f, 0, SEEK_SET);
fread(&str[0], pos, 1, f);
Expand Down
Loading

0 comments on commit 3eca1fa

Please sign in to comment.