Adds a basic c++ app using ncurses and a build system.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@
|
|||||||
/asm
|
/asm
|
||||||
/dos/sbf/sbf
|
/dos/sbf/sbf
|
||||||
/dos/sbf/sbf_start.command
|
/dos/sbf/sbf_start.command
|
||||||
|
/build
|
||||||
|
*.o
|
||||||
|
|||||||
68
Makefile
Normal file
68
Makefile
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
BUILD_DIR := build
|
||||||
|
OUT_DIR := build
|
||||||
|
SRC_DIR = sbf-cpp
|
||||||
|
|
||||||
|
ifdef DEBUG
|
||||||
|
DBG_OPT_FLAGS=-g
|
||||||
|
else
|
||||||
|
DBG_OPT_FLAGS=-O2
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef ASAN
|
||||||
|
ASAN_FLAGS=-fsanitize=address
|
||||||
|
else
|
||||||
|
ASAN_FLAGS=
|
||||||
|
endif
|
||||||
|
|
||||||
|
INCLUDE_DIRS = sbf-cpp
|
||||||
|
INCLUDES = $(patsubst %, -I%, $(INCLUDE_DIRS))
|
||||||
|
LIBRARY_DIRS =
|
||||||
|
LIBRARIES = $(patsubst %, -L%, $(LIBRARY_DIRS)) -lncurses
|
||||||
|
FRAMEWORK_NAMES =
|
||||||
|
FRAMEWORKS = $(patsubst %, -framework %, $(FRAMEWORK_NAMES))
|
||||||
|
ARCHS = -arch arm64 -arch x86_64
|
||||||
|
CCFLAGS := -std=c++17 -Wall -fno-objc-arc $(INCLUDES) $(DBG_OPT_FLAGS) $(ASAN_FLAGS) $(ARCHS)
|
||||||
|
LDFLAGS := $(LIBRARIES) $(FRAMEWORKS) $(ARCHS) $(DBG_OPT_FLAGS) $(ASAN_FLAGS)
|
||||||
|
CC = clang++
|
||||||
|
LD = clang++
|
||||||
|
CLIAPPNAME=sbf-cpp
|
||||||
|
APPNAME=SBF
|
||||||
|
BUNDLENAME = $(APPNAME).app
|
||||||
|
BUNDLEFOLDER = $(BUILD_DIR)/$(BUNDLENAME)
|
||||||
|
BUNDLEIDENTIFIER = com.majinnaibu.test.$(APPNAME)
|
||||||
|
BUNDLESIGNATURE = SBF_
|
||||||
|
RESOURCES_DIR = Resources
|
||||||
|
APP_OBJECTS = main.o
|
||||||
|
|
||||||
|
MANDATORY_TARGETS = Makefile
|
||||||
|
|
||||||
|
.Phony: all clean app test
|
||||||
|
|
||||||
|
all: $(BUILD_DIR)/$(CLIAPPNAME) app
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
mkdir -p $(BUILD_DIR)/Contents
|
||||||
|
mkdir -p $(BUNDLEFOLDER)/Contents/MacOS
|
||||||
|
mkdir -p $(BUNDLEFOLDER)/Contents/Resources
|
||||||
|
|
||||||
|
test: clean all
|
||||||
|
./$(BUILD_DIR)/$(CLIAPPNAME)
|
||||||
|
|
||||||
|
# Main app
|
||||||
|
app: $(BUILD_DIR)/$(CLIAPPNAME) $(SRC_DIR)/Info.plist $(RESOURCES_DIR)/en-US.lproj/InfoPlist.strings $(MANDATORY_TARGETS)
|
||||||
|
cp $(SRC_DIR)/Info.plist $(BUILD_DIR)/Contents/Info.plist
|
||||||
|
plutil -replace CFBundleExecutable -string "$(APPNAME)" $(BUILD_DIR)/Contents/Info.plist
|
||||||
|
plutil -replace CFBundleIdentifier -string "com.majinnaibu.$(APPNAME)" $(BUILD_DIR)/Contents/Info.plist
|
||||||
|
plutil -replace CFBundleName -string "$(APPNAME)" $(BUILD_DIR)/Contents/Info.plist
|
||||||
|
plutil -replace CFBundleSignature -string $(BUNDLESIGNATURE) $(BUILD_DIR)/Contents/Info.plist
|
||||||
|
cp $(BUILD_DIR)/Contents/Info.plist $(BUNDLEFOLDER)/Contents/
|
||||||
|
cp $(BUILD_DIR)/$(CLIAPPNAME) $(BUNDLEFOLDER)/Contents/MacOS/$(APPNAME)
|
||||||
|
cp -r $(RESOURCES_DIR)/* $(BUNDLEFOLDER)/Contents/Resources/
|
||||||
|
|
||||||
|
$(BUILD_DIR)/$(CLIAPPNAME): $(patsubst %, $(BUILD_DIR)/%, $(APP_OBJECTS)) $(MANDATORY_TARGETS)
|
||||||
|
$(LD) $(LDFLAGS) -o $@ $(patsubst %, $(BUILD_DIR)/%, $(APP_OBJECTS))
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/*.h $(MANDATORY_TARGETS)
|
||||||
|
$(CC) $(CCFLAGS) -c -o $@ $<
|
||||||
3
Resources/en-US.lproj/InfoPlist.strings
Normal file
3
Resources/en-US.lproj/InfoPlist.strings
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/* Localized versions of Info.plist keys */
|
||||||
|
|
||||||
|
NSHumanReadableCopyright = "? Tom Hicks, 2023";
|
||||||
32
sbf-cpp/Info.plist
Normal file
32
sbf-cpp/Info.plist
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en-US</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Metal Test</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CSResourcesFileMapped</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>? Tom Hicks, 2023</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string></string>
|
||||||
|
<key>MetalCaptureEnabled</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
19
sbf-cpp/main.cpp
Normal file
19
sbf-cpp/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <ncurses.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
// cout << "Hello, World!" << endl;
|
||||||
|
initscr();
|
||||||
|
raw();
|
||||||
|
noecho();
|
||||||
|
keypad(stdscr, true);
|
||||||
|
|
||||||
|
printw("Hello, World!");
|
||||||
|
refresh();
|
||||||
|
getch();
|
||||||
|
endwin();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
0
sbf-cpp/main.h
Normal file
0
sbf-cpp/main.h
Normal file
Reference in New Issue
Block a user