Skip to content

Commit

Permalink
Support modify native render macro
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylanwanjun committed Aug 6, 2019
1 parent d47db49 commit c33ea90
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions cocos2d/core/assets/CCRenderTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ let RenderTexture = cc.Class({
this._super();
if (this._framebuffer) {
this._framebuffer.destroy();
this._framebuffer = null;
}
}
});
Expand Down
1 change: 1 addition & 0 deletions cocos2d/core/renderer/utils/label/letter-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ cc.js.mixin(LetterAtlas.prototype, {
destroy () {
this.reset();
this._fontDefDictionary._texture.destroy();
this._fontDefDictionary._texture = null;
},

beforeSceneLoad () {
Expand Down
41 changes: 31 additions & 10 deletions gulp/tasks/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ exports.buildJsb = function (sourceFile, outputFile, excludes, opt_macroFlags, c
var opts = {
sourcemaps: createMap !== false
};
if (opt_macroFlags && opt_macroFlags.nativeRenderer) {

let flags = Object.assign({ jsb: true, debug: true }, opt_macroFlags);
let macro = Utils.getMacros('build', flags);
let nativeRenderer = macro["CC_NATIVERENDERER"];

if (opt_macroFlags && nativeRenderer) {
opts.aliasifyConfig = jsbAliasify;
}

Expand All @@ -273,7 +278,7 @@ exports.buildJsb = function (sourceFile, outputFile, excludes, opt_macroFlags, c
var outDir = Path.dirname(outputFile);

var bundler = createBundler(sourceFile, opts);
if (opt_macroFlags.nativeRenderer) {
if (nativeRenderer) {
excludes = excludes.concat(jsbSkipModules);
}
excludes.forEach(function (module) {
Expand All @@ -285,7 +290,7 @@ exports.buildJsb = function (sourceFile, outputFile, excludes, opt_macroFlags, c
.pipe(Source(outFile))
.pipe(Buffer())
.pipe(FixJavaScriptCore())
.pipe(Utils.uglify('build', Object.assign({ jsb: true, debug: true }, opt_macroFlags)))
.pipe(Utils.uglify('build', flags))
.pipe(Optimizejs({
sourceMap: false
}))
Expand All @@ -302,7 +307,12 @@ exports.buildJsbMin = function (sourceFile, outputFile, excludes, opt_macroFlags
var opts = {
sourcemaps: createMap !== false
};
if (opt_macroFlags && opt_macroFlags.nativeRenderer) {

let flags = Object.assign({ jsb: true }, opt_macroFlags);
let macro = Utils.getMacros('build', flags);
let nativeRenderer = macro["CC_NATIVERENDERER"];

if (opt_macroFlags && nativeRenderer) {
opts.aliasifyConfig = jsbAliasify;
}

Expand All @@ -312,7 +322,7 @@ exports.buildJsbMin = function (sourceFile, outputFile, excludes, opt_macroFlags
var outDir = Path.dirname(outputFile);

var bundler = createBundler(sourceFile, opts);
if (opt_macroFlags.nativeRenderer) {
if (nativeRenderer) {
excludes = excludes.concat(jsbSkipModules);
}
excludes.forEach(function (module) {
Expand All @@ -327,7 +337,7 @@ exports.buildJsbMin = function (sourceFile, outputFile, excludes, opt_macroFlags
.pipe(Source(outFile))
.pipe(Buffer())
.pipe(FixJavaScriptCore())
.pipe(Utils.uglify('build', Object.assign({ jsb: true }, opt_macroFlags)))
.pipe(Utils.uglify('build', flags))
.pipe(Optimizejs({
sourceMap: false
}))
Expand All @@ -344,7 +354,12 @@ exports.buildRuntime = function (sourceFile, outputFile, excludes, opt_macroFlag
var opts = {
sourcemaps: createMap !== false
};
if (opt_macroFlags && opt_macroFlags.nativeRenderer) {

let flags = Object.assign({ jsb: false, runtime: true, debug: true }, opt_macroFlags);
let macro = Utils.getMacros('build', flags);
let nativeRenderer = macro["CC_NATIVERENDERER"];

if (opt_macroFlags && nativeRenderer) {
opts.aliasifyConfig = jsbAliasify;
}

Expand All @@ -357,13 +372,14 @@ exports.buildRuntime = function (sourceFile, outputFile, excludes, opt_macroFlag
excludes.forEach(function (module) {
bundler.exclude(require.resolve(module));
});

bundler.bundle()
.on('error', HandleErrors.handler)
.pipe(HandleErrors())
.pipe(Source(outFile))
.pipe(Buffer())
.pipe(FixJavaScriptCore())
.pipe(Utils.uglify('build', Object.assign({ jsb: false, runtime: true, debug: true }, opt_macroFlags)))
.pipe(Utils.uglify('build', flags))
.pipe(Optimizejs({
sourceMap: false
}))
Expand All @@ -380,7 +396,12 @@ exports.buildRuntimeMin = function (sourceFile, outputFile, excludes, opt_macroF
var opts = {
sourcemaps: createMap !== false
};
if (opt_macroFlags && opt_macroFlags.nativeRenderer) {

let flags = Object.assign({ jsb: false, runtime: true }, opt_macroFlags);
let macro = Utils.getMacros('build', flags);
let nativeRenderer = macro["CC_NATIVERENDERER"];

if (opt_macroFlags && nativeRenderer) {
opts.aliasifyConfig = jsbAliasify;
}

Expand All @@ -402,7 +423,7 @@ exports.buildRuntimeMin = function (sourceFile, outputFile, excludes, opt_macroF
.pipe(Source(outFile))
.pipe(Buffer())
.pipe(FixJavaScriptCore())
.pipe(Utils.uglify('build', Object.assign({ jsb: false, runtime: true }, opt_macroFlags)))
.pipe(Utils.uglify('build', flags))
.pipe(Optimizejs({
sourceMap: false
}))
Expand Down
2 changes: 1 addition & 1 deletion gulp/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports.getMacros = function (platform, flags) {
res['CC_DEV'] = res['CC_EDITOR'] || res['CC_PREVIEW'] || res['CC_TEST'];
res['CC_DEBUG'] = res['CC_DEBUG'] || res['CC_DEV'];
res['CC_SUPPORT_JIT'] = !(res['CC_RUNTIME'] || res['CC_MINIGAME']);
res['CC_NATIVERENDERER'] = false;
res['CC_NATIVERENDERER'] = res['CC_JSB'] && true;
return res;
};

Expand Down

0 comments on commit c33ea90

Please sign in to comment.