Skip to content

Commit

Permalink
up: linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-tru committed Feb 4, 2025
1 parent e4cff0a commit 726fe9e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 30 deletions.
9 changes: 5 additions & 4 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

set -e
# set -e

# install depes

Expand All @@ -17,14 +17,15 @@ else
fi
# PYTHON=/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python


if [ ! "$PYTHON" ]; then
echo "\nError: python 2.7 needs to be installed first\n";
exit -1;
exit 1;
fi

if [ ! "`which node`" ]; then
echo "\nError: nodejs needs to be installed first\n";
exit -1;
exit 2;
fi

if [ "`which tsc`" = "" ]; then
Expand Down Expand Up @@ -85,4 +86,4 @@ fi

export PYTHON=$PYTHON

node tools/configure.js "$@"
node tools/configure.js "$@"
3 changes: 1 addition & 2 deletions src/render/math.cc
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,7 @@ namespace qk {
}

Mat4::Mat4(float value) {
constexpr float src = 0;
memset_pattern4(val, &src, 16);
memset(val, 0, 16 * 4);
val[0] = value;
val[5] = value;
val[10] = value;
Expand Down
24 changes: 16 additions & 8 deletions src/render/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,40 @@ namespace qk {
// ------------------------------------------
inline Vec operator+(const Vec& b) const {
Vec c(*this);
for (int i = 0; i < LEN; i++) c.val[i] += b.val[i]; return c;
for (int i = 0; i < LEN; i++) c.val[i] += b.val[i];
return c;
}
inline Vec operator-(const Vec& b) const {
Vec c(*this);
for (int i = 0; i < LEN; i++) c.val[i] -= b.val[i]; return c;
for (int i = 0; i < LEN; i++) c.val[i] -= b.val[i];
return c;
}
inline Vec operator*(const Vec& b) const {
Vec c(*this);
for (int i = 0; i < LEN; i++) c.val[i] *= b.val[i]; return c;
for (int i = 0; i < LEN; i++) c.val[i] *= b.val[i];
return c;
}
inline Vec operator/(const Vec& b) const {
Vec c(*this);
for (int i = 0; i < LEN; i++) c.val[i] /= b.val[i]; return c;
for (int i = 0; i < LEN; i++) c.val[i] /= b.val[i];
return c;
}
// ------------------------------------------
inline Vec& operator+=(const Vec& b) {
for (int i = 0; i < LEN; i++) val[i] += b.val[i]; return *this;
for (int i = 0; i < LEN; i++) val[i] += b.val[i];
return *this;
}
inline Vec& operator-=(const Vec& b) {
for (int i = 0; i < LEN; i++) val[i] -= b.val[i]; return *this;
for (int i = 0; i < LEN; i++) val[i] -= b.val[i];
return *this;
}
inline Vec& operator*=(const Vec& b) {
for (int i = 0; i < LEN; i++) val[i] *= b.val[i]; return *this;
for (int i = 0; i < LEN; i++) val[i] *= b.val[i];
return *this;
}
inline Vec& operator/=(const Vec& b) {
for (int i = 0; i < LEN; i++) val[i] /= b.val[i]; return *this;
for (int i = 0; i < LEN; i++) val[i] /= b.val[i];
return *this;
}

// ------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/util/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "./object.h"
#include "./iterator.h"
#include <string.h>
#include <vector>
#include <functional>

Expand Down
4 changes: 2 additions & 2 deletions src/util/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ namespace qk {
Log::shared()->println(Log::kLog, Qk_ARCH_64BIT ? "%lu": "%llu", msg );
}

void log_println(size_t msg) {
/*void log_println(size_t msg) {
Log::shared()->println(Log::kLog, Qk_ARCH_64BIT ? "%lu": "%llu", msg );
}
}*/

void log_println(bool msg) {
Log::shared()->log( msg ? "true\n": "false\n" );
Expand Down
2 changes: 2 additions & 0 deletions src/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@
#endif

#define Qk_DEBUG DEBUG
#if __cplusplus >= 201703L
#define throw(...)
#endif

#define Qk_Type_Check(Base, Sub) \
while (false) { *(static_cast<Base* volatile*>(0)) = static_cast<Sub*>(0); }
Expand Down
30 changes: 16 additions & 14 deletions src/util/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "./macros.h"
#include <utility>
#include <atomic>
#include <malloc.h>

namespace qk {
struct Allocator;
Expand Down Expand Up @@ -143,6 +144,19 @@ namespace qk {
Qk_EXPORT void Release(Object* obj);
Qk_EXPORT void Fatal(const char* file, uint32_t line, const char* func, const char* msg = 0, ...);

template <typename T, int kind> struct object_traits_basic { // Object
static inline void Retain(T* obj) { qk::Retain(obj); }
static inline void Release(T* obj) { qk::Release(obj); }
};
template <typename T> struct object_traits_basic<T, 0> { // Other
static inline void Retain(T* obj) {}
static inline void Release(T* obj) { delete obj; }
};
template <typename T> struct object_traits_basic<T, 3> { //protocol
static inline void Retain(T* obj) { if (obj) qk::Retain(obj->asObject()); }
static inline void Release(T* obj) { if (obj) qk::Release(obj->asObject()); }
};

template<typename T>
struct object_traits {
typedef char __non[0];
Expand All @@ -161,21 +175,9 @@ namespace qk {
static constexpr bool ref = (k == 2);
static constexpr bool protocol = (k == 3);
};
template <int kind> struct __inl { // Object
static inline void Retain(T* obj) { qk::Retain(obj); }
static inline void Release(T* obj) { qk::Release(obj); }
};
template <> struct __inl<0> { // Other
static inline void Retain(T* obj) {}
static inline void Release(T* obj) { delete obj; }
};
template <> struct __inl<3> { //protocol
static inline void Retain(T* obj) { if (obj) qk::Retain(obj->asObject()); }
static inline void Release(T* obj) { if (obj) qk::Release(obj->asObject()); }
};
typedef __is<Kind(sizeof(test<T>(0)) / sizeof(char))> is;
inline static void Retain(T* obj) { __inl<is::kind>::Retain(obj); }
inline static void Release(T* obj) { __inl<is::kind>::Release(obj); }
inline static void Retain(T* obj) { object_traits_basic<T, is::kind>::Retain(obj); }
inline static void Release(T* obj) { object_traits_basic<T, is::kind>::Release(obj); }
};

template <>
Expand Down
2 changes: 2 additions & 0 deletions src/util/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#if Qk_POSIX
# include <sys/utsname.h>
# include <unistd.h>
# include <time.h>
# include <stdlib.h>
#endif

#if Qk_MAC
Expand Down
1 change: 1 addition & 0 deletions test/2/test2-str.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <string.h>
#include <vector>
#include <unordered_map>
#include <algorithm>

const char test_big_char[] = { 1, 0, 0, 0 };
const int* test_big_int = (const int*)test_big_char;
Expand Down
2 changes: 2 additions & 0 deletions test/2/test2-thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
*
* ***** END LICENSE BLOCK ***** */

#include <stdio.h>
#include <thread>
#include <stdlib.h>

int test2_thread(int argc, char *argv[]) {

Expand Down

0 comments on commit 726fe9e

Please sign in to comment.