Skip to content

Commit

Permalink
removed not necessary includes
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Nov 26, 2024
1 parent e0ea7a6 commit 426e58a
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 127 deletions.
9 changes: 0 additions & 9 deletions emscripten/markerCompress.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#include <emscripten.h>

#ifdef _WIN32
#include <Windows.h>
#else
#include <sys/stat.h>
#endif

#include "zlib/zlib.h"
#include <AR/ar.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>


Expand Down
7 changes: 5 additions & 2 deletions emscripten/markerCreator_bindings.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <emscripten.h>

using namespace emscripten;

int createNftDataSet_em(emscripten::val imgData, float dpiIn, int xsizeIn,
int ysizeIn, int ncIn, std::string cmdStr) {
Expand All @@ -14,6 +17,6 @@ int compressZip_em(std::string srcStr, int srclen) {
}

EMSCRIPTEN_BINDINGS(markerCreator_bindings) {
emscripten::function("createNftDataSet", &createNftDataSet_em);
emscripten::function("compressZip", &compressZip_em);
function("createNftDataSet", &createNftDataSet_em);
function("compressZip", &compressZip_em);
};
232 changes: 116 additions & 116 deletions tools/makem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
*/

let exec = require("child_process").exec,
path = require("path"),
fs = require("fs");
path = require("path"),
fs = require("fs");

const HAVE_NFT = 1;

const EMSCRIPTEN_ROOT = process.env.EMSCRIPTEN;
const WEBARKITLIB_ROOT = process.env.WEBARKITLIB_ROOT || "../emscripten/WebARKitLib";

if (!EMSCRIPTEN_ROOT) {
console.log("\nWarning: EMSCRIPTEN environment variable not found.");
console.log(
'If you get a "command not found" error,\ndo `source <path to emsdk>/emsdk_env.sh` and try again.',
);
console.log("\nWarning: EMSCRIPTEN environment variable not found.");
console.log(
'If you get a "command not found" error,\ndo `source <path to emsdk>/emsdk_env.sh` and try again.',
);
}

const EMCC = EMSCRIPTEN_ROOT ? path.resolve(EMSCRIPTEN_ROOT, "emcc") : "emcc";
Expand All @@ -39,7 +39,7 @@ let MAIN_SOURCES = [
];

MAIN_SOURCES = MAIN_SOURCES.map(function (src) {
return path.resolve(SOURCE_PATH, src);
return path.resolve(SOURCE_PATH, src);
}).join(" ");

// prettier-ignore
Expand All @@ -51,48 +51,48 @@ let ar_sources = [
});

const ar2_sources = [
"handle.c",
"imageSet.c",
"jpeg.c",
"marker.c",
"featureMap.c",
"featureSet.c",
"selectTemplate.c",
"surface.c",
"tracking.c",
"tracking2d.c",
"matching.c",
"matching2.c",
"template.c",
"searchPoint.c",
"coord.c",
"util.c",
"handle.c",
"imageSet.c",
"jpeg.c",
"marker.c",
"featureMap.c",
"featureSet.c",
"selectTemplate.c",
"surface.c",
"tracking.c",
"tracking2d.c",
"matching.c",
"matching2.c",
"template.c",
"searchPoint.c",
"coord.c",
"util.c",
].map(function (src) {
return path.resolve(__dirname, WEBARKITLIB_ROOT + "/lib/SRC/AR2/", src);
return path.resolve(__dirname, WEBARKITLIB_ROOT + "/lib/SRC/AR2/", src);
});

const kpm_sources = [
"KPM/kpmHandle.cpp",
"KPM/kpmRefDataSet.cpp",
"KPM/kpmMatching.cpp",
"KPM/kpmResult.cpp",
"KPM/kpmUtil.cpp",
"KPM/kpmFopen.c",
"KPM/FreakMatcher/detectors/DoG_scale_invariant_detector.cpp",
"KPM/FreakMatcher/detectors/gaussian_scale_space_pyramid.cpp",
"KPM/FreakMatcher/detectors/gradients.cpp",
//"KPM/FreakMatcher/detectors/harris.cpp",
"KPM/FreakMatcher/detectors/orientation_assignment.cpp",
"KPM/FreakMatcher/detectors/pyramid.cpp",
"KPM/FreakMatcher/facade/visual_database_facade.cpp",
"KPM/FreakMatcher/matchers/hough_similarity_voting.cpp",
"KPM/FreakMatcher/matchers/freak.cpp",
"KPM/FreakMatcher/framework/date_time.cpp",
"KPM/FreakMatcher/framework/image.cpp",
"KPM/FreakMatcher/framework/logger.cpp",
"KPM/FreakMatcher/framework/timers.cpp",
"KPM/kpmHandle.cpp",
"KPM/kpmRefDataSet.cpp",
"KPM/kpmMatching.cpp",
"KPM/kpmResult.cpp",
"KPM/kpmUtil.cpp",
"KPM/kpmFopen.c",
"KPM/FreakMatcher/detectors/DoG_scale_invariant_detector.cpp",
"KPM/FreakMatcher/detectors/gaussian_scale_space_pyramid.cpp",
"KPM/FreakMatcher/detectors/gradients.cpp",
//"KPM/FreakMatcher/detectors/harris.cpp",
"KPM/FreakMatcher/detectors/orientation_assignment.cpp",
"KPM/FreakMatcher/detectors/pyramid.cpp",
"KPM/FreakMatcher/facade/visual_database_facade.cpp",
"KPM/FreakMatcher/matchers/hough_similarity_voting.cpp",
"KPM/FreakMatcher/matchers/freak.cpp",
"KPM/FreakMatcher/framework/date_time.cpp",
"KPM/FreakMatcher/framework/image.cpp",
"KPM/FreakMatcher/framework/logger.cpp",
"KPM/FreakMatcher/framework/timers.cpp",
].map(function (src) {
return path.resolve(__dirname, WEBARKITLIB_ROOT + "/lib/SRC/", src);
return path.resolve(__dirname, WEBARKITLIB_ROOT + "/lib/SRC/", src);
});

// prettier-ignore
Expand All @@ -116,7 +116,7 @@ FLAGS += " -s FORCE_FILESYSTEM=1";

let ES6_FLAGS = "";
ES6_FLAGS +=
" -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 -s MODULARIZE=1 -sENVIRONMENT=web -s EXPORT_NAME='NftMC' ";
" -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 -s MODULARIZE=1 -sENVIRONMENT=web -s EXPORT_NAME='NftMC' ";

const WASM_FLAGS = " -s WASM=1 ";

Expand All @@ -125,7 +125,7 @@ const SINGLE_FILE_FLAG = " -s SINGLE_FILE=1 ";
const BIND_FLAG = " --bind ";

const EXPORTED_FUNCTIONS =
' -s EXPORTED_FUNCTIONS=["_malloc,_free"] -s EXPORTED_RUNTIME_METHODS=["FS,stringToUTF8,lengthBytesUTF8"] ';
' -s EXPORTED_FUNCTIONS=["_malloc,_free"] -s EXPORTED_RUNTIME_METHODS=["FS,stringToUTF8,lengthBytesUTF8"] ';

/* DEBUG FLAGS */
let DEBUG_FLAGS = " -g ";
Expand All @@ -137,45 +137,45 @@ DEBUG_FLAGS += " -s ALLOW_MEMORY_GROWTH=1";
DEBUG_FLAGS += " -s DEMANGLE_SUPPORT=1 ";

var INCLUDES = [
path.resolve(__dirname, WEBARKITLIB_ROOT + "/include"),
OUTPUT_PATH,
SOURCE_PATH,
path.resolve(__dirname, WEBARKITLIB_ROOT + "/lib/SRC/KPM/FreakMatcher"),
path.resolve(__dirname, WEBARKITLIB_ROOT + "/include"),
OUTPUT_PATH,
SOURCE_PATH,
path.resolve(__dirname, WEBARKITLIB_ROOT + "/lib/SRC/KPM/FreakMatcher"),
]
.map(function (s) {
return "-I" + s;
})
.join(" ");
.map(function (s) {
return "-I" + s;
})
.join(" ");

function format(str) {
for (let f = 1; f < arguments.length; f++) {
str = str.replace(/{\w*}/, arguments[f]);
}
return str;
for (let f = 1; f < arguments.length; f++) {
str = str.replace(/{\w*}/, arguments[f]);
}
return str;
}

function clean_builds() {
try {
const stats = fs.statSync(OUTPUT_PATH);
} catch (e) {
fs.mkdirSync(OUTPUT_PATH);
}

try {
const files = fs.readdirSync(OUTPUT_PATH);
if (files.length > 0)
for (let i = 0; i < files.length; i++) {
const filePath = OUTPUT_PATH + "/" + files[i];
if (fs.statSync(filePath).isFile()) fs.unlinkSync(filePath);
}
} catch (e) {
return console.log(e);
}
try {
const stats = fs.statSync(OUTPUT_PATH);
} catch (e) {
fs.mkdirSync(OUTPUT_PATH);
}

try {
const files = fs.readdirSync(OUTPUT_PATH);
if (files.length > 0)
for (let i = 0; i < files.length; i++) {
const filePath = OUTPUT_PATH + "/" + files[i];
if (fs.statSync(filePath).isFile()) fs.unlinkSync(filePath);
}
} catch (e) {
return console.log(e);
}
}

const compile_arlib = format(
EMCC + " " + INCLUDES + " " + ar_sources.join(" ") + FLAGS + " " + DEFINES + " -r -o {OUTPUT_PATH}libar.o ",
OUTPUT_PATH,
EMCC + " " + INCLUDES + " " + ar_sources.join(" ") + FLAGS + " " + DEFINES + " -r -o {OUTPUT_PATH}libar.o ",
OUTPUT_PATH,
);

const configure_zlib = format("emcmake cmake -B emscripten/build -S emscripten/zlib ..");
Expand All @@ -185,7 +185,7 @@ const build_zlib = format("cd emscripten/build && emmake make");
const copy_zlib = format("cp emscripten/build/libz.a {OUTPUT_PATH}libz.a", OUTPUT_PATH);

const compile_combine_min = format(
EMCC +
EMCC +
" " +
INCLUDES +
" " +
Expand All @@ -199,14 +199,14 @@ const compile_combine_min = format(
DEFINES +
BIND_FLAG +
" -o {OUTPUT_PATH}{BUILD_MIN_FILE} ",
OUTPUT_PATH,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_MIN_FILE,
OUTPUT_PATH,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_MIN_FILE,
);

const compile_wasm = format(
EMCC +
EMCC +
" " +
INCLUDES +
" " +
Expand All @@ -221,14 +221,14 @@ const compile_wasm = format(
BIND_FLAG +
" -std=c++11 " +
" -o {OUTPUT_PATH}{BUILD_WASM_FILE} ",
OUTPUT_PATH,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_WASM_FILE,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_WASM_FILE,
);

const compile_wasm_es6 = format(
EMCC +
EMCC +
" " +
INCLUDES +
" " +
Expand All @@ -244,14 +244,14 @@ const compile_wasm_es6 = format(
BIND_FLAG +
" -std=c++11 " +
" -o {OUTPUT_PATH}{BUILD_WASM_ES6_FILE} ",
OUTPUT_PATH,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_WASM_ES6_FILE,
OUTPUT_PATH,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_WASM_ES6_FILE,
);

const compile_wasm_td = format(
EMCC +
EMCC +
" " +
INCLUDES +
" " +
Expand All @@ -267,49 +267,49 @@ const compile_wasm_td = format(
" -std=c++11 -pthread " +
BIND_FLAG +
" -o {OUTPUT_PATH}{BUILD_WASM_TD_FILE} ",
OUTPUT_PATH,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_WASM_TD_FILE,
OUTPUT_PATH,
OUTPUT_PATH,
OUTPUT_PATH,
BUILD_WASM_TD_FILE,
);

/*
* Run commands
*/

function onExec(error, stdout, stderr) {
if (stdout) console.log("stdout: " + stdout);
if (stderr) console.log("stderr: " + stderr);
if (error !== null) {
console.log("exec error: " + error.code);
process.exit(error.code);
} else {
runJob();
}
if (stdout) console.log("stdout: " + stdout);
if (stderr) console.log("stderr: " + stderr);
if (error !== null) {
console.log("exec error: " + error.code);
process.exit(error.code);
} else {
runJob();
}
}

const jobs = [];

function runJob() {
if (!jobs.length) {
console.log("Jobs completed");
return;
}
if (!jobs.length) {
console.log("Jobs completed");
return;
}

const cmd = jobs.shift();
const cmd = jobs.shift();

if (typeof cmd === "function") {
cmd();
runJob();
return;
}
if (typeof cmd === "function") {
cmd();
runJob();
return;
}

console.log("\nRunning command: " + cmd + "\n");
exec(cmd, onExec);
console.log("\nRunning command: " + cmd + "\n");
exec(cmd, onExec);
}

function addJob(job) {
jobs.push(job);
jobs.push(job);
}

addJob(clean_builds);
Expand Down

0 comments on commit 426e58a

Please sign in to comment.