Merge pull request #8 from Decompollaborate/develop

1.2.1: Static library building in the Makefile
This commit is contained in:
Anghelo Carvajal 2022-09-26 11:31:59 -03:00 committed by GitHub
commit 70426d5ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 7 deletions

View File

@ -5,10 +5,11 @@ ASAN ?= 0
EXPERIMENTAL ?= 0
CC := clang
AR := ar
IINC := -I include
CSTD := -std=c11
CFLAGS :=
LDFLAGS :=
CFLAGS := -fPIC
LDFLAGS := -Lbuild -lrabbitizer
WARNINGS := -Wall -Wextra -Wpedantic
# WARNINGS := -Wall -Wextra -Wpedantic -Wpadded
WARNINGS += -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=vla -Werror=switch -Werror=implicit-fallthrough -Werror=unused-function -Werror=unused-parameter -Werror=shadow
@ -43,6 +44,8 @@ H_FILES := $(foreach dir,$(IINC),$(wildcard $(dir)/**/*.h))
O_FILES := $(foreach f,$(C_FILES:.c=.o),build/$f)
DEP_FILES := $(O_FILES:%.o=%.d)
STATIC_LIB := build/librabbitizer.a
DYNAMIC_LIB := build/librabbitizer.so
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
@ -50,7 +53,10 @@ $(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
#### Main Targets ###
all: tests
all: static tests
static: $(STATIC_LIB)
dynamic: $(DYNAMIC_LIB)
clean:
$(RM) -rf build
@ -73,8 +79,14 @@ tests: build/test.elf build/rsptest.elf build/r5900test.elf build/registersTrack
#### Various Recipes ####
build/%.elf: %.c $(O_FILES)
$(CC) -MMD $(CSTD) $(OPTFLAGS) $(IINC) $(WARNINGS) $(CFLAGS) $(LDFLAGS) -o $@ $^
build/%.elf: %.c | $(STATIC_LIB)
$(CC) -MMD $(CSTD) $(OPTFLAGS) $(IINC) $(WARNINGS) $(CFLAGS) -o $@ $^ $(LDFLAGS)
build/%.a: $(O_FILES)
$(AR) rcs $@ $^
build/%.so: $(O_FILES)
$(CC) -shared -o $@ $^
build/%.o: %.c
# The -MMD flags additionaly creates a .d file with the same name as the .o file.

View File

@ -0,0 +1,23 @@
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
#ifndef RABBITIZER_VERSION_H
#define RABBITIZER_VERSION_H
#include "Utils.h"
// Header version
#define RAB_VERSION_MAJOR 1
#define RAB_VERSION_MINOR 2
#define RAB_VERSION_PATCH 1
#define RAB_VERSION_STR RAB_STRINGIFY(RAB_VERSION_MAJOR) "." RAB_STRINGIFY(RAB_VERSION_MINOR) "." RAB_STRINGIFY(RAB_VERSION_PATCH)
// Compiled library version
extern const int RabVersion_Major;
extern const int RabVersion_Minor;
extern const int RabVersion_Patch;
extern const char RabVersion_Str[];
#endif

View File

@ -46,6 +46,8 @@
#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof((arr)[0]))
#define RAB_STRINGIFY(x) #x
#define MASK(v, w) ((v) & ((1 << (w)) - 1))
/*

24
include/rabbitizer.h Normal file
View File

@ -0,0 +1,24 @@
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
#ifndef RABBITIZER_H
#define RABBITIZER_H
#include "common/Utils.h"
#include "common/RabbitizerVersion.h"
#include "common/RabbitizerConfig.h"
#include "instructions/RabbitizerOperandType.h"
#include "instructions/RabbitizerInstrId.h"
#include "instructions/RabbitizerInstrSuffix.h"
#include "instructions/RabbitizerInstrDescriptor.h"
#include "instructions/RabbitizerRegister.h"
#include "instructions/RabbitizerInstruction.h"
#include "instructions/RabbitizerInstructionRsp.h"
#include "instructions/RabbitizerInstructionR5900.h"
#include "analysis/RabbitizerTrackedRegisterState.h"
#include "analysis/RabbitizerLoPairingInfo.h"
#include "analysis/RabbitizerRegistersTracker.h"
#endif

View File

@ -3,7 +3,8 @@
[metadata]
name = rabbitizer
version = 1.2.0
# Version should be synced with include/common/RabbitizerVersion.h
version = 1.2.1
author = Decompollaborate
license = MIT
description = MIPS instruction decoder

View File

@ -16,7 +16,7 @@ setup(
"src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c", "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c",
"src/instructions/RabbitizerInstrDescriptor.c", "src/instructions/RabbitizerInstrId.c", "src/instructions/RabbitizerRegister.c", "src/instructions/RabbitizerInstrSuffix.c",
"src/analysis/RabbitizerTrackedRegisterState.c", "src/analysis/RabbitizerRegistersTracker.c", "src/analysis/RabbitizerLoPairingInfo.c",
"src/common/Utils.c", "src/common/RabbitizerConfig.c"],
"src/common/Utils.c", "src/common/RabbitizerVersion.c", "src/common/RabbitizerConfig.c"],
include_dirs=["include", "rabbitizer"],
extra_compile_args = [
"-std=c11",

View File

@ -0,0 +1,10 @@
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
#include "common/RabbitizerVersion.h"
const int RabVersion_Major = RAB_VERSION_MAJOR;
const int RabVersion_Minor = RAB_VERSION_MINOR;
const int RabVersion_Patch = RAB_VERSION_PATCH;
const char RabVersion_Str[] = RAB_VERSION_STR;